use of io.mantisrx.server.core.JobSchedulingInfo in project mantis by Netflix.
the class JobDiscoveryStreamRouteTest method testJobDiscoveryStreamForNonExistentJob.
@Test
public void testJobDiscoveryStreamForNonExistentJob() throws InterruptedException {
// The current behavior of Mantis client is to retry non-200 responses
// This test overrides the default retry/repeat behavior to test a Sched info observable would complete if the job id requested is non-existent
final CountDownLatch latch = new CountDownLatch(1);
Observable<JobSchedulingInfo> jobSchedulingInfoObservable = mantisClient.discoveryStream("testJobCluster-1", obs -> Observable.just(1), obs -> Observable.empty());
jobSchedulingInfoObservable.doOnNext(x -> logger.info("onNext {}", x)).doOnError(t -> logger.warn("onError", t)).doOnCompleted(() -> {
logger.info("onCompleted");
latch.countDown();
}).subscribe();
latch.await();
}
use of io.mantisrx.server.core.JobSchedulingInfo in project mantis by Netflix.
the class JobRouteTest method testSchedulingInfo.
@Test(dependsOnMethods = { "testNamedJobInfoStream" })
public void testSchedulingInfo() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final String jobId = "sine-function-1";
// final AtomicBoolean flag = new AtomicBoolean(false);
Observable<JobSchedulingInfo> jobSchedulingInfoObservable = mantisClient.schedulingChanges(jobId);
jobSchedulingInfoObservable.map(schedInfo -> {
logger.info("schedInfo {}", schedInfo);
try {
assertEquals(jobId, schedInfo.getJobId());
Map<Integer, WorkerAssignments> wa = schedInfo.getWorkerAssignments();
assertEquals(2, wa.size());
// 1 worker in stage 0
assertEquals(1, wa.get(0).getHosts().size());
assertEquals(0, wa.get(0).getHosts().get(1).getWorkerIndex());
assertEquals(1, wa.get(0).getHosts().get(1).getWorkerNumber());
assertEquals(MantisJobState.Started, wa.get(0).getHosts().get(1).getState());
// 1 worker in stage 1
assertEquals(1, wa.get(1).getHosts().size());
assertEquals(0, wa.get(1).getHosts().get(2).getWorkerIndex());
assertEquals(2, wa.get(1).getHosts().get(2).getWorkerNumber());
assertEquals(MantisJobState.Started, wa.get(1).getHosts().get(2).getState());
// if (flag.compareAndSet(false, true)) {
// testJobResubmitWorker();
// }
} catch (Exception e) {
logger.error("caught exception", e);
org.testng.Assert.fail("testSchedulingInfo test failed with exception " + e.getMessage(), e);
}
latch.countDown();
return schedInfo;
}).take(1).doOnError(t -> logger.warn("onError", t)).doOnCompleted(() -> logger.info("onCompleted")).doAfterTerminate(() -> latch.countDown()).subscribe();
latch.await();
}
use of io.mantisrx.server.core.JobSchedulingInfo in project mantis by Netflix.
the class JobDiscoveryRouteTest method testSchedulingInfoStreamForNonExistentJob.
@Test
public void testSchedulingInfoStreamForNonExistentJob() throws InterruptedException {
// The current behavior of Mantis client is to retry non-200 responses
// This test overrides the default retry/repeat behavior to test a Sched info observable would complete if the job id requested is non-existent
final CountDownLatch latch = new CountDownLatch(1);
Observable<JobSchedulingInfo> jobSchedulingInfoObservable = mantisClient.schedulingChanges("testJobCluster-1", obs -> Observable.just(1), obs -> Observable.empty());
jobSchedulingInfoObservable.doOnNext(x -> logger.info("onNext {}", x)).doOnError(t -> logger.warn("onError", t)).doOnCompleted(() -> {
logger.info("onCompleted");
latch.countDown();
}).subscribe();
latch.await();
}
use of io.mantisrx.server.core.JobSchedulingInfo in project mantis by Netflix.
the class JobActor method onGetLatestJobDiscoveryInfo.
@Override
public void onGetLatestJobDiscoveryInfo(GetLatestJobDiscoveryInfoRequest r) {
LOGGER.trace("Entering onGetLatestJobDiscoveryInfo {}", r);
ActorRef sender = getSender();
if (r.getJobCluster().equals(this.jobId.getCluster())) {
JobSchedulingInfo schedulingInfo = workerManager.getJobStatusSubject().getValue();
if (schedulingInfo != null) {
sender.tell(new GetLatestJobDiscoveryInfoResponse(r.requestId, SUCCESS, "", ofNullable(schedulingInfo)), getSelf());
} else {
LOGGER.info("discoveryInfo from BehaviorSubject is null {}", jobId);
sender.tell(new GetLatestJobDiscoveryInfoResponse(r.requestId, SERVER_ERROR, "discoveryInfo from BehaviorSubject is null " + jobId, empty()), getSelf());
}
} else {
String msg = "JobCluster in the request " + r.getJobCluster() + " does not match Job Actors job ID " + this.jobId;
LOGGER.warn(msg);
sender.tell(new GetLatestJobDiscoveryInfoResponse(r.requestId, SERVER_ERROR, msg, empty()), getSelf());
}
}
use of io.mantisrx.server.core.JobSchedulingInfo 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