public void stopContainer(String containerId) { KieServerState currentState = context.getStateRepository().load(KieServerEnvironment.getServerId()); Set<String> controllers = currentState.getControllers(); KieServerConfig config = currentState.getConfiguration(); if (controllers != null && !controllers.isEmpty()) { for (String controllerUrl : controllers) { if (controllerUrl != null && !controllerUrl.isEmpty()) { String connectAndSyncUrl = controllerUrl + "/management/servers/" + KieServerEnvironment.getServerId() + "/containers/" + containerId + "/status/stopped"; String userName = config.getConfigItemValue(KieServerConstants.CFG_KIE_CONTROLLER_USER, "kieserver"); String password = loadControllerPassword(config); String token = config.getConfigItemValue(KieServerConstants.CFG_KIE_CONTROLLER_TOKEN); try { makeHttpPostRequestAndCreateCustomResponse(connectAndSyncUrl, "", null, userName, password, token); break; } catch (Exception e) { // let's check all other controllers in case of running in cluster of controllers logger.warn("Exception encountered while syncing with controller at {} error {}", connectAndSyncUrl, e.getCause() == null ? e.getMessage() : e.getCause().getMessage()); logger.debug("Exception encountered while syncing with controller at {} error {}", connectAndSyncUrl, e.getMessage(), e); } } } } } }
public void startContainer(String containerId) { KieServerState currentState = context.getStateRepository().load(KieServerEnvironment.getServerId()); Set<String> controllers = currentState.getControllers(); KieServerConfig config = currentState.getConfiguration(); if (controllers != null && !controllers.isEmpty()) { for (String controllerUrl : controllers) { if (controllerUrl != null && !controllerUrl.isEmpty()) { String connectAndSyncUrl = controllerUrl + "/management/servers/" + KieServerEnvironment.getServerId() + "/containers/" + containerId + "/status/started"; String userName = config.getConfigItemValue(KieServerConstants.CFG_KIE_CONTROLLER_USER, "kieserver"); String password = loadControllerPassword(config); String token = config.getConfigItemValue(KieServerConstants.CFG_KIE_CONTROLLER_TOKEN); try { makeHttpPostRequestAndCreateCustomResponse(connectAndSyncUrl, "", null, userName, password, token); break; } catch (Exception e) { // let's check all other controllers in case of running in cluster of controllers logger.warn("Exception encountered while syncing with controller at {} error {}", connectAndSyncUrl, e.getCause() == null ? e.getMessage() : e.getCause().getMessage()); logger.debug("Exception encountered while syncing with controller at {} error {}", connectAndSyncUrl, e.getMessage(), e); } } } } }
@Override public void disconnect(KieServerInfo serverInfo) { if (this.client.isActive()) { this.client.close(); } else { KieServerState currentState = context.getStateRepository().load(KieServerEnvironment.getServerId()); Set<String> controllers = currentState.getControllers(); KieServerConfig config = currentState.getConfiguration(); if (controllers != null && !controllers.isEmpty()) { for (String controllerUrl : controllers) { if (controllerUrl != null && !controllerUrl.isEmpty() && !controllerUrl.toLowerCase().startsWith("ws")) { logger.info("Kie Server points to non Web Socket controller '{}', using default REST mechanism", controllerUrl); boolean disconnected = restController.disconnectFromSingleController(serverInfo, config, controllerUrl); if (disconnected) { break; } } } } } }
@Override public void disconnect(KieServerInfo serverInfo) { KieServerState currentState = context.getStateRepository().load(KieServerEnvironment.getServerId()); Set<String> controllers = currentState.getControllers(); KieServerConfig config = currentState.getConfiguration(); for (String controllerUrl : controllers ) { if (controllerUrl != null && !controllerUrl.isEmpty()) { boolean disconnected = disconnectFromSingleController(serverInfo, config, controllerUrl); if (disconnected) { break; } } } }
@Override public KieServerSetup connect(KieServerInfo serverInfo) { KieServerState currentState = context.getStateRepository().load(KieServerEnvironment.getServerId()); Set<String> controllers = currentState.getControllers(); KieServerConfig config = currentState.getConfiguration(); if (controllers != null && !controllers.isEmpty()) { for (String controllerUrl : controllers) { if (controllerUrl != null && !controllerUrl.isEmpty()) { KieServerSetup kieServerSetup = connectToSingleController(serverInfo, config, controllerUrl); if (kieServerSetup != null) { return kieServerSetup; } } } throw new KieControllerNotConnectedException("Unable to connect to any controller"); } else { throw new KieControllerNotDefinedException("Unable to connect to any controller"); } }
@Override public KieServerSetup connect(KieServerInfo serverInfo) { KieServerState currentState = context.getStateRepository().load(KieServerEnvironment.getServerId()); Set<String> controllers = currentState.getControllers(); this.serverInfo = serverInfo;
public void installContainersSync(KieServerImpl kieServer, Set<KieContainerResource> containers, KieServerState currentState, KieServerSetup kieServerSetup) { logger.info("About to install containers '{}' on kie server '{}'", containers, kieServer); if (containers == null) { kieServer.markAsReady(); return; } for (KieContainerResource containerResource : containers) { if (KieContainerStatus.STARTED.equals(containerResource.getStatus())) { kieServer.createContainer(containerResource.getContainerId(), containerResource); } else if (KieContainerStatus.DEACTIVATED.equals(containerResource.getStatus())) { kieServer.createContainer(containerResource.getContainerId(), containerResource); kieServer.deactivateContainer(containerResource.getContainerId()); containerResource.setStatus(KieContainerStatus.DEACTIVATED); } } currentState.setContainers(containers); if (kieServerSetup.getServerConfig() != null) { currentState.setConfiguration(kieServerSetup.getServerConfig()); } kieServer.getServerRegistry().getStateRepository().store(KieServerEnvironment.getServerId(), currentState); kieServer.markAsReady(); } }
while (matcher.find()) { String paramName = matcher.group(1); KieServerConfig configuration = context.getStateRepository().load(KieServerEnvironment.getServerId()).getConfiguration(); dataSource = configuration.getConfigItemValue(paramName, "java:jboss/datasources/ExampleDS"); logger.info("Data source expression {} resolved to {}", input, dataSource);