Search in sources :

Example 1 with ExtendedTwillController

use of io.cdap.cdap.master.spi.twill.ExtendedTwillController in project cdap by caskdata.

the class DistributedPreviewRunStopper method stop.

@Override
public void stop(ApplicationId previewApp) throws Exception {
    byte[] info = previewStore.getPreviewRequestPollerInfo(previewApp);
    if (info == null) {
        // should not happen
        throw new IllegalStateException("Preview cannot be stopped. Please try stopping again or run the new preview.");
    }
    PreviewRequestPollerInfo pollerInfo = GSON.fromJson(new String(info, StandardCharsets.UTF_8), PreviewRequestPollerInfo.class);
    Iterator<TwillController> controllers = twillRunner.lookup(PreviewRunnerTwillApplication.NAME).iterator();
    if (!controllers.hasNext()) {
        throw new IllegalStateException("Preview runners cannot be stopped. Please try again.");
    }
    LOG.debug("Stopping preview run {} with poller info {}", previewApp, pollerInfo);
    TwillController controller = controllers.next();
    Future<String> future;
    if (controller instanceof ExtendedTwillController) {
        future = ((ExtendedTwillController) controller).restartInstance(PreviewRunnerTwillRunnable.class.getSimpleName(), pollerInfo.getInstanceId(), pollerInfo.getInstanceUid());
    } else {
        future = controller.restartInstances(PreviewRunnerTwillRunnable.class.getSimpleName(), pollerInfo.getInstanceId());
    }
    future.get();
    LOG.info("Force stopped preview run {}", previewApp);
}
Also used : TwillController(org.apache.twill.api.TwillController) ExtendedTwillController(io.cdap.cdap.master.spi.twill.ExtendedTwillController) ExtendedTwillController(io.cdap.cdap.master.spi.twill.ExtendedTwillController) PreviewRequestPollerInfo(io.cdap.cdap.internal.app.runtime.k8s.PreviewRequestPollerInfo)

Example 2 with ExtendedTwillController

use of io.cdap.cdap.master.spi.twill.ExtendedTwillController in project cdap by cdapio.

the class DistributedPreviewRunStopper method stop.

@Override
public void stop(ApplicationId previewApp) throws Exception {
    byte[] info = previewStore.getPreviewRequestPollerInfo(previewApp);
    if (info == null) {
        // should not happen
        throw new IllegalStateException("Preview cannot be stopped. Please try stopping again or run the new preview.");
    }
    PreviewRequestPollerInfo pollerInfo = GSON.fromJson(new String(info, StandardCharsets.UTF_8), PreviewRequestPollerInfo.class);
    Iterator<TwillController> controllers = twillRunner.lookup(PreviewRunnerTwillApplication.NAME).iterator();
    if (!controllers.hasNext()) {
        throw new IllegalStateException("Preview runners cannot be stopped. Please try again.");
    }
    LOG.debug("Stopping preview run {} with poller info {}", previewApp, pollerInfo);
    TwillController controller = controllers.next();
    Future<String> future;
    if (controller instanceof ExtendedTwillController) {
        future = ((ExtendedTwillController) controller).restartInstance(PreviewRunnerTwillRunnable.class.getSimpleName(), pollerInfo.getInstanceId(), pollerInfo.getInstanceUid());
    } else {
        future = controller.restartInstances(PreviewRunnerTwillRunnable.class.getSimpleName(), pollerInfo.getInstanceId());
    }
    future.get();
    LOG.info("Force stopped preview run {}", previewApp);
}
Also used : TwillController(org.apache.twill.api.TwillController) ExtendedTwillController(io.cdap.cdap.master.spi.twill.ExtendedTwillController) ExtendedTwillController(io.cdap.cdap.master.spi.twill.ExtendedTwillController) PreviewRequestPollerInfo(io.cdap.cdap.internal.app.runtime.k8s.PreviewRequestPollerInfo)

Aggregations

PreviewRequestPollerInfo (io.cdap.cdap.internal.app.runtime.k8s.PreviewRequestPollerInfo)2 ExtendedTwillController (io.cdap.cdap.master.spi.twill.ExtendedTwillController)2 TwillController (org.apache.twill.api.TwillController)2