use of org.kie.server.services.impl.KieContainerInstanceImpl in project droolsjbpm-integration by kiegroup.
the class TaskAssigningPlanningKieServerExtension method initSolverRuntime.
private boolean initSolverRuntime() {
if (!isEmpty(solverDef.getContainerId())) {
KieContainerResource resource = new KieContainerResource(solverDef.getContainerId(), new ReleaseId(solverDef.getGroupId(), solverDef.getArtifactId(), solverDef.getVersion()));
KieContainerInstanceImpl container = prepareContainer(resource);
if (container == null) {
String msg = String.format(PLANNER_CONTAINER_NOT_AVAILABLE, solverDef.getContainerId());
LOGGER.error(msg);
registerMessage(Severity.ERROR, msg);
return false;
}
registerExtractors(container);
}
try {
// early check that solver can be properly started.
createSolver(registry, solverDef);
} catch (Exception e) {
String msg = String.format(PLANNER_SOLVER_INSTANTIATION_CHECK_ERROR, e.getMessage());
LOGGER.error(msg, e);
registerMessage(Severity.ERROR, msg);
return false;
}
return true;
}
use of org.kie.server.services.impl.KieContainerInstanceImpl in project droolsjbpm-integration by kiegroup.
the class KeepLatestContainerOnlyPolicyTest method testDisposeOldContainer.
@Test
public void testDisposeOldContainer() {
KieServerRegistry kieServerRegistry = new KieServerRegistryImpl();
KieContainerInstanceImpl kieContainerInstance = new KieContainerInstanceImpl(CONTAINER_ONE, KieContainerStatus.STARTED, kieContainerOne);
kieServerRegistry.registerContainer(CONTAINER_ONE, kieContainerInstance);
kieContainerInstance = new KieContainerInstanceImpl(CONTAINER_TWO, KieContainerStatus.STARTED, kieContainerTwo);
kieServerRegistry.registerContainer(CONTAINER_TWO, kieContainerInstance);
KeepLatestContainerOnlyPolicy policy = new KeepLatestContainerOnlyPolicy();
policy.apply(kieServerRegistry, kieServer);
verify(kieServer).disposeContainer(CONTAINER_ONE);
}
use of org.kie.server.services.impl.KieContainerInstanceImpl in project droolsjbpm-integration by kiegroup.
the class KeepLatestContainerOnlyPolicyTest method testDoNotDisposeNewerCreatedContainer.
@Test
public void testDoNotDisposeNewerCreatedContainer() {
KieServerRegistry kieServerRegistry = new KieServerRegistryImpl();
KieContainerInstanceImpl kieContainerInstance = new KieContainerInstanceImpl(CONTAINER_ONE, KieContainerStatus.STARTED, kieContainerOne);
kieServerRegistry.registerContainer(CONTAINER_ONE, kieContainerInstance);
kieContainerInstance = new KieContainerInstanceImpl(CONTAINER_TWO, KieContainerStatus.CREATING, kieContainerTwo);
kieServerRegistry.registerContainer(CONTAINER_TWO, kieContainerInstance);
KeepLatestContainerOnlyPolicy policy = new KeepLatestContainerOnlyPolicy();
policy.apply(kieServerRegistry, kieServer);
verify(kieServer, never()).disposeContainer(anyString());
}
use of org.kie.server.services.impl.KieContainerInstanceImpl in project droolsjbpm-integration by kiegroup.
the class ModelEvaluatorServiceBase method getModels.
public ServiceResponse<DMNModelInfoList> getModels(String containerId) {
try {
KieContainerInstanceImpl kContainer = context.getContainer(containerId, ContainerLocatorProvider.get().getLocator());
DMNRuntime kieRuntime = KieRuntimeFactory.of(kContainer.getKieContainer().getKieBase()).get(DMNRuntime.class);
List<DMNModel> models = kieRuntime.getModels();
List<DMNModelInfo> result = models.stream().map(ModelEvaluatorServiceBase::modelToInfo).collect(Collectors.toList());
return new ServiceResponse<DMNModelInfoList>(ServiceResponse.ResponseType.SUCCESS, "OK models successfully retrieved from container '" + containerId + "'", new DMNModelInfoList(result));
} catch (Exception e) {
LOG.error("Error retrieving models from container '" + containerId + "'", e);
return new ServiceResponse<DMNModelInfoList>(ServiceResponse.ResponseType.FAILURE, "Error retrieving models from container '" + containerId + "'" + e.getMessage(), null);
}
}
use of org.kie.server.services.impl.KieContainerInstanceImpl in project droolsjbpm-integration by kiegroup.
the class ModelEvaluatorServiceBase method evaluateDecisions.
public ServiceResponse<DMNResultKS> evaluateDecisions(String containerId, String contextPayload, String marshallingType) {
try {
KieContainerInstanceImpl kContainer = context.getContainer(containerId, ContainerLocatorProvider.get().getLocator());
DMNRuntime dmnRuntime = KieRuntimeFactory.of(kContainer.getKieContainer().getKieBase()).get(DMNRuntime.class);
wirePrometheus(kContainer, dmnRuntime);
LOG.debug("Will deserialize payload: {}", contextPayload);
DMNContextKS evalCtx = marshallerHelper.unmarshal(containerId, contextPayload, marshallingType, DMNContextKS.class);
DMNEvaluationResult evaluationResult = DMNEvaluationUtils.evaluate(dmnRuntime, evalCtx.getNamespace(), evalCtx.getModelName(), evalCtx.getDmnContext(), evalCtx.getDecisionNames(), evalCtx.getDecisionIds(), evalCtx.getDecisionServiceName());
DMNResultKS res = new DMNResultKS(evaluationResult.model.getNamespace(), evaluationResult.model.getName(), evalCtx.getDecisionNames(), evaluationResult.result);
return new ServiceResponse<DMNResultKS>(ServiceResponse.ResponseType.SUCCESS, "OK from container '" + containerId + "'", res);
} catch (Exception e) {
e.printStackTrace();
LOG.error("Error from container '" + containerId + "'", e);
return new ServiceResponse<DMNResultKS>(ServiceResponse.ResponseType.FAILURE, "Error from container '" + containerId + "'" + e.getMessage(), null);
}
}
Aggregations