Search in sources :

Example 91 with ProgramId

use of co.cask.cdap.proto.id.ProgramId in project cdap by caskdata.

the class MetadataHttpHandler method removeProgramProperty.

@DELETE
@Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/metadata/properties/{property}")
public void removeProgramProperty(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId, @PathParam("property") String property) throws NotFoundException {
    ProgramId program = new ProgramId(namespaceId, appId, ProgramType.valueOfCategoryName(programType), programId);
    metadataAdmin.removeProperties(program, property);
    responder.sendString(HttpResponseStatus.OK, String.format("Metadata property %s for program %s deleted successfully.", property, program));
}
Also used : ProgramId(co.cask.cdap.proto.id.ProgramId) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 92 with ProgramId

use of co.cask.cdap.proto.id.ProgramId in project cdap by caskdata.

the class MetadataHttpHandler method addProgramTags.

@POST
@Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/metadata/tags")
@AuditPolicy(AuditDetail.REQUEST_BODY)
public void addProgramTags(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId) throws BadRequestException, NotFoundException {
    ProgramId program = new ProgramId(namespaceId, appId, ProgramType.valueOfCategoryName(programType), programId);
    metadataAdmin.addTags(program, readArray(request));
    responder.sendString(HttpResponseStatus.OK, String.format("Added tags to program %s successfully.", program));
}
Also used : ProgramId(co.cask.cdap.proto.id.ProgramId) Path(javax.ws.rs.Path) AuditPolicy(co.cask.cdap.common.security.AuditPolicy) POST(javax.ws.rs.POST)

Example 93 with ProgramId

use of co.cask.cdap.proto.id.ProgramId in project cdap by caskdata.

the class MetadataHttpHandler method addProgramProperties.

@POST
@Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/metadata/properties")
@AuditPolicy(AuditDetail.REQUEST_BODY)
public void addProgramProperties(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId) throws BadRequestException, NotFoundException {
    ProgramId program = new ProgramId(namespaceId, appId, ProgramType.valueOfCategoryName(programType), programId);
    metadataAdmin.addProperties(program, readMetadata(request));
    responder.sendString(HttpResponseStatus.OK, "Metadata added successfully to " + program);
}
Also used : ProgramId(co.cask.cdap.proto.id.ProgramId) Path(javax.ws.rs.Path) AuditPolicy(co.cask.cdap.common.security.AuditPolicy) POST(javax.ws.rs.POST)

Example 94 with ProgramId

use of co.cask.cdap.proto.id.ProgramId in project cdap by caskdata.

the class MetadataHttpHandler method removeProgramTags.

@DELETE
@Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/metadata/tags")
public void removeProgramTags(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId) throws NotFoundException {
    ProgramId program = new ProgramId(namespaceId, appId, ProgramType.valueOfCategoryName(programType), programId);
    metadataAdmin.removeTags(program);
    responder.sendString(HttpResponseStatus.OK, String.format("Tags for program %s deleted successfully.", program));
}
Also used : ProgramId(co.cask.cdap.proto.id.ProgramId) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 95 with ProgramId

use of co.cask.cdap.proto.id.ProgramId in project cdap by caskdata.

the class AbstractProgramRuntimeServiceTest method testUpdateDeadLock.

@Test(timeout = 5000L)
public void testUpdateDeadLock() {
    // This test is for testing (CDAP-3716)
    // Create a service to simulate an existing running app.
    Service service = new TestService();
    ProgramId programId = NamespaceId.DEFAULT.app("dummyApp").program(ProgramType.WORKER, "dummy");
    RunId runId = RunIds.generate();
    ProgramRuntimeService.RuntimeInfo extraInfo = createRuntimeInfo(service, programId, runId);
    service.startAndWait();
    ProgramRunnerFactory runnerFactory = createProgramRunnerFactory();
    TestProgramRuntimeService runtimeService = new TestProgramRuntimeService(CConfiguration.create(), runnerFactory, null, extraInfo);
    runtimeService.startAndWait();
    // The lookup will get deadlock for CDAP-3716
    Assert.assertNotNull(runtimeService.lookup(programId, runId));
    service.stopAndWait();
    runtimeService.stopAndWait();
}
Also used : AbstractExecutionThreadService(com.google.common.util.concurrent.AbstractExecutionThreadService) AbstractIdleService(com.google.common.util.concurrent.AbstractIdleService) Service(com.google.common.util.concurrent.Service) ProgramId(co.cask.cdap.proto.id.ProgramId) RunId(org.apache.twill.api.RunId) Test(org.junit.Test)

Aggregations

ProgramId (co.cask.cdap.proto.id.ProgramId)209 Test (org.junit.Test)89 ApplicationId (co.cask.cdap.proto.id.ApplicationId)69 Path (javax.ws.rs.Path)45 StreamId (co.cask.cdap.proto.id.StreamId)35 DatasetId (co.cask.cdap.proto.id.DatasetId)34 RunId (org.apache.twill.api.RunId)34 ProgramRunId (co.cask.cdap.proto.id.ProgramRunId)31 NamespaceId (co.cask.cdap.proto.id.NamespaceId)29 ProgramType (co.cask.cdap.proto.ProgramType)25 ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)24 IOException (java.io.IOException)24 NotFoundException (co.cask.cdap.common.NotFoundException)22 HttpResponse (org.apache.http.HttpResponse)19 ArrayList (java.util.ArrayList)18 GET (javax.ws.rs.GET)18 Id (co.cask.cdap.proto.Id)16 File (java.io.File)15 POST (javax.ws.rs.POST)15 ArtifactId (co.cask.cdap.proto.id.ArtifactId)13