@POST @Path("/build") public String build() throws Exception { ScheduleOption option = new ScheduleOption(); ScheduleState state = alertCoordinator.schedule(option); return JsonUtils.writeValueAsString(state); }
@SuppressWarnings( {"resource", "unused"}) @Test public void test_01() throws Exception { before(); Config config = ConfigFactory.load().getConfig("coordinator"); ZKConfig zkConfig = ZKConfigBuilder.getZKConfig(config); IMetadataServiceClient client = ScheduleContextBuilderTest.getSampleMetadataService(); Coordinator coordinator = new Coordinator(config, zkConfig, client); ScheduleOption option = new ScheduleOption(); ScheduleState state = coordinator.schedule(option); String v = state.getVersion(); // TODO : assert version CountDownLatch latch = new CountDownLatch(1); AtomicBoolean validated = new AtomicBoolean(false); ConfigBusConsumer consumer = new ConfigBusConsumer(zkConfig, "topo1/spout", new ConfigChangeCallback() { @Override public void onNewConfig(ConfigValue value) { String vId = value.getValue().toString(); Assert.assertEquals(v, vId); validated.set(true); latch.countDown(); } }); latch.await(3, TimeUnit.SECONDS); Assert.assertTrue(validated.get()); }
@SuppressWarnings( {"resource", "unused"}) @Ignore @Test public void test() throws Exception { before(); Config config = ConfigFactory.load().getConfig("coordinator"); ZKConfig zkConfig = ZKConfigBuilder.getZKConfig(config); IMetadataServiceClient client = new MetadataServiceClientImpl(config); Coordinator coordinator = new Coordinator(config, zkConfig, client); ScheduleOption option = new ScheduleOption(); ScheduleState state = coordinator.schedule(option); String v = state.getVersion(); AtomicBoolean validated = new AtomicBoolean(false); ConfigBusConsumer consumer = new ConfigBusConsumer(zkConfig, "topo1/spout", new ConfigChangeCallback() { @Override public void onNewConfig(ConfigValue value) { String vId = value.getValue().toString(); Assert.assertEquals(v, vId); validated.set(true); } }); Thread.sleep(1000); Assert.assertTrue(validated.get()); }