Search in sources :

Example 16 with ServiceSpecification

use of co.cask.cdap.api.service.ServiceSpecification in project cdap by caskdata.

the class InMemoryServiceProgramRunner method run.

@Override
public ProgramController run(Program program, ProgramOptions options) {
    // Extract and verify parameters
    ApplicationSpecification appSpec = program.getApplicationSpecification();
    Preconditions.checkNotNull(appSpec, "Missing application specification.");
    ProgramType processorType = program.getType();
    Preconditions.checkNotNull(processorType, "Missing processor type.");
    Preconditions.checkArgument(processorType == ProgramType.SERVICE, "Only SERVICE process type is supported.");
    ServiceSpecification serviceSpec = appSpec.getServices().get(program.getName());
    Preconditions.checkNotNull(serviceSpec, "Missing ServiceSpecification for %s", program.getName());
    //RunId for the service
    RunId runId = RunIds.generate();
    return startAll(program, options, runId, serviceSpec.getInstances());
}
Also used : ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) ServiceSpecification(co.cask.cdap.api.service.ServiceSpecification) ProgramType(co.cask.cdap.proto.ProgramType) RunId(org.apache.twill.api.RunId)

Example 17 with ServiceSpecification

use of co.cask.cdap.api.service.ServiceSpecification in project cdap by caskdata.

the class DefaultAppConfigurer method addService.

public void addService(Service service) {
    Preconditions.checkArgument(service != null, "Service cannot be null.");
    DefaultServiceConfigurer configurer = new DefaultServiceConfigurer(service, deployNamespace, artifactId, artifactRepository, pluginInstantiator);
    service.configure(configurer);
    ServiceSpecification spec = configurer.createSpecification();
    addDatasetsAndPlugins(configurer);
    services.put(spec.getName(), spec);
}
Also used : ServiceSpecification(co.cask.cdap.api.service.ServiceSpecification) DefaultServiceConfigurer(co.cask.cdap.internal.app.services.DefaultServiceConfigurer)

Aggregations

ServiceSpecification (co.cask.cdap.api.service.ServiceSpecification)17 ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)7 HttpServiceHandlerSpecification (co.cask.cdap.api.service.http.HttpServiceHandlerSpecification)5 ServiceHttpEndpoint (co.cask.cdap.api.service.http.ServiceHttpEndpoint)4 ProgramId (co.cask.cdap.proto.id.ProgramId)4 Resources (co.cask.cdap.api.Resources)3 ProgramType (co.cask.cdap.proto.ProgramType)3 JsonObject (com.google.gson.JsonObject)3 Test (org.junit.Test)3 FlowSpecification (co.cask.cdap.api.flow.FlowSpecification)2 MapReduceSpecification (co.cask.cdap.api.mapreduce.MapReduceSpecification)2 SparkSpecification (co.cask.cdap.api.spark.SparkSpecification)2 ApplicationId (co.cask.cdap.proto.id.ApplicationId)2 RunId (org.apache.twill.api.RunId)2 AppWithServices (co.cask.cdap.AppWithServices)1 TxRunnable (co.cask.cdap.api.TxRunnable)1 ArtifactId (co.cask.cdap.api.artifact.ArtifactId)1 DatasetContext (co.cask.cdap.api.data.DatasetContext)1 StreamSpecification (co.cask.cdap.api.data.stream.StreamSpecification)1 DatasetManagementException (co.cask.cdap.api.dataset.DatasetManagementException)1