use of com.netflix.titus.grpc.protogen.JobManagementServiceGrpc.JobManagementServiceBlockingStub in project titus-control-plane by Netflix.
the class ObserveJobsCommand method executeWithFiltering.
private void executeWithFiltering(CommandContext context, Set<String> jobFields, Set<String> taskFields, boolean printEvents, boolean snapshotOnly) {
JobManagementServiceBlockingStub stub = context.getJobManagementGrpcBlockingStub();
Stopwatch stopwatch = Stopwatch.createStarted();
ObserveJobsQuery query = ObserveJobsQuery.newBuilder().addAllJobFields(jobFields).addAllTaskFields(taskFields).build();
Iterator<JobChangeNotification> eventIt = stub.observeJobs(query);
while (eventIt.hasNext()) {
JobChangeNotification next = eventIt.next();
if (next.getNotificationCase() == JobChangeNotification.NotificationCase.SNAPSHOTEND) {
logger.info("Emitted: snapshot marker in {}ms", stopwatch.elapsed(TimeUnit.MILLISECONDS));
if (snapshotOnly) {
return;
}
} else if (next.getNotificationCase() == JobChangeNotification.NotificationCase.JOBUPDATE) {
com.netflix.titus.grpc.protogen.Job job = next.getJobUpdate().getJob();
if (printEvents) {
logger.info("Emitted job update: jobId={}({}), jobState={}, version={}", job.getId(), next.getJobUpdate().getArchived() ? "archived" : job.getStatus().getState(), job.getStatus(), job.getVersion());
}
} else if (next.getNotificationCase() == JobChangeNotification.NotificationCase.TASKUPDATE) {
com.netflix.titus.grpc.protogen.Task task = next.getTaskUpdate().getTask();
if (printEvents) {
logger.info("Emitted task update: jobId={}({}), taskId={}, taskState={}, version={}", task.getJobId(), next.getTaskUpdate().getArchived() ? "archived" : task.getStatus().getState(), task.getId(), task.getStatus(), task.getVersion());
}
} else {
logger.info("Unrecognized event type: {}", next);
}
}
}
Aggregations