use of io.cdap.cdap.internal.tethering.TetheringControlMessage in project cdap by caskdata.
the class TetheringRuntimeJobManager method launch.
@Override
public void launch(RuntimeJobInfo runtimeJobInfo) throws Exception {
ProgramRunInfo runInfo = runtimeJobInfo.getProgramRunInfo();
LOG.debug("Launching run {} with following configurations: tethered instance name {}, tethered namespace {}.", runInfo.getRun(), tetheredInstanceName, tetheredNamespace);
byte[] payload = Bytes.toBytes(GSON.toJson(createLaunchPayload(runtimeJobInfo.getLocalizeFiles())));
TetheringControlMessage message = new TetheringControlMessage(TetheringControlMessage.Type.RUN_PIPELINE, payload);
publishToControlChannel(message);
}
use of io.cdap.cdap.internal.tethering.TetheringControlMessage in project cdap by caskdata.
the class TetheringRuntimeJobManager method stop.
@Override
public void stop(ProgramRunInfo programRunInfo) throws Exception {
RuntimeJobDetail jobDetail = getDetail(programRunInfo).orElse(null);
if (jobDetail == null) {
return;
}
RuntimeJobStatus status = jobDetail.getStatus();
if (status.isTerminated() || status == RuntimeJobStatus.STOPPING) {
return;
}
LOG.debug("Stopping run {} with following configurations: tethered instance name {}, tethered namespace {}.", programRunInfo.getRun(), tetheredInstanceName, tetheredNamespace);
byte[] payload = Bytes.toBytes(GSON.toJson(programRunInfo));
TetheringControlMessage message = new TetheringControlMessage(TetheringControlMessage.Type.STOP_PIPELINE, payload);
publishToControlChannel(message);
}
use of io.cdap.cdap.internal.tethering.TetheringControlMessage in project cdap by caskdata.
the class TetheringRuntimeJobManagerTest method testPublishToControlChannel.
@Test
public void testPublishToControlChannel() throws Exception {
TetheringControlMessage message = new TetheringControlMessage(TetheringControlMessage.Type.RUN_PIPELINE, "payload".getBytes(StandardCharsets.UTF_8));
runtimeJobManager.publishToControlChannel(message);
try (CloseableIterator<Message> iterator = messageFetcher.fetch(topicId.getNamespace(), topicId.getTopic(), 1, 0)) {
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals(GSON.toJson(message), iterator.next().getPayloadAsString());
}
}
Aggregations