Beispiel #1
0
 /**
  * This function deploys an instance of the flowClass. Recommended, make this function call from a
  * {@link org.junit.BeforeClass} annotated method.
  *
  * @param flowClass Class of the {@link co.cask.tigon.api.flow.Flow} to be deployed
  * @throws Exception
  */
 public static void setupFlow(Class<? extends Flow> flowClass) throws Exception {
   Map<String, String> runtimeArgs = Maps.newHashMap();
   handler = new TestHandler();
   service =
       NettyHttpService.builder()
           .addHttpHandlers(ImmutableList.of(handler))
           .setPort(Networks.getRandomPort())
           .build();
   service.startAndWait();
   InetSocketAddress address = service.getBindAddress();
   serviceURL = "http://" + address.getHostName() + ":" + address.getPort() + "/queue";
   runtimeArgs.put("baseURL", serviceURL);
   runtimeArgs.put(Constants.HTTP_PORT, Integer.toString(httpPort));
   flowManager = deployFlow(flowClass, runtimeArgs);
   int maxWait = 100;
   // Waiting for the Tigon SQL Flow initialization
   while ((!flowManager.discover(Constants.HTTP_PORT).iterator().hasNext()) && (maxWait > 0)) {
     TimeUnit.SECONDS.sleep(1);
     maxWait = maxWait - 1;
   }
   if (maxWait <= 0) {
     throw new TimeoutException("Timeout Error, Tigon SQL flow took too long to initiate");
   }
 }
Beispiel #2
0
 @AfterClass
 public static void afterClass() {
   flowManager.stop();
   service.stopAndWait();
 }