congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
HttpPostClusterCallback
Code IndexAdd Tabnine to your IDE (free)

How to use
HttpPostClusterCallback
in
co.cask.coopr.scheduler.callback

Best Java code snippets using co.cask.coopr.scheduler.callback.HttpPostClusterCallback (Showing top 7 results out of 315)

origin: caskdata/coopr

this.onSuccessUrl = conf.get(Constants.HttpCallback.SUCCESS_URL);
this.onFailureUrl = conf.get(Constants.HttpCallback.FAILURE_URL);
this.startTriggerActions = parseActionsString(conf.get(Constants.HttpCallback.START_TRIGGERS,
                            Constants.HttpCallback.DEFAULT_START_TRIGGERS));
this.successTriggerActions = parseActionsString(conf.get(Constants.HttpCallback.SUCCESS_TRIGGERS,
                            Constants.HttpCallback.DEFAULT_SUCCESS_TRIGGERS));
this.failureTriggerActions = parseActionsString(conf.get(Constants.HttpCallback.FAILURE_TRIGGERS,
                             Constants.HttpCallback.DEFAULT_FAILURE_TRIGGERS));
if (onStartUrl != null) {
origin: caskdata/coopr

public boolean onStart(CallbackData data, CallbackContext context) {
 ClusterAction jobAction = data.getJob().getClusterAction();
 if (startTriggerActions.contains(jobAction)) {
  if (onStartUrl != null) {
   LOG.debug("sending request to {} before performing {} on cluster {}",
        onStartUrl, jobAction, data.getCluster().getId());
   sendPost(onStartUrl, data, context);
  }
 }
 return true;
}
origin: caskdata/coopr

@Test
public void testCalls() {
 HttpPostClusterCallback callback = new HttpPostClusterCallback();
 String base = "http://" + host + ":" + port;
 conf = Configuration.create();
 conf.set(Constants.HttpCallback.START_URL, base + "/start/endpoint");
 conf.set(Constants.HttpCallback.SUCCESS_URL, base + "/success/endpoint");
 conf.set(Constants.HttpCallback.FAILURE_URL, base + "/failure/endpoint");
 callback.initialize(conf);
 ClusterJob job = new ClusterJob(new JobId(cluster.getId(), 1), ClusterAction.CLUSTER_CREATE);
 CallbackData data = new CallbackData(CallbackData.Type.START, cluster, job);
 CallbackContext context = new CallbackContext(clusterStoreService, userStore, cluster.getAccount());
 callback.onStart(data, context);
 callback.onSuccess(data, context);
 callback.onSuccess(data, context);
 callback.onFailure(data, context);
 Assert.assertEquals(handler.getStartCount(), 1);
 Assert.assertEquals(handler.getFailureCount(), 1);
 Assert.assertEquals(handler.getSuccessCount(), 2);
}
origin: caskdata/coopr

@Test
public void testOnStartIsTrueWithBadURL() {
 HttpPostClusterCallback callback = new HttpPostClusterCallback();
 conf = Configuration.create();
 conf.set(Constants.HttpCallback.START_URL, "malformed-url");
 callback.initialize(conf);
 ClusterJob job = new ClusterJob(new JobId(cluster.getId(), 1), ClusterAction.CLUSTER_CREATE);
 CallbackData data = new CallbackData(CallbackData.Type.START, cluster, job);
 CallbackContext context = new CallbackContext(clusterStoreService, userStore, cluster.getAccount());
 Assert.assertTrue(callback.onStart(data, context));
}
origin: caskdata/coopr

@Test
public void testTriggers() {
 HttpPostClusterCallback callback = new HttpPostClusterCallback();
 String base = "http://" + host + ":" + port;
 conf = Configuration.create();
 conf.set(Constants.HttpCallback.START_URL, base + "/start/endpoint");
 conf.set(Constants.HttpCallback.START_TRIGGERS, ClusterAction.CLUSTER_CONFIGURE.name());
 callback.initialize(conf);
 // should not get triggered
 ClusterJob job = new ClusterJob(new JobId(cluster.getId(), 1), ClusterAction.CLUSTER_CREATE);
 CallbackData data = new CallbackData(CallbackData.Type.START, cluster, job);
 CallbackContext context = new CallbackContext(clusterStoreService, userStore, cluster.getAccount());
 callback.onStart(data, context);
 Assert.assertEquals(0, handler.getStartCount());
 // should get triggered
 job = new ClusterJob(new JobId(cluster.getId(), 1), ClusterAction.CLUSTER_CONFIGURE);
 data = new CallbackData(CallbackData.Type.START, cluster, job);
 callback.onStart(data, context);
 Assert.assertEquals(1, handler.getStartCount());
}
origin: caskdata/coopr

public void onSuccess(CallbackData data, CallbackContext context) {
 ClusterAction jobAction = data.getJob().getClusterAction();
 if (successTriggerActions.contains(data.getJob().getClusterAction())) {
  if (onSuccessUrl != null) {
   LOG.debug("{} completed successfully on cluster {}, sending request to {}",
        jobAction, data.getCluster().getId(), onSuccessUrl);
   sendPost(onSuccessUrl, data, context);
  }
 }
}
origin: caskdata/coopr

@Override
public void onFailure(CallbackData data, CallbackContext context) {
 ClusterAction jobAction = data.getJob().getClusterAction();
 if (failureTriggerActions.contains(data.getJob().getClusterAction())) {
  if (onFailureUrl != null) {
   LOG.debug("{} failed on cluster {}, sending request to {}",
        jobAction, data.getCluster().getId(), onFailureUrl);
   sendPost(onFailureUrl, data, context);
  }
 }
}
co.cask.coopr.scheduler.callbackHttpPostClusterCallback

Javadoc

Executes before and after hooks by sending an HTTP POST request to some configurable endpoints, with the post body containing the cluster and job objects, assuming there is a valid url assigned to the start, success, and/or failure urls. If no url is specified, no request will be sent. Additionally, trigger actions can be configured so that the HTTP POST request is sent only for specific cluster actions. This is done by specifying a comma separated list of ClusterActions in the configuration for start, success, and/or triggers.

Most used methods

  • <init>
  • initialize
  • onFailure
  • onStart
  • onSuccess
  • parseActionsString
  • sendPost

Popular in Java

  • Finding current android device location
  • setContentView (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Notification (javax.management)
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now