org.apache.edgent.topology.Topology.getRuntimeServiceSupplier()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中org.apache.edgent.topology.Topology.getRuntimeServiceSupplier()方法的一些代码示例,展示了Topology.getRuntimeServiceSupplier()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Topology.getRuntimeServiceSupplier()方法的具体详情如下:
包路径:org.apache.edgent.topology.Topology
类名称:Topology
方法名:getRuntimeServiceSupplier

Topology.getRuntimeServiceSupplier介绍

[英]Return a function that at execution time will return a RuntimeServices instance a stream function can use.
[中]返回一个函数,该函数在执行时将返回流函数可以使用的RuntimeServices实例。

代码示例

代码示例来源:origin: apache/incubator-edgent

/**
 * Declares a stream populated by {@link JobRegistryService} events.
 * <p>
 * The job registry is passed as a runtime service. At startup 
 * {@code JobRegistryService#addListener()} is called by the 
 * runtime to subscribe an event listener.  The listener invokes the given 
 * {@code wrapper} function to construct a tuple from a job event
 * and submits the tuple on the returned stream.</p>
 * <p>
 * When the topology's execution is terminated, 
 * {@code JobRegistryServic#removeListener()}  in invoked to unsubscribe 
 * the tuple source from the job registry. 
 * </p>
 *
 * @param <T> Tuple type
 * @param topology the stream topology
 * @param wrapper constructs a tuple from a job event
 * @return new stream containing the tuples generated by the specified {@code wrapper}.
 * 
 * @see Topology#getRuntimeServiceSupplier() 
 * @see JobRegistryService#addListener(BiConsumer)
 * @see JobRegistryService#removeListener(BiConsumer)
 */
public static <T> TStream<T> source(
    Topology topology, 
    BiFunction<JobRegistryService.EventType, Job, T> wrapper) {
  Supplier<RuntimeServices> rts = topology.getRuntimeServiceSupplier();
  return topology.events(new JobEventsSetup<T>(wrapper, rts));
}

代码示例来源:origin: apache/incubator-edgent

/**
 * Subscribe to a published topic.
 * This is a model that allows jobs to subscribe to 
 * streams published by other jobs.
 * @param <T> Tuple type
 * @param te TopologyElement whose Topology to add to
 * @param topic Topic to subscribe to.
 * @param streamType Type of the stream.
 * @return Stream containing published tuples.
 * 
 * @see #publish(TStream, String, Class)
 */
public static <T> TStream<T> subscribe(TopologyElement te, String topic, Class<T> streamType) {
  
  Topology topology = te.topology();
  
  Supplier<RuntimeServices> rts = topology.getRuntimeServiceSupplier();
  
  return te.topology().events(new SubscriberSetup<T>(topic, streamType, rts));
}

代码示例来源:origin: org.apache.edgent/edgent-connectors-pubsub

/**
 * Subscribe to a published topic.
 * This is a model that allows jobs to subscribe to 
 * streams published by other jobs.
 * @param <T> Tuple type
 * @param te TopologyElement whose Topology to add to
 * @param topic Topic to subscribe to.
 * @param streamType Type of the stream.
 * @return Stream containing published tuples.
 * 
 * @see #publish(TStream, String, Class)
 */
public static <T> TStream<T> subscribe(TopologyElement te, String topic, Class<T> streamType) {
  
  Topology topology = te.topology();
  
  Supplier<RuntimeServices> rts = topology.getRuntimeServiceSupplier();
  
  return te.topology().events(new SubscriberSetup<T>(topic, streamType, rts));
}

代码示例来源:origin: org.apache.edgent/edgent-apps-runtime

jobEvents.sink(new JobRestarter(t.getRuntimeServiceSupplier()));

代码示例来源:origin: apache/incubator-edgent

jobEvents.sink(new JobRestarter(t.getRuntimeServiceSupplier()));

代码示例来源:origin: apache/incubator-edgent

@Test
public void testServiceRegistered() throws Exception {
 Topology t1 = newTopology();
 StreamScopeRegistry rgy1 = t1.getRuntimeServiceSupplier().get()
   .getService(StreamScopeRegistry.class);
 assertNotNull(rgy1);
 
 Topology t2 = newTopology();
 StreamScopeRegistry rgy2 = t2.getRuntimeServiceSupplier().get()
   .getService(StreamScopeRegistry.class);
 assertNotNull(rgy2);
 
 assertSame(rgy1, rgy2);
}

代码示例来源:origin: apache/incubator-edgent

static <T> void setPollFrequency(TStream<T> pollStream, long period, TimeUnit unit) {
  ControlService cs = pollStream.topology().getRuntimeServiceSupplier()
                .get().getService(ControlService.class);
  PeriodMXBean control = cs.getControl(TStream.TYPE,
               pollStream.getAlias(), PeriodMXBean.class);
  control.setPeriod(period, unit);
}

代码示例来源:origin: apache/incubator-edgent

t.getRuntimeServiceSupplier().get()
   .getService(StreamScopeRegistry.class);
if (rgy == null)

代码示例来源:origin: apache/incubator-edgent

@Test
public void testRegistryControlRegistered() throws Exception {
 Topology t1 = newTopology();
 ControlService cs1 = t1.getRuntimeServiceSupplier().get()
   .getService(ControlService.class);
 StreamScopeRegistryMXBean rgy1 = cs1.getControl(StreamScopeRegistryMXBean.TYPE,
   StreamScopeRegistryMXBean.TYPE, StreamScopeRegistryMXBean.class);
 assertNotNull(rgy1);
 
 Topology t2 = newTopology();
 ControlService cs2 = t2.getRuntimeServiceSupplier().get()
   .getService(ControlService.class);
 StreamScopeRegistryMXBean rgy2 = cs2.getControl(StreamScopeRegistryMXBean.TYPE,
   StreamScopeRegistryMXBean.TYPE, StreamScopeRegistryMXBean.class);
 assertNotNull(rgy2);
 
 // The rgy1, rgy1 mbean instances may or may not be the same object
 // depending on the ControlService implementation.  For JMXControlService,
 // each getControl() yields a different MXBeanProxy instance but they are
 // for the underlying bean (same objectname).
 //assertSame(rgy1, rgy2);
}

代码示例来源:origin: apache/incubator-edgent

StreamScopeRegistry rgy = t1.getRuntimeServiceSupplier().get()
  .getService(StreamScopeRegistry.class);
assertNotNull(rgy);
ControlService cs = t1.getRuntimeServiceSupplier().get()
           .getService(ControlService.class);
StreamScopeRegistryMXBean rgyBean =

代码示例来源:origin: apache/incubator-edgent

@Test
public void testRuntimeServices() throws Exception {
  Topology t = newTopology();
  TStream<String> s = t.strings("A");
  
  Supplier<RuntimeServices> serviceGetter =
      t.getRuntimeServiceSupplier();
  
  TStream<Boolean> b = s.map(tuple -> 
    serviceGetter.get().getService(ThreadFactory.class) != null
    && serviceGetter.get().getService(ScheduledExecutorService.class) != null
  );
  
  Condition<List<Boolean>> tc = t.getTester().streamContents(b, Boolean.TRUE);
  complete(t, tc);
  
  assertTrue(tc.valid());
}

相关文章