Search in sources :

Example 1 with MasterClientWrapper

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) {
    }
}
Also used : MasterClientWrapper(io.mantisrx.server.master.client.MasterClientWrapper) WorkerHost(io.mantisrx.server.core.WorkerHost) Action1(rx.functions.Action1) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) JobSchedulingInfo(io.mantisrx.server.core.JobSchedulingInfo) IOException(java.io.IOException) Properties(java.util.Properties) FileInputStream(java.io.FileInputStream) MantisMasterClientApi(io.mantisrx.server.master.client.MantisMasterClientApi) WorkerAssignments(io.mantisrx.server.core.WorkerAssignments) Map(java.util.Map)

Aggregations

JobSchedulingInfo (io.mantisrx.server.core.JobSchedulingInfo)1 WorkerAssignments (io.mantisrx.server.core.WorkerAssignments)1 WorkerHost (io.mantisrx.server.core.WorkerHost)1 MantisMasterClientApi (io.mantisrx.server.master.client.MantisMasterClientApi)1 MasterClientWrapper (io.mantisrx.server.master.client.MasterClientWrapper)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Map (java.util.Map)1 Properties (java.util.Properties)1 Action1 (rx.functions.Action1)1