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

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

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

Topology.getName介绍

[英]Name of this topology.
[中]此拓扑的名称。

代码示例

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

@Test
public void testGenerateRestart() throws Exception {
 Topology t = newTopology("testGenerateRestart");
 Path tempFile1 = FileUtil.createTempFile("test1", ".txt", getLines());
 System.out.println("Test: "+t.getName()+" "+tempFile1);
 
 ProcessBuilder cmd = new ProcessBuilder(mkCatFileCmd(tempFile1.toString()));
 int NUM_RUNS = 3;
 List<String> expLines = new ArrayList<>();
 for (int i = 0; i < NUM_RUNS; i++) {
  expLines.addAll(Arrays.asList(getLines()));
 }
 
 // N.B. if looking at trace: EDGENT-224 generate() continues running after job is closed
 TStream<String> s = CommandStreams.generate(t, cmd);
 
 completeAndValidate("", t, s, 10 + ((NUM_RUNS-1) * 1/*restart delay time*/), expLines.toArray(new String[0]));
}

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

public void completeAndValidate(boolean ordered, String msg, Topology t,
    TStream<String> s, MsgGenerator mgen, int secTimeout, String... expected)
    throws Exception {
  
  s = s.filter(tuple -> tuple.matches(mgen.pattern()));
  s.sink(tuple -> System.out.println(
      String.format("[%s][%s] rcvd: %s", t.getName(), simpleTS(), tuple)));
  super.completeAndValidate(ordered, msg, t, s, secTimeout, expected);
}

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

@Test
public void testGenerate() throws Exception {
 Topology t = newTopology("testGenerate");
 Path tempFile1 = FileUtil.createTempFile("test1", ".txt", getLines());
 System.out.println("Test: "+t.getName()+" "+tempFile1);
 
 ProcessBuilder cmd = new ProcessBuilder(mkCatFileCmd(tempFile1.toString()));
 
 // N.B. if looking at trace: EDGENT-224 generate() continues running after job is closed
 TStream<String> s = CommandStreams.generate(t, cmd);
 
 try {
  completeAndValidate("", t, s, 10, getLines());
 }
 finally {
   tempFile1.toFile().delete();
 }
}

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

@Test
public void testBasics() {
  final Topology t = newTopology("T123");
  assertEquals("T123", t.getName());
  assertSame(t, t.topology());
}

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

@Test
public void testDefaultName() {
  final Topology t = newTopology();
  assertSame(t, t.topology());
  assertNotNull(t.getName());
}

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

@Test(expected=IllegalArgumentException.class)
public void testDupTopicSub1Neg() throws Exception {
  Topology t = newTopology("testDupTopicSub1Neg");
  String groupId = newGroupId(t.getName());
  
  Map<String,Object> cConfig = newConsumerConfig(groupId);
  KafkaConsumer consumer = new KafkaConsumer(t, () -> cConfig);
  
  consumer.subscribe(rec -> rec.value(), "topic1", "topic1");
}

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

@Test(expected=IllegalArgumentException.class)
public void testNoTopicSubNeg() throws Exception {
  Topology t = newTopology("testNoTopicSubNeg");
  String groupId = newGroupId(t.getName());
  
  Map<String,Object> cConfig = newConsumerConfig(groupId);
  KafkaConsumer consumer = new KafkaConsumer(t, () -> cConfig);
  
  consumer.subscribe(rec -> rec.value()/*, "topic1"*/);
}

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

@Test
public void testBytes() throws Exception {
  Topology t = newTopology("testBytes");
  System.out.println("===== "+t.getName());
  startEchoer();  // before getConfig() so it gets the port
  
  Properties config = getConfig();
  WebSocketClient wsClient = new Jsr356WebSocketClient(t, config);
  
  String[] expected = new String[] { getStr1(), getStr2() };
  
  TStream<byte[]> s = t.strings(expected)
              .map(tup -> tup.getBytes(StandardCharsets.UTF_8));
  s = PlumbingStreams.blockingOneShotDelay(s, 2, TimeUnit.SECONDS);
  wsClient.sendBytes(s);
  
  TStream<String> rcvd = wsClient.receiveBytes()
              .map(tup -> new String(tup, StandardCharsets.UTF_8));
  
  completeAndValidate("", t, rcvd, SEC_TMO, expected);
}

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

@Test
public void testBasicRead() throws Exception {
  Topology t = this.newTopology("testBasicRead");
  
  populatePersonsTable(getPersonList());
  List<String> expected = expectedPersons(person->true, getPersonList());
  JdbcStreams db = new JdbcStreams(t,
      () -> getDataSource(DB_NAME),
      dataSource -> connect(dataSource));
  // Create a stream of Person from a stream of ids
  TStream<Person> rcvdPerson = readPersonsTable(t, db, getPersonIdList(), 0/*msec*/);
  TStream<String> rcvd = rcvdPerson.map(person -> person.toString());
  
  rcvd.sink(tuple -> System.out.println(
      String.format("%s rcvd: %s", t.getName(), tuple)));
  completeAndValidate("", t, rcvd, SEC_TIMEOUT, expected.toArray(new String[0]));
}

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

@Test
public void testPublicServer() throws Exception {
  Topology t = newTopology("testPublicServer");
  System.out.println("===== "+t.getName());
  
  // startEchoer();  // before getConfig() so it gets the port
  
  Properties config = getConfig();
  config.setProperty("ws.uri", "ws://echo.websocket.org");
  skipTestIfCantConnect(config);
  // System.setProperty("javax.net.debug", "ssl"); // or "all"; "help" for full list
  
  WebSocketClient wsClient = new Jsr356WebSocketClient(t, config);
  
  String[] expected = new String[] { getStr1(), getStr2() };
  
  TStream<String> s = t.strings(expected);
  s = PlumbingStreams.blockingOneShotDelay(s, 2, TimeUnit.SECONDS);
  wsClient.sendString(s);
  
  TStream<String> rcvd = wsClient.receiveString();
  
  completeAndValidate("", t, rcvd, SEC_TMO, expected);
}

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

@Test
public void testSimple() throws Exception {
  Topology t = newTopology("testSimple");
  Map<String, Object> configMap = initRabbitmqConfig();
  MsgGenerator generator = new MsgGenerator(t.getName());
  String queue = "testQueue";
  List<String> msgs = createMsgs(generator, queue, getMsg1(), getMsg2());
  TStream<String> stream = PlumbingStreams.blockingOneShotDelay(
    t.collection(msgs), PUB_DELAY_MSEC, TimeUnit.MILLISECONDS);
  RabbitmqConsumer consumer = new RabbitmqConsumer(t, () -> configMap);
  TStream<String> receivedStream = consumer.subscribe((byte[] bytes) -> new String(bytes), queue);
  RabbitmqProducer producer = new RabbitmqProducer(t, () -> configMap);
  TSink<String> sink = producer.publish(stream, queue, (String s) -> s.getBytes());
  completeAndValidate("", t, receivedStream, generator, SEC_TIMEOUT, msgs.toArray(new String[0]));
  assertNotNull(sink);
}

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

@Test(expected = IllegalStateException.class)
public void testMultiSubscribeNeg() throws Exception {
  Topology top = newTopology("testMultiSubscribeNeg");
  int qos = 0;
  String clientId = newClientId(top.getName());
  String topic = getMqttTopics()[0];
  // Verify the current behavior of at-most-one subscribe()
  // for a MqttStreams instance
  
  MqttStreams mqtt = new MqttStreams(top, getServerURI(), clientId);
  mqtt.subscribe(topic, qos);
  mqtt.subscribe(topic, qos); // should throw
}

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

@Test
public void testSslClientAuthDefault() throws Exception {
  Topology t = newTopology("testSslClientAuthDefault");
  System.out.println("===== "+t.getName());
  startEchoer(ServerMode.SSL_CLIENT_AUTH);  // before getConfig() so it gets the port
  
  // explicitly specify client's "default" certificate
  Properties config = getWssConfig();
  config.setProperty("ws.keyCertificateAlias", "default");
  // System.setProperty("javax.net.debug", "ssl"); // or "all"; "help" for full list
  
  WebSocketClient wsClient = new Jsr356WebSocketClient(t, config);
  
  String[] expected = new String[] { getStr1(), getStr2() };
  
  TStream<String> s = t.strings(expected);
  s = PlumbingStreams.blockingOneShotDelay(s, 2, TimeUnit.SECONDS);
  wsClient.sendString(s);
  
  TStream<String> rcvd = wsClient.receiveString();
  
  completeAndValidate("", t, rcvd, SEC_TMO, expected);
}

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

@Test
public void testSslClientAuthMy3rdCert() throws Exception {
  Topology t = newTopology("testSslClientAuthMy3rdCert");
  System.out.println("===== "+t.getName());
  startEchoer(ServerMode.SSL_CLIENT_AUTH);  // before getConfig() so it gets the port
  
  // explicitly specify client's "my3rdcert" certificate
  Properties config = getWssConfig();
  config.setProperty("ws.keyCertificateAlias", "my3rdcert");
  // System.setProperty("javax.net.debug", "ssl"); // or "all"; "help" for full list
  
  WebSocketClient wsClient = new Jsr356WebSocketClient(t, config);
  
  String[] expected = new String[] { getStr1(), getStr2() };
  
  TStream<String> s = t.strings(expected);
  s = PlumbingStreams.blockingOneShotDelay(s, 2, TimeUnit.SECONDS);
  wsClient.sendString(s);
  
  TStream<String> rcvd = wsClient.receiveString();
  
  completeAndValidate("", t, rcvd, SEC_TMO, expected);
}

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

@Test(expected=IllegalArgumentException.class)
public void testDupTopicSub2Neg() throws Exception {
  Topology t = newTopology("testDupTopicSub2Neg");
  String groupId = newGroupId(t.getName());
  
  Map<String,Object> cConfig = newConsumerConfig(groupId);
  KafkaConsumer consumer = new KafkaConsumer(t, () -> cConfig);
  
  consumer.subscribe(rec -> rec.value(), "topic1");
  consumer.subscribe(rec -> rec.value(), "topic1");
}

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

@Test
public void testString() throws Exception {
  Topology t = newTopology("testString");
  System.out.println("===== "+t.getName());
  
  startEchoer();  // before getConfig() so it gets the port
  
  Properties config = getConfig();
  WebSocketClient wsClient = new Jsr356WebSocketClient(t, config);
  
  String[] expected = new String[] { getStr1(), getStr2() };
  
  TStream<String> s = t.strings(expected);
  s = PlumbingStreams.blockingOneShotDelay(s, 2, TimeUnit.SECONDS);
  wsClient.sendString(s);
  
  TStream<String> rcvd = wsClient.receiveString();
  
  completeAndValidate("", t, rcvd, SEC_TMO, expected);
}

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

@Test
public void testSslClientAuth() throws Exception {
  Topology t = newTopology("testSslClientAuth");
  System.out.println("===== "+t.getName());
  startEchoer(ServerMode.SSL_CLIENT_AUTH);  // before getConfig() so it gets the port
  
  Properties config = getWssConfig();
  // System.setProperty("javax.net.debug", "ssl"); // or "all"; "help" for full list
  
  WebSocketClient wsClient = new Jsr356WebSocketClient(t, config);
  
  String[] expected = new String[] { getStr1(), getStr2() };
  
  TStream<String> s = t.strings(expected);
  s = PlumbingStreams.blockingOneShotDelay(s, 2, TimeUnit.SECONDS);
  wsClient.sendString(s);
  
  TStream<String> rcvd = wsClient.receiveString();
  
  completeAndValidate("", t, rcvd, SEC_TMO, expected);
}

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

@Test
public void testSsl() throws Exception {
  Topology t = newTopology("testSsl");
  System.out.println("===== "+t.getName());
  startEchoer(ServerMode.SSL);  // before getConfig() so it gets the port
  
  Properties config = getWssConfig();
  // System.setProperty("javax.net.debug", "ssl"); // or "all"; "help" for full list
  
  WebSocketClient wsClient = new Jsr356WebSocketClient(t, config);
  
  String[] expected = new String[] { getStr1(), getStr2() };
  
  TStream<String> s = t.strings(expected);
  s = PlumbingStreams.blockingOneShotDelay(s, 2, TimeUnit.SECONDS);
  wsClient.sendString(s);
  
  TStream<String> rcvd = wsClient.receiveString();
  
  completeAndValidate("", t, rcvd, SEC_TMO, expected);
}

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

@Test
public void testAutoClientId() throws Exception {
  Topology top = newTopology("testAutoClientId");
  MsgGenerator mgen = new MsgGenerator(top.getName());
  int qos = 0;
  boolean retain = false;
  String topic = getMqttTopics()[0];
  List<String> msgs = createMsgs(mgen, topic, getMsg1(), getMsg2());
  
  TStream<String> s = PlumbingStreams.blockingOneShotDelay(
      top.collection(msgs), PUB_DELAY_MSEC, TimeUnit.MILLISECONDS);
  
  // Test with auto-generated clientId
  MqttConfig config = newConfig(getServerURI(), null/*clientId*/);
  MqttStreams mqtt = new MqttStreams(top, () -> config);
  mqtt.publish(s, topic, qos, retain);
  TStream<String> rcvd = mqtt.subscribe(topic, qos);
  completeAndValidate("some-auto-clientId", top, rcvd, mgen, SEC_TIMEOUT, msgs.toArray(new String[0]));
}

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

@Test
public void testJson() throws Exception {
  Topology t = newTopology("testJson");
  System.out.println("===== "+t.getName());
  
  startEchoer();  // before getConfig() so it gets the port
  
  Properties config = getConfig();
  WebSocketClient wsClient = new Jsr356WebSocketClient(t, config);
  
  String[] expected = new String[] {
      "{\"id\":\"" + getStr1() + "\",\"value\":27}",
      "{\"id\":\"" + getStr2() + "\",\"value\":13}"
  };
  
  TStream<JsonObject> s = t.strings(expected)
              .map(JsonFunctions.fromString());
  s = PlumbingStreams.blockingOneShotDelay(s, 2, TimeUnit.SECONDS);
  wsClient.send(s);
  
  TStream<String> rcvd = wsClient.receive()
              .map(JsonFunctions.asString());
  
  completeAndValidate("", t, rcvd, SEC_TMO, expected);
}

相关文章