use of org.kie.server.services.api.KieServerExtension in project droolsjbpm-integration by kiegroup.
the class KieServerImpl method updateExtensions.
private void updateExtensions(KieModuleMetaData metadata, KieContainerInstanceImpl kci, ReleaseId releaseId, List<Message> messages, boolean resetBeforeUpdate) {
String containerId = kci.getContainerId();
List<KieServerExtension> extensions = getServerExtensions();
Map<String, Object> parameters = getReleaseUpdateParameters(metadata, releaseId, kci.getKieContainer(), messages, resetBeforeUpdate);
// once the upgrade was successful, notify all extensions so they can be upgraded (if needed)
for (KieServerExtension extension : extensions) {
extension.updateContainer(containerId, kci, parameters);
logger.debug("Container {} (for release id {}) on {} updated successfully", containerId, releaseId, extension);
}
}
use of org.kie.server.services.api.KieServerExtension in project droolsjbpm-integration by kiegroup.
the class KieServerExecutor method addServerSingletonResources.
private void addServerSingletonResources() {
kieServer = new KieServerImpl();
kieServer.init();
ResteasyDeployment deployment = new ResteasyDeployment();
deployment.setApplication(new Application());
deployment.getResources().add(new KieServerRestImpl(kieServer));
List<KieServerExtension> extensions = kieServer.getServerExtensions();
for (KieServerExtension extension : extensions) {
List<Object> components = extension.getAppComponents(SupportedTransports.REST);
deployment.getResources().addAll(components);
}
server.deploy(deployment);
}
use of org.kie.server.services.api.KieServerExtension in project droolsjbpm-integration by kiegroup.
the class OptaplannerKieServerExtension method init.
@Override
public void init(KieServerImpl kieServer, KieServerRegistry registry) {
KieServerExtension droolsExtension = registry.getServerExtension(DroolsKieServerExtension.EXTENSION_NAME);
if (droolsExtension == null) {
logger.warn("No Drools extension available, quiting...");
return;
}
this.registry = registry;
// The following thread pool will have a max thread count equal to the number of cores on the machine minus 2,
// leaving a few cores unoccupied to handle REST/JMS requests and run the OS.
// If new jobs are submitted and all threads are busy, the default reject policy will kick in.
int availableProcessorCount = Runtime.getRuntime().availableProcessors();
int resolvedActiveThreadCount = Math.max(1, availableProcessorCount - 2);
int queueSize = Integer.parseInt(System.getProperty(KieServerConstants.KIE_OPTAPLANNER_THREAD_POOL_QUEUE_SIZE, String.valueOf(resolvedActiveThreadCount)));
logger.info("Creating a ThreadPoolExecutor with corePoolSize = " + resolvedActiveThreadCount + "," + " maximumPoolSize = " + resolvedActiveThreadCount + ", queueSize = " + queueSize);
this.threadPool = new ThreadPoolExecutor(resolvedActiveThreadCount, resolvedActiveThreadCount, // thread keep alive time
10, TimeUnit.SECONDS, // queue with a size
new ArrayBlockingQueue<>(queueSize));
this.solverServiceBase = new SolverServiceBase(registry, threadPool);
this.optaplannerCommandService = new OptaplannerCommandServiceImpl(registry, solverServiceBase);
this.services.add(solverServiceBase);
initialized = true;
}
use of org.kie.server.services.api.KieServerExtension in project droolsjbpm-integration by kiegroup.
the class KafkaServerExtensionConsumerTest method setup.
@Before
public void setup() {
System.setProperty(KAFKA_EXTENSION_PREFIX + "poll.interval", Long.toString(TIMEOUT));
System.setProperty(SIGNAL_MAPPING_PROPERTY, Mapping.AUTO.toString());
mockConsumer = new MockConsumer<>(OffsetResetStrategy.EARLIEST);
extension = new MockKafkaServerExtension(mockConsumer);
server = mock(KieServerImpl.class);
registry = mock(KieServerRegistry.class);
itemsFactory = new SimpleRegisterableItemsFactory();
KieServerExtension serverExtension = mock(KieServerExtension.class);
when(registry.getServerExtension(Mockito.anyString())).thenReturn(serverExtension);
ListenerSupport deployService = mock(ListenerSupport.class, withSettings().extraInterfaces(DeploymentService.class));
processService = mock(ProcessService.class);
when(serverExtension.getServices()).thenReturn(Arrays.asList(deployService, processService));
runtimeManager = mock(InternalRuntimeManager.class);
RuntimeEnvironment runtimeEngine = mock(RuntimeEnvironment.class);
when(runtimeManager.getEnvironment()).thenReturn(runtimeEngine);
when(runtimeEngine.getRegisterableItemsFactory()).thenReturn(itemsFactory);
processDefinition = mock(ProcessDefinition.class);
extension.init(server, registry);
kieContainer = mock(KieContainer.class);
when(kieContainer.getClassLoader()).thenReturn(Thread.currentThread().getContextClassLoader());
extension.serverStarted();
}
use of org.kie.server.services.api.KieServerExtension in project droolsjbpm-integration by kiegroup.
the class KieServerTest method testCommandServiceSetup.
@Test
public void testCommandServiceSetup() {
List<String> extensionsWithoutCommandSupport = asList(PrometheusKieServerExtension.EXTENSION_NAME, ScenarioSimulationKieServerExtension.EXTENSION_NAME);
for (KieServerExtension extension : ((KieServerImpl) kieServer).getServerExtensions()) {
KieContainerCommandService<?> kieContainerCommandService = extension.getAppComponents(KieContainerCommandService.class);
String extensionName = extension.getExtensionName();
Objects.requireNonNull(extensionName, "extension.getExtensionName() should not be null");
if (extensionsWithoutCommandSupport.contains(extensionName)) {
assertNull(kieContainerCommandService);
} else {
assertNotNull(kieContainerCommandService);
}
}
}
Aggregations