Search in sources :

Example 26 with ReadOperation

use of org.springframework.boot.actuate.endpoint.annotation.ReadOperation in project Activiti by Activiti.

the class ProcessEngineEndpoint method invoke.

@ReadOperation
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<ProcessDefinitionCacheEntry> 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) HashMap(java.util.HashMap) ProcessDefinitionCacheEntry(org.activiti.engine.impl.persistence.deploy.ProcessDefinitionCacheEntry) ArrayList(java.util.ArrayList) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) Date(java.util.Date) ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation)

Example 27 with ReadOperation

use of org.springframework.boot.actuate.endpoint.annotation.ReadOperation in project spring-cloud-netflix by spring-cloud.

the class FiltersEndpoint method invoke.

@ReadOperation
public Map<String, List<Map<String, Object>>> invoke() {
    // Map of filters by type
    final Map<String, List<Map<String, Object>>> filterMap = new TreeMap<>();
    for (ZuulFilter filter : this.filterRegistry.getAllFilters()) {
        // Ensure that we have a list to store filters of each type
        if (!filterMap.containsKey(filter.filterType())) {
            filterMap.put(filter.filterType(), new ArrayList<>());
        }
        final Map<String, Object> filterInfo = new LinkedHashMap<>();
        filterInfo.put("class", filter.getClass().getName());
        filterInfo.put("order", filter.filterOrder());
        filterInfo.put("disabled", filter.isFilterDisabled());
        filterInfo.put("static", filter.isStaticFilter());
        filterMap.get(filter.filterType()).add(filterInfo);
    }
    return filterMap;
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) ZuulFilter(com.netflix.zuul.ZuulFilter) TreeMap(java.util.TreeMap) LinkedHashMap(java.util.LinkedHashMap) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation)

Aggregations

ReadOperation (org.springframework.boot.actuate.endpoint.annotation.ReadOperation)27 Operation (io.swagger.v3.oas.annotations.Operation)14 lombok.val (lombok.val)14 HashMap (java.util.HashMap)10 LinkedHashMap (java.util.LinkedHashMap)10 Map (java.util.Map)9 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)9 BaseCasActuatorEndpoint (org.apereo.cas.web.BaseCasActuatorEndpoint)9 Endpoint (org.springframework.boot.actuate.endpoint.annotation.Endpoint)9 Parameter (io.swagger.v3.oas.annotations.Parameter)8 StringUtils (org.apache.commons.lang3.StringUtils)8 Nullable (org.springframework.lang.Nullable)6 ApplicationContext (org.springframework.context.ApplicationContext)5 Collectors (java.util.stream.Collectors)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Objects (java.util.Objects)3 StreamSupport (java.util.stream.StreamSupport)3 Slf4j (lombok.extern.slf4j.Slf4j)3 CollectionUtils (org.apereo.cas.util.CollectionUtils)3