Search in sources :

Example 1 with DefaultDeploymentCache

use of org.activiti.engine.impl.persistence.deploy.DefaultDeploymentCache in project Activiti by Activiti.

the class DeploymentCacheLimitTest method testDeploymentCacheLimit.

public void testDeploymentCacheLimit() {
    // This is set in the configuration above
    int processDefinitionCacheLimit = 3;
    DefaultDeploymentCache<ProcessDefinitionEntity> processDefinitionCache = (DefaultDeploymentCache<ProcessDefinitionEntity>) processEngineConfiguration.getProcessDefinitionCache();
    assertEquals(0, processDefinitionCache.size());
    String processDefinitionTemplate = DeploymentCacheTestUtil.readTemplateFile("/org/activiti/standalone/deploy/deploymentCacheTest.bpmn20.xml");
    for (int i = 1; i <= 5; i++) {
        repositoryService.createDeployment().addString("Process " + i + ".bpmn20.xml", MessageFormat.format(processDefinitionTemplate, i)).deploy();
        if (i < processDefinitionCacheLimit) {
            assertEquals(i, processDefinitionCache.size());
        } else {
            assertEquals(processDefinitionCacheLimit, processDefinitionCache.size());
        }
    }
    // Cleanup
    for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
        repositoryService.deleteDeployment(deployment.getId(), true);
    }
}
Also used : DefaultDeploymentCache(org.activiti.engine.impl.persistence.deploy.DefaultDeploymentCache) Deployment(org.activiti.engine.repository.Deployment) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 2 with DefaultDeploymentCache

use of org.activiti.engine.impl.persistence.deploy.DefaultDeploymentCache in project Activiti by Activiti.

the class ProcessEngineEndpoint method invoke.

@Override
public Map<String, Object> invoke() {
    Map<String, Object> metrics = new HashMap<String, Object>();
    // Process definitions
    metrics.put("processDefinitionCount", processEngine.getRepositoryService().createProcessDefinitionQuery().count());
    // List of all process definitions
    List<ProcessDefinition> processDefinitions = processEngine.getRepositoryService().createProcessDefinitionQuery().orderByProcessDefinitionKey().asc().list();
    List<String> processDefinitionKeys = new ArrayList<String>();
    for (ProcessDefinition processDefinition : processDefinitions) {
        processDefinitionKeys.add(processDefinition.getKey() + " (v" + processDefinition.getVersion() + ")");
    }
    metrics.put("deployedProcessDefinitions", processDefinitionKeys);
    // Process instances
    Map<String, Object> processInstanceCountMap = new HashMap<String, Object>();
    metrics.put("runningProcessInstanceCount", processInstanceCountMap);
    for (ProcessDefinition processDefinition : processDefinitions) {
        processInstanceCountMap.put(processDefinition.getKey() + " (v" + processDefinition.getVersion() + ")", processEngine.getRuntimeService().createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).count());
    }
    Map<String, Object> completedProcessInstanceCountMap = new HashMap<String, Object>();
    metrics.put("completedProcessInstanceCount", completedProcessInstanceCountMap);
    for (ProcessDefinition processDefinition : processDefinitions) {
        completedProcessInstanceCountMap.put(processDefinition.getKey() + " (v" + processDefinition.getVersion() + ")", processEngine.getHistoryService().createHistoricProcessInstanceQuery().finished().processDefinitionId(processDefinition.getId()).count());
    }
    // Open tasks
    metrics.put("openTaskCount", processEngine.getTaskService().createTaskQuery().count());
    metrics.put("completedTaskCount", processEngine.getHistoryService().createHistoricTaskInstanceQuery().finished().count());
    // Tasks completed today
    metrics.put("completedTaskCountToday", processEngine.getHistoryService().createHistoricTaskInstanceQuery().finished().taskCompletedAfter(new Date(System.currentTimeMillis() - secondsForDays(1))).count());
    // Process steps
    metrics.put("completedActivities", processEngine.getHistoryService().createHistoricActivityInstanceQuery().finished().count());
    // Process definition cache
    DeploymentCache<ProcessDefinitionEntity> deploymentCache = ((ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration()).getProcessDefinitionCache();
    if (deploymentCache instanceof DefaultDeploymentCache) {
        metrics.put("cachedProcessDefinitionCount", ((DefaultDeploymentCache) deploymentCache).size());
    }
    return metrics;
}
Also used : DefaultDeploymentCache(org.activiti.engine.impl.persistence.deploy.DefaultDeploymentCache) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl)

Aggregations

DefaultDeploymentCache (org.activiti.engine.impl.persistence.deploy.DefaultDeploymentCache)2 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)2 ProcessEngineConfigurationImpl (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl)1 Deployment (org.activiti.engine.repository.Deployment)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1