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);
}
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);
}
Aggregations