use of io.mantisrx.server.master.client.MasterClientWrapper in project mantis by Netflix.
the class ConnectToNamedJob method main2.
public static void main2(final String[] args) {
List<String> remArgs = Collections.emptyList();
try {
remArgs = Args.parse(ConnectToNamedJob.class, args);
} catch (IllegalArgumentException e) {
Args.usage(SubmitEphemeralJob.class);
System.exit(1);
}
if (remArgs.isEmpty()) {
System.err.println("Must provide JobId as argument");
System.exit(1);
}
final String jobId = remArgs.get(0);
Properties properties = new Properties();
System.out.println("propfile=" + propFile);
try (InputStream inputStream = new FileInputStream(propFile)) {
properties.load(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
MasterClientWrapper clientWrapper = new MasterClientWrapper(properties);
clientWrapper.getMasterClientApi().doOnNext(new Action1<MantisMasterClientApi>() {
@Override
public void call(MantisMasterClientApi clientApi) {
logger.info("************** connecting to schedInfo for job " + jobId);
clientApi.schedulingChanges(jobId).doOnNext(new Action1<JobSchedulingInfo>() {
@Override
public void call(JobSchedulingInfo schedulingInfo) {
final WorkerAssignments workerAssignments = schedulingInfo.getWorkerAssignments().get(1);
for (Map.Entry<Integer, WorkerHost> entry : workerAssignments.getHosts().entrySet()) {
System.out.println("Worker " + entry.getKey() + ": state=" + entry.getValue().getState() + ", host=" + entry.getValue().getHost() + ", port=" + entry.getValue().getPort());
}
}
}).subscribe();
;
}
}).subscribe();
// .subscribe();
try {
Thread.sleep(10000000);
} catch (InterruptedException ie) {
}
}
Aggregations