本文整理了Java中org.apache.eagle.alert.config.ZKConfigBuilder.getZKConfig()
方法的一些代码示例,展示了ZKConfigBuilder.getZKConfig()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKConfigBuilder.getZKConfig()
方法的具体详情如下:
包路径:org.apache.eagle.alert.config.ZKConfigBuilder
类名称:ZKConfigBuilder
方法名:getZKConfig
暂无
代码示例来源:origin: apache/eagle
private static ZKMetadataChangeNotifyService createZKNotifyService(Config config, String topologyId) {
ZKConfig zkConfig = ZKConfigBuilder.getZKConfig(config);
ZKMetadataChangeNotifyService changeNotifyService = new ZKMetadataChangeNotifyService(zkConfig, topologyId);
return changeNotifyService;
}
代码示例来源:origin: apache/eagle
public Coordinator() {
config = ConfigFactory.load().getConfig(COORDINATOR);
zkConfig = ZKConfigBuilder.getZKConfig(config);
client = new MetadataServiceClientImpl(config);
}
代码示例来源:origin: apache/eagle
@Override
public void run() {
if (Coordinator.isPeriodicallyForceBuildEnable()) {
LOG.info("CoordinatorTrigger started ... ");
Stopwatch watch = Stopwatch.createStarted();
ZKConfig zkConfig = ZKConfigBuilder.getZKConfig(config);
try (ExclusiveExecutor executor = new ExclusiveExecutor(zkConfig)) {
executor.execute(Coordinator.GREEDY_SCHEDULER_ZK_PATH, () -> {
// schedule
IScheduleContext context = new ScheduleContextBuilder(config, client).buildContext();
TopologyMgmtService mgmtService = new TopologyMgmtService();
IPolicyScheduler scheduler = PolicySchedulerFactory.createScheduler();
scheduler.init(context, mgmtService);
ScheduleState state = scheduler.schedule(new ScheduleOption());
// use try catch to use AutoCloseable interface to close producer automatically
try (ConfigBusProducer producer = new ConfigBusProducer(ZKConfigBuilder.getZKConfig(config))) {
Coordinator.postSchedule(client, state, producer);
}
watch.stop();
LOG.info("CoordinatorTrigger ended, used time {} sm.", watch.elapsed(TimeUnit.MILLISECONDS));
});
} catch (Exception e) {
LOG.error("trigger schedule failed!", e);
}
} else {
LOG.info("CoordinatorTrigger found isPeriodicallyForceBuildEnable = false, skipped build");
}
}
代码示例来源:origin: apache/eagle
public int schedule(int input) throws TimeoutException {
Config config = ConfigFactory.load().getConfig("coordinator");
ZKConfig zkConfig = ZKConfigBuilder.getZKConfig(config);
ExclusiveExecutor executor = new ExclusiveExecutor(zkConfig);
final AtomicInteger r = new AtomicInteger();
executor.execute("/alert/test", () -> {
try {
Thread.sleep(input);
} catch (Exception e){
}
r.set(input);
});
try {
executor.close();
} catch (IOException e) {
e.printStackTrace();
}
throw new RuntimeException("Acquire greedy scheduler lock failed, please retry later");
}
}
代码示例来源:origin: apache/eagle
try (ConfigBusProducer producer = new ConfigBusProducer(ZKConfigBuilder.getZKConfig(config))) {
postSchedule(client, state, producer);
代码示例来源:origin: apache/eagle
@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());
}
代码示例来源:origin: apache/eagle
@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());
}
代码示例来源:origin: apache/eagle
@Test
public void testZKConfigBuilder() {
Config config = ConfigFactory.load();
ZKConfig zKConfig = ZKConfigBuilder.getZKConfig(config);
Assert.assertEquals("localhost:2181", zKConfig.zkQuorum);
Assert.assertEquals("/alert", zKConfig.zkRoot);
Assert.assertEquals(10000, zKConfig.zkSessionTimeoutMs);
Assert.assertEquals(10000, zKConfig.connectionTimeoutMs);
Assert.assertEquals(3, zKConfig.zkRetryTimes);
Assert.assertEquals(3000, zKConfig.zkRetryInterval);
}
}
代码示例来源:origin: apache/eagle
@Ignore
@Test
public void addScheduleState() throws Exception {
ConfigFactory.invalidateCaches();
System.setProperty("config.resource", "/test-application.conf");
Config config = ConfigFactory.load("test-application.conf").getConfig("coordinator");
MetadataServiceClientImpl client = new MetadataServiceClientImpl(config);
ScheduleState ss = new ScheduleState();
ss.setVersion("spec_version_1463764252582");
client.addScheduleState(ss);
client.close();
ss.setVersion("spec_version_1464764252582");
ZKConfig zkConfig = ZKConfigBuilder.getZKConfig(config);
ConfigBusProducer producer = new ConfigBusProducer(zkConfig);
Coordinator.postSchedule(client, ss, producer);
}
}
内容来源于网络,如有侵权,请联系作者删除!