Search in sources :

Example 16 with KieServerExtension

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);
    }
}
Also used : KieServerExtension(org.kie.server.services.api.KieServerExtension)

Example 17 with KieServerExtension

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);
}
Also used : ResteasyDeployment(org.jboss.resteasy.spi.ResteasyDeployment) KieServerExtension(org.kie.server.services.api.KieServerExtension) KieServerRestImpl(org.kie.server.remote.rest.common.resource.KieServerRestImpl) KieServerImpl(org.kie.server.services.impl.KieServerImpl) Application(javax.ws.rs.core.Application)

Example 18 with KieServerExtension

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;
}
Also used : ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) DroolsKieServerExtension(org.kie.server.services.drools.DroolsKieServerExtension) KieServerExtension(org.kie.server.services.api.KieServerExtension) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 19 with KieServerExtension

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();
}
Also used : InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) RuntimeEnvironment(org.kie.internal.runtime.manager.RuntimeEnvironment) KieServerExtension(org.kie.server.services.api.KieServerExtension) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) ListenerSupport(org.jbpm.services.api.ListenerSupport) KieServerRegistry(org.kie.server.services.api.KieServerRegistry) DeploymentService(org.jbpm.services.api.DeploymentService) SimpleRegisterableItemsFactory(org.jbpm.runtime.manager.impl.SimpleRegisterableItemsFactory) KieServerImpl(org.kie.server.services.impl.KieServerImpl) ProcessService(org.jbpm.services.api.ProcessService) KieContainer(org.kie.api.runtime.KieContainer) Before(org.junit.Before)

Example 20 with KieServerExtension

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);
        }
    }
}
Also used : KieServerExtension(org.kie.server.services.api.KieServerExtension) PrometheusKieServerExtension(org.kie.server.services.prometheus.PrometheusKieServerExtension) ScenarioSimulationKieServerExtension(org.kie.server.services.scenariosimulation.ScenarioSimulationKieServerExtension) KieServerImpl(org.kie.server.services.impl.KieServerImpl) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Aggregations

KieServerExtension (org.kie.server.services.api.KieServerExtension)43 Message (org.kie.server.api.model.Message)10 ArrayList (java.util.ArrayList)9 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)9 ReleaseId (org.kie.server.api.model.ReleaseId)8 Test (org.junit.Test)6 KieModuleMetaData (org.kie.scanner.KieModuleMetaData)6 KieContainerResource (org.kie.server.api.model.KieContainerResource)6 ServiceResponse (org.kie.server.api.model.ServiceResponse)6 Matchers.anyString (org.mockito.Matchers.anyString)6 JbpmKieServerExtension (org.kie.server.services.jbpm.JbpmKieServerExtension)5 DeploymentService (org.jbpm.services.api.DeploymentService)4 ProcessService (org.jbpm.services.api.ProcessService)4 KieContainerInstance (org.kie.server.services.api.KieContainerInstance)4 KieServerRegistry (org.kie.server.services.api.KieServerRegistry)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 ExecutorServiceImpl (org.jbpm.executor.impl.ExecutorServiceImpl)3 RuntimeDataService (org.jbpm.services.api.RuntimeDataService)3