Search in sources :

Example 1 with KieScannerResource

use of org.kie.server.api.model.KieScannerResource in project kiegroup-examples by tkobayas.

the class CreateContainerWithInternalFireOnlyWarmup method main.

public static void main(String[] args) {
    KieServicesConfiguration config = KieServicesFactory.newRestConfiguration(BASE_URL, "kieserver", "kieserver1!");
    config.setTimeout(1200000);
    KieServicesClient client = KieServicesFactory.newKieServicesClient(config);
    ReleaseId releaseId = new ReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
    KieContainerResource resource = new KieContainerResource(CONTAINER_ID, releaseId);
    resource.addConfigItem(new KieServerConfigItem("org.example.kie.server.warmup.strategy", "internal-fire-only", String.class.getName()));
    KieScannerResource scanner = new KieScannerResource(KieScannerStatus.STARTED, 10000L);
    resource.setScanner(scanner);
    ServiceResponse<KieContainerResource> response = client.createContainer(CONTAINER_ID, resource);
    System.out.println(response);
}
Also used : KieScannerResource(org.kie.server.api.model.KieScannerResource) KieServicesConfiguration(org.kie.server.client.KieServicesConfiguration) KieServicesClient(org.kie.server.client.KieServicesClient) ReleaseId(org.kie.server.api.model.ReleaseId) KieServerConfigItem(org.kie.server.api.model.KieServerConfigItem) KieContainerResource(org.kie.server.api.model.KieContainerResource)

Example 2 with KieScannerResource

use of org.kie.server.api.model.KieScannerResource in project kiegroup-examples by tkobayas.

the class CreateContainerWithInternalFullWarmup method main.

public static void main(String[] args) {
    KieServicesConfiguration config = KieServicesFactory.newRestConfiguration(BASE_URL, "kieserver", "kieserver1!");
    config.setTimeout(1200000);
    KieServicesClient client = KieServicesFactory.newKieServicesClient(config);
    ReleaseId releaseId = new ReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
    KieContainerResource resource = new KieContainerResource(CONTAINER_ID, releaseId);
    resource.addConfigItem(new KieServerConfigItem("org.example.kie.server.warmup.strategy", "internal-full", String.class.getName()));
    KieScannerResource scanner = new KieScannerResource(KieScannerStatus.STARTED, 10000L);
    resource.setScanner(scanner);
    ServiceResponse<KieContainerResource> response = client.createContainer(CONTAINER_ID, resource);
    System.out.println(response);
}
Also used : KieScannerResource(org.kie.server.api.model.KieScannerResource) KieServicesConfiguration(org.kie.server.client.KieServicesConfiguration) KieServicesClient(org.kie.server.client.KieServicesClient) ReleaseId(org.kie.server.api.model.ReleaseId) KieServerConfigItem(org.kie.server.api.model.KieServerConfigItem) KieContainerResource(org.kie.server.api.model.KieContainerResource)

Example 3 with KieScannerResource

use of org.kie.server.api.model.KieScannerResource in project droolsjbpm-integration by kiegroup.

the class KieServerRestImpl method updateScanner.

@ApiOperation(value = "Starts or stops a KIE scanner that controls polling for updated KIE container deployments, if applicable.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = ServiceResponse.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = UPDATE_SCANNER_RESPONSE_JSON) })) })
@POST
@Path("containers/{" + CONTAINER_ID + "}/scanner")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response updateScanner(@Context HttpHeaders headers, @ApiParam(value = "Container id for scanner to be updated", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String id, @ApiParam(value = "Scanner information given as KieScannerResource type", required = true, examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = UPDATE_SCANNER_JSON), @ExampleProperty(mediaType = XML, value = UPDATE_SCANNER_XML) })) String resourcePayload) {
    ServiceResponse<?> forbidden = this.server.checkAccessability();
    if (forbidden != null) {
        return createCorrectVariant(forbidden, headers, Status.BAD_REQUEST);
    }
    String contentType = getContentType(headers);
    KieScannerResource resource = marshallerHelper.unmarshal(resourcePayload, contentType, KieScannerResource.class);
    Header conversationIdHeader = buildConversationIdHeader(id, server.getServerRegistry(), headers);
    return createCorrectVariant(server.updateScanner(id, resource), headers, conversationIdHeader);
}
Also used : KieScannerResource(org.kie.server.api.model.KieScannerResource) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 4 with KieScannerResource

use of org.kie.server.api.model.KieScannerResource in project droolsjbpm-integration by kiegroup.

the class KieServerIntegrationTest method testScanner.

@Test
public void testScanner() throws Exception {
    ServiceResponse<KieScannerResource> si = client.getScannerInfo(CONTAINER_ID);
    Assert.assertEquals(ResponseType.SUCCESS, si.getType());
    KieScannerResource info = si.getResult();
    Assert.assertEquals(KieScannerStatus.DISPOSED, info.getStatus());
    si = client.updateScanner(CONTAINER_ID, new KieScannerResource(KieScannerStatus.STARTED, 10000L));
    Assert.assertEquals(si.getMsg(), ResponseType.SUCCESS, si.getType());
    info = si.getResult();
    Assert.assertEquals(KieScannerStatus.STARTED, info.getStatus());
    si = client.getScannerInfo(CONTAINER_ID);
    Assert.assertEquals(si.getMsg(), ResponseType.SUCCESS, si.getType());
    info = si.getResult();
    Assert.assertEquals(KieScannerStatus.STARTED, info.getStatus());
    si = client.updateScanner(CONTAINER_ID, new KieScannerResource(KieScannerStatus.STOPPED, 10000L));
    Assert.assertEquals(si.getMsg(), ResponseType.SUCCESS, si.getType());
    info = si.getResult();
    Assert.assertEquals(KieScannerStatus.STOPPED, info.getStatus());
    si = client.getScannerInfo(CONTAINER_ID);
    Assert.assertEquals(si.getMsg(), ResponseType.SUCCESS, si.getType());
    info = si.getResult();
    Assert.assertEquals(KieScannerStatus.STOPPED, info.getStatus());
    si = client.updateScanner(CONTAINER_ID, new KieScannerResource(KieScannerStatus.DISPOSED, 10000L));
    Assert.assertEquals(si.getMsg(), ResponseType.SUCCESS, si.getType());
    info = si.getResult();
    Assert.assertEquals(KieScannerStatus.DISPOSED, info.getStatus());
    si = client.getScannerInfo(CONTAINER_ID);
    Assert.assertEquals(si.getMsg(), ResponseType.SUCCESS, si.getType());
    info = si.getResult();
    Assert.assertEquals(KieScannerStatus.DISPOSED, info.getStatus());
}
Also used : KieScannerResource(org.kie.server.api.model.KieScannerResource) RestJmsSharedBaseIntegrationTest(org.kie.server.integrationtests.shared.basetests.RestJmsSharedBaseIntegrationTest) Test(org.junit.Test)

Example 5 with KieScannerResource

use of org.kie.server.api.model.KieScannerResource in project droolsjbpm-integration by kiegroup.

the class KieServerIntegrationTest method testScannerScanNow.

@Test
public void testScannerScanNow() throws Exception {
    ServiceResponse<KieScannerResource> si = client.getScannerInfo(CONTAINER_ID);
    Assert.assertEquals(ResponseType.SUCCESS, si.getType());
    KieScannerResource info = si.getResult();
    Assert.assertEquals(KieScannerStatus.DISPOSED, info.getStatus());
    si = client.updateScanner(CONTAINER_ID, new KieScannerResource(KieScannerStatus.SCANNING, 0L));
    Assert.assertEquals(si.getMsg(), ResponseType.SUCCESS, si.getType());
    info = si.getResult();
    Assert.assertEquals(KieScannerStatus.STOPPED, info.getStatus());
    si = client.getScannerInfo(CONTAINER_ID);
    Assert.assertEquals(si.getMsg(), ResponseType.SUCCESS, si.getType());
    info = si.getResult();
    Assert.assertEquals(KieScannerStatus.STOPPED, info.getStatus());
    si = client.updateScanner(CONTAINER_ID, new KieScannerResource(KieScannerStatus.DISPOSED, 10000L));
    Assert.assertEquals(si.getMsg(), ResponseType.SUCCESS, si.getType());
    info = si.getResult();
    Assert.assertEquals(KieScannerStatus.DISPOSED, info.getStatus());
    si = client.getScannerInfo(CONTAINER_ID);
    Assert.assertEquals(si.getMsg(), ResponseType.SUCCESS, si.getType());
    info = si.getResult();
    Assert.assertEquals(KieScannerStatus.DISPOSED, info.getStatus());
}
Also used : KieScannerResource(org.kie.server.api.model.KieScannerResource) RestJmsSharedBaseIntegrationTest(org.kie.server.integrationtests.shared.basetests.RestJmsSharedBaseIntegrationTest) Test(org.junit.Test)

Aggregations

KieScannerResource (org.kie.server.api.model.KieScannerResource)41 KieContainerResource (org.kie.server.api.model.KieContainerResource)23 ReleaseId (org.kie.server.api.model.ReleaseId)14 Test (org.junit.Test)11 KieServerConfigItem (org.kie.server.api.model.KieServerConfigItem)10 ServiceResponse (org.kie.server.api.model.ServiceResponse)9 RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)7 KieServicesClient (org.kie.server.client.KieServicesClient)6 KieServicesConfiguration (org.kie.server.client.KieServicesConfiguration)6 ContainerConfig (org.kie.server.controller.api.model.spec.ContainerConfig)6 KieScannerStatus (org.kie.server.api.model.KieScannerStatus)5 KieServerConfig (org.kie.server.api.model.KieServerConfig)5 ProcessConfig (org.kie.server.controller.api.model.spec.ProcessConfig)5 CommandScript (org.kie.server.api.commands.CommandScript)4 KieServerCommand (org.kie.server.api.model.KieServerCommand)4 Message (org.kie.server.api.model.Message)4 RestJmsSharedBaseIntegrationTest (org.kie.server.integrationtests.shared.basetests.RestJmsSharedBaseIntegrationTest)4 Matchers.anyString (org.mockito.Matchers.anyString)4 HashSet (java.util.HashSet)3 KieContainerResourceList (org.kie.server.api.model.KieContainerResourceList)3