Lifecycle Microservices

 

Use the CDAP Lifecycle Microservices to deploy or delete applications and manage the lifecycle of MapReduce (DEPRECATED) and Spark programs, custom services, workers, and workflows.

For more information about CDAP components, see CDAP Components.

All methods or endpoints described in this API have a base URL (typically http://<host>:11015 or https://<host>:10443) that precedes the resource identifier, as described in the Microservices Conventions. These methods return a status code, as listed in the Microservices Status Codes.

Application Lifecycle

Create an Application

To create an application, submit an HTTP PUT request:

PUT /v3/namespaces/<namespace-id>/apps/<app-id>

(DEPRECATED) To create an application with a non-default version, submit an HTTP POST request with the version specified:

POST /v3/namespaces/<namespace-id>/apps/<app-id>/versions/<version-id>/create

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application

version-id

(DEPRECATED) Version of the application, typically following semantic versioning;

The version-id defaults to -SNAPSHOT when you don’t specify a version-id.

The request body is a JSON object specifying the artifact to use to create the application, and an optional application configuration. For example:

PUT /v3/namespaces/default/apps/purchaseWordCount { "artifact": { "name": "WordCount", "version": "6.8.0", "scope": "USER" }, "config": { “datasetName”: “purchases” }, "principal":"user/example.net@EXAMPLEKDC.NET", "app.deploy.update.schedules":"true" }

will create an application named purchaseWordCount from the example WordCount artifact. The application will receive the specified config, which will configure the application to create a dataset named purchases instead of using the default dataset name.

Optionally, you can specify a Kerberos principal with which the application should be deployed. If a Kerberos principal is specified, then all the datasets created by the application will be created with the application's Kerberos principal.

Optionally, you can set or reset the flag app.deploy.update.schedules. If true, redeploying an application will modify any schedules that currently exist for the application; if false, redeploying an application does not create any new schedules and existing schedules are neither deleted nor updated.

Update an Application (DEPRECATED)

To update an application, submit an HTTP POST request:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application

The request body is a JSON object specifying the updated artifact version and the updated application config. For example, a request body of:

will update the purchaseWordCount application to use version 6.3.0 of the WordCount artifact, and update the name of the dataset to logs. If no artifact is given, the current artifact will be used.

Only changes to artifact version are supported; changes to the artifact name are not allowed. If no config is given, the current config will be used. If the config key is present, the current config will be overwritten by the config specified in the request. As the principal of an application cannot be updated, during an update the principal should either be the same or absent.

Deploy an Artifact and Application

To deploy an application from your local file system into the namespace namespace-id, submit an HTTP POST request:

with the name of the JAR file as a header:

and Kerberos principal with which the application is to be deployed (if required):

and enable or disable updating schedules of the existing workflows using the header:

This will add the JAR file as an artifact and then create an application from that artifact. The archive name must be in the form <artifact-name>-<artifact-version>.jar. An optional header can supply a configuration object as a serialized JSON string:

The application's content is the body of the request:

Invoke the same command to update an application to a newer version. However, be sure to stop all of its Spark and MapReduce programs before updating the application.

For an application that has a configuration class such as:

We can deploy it with this call:

Note: The X-App-Config header contains the JSON serialization string of the MyAppConfig object.

List Applications

To list all of the applications in the namespace namespace-id, issue an HTTP GET request:

Parameter

Version Introduced

Description

Parameter

Version Introduced

Description

namespace-id

 

Namespace ID.

artifactName

 

Optional filter to list all applications that use the specified artifact name. Valid values are cdap-data-pipeline, cdap-data-streams, and delta-app.

artifactVersion

 

Optional filter. This is the version of the artifact given in the artifactName parameter. It will be different depending on the artifact given. To get the version list, use Artifact Microservices.

pageSize

6.6.0

Optional filter. The number of pipelines to be returned in the response. If pageSize is not specified, all pipelines will be returned. Basically, pageSize enables pagination of the results. Using this parameter changes the result format. For details, see the examples that follow.

pageToken

6.6.0

Optional filter. If pageSize is specified, use nextPageToken as the value from the response. If pageToken is not specified, returns the first page.

orderBy

6.6.0

Optional filter. Specifies the sorting order. The sorting is by Application Name and then Application Version.

Values can be ASCor DESC. If unspecified, the value will be ASC. ASC stands for ascending order whereas DESC stands for descending order.

nameFilter

6.8.0

Optional filter. Filters the application name based on nameFilterType. If nameFilterType is not set, it will use default CONTAINS type.

nameFilterType

6.8.0

Optional filter. Values can be EQUALS, CONTAINS or EQUALS_IGNORE_CASE. Specifies the way to filter application names based on nameFilter.

EQUALS: Application name must be equal to the nameFilter, case sensitive.

CONTAINS: Application name must contain the nameFilter, case insensitive.

EQUALS_IGNORE_CASE: Application name must be equal to the nameFilter, case insensitive.

sortCreationTime

6.8.0

Optional Boolean. Values can be true or false. If set to true, the sorting order will be based on the creation time of the applications, instead of by Application Name and then Application Version.

Default is false.

latestOnly

6.8.0

Optional filter. Values can be trueor false. If set to false, it returns all versions of the apps. If not specified, it will use a default true value, that only returns the latest version of the applications.

Note: When upgrading the instance from versions < 6.8 to versions >= 6.8, it’s important to follow the “upgrade applications” process in order to have the UI properly render all existing applications.

If pageSize is not specified, this returns an array of JSON Objects that lists each application with its name, description, and artifact. The list can optionally be filtered by one or more artifact names. It can also be filtered by artifact version. For example:

will return all applications that use either the cdap-data-pipeline,cdap-data-streams,or delta-app artifacts.

The following is an example response when pageSize is not specified:

If pageSize is specified, the result is a JSON object that returns the applications as a JSON array under the applications key. The page token identifier for the next page of results is specified under nextPageToken key. The absence of nextPageToken in the response denotes that it was the last page in the results.

Details of an Application

For detailed information on an application in a namespace namespace-id, use:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID.

app-id

Name of the application.

Note: To get the creation time of an application and other types of metadata, see Metadata Microservices.

The information will be returned in the body of the response. It includes the name and description of the application; the artifact and datasets that it uses, all of its programs; and the Kerberos principal, if that was provided during the deployment. For example:

HTTP Responses

Status Codes

Description

Status Codes

Description

200 OK

The event successfully called the method, and the body contains the results

Upgrade an Application

To upgrade an application in a namespace to use the latest version of application artifacts and plugin artifacts, run the following POST request:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID.

app-id

Name of the application.

artifactScope

Optional scope filter. If not specified, artifacts in the USER and SYSTEM scopes are upgraded. Otherwise, only artifacts in the specified scope are upgraded.

allowSnapshot

Optional filter to allow SNAPSHOT version of artifacts for upgrade. Set to TRUE to allow SNAPSHOT version of artifacts for upgrade. Set to FALSE to ignore SNAPSHOT version of artifacts for upgrade.

Default is false.

The response will contain a list of application details containing name, application version, namespace, and entity. For example:

Upgrade a List of Applications

To upgrade a list of existing applications in a namespace to use the latest version of application artifacts and plugin artifacts, run the following POST request:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID.

artifactScope

Optional filter to allow artifacts of scope USER and SYSTEM for upgrade. Leave blank to allow artifacts of scope USER and SYSTEM for upgrade.

Optional scope filter. If not specified, artifacts in the USER and SYSTEM scopes are upgraded. Otherwise, only artifacts in the specified scope are upgraded.

allowSnapshot

Optional filter to allow SNAPSHOT version of artifacts for upgrade. Set to TRUE to allow SNAPSHOT version of artifacts for upgrade. Set to FALSE to ignore SNAPSHOT version of artifacts for upgrade.

Default is false.

The request body is a JSON object specifying the updated artifact version and the updated application config.

For example, the following request body will upgrade the listed applications in the default namespace to use the latest version of application artifacts and plugin artifacts.

List Versions of an Application

To list all the versions of an application, submit an HTTP GET:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application being called

The response will be a JSON array containing details about the application. The details returned depend on the application.

For example, depending on the versions deployed:

could return in a JSON array a list of the versions of the application:

Delete an Application

To delete an application, together with all of its MapReduce or Spark programs, schedules, custom services, and workflows, submit an HTTP DELETE:

(DEPRECATED) To delete a specific version of an application, submit an HTTP DELETE that includes the version:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application to be deleted

version-id

(DEPRECATED) Version of the application to be deleted

This does not delete the datasets associated with the application because they belong to the namespace, not the application. Also, this does not delete the artifact used to create the application.

Delete All Applications

To delete all the applications in a namespace, use:

Export All Application Details

If you’re running Windows, you can export all application details for all namespaces as a ZIP archive file, with the following request:

If you’re running Linux or Mac, you can use the curl command to get the output and write it to file using the command:

If you’re running Windows and have powershell, you can use this command:

These commands create a folder with the name of the zip file and write the contents to a file called outfile.zip in the directory you ran the command from. output.zip contains the JSON files for all of the applications in all namespaces in the CDAP instance.

Delete a Streaming Application State (6.9.1+)

To delete a streaming application state, submit an HTTP DELETE:

DELETE namespaces/<namespace-name>/apps/<app-name>/state

Parameter

Description

namespace-name

Namespace name.

app-name

Name of the application with the state to be deleted.

You might use this endpoint after you upgrade a CDAP instance or stop a streaming pipeline to delete the state for the last processed record.

 

Note: This endpoint is supported for Kafka Consumer Streaming and Google Cloud Pub/Sub Streaming sources.

Program Lifecycle

Details of a Program

After an application is deployed, you can retrieve the details of its MapReduce and Spark programs, custom services, schedules, workers, and workflows by submitting an HTTP GET request:

To retrieve information about the schedules of the program's workflows, use:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application being called

program-type

One of mapreduceservicessparkworkers, or workflows

program-id

Name of the MapReducecustom serviceSparkworker, or workflow being called

workflow-id

Name of the workflow being called, when retrieving schedules

The response will be a JSON array containing details about the program. The details returned depend on the program type.

For example:

will return in a JSON array information about the UploadService of the application SportResults. The results will be similar to this (pretty-printed and portions deleted to fit):

MapReduce Jobs Associated with a Namespace (Deprecated)

To get a list of MapReduce jobs associated with a namespace, use:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

The response will be a JSON array containing details about the MapReduce program:

Parameter

Description

Parameter

Description

program-type

One of mapreduceservicessparkworkers, or workflows

app-id

Name of the application being called

program-id

Name of the MapReducecustom serviceSparkworker, or workflow being called

description

Description of the program

Spark Jobs Associated with a Namespace

To get a list of Spark jobs associated with a namespace, use:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

The response will be a JSON array containing details about the Spark program:

Parameter

Description

Parameter

Description

program-type

One of mapreduceservicessparkworkers, or workflows

app-id

Name of the application being called

program-id

Name of the MapReducecustom serviceSparkworker, or workflow being called

description

Description of the program

Workflows Associated with a Namespace

To get a list of workflows associated with a namespace, use:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

The response will be a JSON array containing details about the workflows:

Parameter

Description

Parameter

Description

program-type

One of mapreduceservicessparkworkers, or workflows

app-id

Name of the application being called

program-id

Name of the MapReducecustom serviceSparkworker, or workflow being called

description

Description of the program

Services Associated with a Namespace

To get a list of services associated with a namespace, use:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

The response will be a JSON array containing details about the services:

Parameter

Description

Parameter

Description

program-type

One of mapreduceservicessparkworkers, or workflows

app-id

Name of the application being called

program-id

Name of the MapReducecustom serviceSparkworker, or workflow being called

description

Description of the program

Workers Associated with a Namespace

To get a list of workers associated with a namespace, use:

The response will be a JSON array containing details about the workers:

Parameter

Description

Parameter

Description

program-type

One of mapreduceservicessparkworkers, or workflows

app-id

Name of the application being called

program-id

Name of the MapReducecustom serviceSparkworker, or workflow being called

description

Description of the program

Spark program status for an application

To check if a Spark program is available for an application, use:

GET /v3/namespaces/<namespace-id>/apps/{app-name}/spark/{program-name}/available

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-name

Name of the application.

program-name

Name of the program.

Start a Program

After an application is deployed, you can start its MapReduce and Spark programs, custom services, workers, or workflows by submitting an HTTP POST request:

You can start a program of a particular version of the application by submitting an HTTP POST request that includes the version:

When starting a program, you can optionally specify runtime arguments as a JSON map in the request body. CDAP will use these runtime arguments only for this single invocation of the program.

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application being called

version-id

Version of the application being called

program-type

One of mapreduceservicessparkworkers, or workflows

program-id

Name of the MapReducecustom serviceSparkworker, or workflow being called

ServiceSpark, and Worker programs do not allow concurrent program runs. Programs of these types cannot be started unless the program is in the STOPPED state. MapReduce and Workflow programs support concurrent runs. If you start one of these programs, a new run will be started even if other runs of the program have not finished yet.

For example:

will start the UploadService of the SportResults application with two runtime arguments.

Start Multiple Programs

You can start multiple programs from different applications and program types by submitting an HTTP POST request:

with a JSON array in the request body consisting of multiple JSON objects with these parameters:

Parameter

Description

Parameter

Description

appId

Name of the application being called

programType

One of mapreduceservicesparkworker, or workflow

programId

Name of the MapReducecustom serviceSparkworker, or workflow being started

runtimeargs

Optional JSON object containing a string to string mapping of runtime arguments to start the program with

The response will be a JSON array containing a JSON object for each object in the input. Each JSON object will contain these parameters:

Parameter

Description

Parameter

Description

appId

Name of the application being called

programType

One of mapreduceservicesparkworker, or workflow

programId

Name of the MapReducecustom serviceSparkworker, or workflow being started

statusCode

The status code from starting an individual JSON object

error

If an error, a description of why the program could not be started (for example, the specified program was not found)

runId

A UUID that uniquely identifies a run with CDAP

For example:

will attempt to start the three programs listed in the request body. It will return a response such as:

In this particular example, the service and Spark programs in the App1 application were successfully started, and there was an error starting the last program because the App2 application does not exist.

Stop a Program

You can stop the MapReduce and Spark programs, custom services, workers, and workflows of an application by submitting an HTTP POST request:

You can stop the programs of a particular application version by submitting an HTTP POST request that includes the version:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application being called

version-id

Version of the application being called

program-type

One of mapreduceservicessparkworkers, or workflows

program-id

Name of the MapReducecustom serviceSparkworker, or workflow being stopped

A program that is in the STOPPED state cannot be stopped. If there are multiple runs of the program in the RUNNING state, this call will stop one of the runs, but not all of the runs.

For example:

will stop the UploadService service in the SportResults application.

Stop a Program Run

You can stop a specific run of a program by submitting an HTTP POST request:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application being called

program-type

One of mapreduceservicessparkworkers, or workflows

program-id

Name of the MapReducecustom serviceSparkworker, or workflow being called

run-id

Run id of the run being called

For example:

will stop a specific run of the PurchaseHistoryBuilder MapReduce program in the PurchaseHistory application.

Stop Multiple Programs

You can stop multiple programs from different applications and program types by submitting an HTTP POST request:

with a JSON array in the request body consisting of multiple JSON objects with these parameters:

Parameter

Description

Parameter

Description

appId

Name of the application being called

programType

One of mapreduceservicesparkworker, or workflow

programId

Name of the MapReducecustom serviceSparkworker, or workflow being stopped

The response will be a JSON array containing a JSON object corresponding to each object in the input. Each JSON object will contain these parameters:

Parameter

Description

Parameter

Description

appId

Name of the application being called

programType

One of mapreduceservicesparkworker, or workflow

programId

Name of the MapReducecustom serviceSparkworker, or workflow being stopped

statusCode

The status code from stopping an individual JSON object

error

If an error, a description of why the program could not be stopped (for example, the specified program was not found)

For example:

will attempt to stop the three programs listed in the request body. It will return a response such as:

In this particular example, the service and MapReduce programs in the App1 application were successfully stopped, and there was an error starting the last program because the App2 application does not exist.

Status of a Program

To retrieve the status of a program, submit an HTTP GET request:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application being called

program-type

One of mapreduceschedulesservicessparkworkers, or workflows

program-id

Name of the MapReduceschedulecustom serviceSparkworker, or workflow being called

The response will be a JSON array with status of the program. For example, retrieving the status of the UploadService of the program SportResults:

will return (pretty-printed) a response such as:

Status of Multiple Programs

You can retrieve the status of multiple programs from different applications and program types by submitting an HTTP POST request:

with a JSON array in the request body consisting of multiple JSON objects with these parameters:

Parameter

Description

Parameter

Description

appId

Name of the application being called

programType

One of mapreducescheduleservicesparkworker, or workflow

programId

Name of the MapReduceschedulecustom serviceSparkworker, or workflow being called

The response will be the same JSON array as submitted with additional parameters for each of the underlying JSON objects:

Parameter

Description

Parameter

Description

status

Maps to the status of an individual JSON object's queried program if the query is valid and the program was found

statusCode

The status code from retrieving the status of an individual JSON object

error

If an error, a description of why the status was not retrieved (for example, the specified program was not found)

The status and error fields are mutually exclusive meaning if there is an error, then there will never be a status and vice versa.

For example:

will retrieve the status of two programs. It will return a response such as:

Schedule Lifecycle

Schedules can only be created for workflows.

Add a Schedule

To add a schedule for a program to an application, submit an HTTP PUT request:

To add the schedule to an application with a non-default version, submit an HTTP PUT request with the version specified:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application

schedule-id

Name of the schedule; it is unique to the application and, if specified, the application version

version-id

Version of the application, typically following semantic versioning

The request body is a JSON object specifying the details of the schedule to be created:

where a trigger is one of the trigger types. It can be a time trigger:

or a partition trigger:

or a program status trigger:

or an AND trigger, where "triggers" is a non-empty list of any type of triggers:

or an OR trigger, where "triggers" is a non-empty list of any type of triggers:

and a constraint can be one of:

HTTP Responses

Status Codes

Description

Status Codes

Description

409 Conflict

Schedule with the same name already exists

Update a Schedule

To update a schedule, submit an HTTP POST request:

To update a schedule of an application with a non-default version, submit an HTTP POST request with the version specified:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application

schedule-id

Name of the schedule; it is unique to the application and, if specified, the application version.

version-id

Version of the application, typically following semantic versioning.

The request body is a JSON object specifying the details of the schedule to be updated, and follows the same form as documented in Add a Schedule.

Only changes to the schedule configurations are supported; changes to the schedule name, or to the program associated with it are not allowed. If any properties are provided, they will overwrite all existing properties with what is provided. You must include all properties, even ones you are are not altering.

HTTP Responses

Status Codes

Description

Status Codes

Description

400 Bad Request

If the new schedule type does not match the existing schedule type or there are other client errors

Retrieving a Schedule

To retrieve a schedule in an application, submit an HTTP GET request:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application

schedule-name

Name of the schedule

The response will contain the schedule in the same form described in this topic in “Add a Schedule”.

List Schedules

To list all of the schedules for an application, use an HTTP GET request:

As schedules are created for a workflow, you can also list schedules for a workflow of an application. You can use the Details of a Deployed Application to obtain the workflows of an application.

Optionally, you can filter the schedules by trigger type and schedule status using the query parameters trigger-type and schedule-status. For more information, see Schedules.

To list all of the schedules of a workflow of an application, use an HTTP GET request:

The response will contain a list of schedules in the same form as described in “Add a Schedule”.

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application

workflow-id

Name of the workflow

Next Scheduled Run Time

To list the next time that the workflow will be be scheduled by a time trigger, use the parameter nextruntime:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application

workflow-id

Name of the workflow

Example: Retrieving The Next Runtime

HTTP Method

GET /v3/namespaces/default/apps/PurchaseHistory/workflows/PurchaseHistoryWorkflow/nextruntime

HTTP Response

[{"id":"DEFAULT.WORKFLOW:developer:PurchaseHistory:PurchaseHistoryWorkflow:0:DailySchedule","time":1415102400000}]

Description

Retrieves the next runtime of the workflow PurchaseHistoryWorkflow of the application PurchaseHistory

Next Scheduled Run Time in Batch

To list the next time that all workflows in a namespace will be be scheduled by a time trigger, use the parameter nextruntime:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

The request body must be a JSON array of objects with the following parameters:

Parameter

Description

Parameter

Description

appId

Name of the application being called

programType

Currently, only the Workflow type is supported.

programId

Name of the program being called

The response will be an array of JSON Objects, each of which will contain the three input parameters as well as two of three possible extra fields: "schedules" or “error” if an error occurs.

Parameter

Description

Parameter

Description

schedules

The next scheduled runtimes for the program defined by the individual JSON object's parameters

statusCode

The status code from retrieving the program runs

error

If an error, a description of why the status was not retrieved (for example, the specified program was not found, or the requested JSON object was missing a parameter)

Example

HTTP Method

POST /v3/namespaces/default/nextruntime

HTTP Body

[{"appId": "App1", "programType": "Service", "programId": "Service1"}, {"appId": "App1", "programType": "Workflow", "programId": "testWorkflow"}, {"appId": "App2", "programType": "Workflow", "programId": "DataPipelineWorkflow"}]

HTTP Response

[{"appId": "App1", "programType": "Service", "programId": "Service1", "statusCode": 200, "schedules": [...]}, {"appId": "App1", "programType": "Workflow", "programId": "testWorkflow", "statusCode": 404, "error": "Program 'testWorkflow' is not found"}, {"appId": "App2", "programType": "Workflow", "programId": "DataPipelineWorkflow", "statusCode": 200, "schedules": [...]]

Description

Attempt to retrieve the next scheduled run of the service Service1 in the application App1, the workflow testWorkflow in the application App1 and the workflow DataPipelineWorkflow in the application App2, all in the namespace default

Previous Run Time of All Schedules

To list the previous scheduled run time for all programs that are passed into the data, use the parameter previousruntime:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

The request body must be a JSON array of objects with the following parameters:

Parameter

Description

Parameter

Description

appId

Name of the application being called

programType

Currently, only the Workflow type is supported.

programId

Name of the program being called

The response will be an array of JSON Objects, each of which will contain the three input parameters as well as two of three possible extra fields: "schedules" or “error” if an error occurs.

Parameter

Description

Parameter

Description

schedules

The previous scheduled runtimes for the program defined by the individual JSON object's parameters

statusCode

The status code from retrieving the program runs

error

If an error, a description of why the status was not retrieved (for example, the specified program was not found, or the requested JSON object was missing a parameter)

Example

HTTP Method

POST /v3/namespaces/default/previousruntime

HTTP Body

[{"appId": "App1", "programType": "Service", "programId": "Service1"}, {"appId": "App1", "programType": "Workflow", "programId": "testWorkflow"}, {"appId": "App2", "programType": "Workflow", "programId": "DataPipelineWorkflow"}]

HTTP Response

[{"appId": "App1", "programType": "Service", "programId": "Service1", "statusCode": 200, "schedules": [...]}, {"appId": "App1", "programType": "Workflow", "programId": "testWorkflow", "statusCode": 404, "error": "Program 'testWorkflow' is not found"}, {"appId": "App2", "programType": "Workflow", "programId": "DataPipelineWorkflow", "statusCode": 200, "schedules": [...]]

Description

Attempt to retrieve the previous scheduled run of the service Service1 in the application App1, the workflow testWorkflow in the application App1 and the workflow DataPipelineWorkflow in the application App2, all in the namespace default

Previous Run Time of a Schedule

To list the previous runtime when the scheduled program ran, use the parameter previousruntime:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application to be deleted

workflow-id

Name of the Workflow

Example

HTTP Method

GET /v3/namespaces/default/apps/PurchaseHistory/workflows/PurchaseHistoryWorkflow/previousruntime

HTTP Response

[{"id":"DEFAULT.WORKFLOW:developer:PurchaseHistory:PurchaseHistoryWorkflow:0:DailySchedule","time":1415102400000}]

Description

Retrieves the previous runtime of the workflow PurchaseHistoryWorkflow of the application PurchaseHistory

Delete a Schedule

To delete a schedule, submit an HTTP DELETE:

To delete a schedule of an application with a non-default version, submit an HTTP DELETE request with the version specified:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application to be deleted

schedule-id

Name of the schedule; it is unique to the application and, if specified, the application version

version-id

Version of the application to be deleted

HTTP Responses

Status Codes

Description

Status Codes

Description

404 Bad Request

If the schedule given by schedule-id was not found

Schedule: Disable and and Enable

For a schedule, you can disable and enable it using the Microservices.

Disable: To disable a schedule means that the program associated with that schedule will not trigger again until the schedule is enabled.

Enable: To enable a schedule means that the trigger is reset, and the program associated will run again at the next scheduled time.

As a schedule is initially deployed in a disabled state, a call to this API is needed to enable it.

To disable or enable a schedule, use:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application

schedule-id

Name of the schedule

Example: Disabling a Schedule

HTTP Method

POST /v3/namespaces/default/apps/PurchaseHistory/schedules/DailySchedule/disable

HTTP Response

OK if successfully set as disabled

Description

Disables the schedule DailySchedule of the application PurchaseHistory

Container Information

To find out the address of an program's container host and the container’s debug port, you can query CDAP for a service’s live info via an HTTP GET method:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application being called

program-type

One of services or workers

program-id

Name of the program (service or worker)

Example:

The response is formatted in JSON; an example of this is shown in CDAP Testing and Debugging.

Scaling

You can retrieve the instance count executing different components from various applications and different program types using an HTTP POST method:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

with a JSON array in the request body consisting of multiple JSON objects with these parameters:

Parameter

Description

Parameter

Description

appId

Name of the application being called

programType

One of service or worker

programId

Name of the program (service or worker) being called

The response will be the same JSON array as submitted with additional parameters for each of the underlying JSON objects:

Parameter

Description

Parameter

Description

requested

Number of instances the user requested for the program defined by the individual JSON object's parameters

provisioned

Number of instances that are actually running for the program defined by the individual JSON object's parameters.

statusCode

The status code from retrieving the instance count of an individual JSON object

error

If an error, a description of why the status was not retrieved (for example, the specified program was not found, or the requested JSON object was missing a parameter)

Example

HTTP Method

POST /v3/namespaces/default/instances

HTTP Body

[{"appId":"MyApp1","programType":"Worker","programId":"MyWorker1",}, {"appId":"MyApp3","programType":"Service","programId":"MySvc1,}]

HTTP Response

[{"appId":"MyApp1","programType":"Worker","programId":"MyWorker1", "provisioned":2,"requested":2,"statusCode":200}, {"appId":"MyApp3","programType":"Service","programId":"MySvc1,}]

Description

Attempt to retrieve the instances of programType Worker in the application MyApp1, and the service handler MyHandler1 in the user service MySvc1 in the application MyApp3, all in the namespace default

Scaling Services

You can query or change the number of instances of a service by using the instances parameter with HTTP GET or PUT methods:

with the arguments as a JSON string in the body:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application

service-id

Name of the service

quantity

Number of instances to be used

Examples

  • Retrieve the number of instances of the service CatalogLookup in the application PurchaseHistory in the namespace default:

  • Set the number of handler instances of the service RetrieveCounts of the application WordCount:

    with the arguments as a JSON string in the body:

  • Using curl and the CDAP Sandbox:

    • Linux
      $ curl -w"\n" -X PUT "http://localhost:11015/v3/namespaces/default/apps/WordCount/services/RetrieveCounts/instances" \ -d '{ "instances" : 2 }'

    • Windows
      > curl -X PUT "http://localhost:11015/v3/namespaces/default/apps/WordCount/services/RetrieveCounts/instances" ^ -d "{ \"instances\" : 2 }"

Scaling Workers

You can query or change the number of instances of a worker by using the instances parameter with HTTP GET or PUT methods:

with the arguments as a JSON string in the body:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application

worker-id

Name of the worker

quantity

Number of instances to be used

Example

Retrieve the number of instances of the worker DataWorker in the application DemoApp in the namespace default:

Run Records

To see all the runs of a selected program (MapReduce programs, Spark programs, services, or workflows), issue an HTTP GET to the program’s URL with the runs parameter. This will return a JSON list of all runs for the program, each with a start time, end time, and program status:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application

program-type

One of mapreduceservicesspark, or workflows

program-id

Name of the MapReducecustom serviceSpark, or workflow being called

You can filter the runs by the status of a program, the start and end times, and can limit the number of returned records:

Query Parameter

Description

Query Parameter

Description

status

PENDING, STARTING, RUNNING, STOPPING, COMPLETED, FAILED, KILLED, REJECTED

start

start timestamp

end

end timestamp

limit

maximum number of returned records

The response will be a JSON array containing a JSON object for each object in the input. Each JSON object will contain these parameters:

Parameter

Description

Parameter

Description

run-id

A UUID that uniquely identifies a run within CDAP, with the start and end times in seconds since the start of the Epoch (midnight 1/1/1970). Use that runid in subsequent calls to obtain additional information.

starting

The timestamp at which the program was requested to start by the user.

start

The timestamp at which the program actually started.

suspend

The timestamp at which this run was suspended (if it was suspended).

resume

The timestamp at which this run was resumed (if it was resumed after being suspended).

stopping

The timestamp at which the request to stop this run was made.

terminate

The timestamp after which the run will be forcefully killed if it does not stop gracefully.

status

The status of the run in question.

properties

A map of the properties of the run. Has subfields.

properties.runtimeArgs

The runtime arguments provided to the run serialized as a JSON string.

cluster

provides information about the cluster on which the run was executed. Has subfields.

cluster.status

The current status of the cluster.

cluster.numNodes

The number of nodes in the cluster.

profile

The compute profile used for the run.

profile.profileName

The name of the compute profile.

profile.namespace

The namespace of the compute profile.

profile.entity

The profile’s entity type.

Example: Retrieving Run Records

HTTP Method

GET /v3/namespaces/default/apps/SportResults/mapreduce/ScoreCounter/runs

HTTP Response

{"runid":"...","start":1382567598,"status":"RUNNING"},

{"runid":"...","start":1382567447,"end":1382567492,"status":"STOPPED"},

{"runid":"...","start":1382567383,"end":1382567397,"status":"STOPPED"}

Description

Retrieve the run records of the MapReduce ScoreCounter of the application SportResults.

Retrieving Specific Run Information

To fetch the run record for a particular run of a program, use:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application

program-type

One of mapreduceservicesspark, or workflows

program-id

Name of the MapReducecustom serviceSpark, or workflow being called

run-id

Run id of the run

The response will be a JSON array containing a JSON object for each object in the input. Each JSON object will contain these parameters:

Parameter

Description

Parameter

Description

run-id

A UUID that uniquely identifies a run within CDAP, with the start and end times in seconds since the start of the Epoch (midnight 1/1/1970). Use that runid in subsequent calls to obtain additional information.

starting

The timestamp at which the program was requested to start by the user.

start

The timestamp at which the program actually started.

suspend

The timestamp at which this run was suspended (if it was suspended).

resume

The timestamp at which this run was resumed (if it was resumed after being suspended).

stopping

The timestamp at which the request to stop this run was made.

terminate

The timestamp after which the run will be forcefully killed if it does not stop gracefully.

status

The status of the run in question.

properties

A map of the properties of the run. Has subfields.

properties.runtimeArgs

The runtime arguments provided to the run serialized as a JSON string.

cluster

provides information about the cluster on which the run was executed. Has subfields.

cluster.status

The current status of the cluster.

cluster.numNodes

The number of nodes in the cluster.

profile

The compute profile used for the run.

profile.profileName

The name of the compute profile.

profile.namespace

The namespace of the compute profile.

profile.entity

The profile’s entity type.

Example: Retrieving a Particular Run Record

HTTP Method

GET /v3/namespaces/default/apps/SportResults/mapreduce/ScoreCounter/runs/b78d0091-da42-11e4-878c-2217c18f435d

HTTP Response

{"runid":"...","start":1382567598,"status":"RUNNING"}

Description

Retrieve the run record of the MapReduce ScoreCounter of the application SportResults run b78d0091-da42-11e4-878c-2217c18f435d

For services, you can retrieve:

  • the history of successfully completed Apache Twill service runs using:

For workflows, you can retrieve:

  • the information about the currently running node(s) in the workflow:

More information about workflow endpoint can be found at Workflows

  • the schedules defined for a workflow (using the parameter schedules):

  • the next time that the workflow is scheduled to run (using the parameter nextruntime):

Examples

Example: Retrieving The Most Recent Run

HTTP Method

GET /v3/namespaces/default/apps/PurchaseHistory/services/CatalogLookup/runs?status=completed&limit=1

HTTP Response

[{"runid":"cad83d45-ecfb-4bf8-8cdb-4928a5601b0e","start":1415051892,"end":1415057103,"status":"STOPPED"}]

Description

Retrieve the most recent successful completed run of the service CatalogLookup of the application PurchaseHistory

Retrieving Run Records in Batch

To retrieve the latest run records for run records for multiple programs, use:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

The request body must be a JSON array of objects with the following parameters:

Parameter

Description

Parameter

Description

run-id

A UUID that uniquely identifies a run within CDAP, with the start and end times in seconds since the start of the Epoch (midnight 1/1/1970). Use that runid in subsequent calls to obtain additional information.

starting

The timestamp at which the program was requested to start by the user.

start

The timestamp at which the program actually started.

suspend

The timestamp at which this run was suspended (if it was suspended).

resume

The timestamp at which this run was resumed (if it was resumed after being suspended).

stopping

The timestamp at which the request to stop this run was made.

terminate

The timestamp after which the run will be forcefully killed if it does not stop gracefully.

status

The status of the run in question.

properties

A map of the properties of the run. Has subfields.

properties.runtimeArgs

The runtime arguments provided to the run serialized as a JSON string.

cluster

provides information about the cluster on which the run was executed. Has subfields.

cluster.status

The current status of the cluster.

cluster.numNodes

The number of nodes in the cluster.

profile

The compute profile used for the run.

profile.profileName

The name of the compute profile.

profile.namespace

The namespace of the compute profile.

profile.entity

The profile’s entity type.

The response will be an array of JSON Objects, each of which will contain the three input parameters as well as two of three possible extra fields: runs, which is a list of the latest run record for that program, statusCode, which maps to the status code for retrieving the runs for that program, and error if there was an error retrieving runs for that program. The "statusCode" property will always be included, but runs and error are mutually exclusive.

Parameter

Description

Parameter

Description

runs

The latest run records for the program defined by the individual JSON object's parameters

statusCode

The status code from retrieving the program runs

error

If an error, a description of why the status was not retrieved (for example, the specified program was not found, or the requested JSON object was missing a parameter)

Example

HTTP Method

POST /v3/namespaces/default/runs

HTTP Body

[{"appId": "App1", "programType": "Service", "programId": "Service1"}, {"appId": "App1", "programType": "Workflow", "programId": "testWorkflow"}, {"appId": "App2", "programType": "Workflow", "programId": "DataPipelineWorkflow"}]

HTTP Response

[{"appId": "App1", "programType": "Service", "programId": "Service1", "statusCode": 200, "runs": [...]}, {"appId": "App1", "programType": "Workflow", "programId": "testWorkflow", "statusCode": 404, "error": "Program 'testWorkflow' is not found"}, {"appId": "App2", "programType": "Workflow", "programId": "DataPipelineWorkflow", "statusCode": 200, "runs": [...]]

Description

Attempt to retrieve the latest run records of the service Service1 in the application App1, the workflow testWorkflow in the application App1 and the workflow DataPipelineWorkflow in the application App2, all in the namespace default

Retrieving Run Counts in Batch

To retrieve the run counts for multiple programs, use:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

The request body must be a JSON array of objects with the following parameters:

Parameter

Description

Parameter

Description

appId

Name of the application being called

programType

One of mapreducesparkworkflowservice, or worker

programId

Name of the program (mapreducesparkworkflowservice, or worker) being called

The response will be an array of Json Objects, each of which will contain the three input parameters as well as two of three possible extra fields -- "runCount", which is count for the program run, "statusCode", which maps to the status code for retrieving the run count for that program, and "error" if there was an error retrieving runs for that program. The "statusCode" property will always be included, but "runCount" and "error" are mutually exclusive.

Parameter

Description

Parameter

Description

runCount

The number of program runs for the program defined by the individual JSON object's parameters over the entire lifetime

statusCode

The status code from retrieving the program run count

error

If an error, a description of why the status was not retrieved (for example, the specified program was not found, or the requested JSON object was missing a parameter)

Example

HTTP Method

POST /v3/namespaces/default/runcount

HTTP Body

[{"appId": "App1", "programType": "Service", "programId": "Service1"}, {"appId": "App1", "programType": "Workflow", "programId": "testWorkflow"}, {"appId": "App2", "programType": "Workflow", "programId": "DataPipelineWorkflow"}]

HTTP Response

[{"appId": "App1", "programType": "Service", "programId": "Service1", "statusCode": 200, "runCount": 20}, {"appId": "App1", "programType": "Workflow", "programId": "testWorkflow", "statusCode": 404, "error": "Program 'testWorkflow' is not found"}, {"appId": "App2", "programType": "Workflow", "programId": "DataPipelineWorkflow", "statusCode": 200, "runCount": 300}]

Description

Attempt to retrieve the run count of the service Service1 in the application App1, the workflow testWorkflow in the application App1 and the workflow DataPipelineWorkflow in the application App2, all in the namespace default

Retrieving Specific Run Count

To fetch the run count for a particular program, use:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application

program-type

One of mapreducesparkworkflowservice, or worker

program-id

Name of the program (mapreducesparkworkflowservice, or worker) being called

Example

HTTP Method

GET /v3/namespaces/default/apps/myApp/workflows/DataPipelineWorkflow/runcount

HTTP Response

[2]

Description

Retrieve the run count of the workflow DataPipelineWorkflow of the application myApp

Workflow Runs: Suspend and Resume

For workflows, in addition to starting and stopping, you can suspend and resume individual runs of a workflow using the RESTful API.

Suspend: To suspend means that the current activity will be taken to completion, but no further programs will be initiated. Programs will not be left partially uncompleted, barring any errors.

In the case of a workflow with multiple MapReduce programs, if one of them is running (first of three perhaps) and you suspend the workflow, that first MapReduce will be completed but the following two will not be started.

Resume: To resume means that activity will start up where it was left off, beginning with the start of the next program in the sequence.

In the case of the workflow mentioned above, resuming it after suspension would start up with the second of the three MapReduce programs, which is where it would have left off when it was suspended.

With workflows, suspend and resume require a run-id as the action takes place on either a currently running or suspended workflow.

To suspend or resume a workflow, use:

Parameter

Description

Parameter

Description

namespace-id

Namespace ID

app-id

Name of the application

workflow-id

Name of the workflow

run-id

UUID of the workflow run

Example: Suspending a Workflow

HTTP Method

POST /v3/namespaces/default/apps/PurchaseHistory/workflows/PurchaseHistoryWorkflow/runs/0ce13912-e980-11e4-a7d7-8cae4cfd0e64/suspend

HTTP Response

Program run suspended. if successfully set as suspended

Description

Suspends the run 0ce13912-e980-11e4-a7d7-8cae4cfd0e64 of the workflow PurchaseHistoryWorkflow of the application PurchaseHistory

 

Created in 2020 by Google Inc.