Search in sources :

Example 1 with IncompatibleVersionException

use of com.datatorrent.stram.client.WebServicesVersionConversion.IncompatibleVersionException in project apex-core by apache.

the class RecordingsAgent method startRecording.

public JSONObject startRecording(String appId, String opId, String portName, long numWindows) throws IncompatibleVersionException {
    LOG.debug("Start recording requested for {}.{} ({} windows)", opId, portName, numWindows);
    try {
        final JSONObject request = new JSONObject();
        StramAgent.StramUriSpec uriSpec = new StramAgent.StramUriSpec();
        uriSpec = uriSpec.path(StramWebServices.PATH_PHYSICAL_PLAN_OPERATORS).path(opId);
        if (!StringUtils.isBlank(portName)) {
            uriSpec = uriSpec.path("ports").path(portName);
        }
        uriSpec = uriSpec.path(StramWebServices.PATH_RECORDINGS_START);
        request.put("numWindows", numWindows);
        WebServicesClient webServicesClient = new WebServicesClient();
        return stramAgent.issueStramWebRequest(webServicesClient, appId, uriSpec, new WebServicesClient.WebServicesHandler<JSONObject>() {

            @Override
            public JSONObject process(WebResource.Builder webResource, Class<JSONObject> clazz) {
                return webResource.type(MediaType.APPLICATION_JSON).post(clazz, request);
            }
        });
    } catch (Exception ex) {
        LOG.error("Cannot start recording: ", ex);
        return null;
    }
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) WebResource(com.sun.jersey.api.client.WebResource) WebServicesClient(com.datatorrent.stram.util.WebServicesClient) IncompatibleVersionException(com.datatorrent.stram.client.WebServicesVersionConversion.IncompatibleVersionException) IOException(java.io.IOException) JSONException(org.codehaus.jettison.json.JSONException)

Example 2 with IncompatibleVersionException

use of com.datatorrent.stram.client.WebServicesVersionConversion.IncompatibleVersionException in project apex-core by apache.

the class RecordingsAgent method stopRecording.

public JSONObject stopRecording(String appId, String opId, String portName) throws IncompatibleVersionException {
    try {
        final JSONObject request = new JSONObject();
        StramAgent.StramUriSpec uriSpec = new StramAgent.StramUriSpec();
        uriSpec = uriSpec.path(StramWebServices.PATH_PHYSICAL_PLAN_OPERATORS).path(opId);
        if (!StringUtils.isBlank(portName)) {
            uriSpec = uriSpec.path("ports").path(portName);
        }
        uriSpec = uriSpec.path(StramWebServices.PATH_RECORDINGS_STOP);
        WebServicesClient webServicesClient = new WebServicesClient();
        return stramAgent.issueStramWebRequest(webServicesClient, appId, uriSpec, new WebServicesClient.WebServicesHandler<JSONObject>() {

            @Override
            public JSONObject process(WebResource.Builder webResource, Class<JSONObject> clazz) {
                return webResource.type(MediaType.APPLICATION_JSON).post(clazz, request);
            }
        });
    } catch (Exception ex) {
        LOG.error("Cannot stop recording: ", ex);
        return null;
    }
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) WebResource(com.sun.jersey.api.client.WebResource) WebServicesClient(com.datatorrent.stram.util.WebServicesClient) IncompatibleVersionException(com.datatorrent.stram.client.WebServicesVersionConversion.IncompatibleVersionException) IOException(java.io.IOException) JSONException(org.codehaus.jettison.json.JSONException)

Aggregations

IncompatibleVersionException (com.datatorrent.stram.client.WebServicesVersionConversion.IncompatibleVersionException)2 WebServicesClient (com.datatorrent.stram.util.WebServicesClient)2 WebResource (com.sun.jersey.api.client.WebResource)2 IOException (java.io.IOException)2 JSONException (org.codehaus.jettison.json.JSONException)2 JSONObject (org.codehaus.jettison.json.JSONObject)2