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);
}
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);
}
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);
}
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());
}
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());
}
Aggregations