org.apache.edgent.graph.Vertex.getInstance()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(101)

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

Vertex.getInstance介绍

[英]Get the instance of the oplet that will be executed.
[中]获取将要执行的oplet的实例。

代码示例

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

  1. @SuppressWarnings({ "rawtypes", "unchecked" })
  2. public VertexType(Vertex<? extends Oplet<?, ?>, ?, ?> value, IdMapper<String> ids) {
  3. this.id = (value instanceof ExecutableVertex) ?
  4. ids.add(value, ((ExecutableVertex) value).getInvocationId()) :
  5. // Can't get an id from the vertex, generate unique value
  6. ids.add(value);
  7. this.invocation = new InvocationType(value.getInstance());
  8. }

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

  1. @SuppressWarnings({ "rawtypes", "unchecked" })
  2. public VertexType(Vertex<? extends Oplet<?, ?>, ?, ?> value, IdMapper<String> ids) {
  3. this.id = (value instanceof ExecutableVertex) ?
  4. ids.add(value, ((ExecutableVertex) value).getInvocationId()) :
  5. // Can't get an id from the vertex, generate unique value
  6. ids.add(value);
  7. this.invocation = new InvocationType(value.getInstance());
  8. }

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

  1. /**
  2. * Add counter metrics to all the topology's streams.
  3. * <p>
  4. * {@link CounterOp} oplets are inserted between every two graph
  5. * vertices with the following exceptions:
  6. * <ul>
  7. * <li>Oplets are only inserted upstream from a FanOut oplet.</li>
  8. * <li>If a chain of Peek oplets exists between oplets A and B, a Metric
  9. * oplet is inserted after the last Peek, right upstream from oplet B.</li>
  10. * <li>If a chain a Peek oplets is followed by a FanOut, a metric oplet is
  11. * inserted between the last Peek and the FanOut oplet.</li>
  12. * <li>Oplets are not inserted immediately downstream from another
  13. * {@code CounterOp} oplet (but they are inserted upstream from one.)</li>
  14. * </ul>
  15. * The implementation is not idempotent: Calling the method twice
  16. * will insert a new set of metric oplets into the graph.
  17. * @param t
  18. * The topology
  19. * @see org.apache.edgent.graph.Graph#peekAll(org.apache.edgent.function.Supplier, org.apache.edgent.function.Predicate) Graph.peekAll()
  20. */
  21. public static void counter(Topology t) {
  22. // peekAll() embodies the above exclusion semantics
  23. t.graph().peekAll(
  24. () -> new CounterOp<>(),
  25. v -> !(v.getInstance() instanceof CounterOp)
  26. );
  27. }
  28. }

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

  1. @Test
  2. public void testMetricsEverywhere() throws Exception {
  3. Topology t = newTopology();
  4. TStream<String> s = t.strings("a", "b", "c");
  5. // Condition inserts a sink
  6. Condition<Long> tc = t.getTester().tupleCount(s, 3);
  7. Graph g = t.graph();
  8. Collection<Vertex<? extends Oplet<?, ?>, ?, ?>> vertices = g.getVertices();
  9. // Two vertices before submission
  10. assertEquals(2, vertices.size());
  11. complete(t, tc);
  12. // At least three vertices after submission
  13. // (provide may have added other oplets as well)
  14. Collection<Vertex<? extends Oplet<?, ?>, ?, ?>> verticesAfterSubmit = g.getVertices();
  15. assertTrue("size="+verticesAfterSubmit.size(), verticesAfterSubmit.size() >= 3);
  16. // There is exactly one vertex for a metric oplet
  17. int numOplets = 0;
  18. for (Vertex<? extends Oplet<?, ?>, ?, ?> v : verticesAfterSubmit) {
  19. Oplet<?,?> oplet = v.getInstance();
  20. if (oplet instanceof CounterOp) {
  21. numOplets++;
  22. }
  23. }
  24. assertEquals(1, numOplets);
  25. }

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

  1. Oplet<?,?> oplet = v.getInstance();
  2. if (oplet instanceof StreamScope) {
  3. numOplets++;

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

  1. PeriodicSource<?> src = null;
  2. for (Vertex<? extends Oplet<?, ?>, ?, ?> v : vertices) {
  3. Oplet<?,?> op = v.getInstance();
  4. assertTrue(op instanceof PeriodicSource);
  5. src = (PeriodicSource<?>) op;

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

  1. assertSame(op, v.getInstance());

相关文章