use of io.mantisrx.server.master.client.config.StaticPropertiesConfigurationFactory in project mantis by Netflix.
the class TestGetMasterMonitor method main.
public static void main(String[] args) {
try {
Args.parse(TestGetMasterMonitor.class, args);
} catch (IllegalArgumentException e) {
Args.usage(TestGetMasterMonitor.class);
System.exit(1);
}
Properties properties = new Properties();
System.out.println("propfile=" + propFile);
try (InputStream inputStream = new FileInputStream(propFile)) {
properties.load(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
final AtomicInteger counter = new AtomicInteger();
final CountDownLatch latch = new CountDownLatch(5);
StaticPropertiesConfigurationFactory configurationFactory = new StaticPropertiesConfigurationFactory(properties);
CoreConfiguration config = configurationFactory.getConfig();
final CuratorService curatorService = new CuratorService(config, null);
MasterMonitor masterMonitor = curatorService.getMasterMonitor();
masterMonitor.getMasterObservable().filter(new Func1<MasterDescription, Boolean>() {
@Override
public Boolean call(MasterDescription masterDescription) {
return masterDescription != null;
}
}).doOnNext(new Action1<MasterDescription>() {
@Override
public void call(MasterDescription masterDescription) {
System.out.println(counter.incrementAndGet() + ": Got new master: " + masterDescription.toString());
latch.countDown();
}
}).subscribe();
curatorService.start();
try {
latch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Aggregations