Search in sources :

Example 1 with TetheringControlMessage

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);
}
Also used : TetheringControlMessage(io.cdap.cdap.internal.tethering.TetheringControlMessage) ProgramRunInfo(io.cdap.cdap.runtime.spi.ProgramRunInfo)

Example 2 with TetheringControlMessage

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);
}
Also used : RuntimeJobStatus(io.cdap.cdap.runtime.spi.runtimejob.RuntimeJobStatus) TetheringControlMessage(io.cdap.cdap.internal.tethering.TetheringControlMessage) RuntimeJobDetail(io.cdap.cdap.runtime.spi.runtimejob.RuntimeJobDetail)

Example 3 with TetheringControlMessage

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());
    }
}
Also used : TetheringControlMessage(io.cdap.cdap.internal.tethering.TetheringControlMessage) Message(io.cdap.cdap.api.messaging.Message) TetheringControlMessage(io.cdap.cdap.internal.tethering.TetheringControlMessage) Test(org.junit.Test)

Aggregations

TetheringControlMessage (io.cdap.cdap.internal.tethering.TetheringControlMessage)3 Message (io.cdap.cdap.api.messaging.Message)1 ProgramRunInfo (io.cdap.cdap.runtime.spi.ProgramRunInfo)1 RuntimeJobDetail (io.cdap.cdap.runtime.spi.runtimejob.RuntimeJobDetail)1 RuntimeJobStatus (io.cdap.cdap.runtime.spi.runtimejob.RuntimeJobStatus)1 Test (org.junit.Test)1