From c4f3b87e475e3c87d2275a956a3d65e2b04f647a Mon Sep 17 00:00:00 2001 From: SAshutosh Date: Tue, 16 Feb 2021 17:49:12 +0530 Subject: [PATCH 1/6] Review comments --- .../monitor/metrics/MemoryUtilizationService.java | 3 ++- .../monitor/service/WorkerMetricsServiceImpl.java | 13 +++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/MemoryUtilizationService.java b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/MemoryUtilizationService.java index 0e63ce04b2..dbed26b5a0 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/MemoryUtilizationService.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/MemoryUtilizationService.java @@ -20,6 +20,7 @@ import oshi.SystemInfo; import oshi.hardware.GlobalMemory; import oshi.software.os.OSProcess; + import javax.annotation.PostConstruct; import java.io.Serializable; @@ -45,7 +46,7 @@ public Pair measure() { public double getCurrentValue() { this.usedRamProcess = process.getResidentSetSize(); - double ramUsed = (double) (usedRamProcess * 100 / totalRam); + double ramUsed = ((double)usedRamProcess * 100 / totalRam); return formatTo2Decimal(ramUsed); } } diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImpl.java b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImpl.java index f971b2dabe..e1540df6a4 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImpl.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImpl.java @@ -32,7 +32,6 @@ public class WorkerMetricsServiceImpl implements WorkerMetricsService { protected static final Logger logger = LogManager.getLogger(WorkerMetricsServiceImpl.class); - static int capacity = Integer.getInteger("metrics.collection.sampleCount", 10); boolean disabled = Boolean.getBoolean("worker.monitoring.disable"); @Autowired PerfMetricCollector perfMetricCollector; @@ -40,7 +39,7 @@ public class WorkerMetricsServiceImpl implements WorkerMetricsService { @Autowired private WorkerStateUpdateService workerStateUpdateService; - private LinkedBlockingQueue> collectMetricQueue = new LinkedBlockingQueue>(capacity); + private LinkedBlockingQueue> collectMetricQueue = new LinkedBlockingQueue>(Integer.MAX_VALUE); @Autowired private EventBus eventBus; @@ -54,9 +53,6 @@ public void collectPerformanceMetrics() { logger.debug("Collected worker metric "+ metricInfo.size()); } } - else{ - Thread.sleep(100); - } } catch (Exception e) { logger.error("Failed to load metric into queue", e); } @@ -69,17 +65,14 @@ private boolean isMonitoringDisabled() { @Override public void dispatchPerformanceMetrics() { try { - if(!isMonitoringDisabled()) { - List> metricData = getCurrentBatch(collectMetricQueue); + List> metricData = getCurrentBatch(collectMetricQueue); + if(!isMonitoringDisabled() && metricData!=null && metricData.size() > 0) { ScoreEvent scoreEvent = new ScoreEvent(EventConstants.WORKER_PERFORMANCE_MONITOR, (Serializable) metricData); eventBus.dispatch(scoreEvent); if (logger.isDebugEnabled()) { logger.debug("Dispatched worker metric "+ metricData.size()); } } - else{ - Thread.sleep(100); - } } catch (Exception e) { logger.error("Failed to dispatch metric info event", e); } From 74502a78949c92e059508d5840790f5974f24b60 Mon Sep 17 00:00:00 2001 From: AkAnand Date: Wed, 17 Feb 2021 13:45:58 +0530 Subject: [PATCH 2/6] lucian suggested changes .. --- .../worker/monitor/metrics/MemoryUtilizationService.java | 3 ++- .../worker/monitor/service/WorkerMetricsServiceImpl.java | 8 +------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/MemoryUtilizationService.java b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/MemoryUtilizationService.java index 0e63ce04b2..fcd75125ca 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/MemoryUtilizationService.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/MemoryUtilizationService.java @@ -20,6 +20,7 @@ import oshi.SystemInfo; import oshi.hardware.GlobalMemory; import oshi.software.os.OSProcess; + import javax.annotation.PostConstruct; import java.io.Serializable; @@ -45,7 +46,7 @@ public Pair measure() { public double getCurrentValue() { this.usedRamProcess = process.getResidentSetSize(); - double ramUsed = (double) (usedRamProcess * 100 / totalRam); + double ramUsed = (((double) usedRamProcess) / totalRam) * 100; return formatTo2Decimal(ramUsed); } } diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImpl.java b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImpl.java index f971b2dabe..e89656942e 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImpl.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImpl.java @@ -32,7 +32,7 @@ public class WorkerMetricsServiceImpl implements WorkerMetricsService { protected static final Logger logger = LogManager.getLogger(WorkerMetricsServiceImpl.class); - static int capacity = Integer.getInteger("metrics.collection.sampleCount", 10); + static int capacity = Integer.getInteger("metrics.collection.sampleCount", Integer.MAX_VALUE); boolean disabled = Boolean.getBoolean("worker.monitoring.disable"); @Autowired PerfMetricCollector perfMetricCollector; @@ -54,9 +54,6 @@ public void collectPerformanceMetrics() { logger.debug("Collected worker metric "+ metricInfo.size()); } } - else{ - Thread.sleep(100); - } } catch (Exception e) { logger.error("Failed to load metric into queue", e); } @@ -77,9 +74,6 @@ public void dispatchPerformanceMetrics() { logger.debug("Dispatched worker metric "+ metricData.size()); } } - else{ - Thread.sleep(100); - } } catch (Exception e) { logger.error("Failed to dispatch metric info event", e); } From d38160b01ce739b4c243e8d0858164636aea7e2a Mon Sep 17 00:00:00 2001 From: Akash Anand Date: Wed, 17 Feb 2021 14:14:10 +0530 Subject: [PATCH 3/6] changed to tabs instead of spaces .. --- .../schema/WorkerBeanDefinitionParser.java | 3 +- .../monitor/PerformanceMetricsCollector.java | 84 ++--- .../metrics/CpuUtilizationService.java | 38 +- .../metrics/DiskReadUtilizationService.java | 34 +- .../metrics/DiskWriteUtilizationService.java | 34 +- .../metrics/HeapUtilizationService.java | 32 +- .../metrics/MemoryUtilizationService.java | 40 +- .../metrics/WorkerPerformanceMetricBase.java | 20 +- .../metrics/WorkerThreadUtilization.java | 26 +- .../service/WorkerMetricsServiceImpl.java | 94 ++--- .../service/WorkerMetricsServiceImplTest.java | 344 +++++++++--------- 11 files changed, 375 insertions(+), 374 deletions(-) diff --git a/package/score-worker/src/main/java/io/cloudslang/schema/WorkerBeanDefinitionParser.java b/package/score-worker/src/main/java/io/cloudslang/schema/WorkerBeanDefinitionParser.java index 1440d84b38..6d18fda612 100644 --- a/package/score-worker/src/main/java/io/cloudslang/schema/WorkerBeanDefinitionParser.java +++ b/package/score-worker/src/main/java/io/cloudslang/schema/WorkerBeanDefinitionParser.java @@ -85,7 +85,6 @@ public class WorkerBeanDefinitionParser extends AbstractBeanDefinitionParser { put(RetryTemplate.class, null); put(SimpleExecutionRunnableFactory.class, null); put(WorkerManagerMBean.class, "io.cloudslang.worker.management.services.WorkerManagerMBean"); - put(WorkerMetricsMBean.class, "io.cloudslang.worker.monitor.mbean.WorkerMetricsMBean"); put(WorkerRecoveryManagerImpl.class, null); put(ReflectionAdapterImpl.class, null); put(SessionDataHandlerImpl.class, "sessionDataHandler"); @@ -98,6 +97,7 @@ public class WorkerBeanDefinitionParser extends AbstractBeanDefinitionParser { put(WorkerMonitorsImpl.class, "workerMonitorsImpl"); put(ScheduledWorkerLoadMonitor.class, "scheduledWorkerLoadMonitor"); put(CpuUtilizationService.class, "cpuUtilizationService"); + //Metrics put(DiskReadUtilizationService.class, "diskReadUtilizationService"); put(DiskWriteUtilizationService.class, "diskWriteUtilizationService"); put(MemoryUtilizationService.class, "memoryUtilizationService"); @@ -105,6 +105,7 @@ public class WorkerBeanDefinitionParser extends AbstractBeanDefinitionParser { put(WorkerMetricsServiceImpl.class, "workerMetricCollectorService"); put(HeapUtilizationService.class, "heapUtilizationService"); put(WorkerThreadUtilization.class, "workerThreadUtilization"); + put(WorkerMetricsMBean.class, "io.cloudslang.worker.monitor.mbean.WorkerMetricsMBean"); }}; private List configurationValues = Arrays.asList( diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/PerformanceMetricsCollector.java b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/PerformanceMetricsCollector.java index d11adda597..5dcc69bb5d 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/PerformanceMetricsCollector.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/PerformanceMetricsCollector.java @@ -38,50 +38,50 @@ @Component public class PerformanceMetricsCollector implements PerfMetricCollector { - List workerPerfMetrics; - @Autowired - private WorkerManager workerManager; - @Autowired - private CpuUtilizationService cpuUtilizationService; - @Autowired - private MemoryUtilizationService memoryUtilizationService; - @Autowired - private DiskReadUtilizationService diskReadUtilizationService; - @Autowired - private DiskWriteUtilizationService diskWriteUtilizationService; - @Autowired - private WorkerThreadUtilization workerThreadUtilization; - @Autowired - private HeapUtilizationService heapUtilizationService; + List workerPerfMetrics; + @Autowired + private WorkerManager workerManager; + @Autowired + private CpuUtilizationService cpuUtilizationService; + @Autowired + private MemoryUtilizationService memoryUtilizationService; + @Autowired + private DiskReadUtilizationService diskReadUtilizationService; + @Autowired + private DiskWriteUtilizationService diskWriteUtilizationService; + @Autowired + private WorkerThreadUtilization workerThreadUtilization; + @Autowired + private HeapUtilizationService heapUtilizationService; - public PerformanceMetricsCollector() { - } + public PerformanceMetricsCollector() { + } - @PostConstruct - public void init() { - createMetrics(); - } + @PostConstruct + public void init() { + createMetrics(); + } - private void createMetrics() { - workerPerfMetrics = new ArrayList<>(); - workerPerfMetrics.add(cpuUtilizationService); - workerPerfMetrics.add(diskReadUtilizationService); - workerPerfMetrics.add(memoryUtilizationService); - workerPerfMetrics.add(heapUtilizationService); - workerPerfMetrics.add(diskWriteUtilizationService); - workerPerfMetrics.add(workerThreadUtilization); - } + private void createMetrics() { + workerPerfMetrics = new ArrayList<>(); + workerPerfMetrics.add(cpuUtilizationService); + workerPerfMetrics.add(diskReadUtilizationService); + workerPerfMetrics.add(memoryUtilizationService); + workerPerfMetrics.add(heapUtilizationService); + workerPerfMetrics.add(diskWriteUtilizationService); + workerPerfMetrics.add(workerThreadUtilization); + } - @Override - public Map collectMetrics() { - Map currentValues = new HashMap<>(); - for (WorkerPerfMetric metric : - workerPerfMetrics) { - Pair currentPair = metric.measure(); - currentValues.put(currentPair.getKey(), currentPair.getValue()); - } - currentValues.put(WorkerPerformanceMetric.WORKER_ID, workerManager.getWorkerUuid()); - currentValues.put(WorkerPerformanceMetric.WORKER_MEASURED_TIME, System.currentTimeMillis()); - return currentValues; - } + @Override + public Map collectMetrics() { + Map currentValues = new HashMap<>(); + for (WorkerPerfMetric metric : + workerPerfMetrics) { + Pair currentPair = metric.measure(); + currentValues.put(currentPair.getKey(), currentPair.getValue()); + } + currentValues.put(WorkerPerformanceMetric.WORKER_ID, workerManager.getWorkerUuid()); + currentValues.put(WorkerPerformanceMetric.WORKER_MEASURED_TIME, System.currentTimeMillis()); + return currentValues; + } } diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/CpuUtilizationService.java b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/CpuUtilizationService.java index c5efb2f9f0..5a4f28b1fb 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/CpuUtilizationService.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/CpuUtilizationService.java @@ -25,26 +25,26 @@ import java.io.Serializable; public class CpuUtilizationService extends WorkerPerformanceMetricBase { - private static OSProcess oldProcess; - private int cpuNumber; + private static OSProcess oldProcess; + private int cpuNumber; - @PostConstruct - public void init() { - SystemInfo systemInfo = new SystemInfo(); - CentralProcessor processor = systemInfo.getHardware().getProcessor(); - this.cpuNumber = processor.getLogicalProcessorCount(); - } + @PostConstruct + public void init() { + SystemInfo systemInfo = new SystemInfo(); + CentralProcessor processor = systemInfo.getHardware().getProcessor(); + this.cpuNumber = processor.getLogicalProcessorCount(); + } - @Override - public Pair measure() { - Pair cpuUsage = Pair.of(WorkerPerformanceMetric.CPU_USAGE,getCurrentValue()); - return cpuUsage; - } + @Override + public Pair measure() { + Pair cpuUsage = Pair.of(WorkerPerformanceMetric.CPU_USAGE, getCurrentValue()); + return cpuUsage; + } - public double getCurrentValue() { - OSProcess osProcess = getProcess(); - double cpuUsed = (osProcess.getProcessCpuLoadBetweenTicks(oldProcess) * 100) / cpuNumber; - oldProcess = osProcess; - return formatTo2Decimal(cpuUsed); - } + public double getCurrentValue() { + OSProcess osProcess = getProcess(); + double cpuUsed = (osProcess.getProcessCpuLoadBetweenTicks(oldProcess) * 100) / cpuNumber; + oldProcess = osProcess; + return formatTo2Decimal(cpuUsed); + } } diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/DiskReadUtilizationService.java b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/DiskReadUtilizationService.java index c17a797983..10ba1e4955 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/DiskReadUtilizationService.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/DiskReadUtilizationService.java @@ -23,24 +23,24 @@ import java.io.Serializable; public class DiskReadUtilizationService extends WorkerPerformanceMetricBase { - private OSProcess process; + private OSProcess process; - @PostConstruct - public void init() { - this.process = getProcess(); - } + @PostConstruct + public void init() { + this.process = getProcess(); + } - @Override - public Pair measure() { - Pair diskUsage = Pair.of(WorkerPerformanceMetric.DISK_READ_USAGE, getCurrentValue()); - return diskUsage; - } + @Override + public Pair measure() { + Pair diskUsage = Pair.of(WorkerPerformanceMetric.DISK_READ_USAGE, getCurrentValue()); + return diskUsage; + } - public long getCurrentValue() { - long readBytes = 0; - if (process != null) { - readBytes = process.getBytesRead(); - } - return readBytes; - } + public long getCurrentValue() { + long readBytes = 0; + if (process != null) { + readBytes = process.getBytesRead(); + } + return readBytes; + } } \ No newline at end of file diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/DiskWriteUtilizationService.java b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/DiskWriteUtilizationService.java index 49e35d4f02..36dbf95e3e 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/DiskWriteUtilizationService.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/DiskWriteUtilizationService.java @@ -23,24 +23,24 @@ import java.io.Serializable; public class DiskWriteUtilizationService extends WorkerPerformanceMetricBase { - private OSProcess process; + private OSProcess process; - @PostConstruct - public void init() { - this.process = getProcess(); - } + @PostConstruct + public void init() { + this.process = getProcess(); + } - @Override - public Pair measure() { - Pair diskWriteUsage = Pair.of(WorkerPerformanceMetric.DISK_WRITE_USAGE, getCurrentValue()); - return diskWriteUsage; - } + @Override + public Pair measure() { + Pair diskWriteUsage = Pair.of(WorkerPerformanceMetric.DISK_WRITE_USAGE, getCurrentValue()); + return diskWriteUsage; + } - public long getCurrentValue() { - long writeBytes = 0; - if (process != null) { - writeBytes = process.getBytesWritten(); - } - return writeBytes; - } + public long getCurrentValue() { + long writeBytes = 0; + if (process != null) { + writeBytes = process.getBytesWritten(); + } + return writeBytes; + } } diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/HeapUtilizationService.java b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/HeapUtilizationService.java index a76f928ed4..b79a165c15 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/HeapUtilizationService.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/HeapUtilizationService.java @@ -17,26 +17,28 @@ import io.cloudslang.worker.monitor.service.WorkerPerformanceMetric; import org.apache.commons.lang3.tuple.Pair; + import java.io.Serializable; + import static java.lang.Runtime.getRuntime; public class HeapUtilizationService extends WorkerPerformanceMetricBase { - @Override - public Pair measure() { - Pair heapUsage = Pair.of(WorkerPerformanceMetric.HEAP_SIZE, getCurrentValue()); - return heapUsage; - } - - public double getCurrentValue() { - // Get current size of heap in bytes - long totalMemory = Runtime.getRuntime().totalMemory(); - long freeMemory = getRuntime().freeMemory(); - double allocatedMemory = totalMemory - freeMemory; - long maxMemory = getRuntime().maxMemory(); - double percentageHeapUsed = (allocatedMemory / formatTo2Decimal(maxMemory)) * 100; - return formatTo2Decimal(percentageHeapUsed); - } + @Override + public Pair measure() { + Pair heapUsage = Pair.of(WorkerPerformanceMetric.HEAP_SIZE, getCurrentValue()); + return heapUsage; + } + + public double getCurrentValue() { + // Get current size of heap in bytes + long totalMemory = Runtime.getRuntime().totalMemory(); + long freeMemory = getRuntime().freeMemory(); + double allocatedMemory = totalMemory - freeMemory; + long maxMemory = getRuntime().maxMemory(); + double percentageHeapUsed = (allocatedMemory / formatTo2Decimal(maxMemory)) * 100; + return formatTo2Decimal(percentageHeapUsed); + } } diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/MemoryUtilizationService.java b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/MemoryUtilizationService.java index fcd75125ca..7f4e2c215f 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/MemoryUtilizationService.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/MemoryUtilizationService.java @@ -26,27 +26,27 @@ public class MemoryUtilizationService extends WorkerPerformanceMetricBase { - private long usedRamProcess; - private OSProcess process; - private long totalRam; + private long usedRamProcess; + private OSProcess process; + private long totalRam; - @PostConstruct - public void init() { - SystemInfo si = new SystemInfo(); - process = getProcess(); - GlobalMemory globalMemory = si.getHardware().getMemory(); - this.totalRam = globalMemory.getTotal(); - } + @PostConstruct + public void init() { + SystemInfo si = new SystemInfo(); + process = getProcess(); + GlobalMemory globalMemory = si.getHardware().getMemory(); + this.totalRam = globalMemory.getTotal(); + } - @Override - public Pair measure() { - Pair memUsage = Pair.of(WorkerPerformanceMetric.MEMORY_USAGE, getCurrentValue()); - return memUsage; - } + @Override + public Pair measure() { + Pair memUsage = Pair.of(WorkerPerformanceMetric.MEMORY_USAGE, getCurrentValue()); + return memUsage; + } - public double getCurrentValue() { - this.usedRamProcess = process.getResidentSetSize(); - double ramUsed = (((double) usedRamProcess) / totalRam) * 100; - return formatTo2Decimal(ramUsed); - } + public double getCurrentValue() { + this.usedRamProcess = process.getResidentSetSize(); + double ramUsed = (((double) usedRamProcess) / totalRam) * 100; + return formatTo2Decimal(ramUsed); + } } diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/WorkerPerformanceMetricBase.java b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/WorkerPerformanceMetricBase.java index 1914d74193..e9ddfed418 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/WorkerPerformanceMetricBase.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/WorkerPerformanceMetricBase.java @@ -25,15 +25,15 @@ public abstract class WorkerPerformanceMetricBase implements WorkerPerfMetric { - protected OSProcess getProcess() { - SystemInfo systemInfo = new SystemInfo(); - OperatingSystem operatingSystem = systemInfo.getOperatingSystem(); - int processId = operatingSystem.getProcessId(); - OSProcess osProcess = operatingSystem.getProcess(processId); - return osProcess; - } + protected OSProcess getProcess() { + SystemInfo systemInfo = new SystemInfo(); + OperatingSystem operatingSystem = systemInfo.getOperatingSystem(); + int processId = operatingSystem.getProcessId(); + OSProcess osProcess = operatingSystem.getProcess(processId); + return osProcess; + } - protected double formatTo2Decimal(double value) { - return new BigDecimal(value).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); - } + protected double formatTo2Decimal(double value) { + return new BigDecimal(value).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); + } } diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/WorkerThreadUtilization.java b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/WorkerThreadUtilization.java index 44e46be185..e47530748b 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/WorkerThreadUtilization.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/WorkerThreadUtilization.java @@ -26,21 +26,21 @@ public class WorkerThreadUtilization implements WorkerPerfMetric { - @Autowired - private WorkerManager workerManager; + @Autowired + private WorkerManager workerManager; - @Autowired - @Qualifier("numberOfExecutionThreads") - private int numberOfThreads; + @Autowired + @Qualifier("numberOfExecutionThreads") + private int numberOfThreads; - @Override - public Pair measure() { - Pair threadUtilization = Pair.of(WorkerPerformanceMetric.THREAD_UTILIZATION, getCurrentValue()); - return threadUtilization; - } + @Override + public Pair measure() { + Pair threadUtilization = Pair.of(WorkerPerformanceMetric.THREAD_UTILIZATION, getCurrentValue()); + return threadUtilization; + } - public int getCurrentValue() { - return ((workerManager.getRunningTasksCount() * 100) / numberOfThreads); - } + public int getCurrentValue() { + return ((workerManager.getRunningTasksCount() * 100) / numberOfThreads); + } } diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImpl.java b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImpl.java index e89656942e..cfc94bf065 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImpl.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImpl.java @@ -31,58 +31,58 @@ import java.util.concurrent.LinkedBlockingQueue; public class WorkerMetricsServiceImpl implements WorkerMetricsService { - protected static final Logger logger = LogManager.getLogger(WorkerMetricsServiceImpl.class); - static int capacity = Integer.getInteger("metrics.collection.sampleCount", Integer.MAX_VALUE); - boolean disabled = Boolean.getBoolean("worker.monitoring.disable"); - @Autowired - PerfMetricCollector perfMetricCollector; + protected static final Logger logger = LogManager.getLogger(WorkerMetricsServiceImpl.class); + static int capacity = Integer.getInteger("metrics.collection.sampleCount", Integer.MAX_VALUE); + boolean disabled = Boolean.getBoolean("worker.monitoring.disable"); + @Autowired + PerfMetricCollector perfMetricCollector; - @Autowired - private WorkerStateUpdateService workerStateUpdateService; + @Autowired + private WorkerStateUpdateService workerStateUpdateService; - private LinkedBlockingQueue> collectMetricQueue = new LinkedBlockingQueue>(capacity); - @Autowired - private EventBus eventBus; + private LinkedBlockingQueue> collectMetricQueue = new LinkedBlockingQueue>(capacity); + @Autowired + private EventBus eventBus; - @Override - public void collectPerformanceMetrics() { - try { - if(!isMonitoringDisabled()) { - Map metricInfo = perfMetricCollector.collectMetrics(); - collectMetricQueue.put(metricInfo); - if (logger.isDebugEnabled()) { - logger.debug("Collected worker metric "+ metricInfo.size()); - } - } - } catch (Exception e) { - logger.error("Failed to load metric into queue", e); - } - } + @Override + public void collectPerformanceMetrics() { + try { + if (!isMonitoringDisabled()) { + Map metricInfo = perfMetricCollector.collectMetrics(); + collectMetricQueue.put(metricInfo); + if (logger.isDebugEnabled()) { + logger.debug("Collected worker metric " + metricInfo.size()); + } + } + } catch (Exception e) { + logger.error("Failed to load metric into queue", e); + } + } - private boolean isMonitoringDisabled() { - return disabled || workerStateUpdateService.isMonitoringDisabled(); - } + private boolean isMonitoringDisabled() { + return disabled || workerStateUpdateService.isMonitoringDisabled(); + } - @Override - public void dispatchPerformanceMetrics() { - try { - if(!isMonitoringDisabled()) { - List> metricData = getCurrentBatch(collectMetricQueue); - ScoreEvent scoreEvent = new ScoreEvent(EventConstants.WORKER_PERFORMANCE_MONITOR, (Serializable) metricData); - eventBus.dispatch(scoreEvent); - if (logger.isDebugEnabled()) { - logger.debug("Dispatched worker metric "+ metricData.size()); - } - } - } catch (Exception e) { - logger.error("Failed to dispatch metric info event", e); - } - } + @Override + public void dispatchPerformanceMetrics() { + try { + if (!isMonitoringDisabled()) { + List> metricData = getCurrentBatch(collectMetricQueue); + ScoreEvent scoreEvent = new ScoreEvent(EventConstants.WORKER_PERFORMANCE_MONITOR, (Serializable) metricData); + eventBus.dispatch(scoreEvent); + if (logger.isDebugEnabled()) { + logger.debug("Dispatched worker metric " + metricData.size()); + } + } + } catch (Exception e) { + logger.error("Failed to dispatch metric info event", e); + } + } - private List> getCurrentBatch(LinkedBlockingQueue> metricQueue) { - List> metricList = new ArrayList<>(); - metricQueue.drainTo(metricList); + private List> getCurrentBatch(LinkedBlockingQueue> metricQueue) { + List> metricList = new ArrayList<>(); + metricQueue.drainTo(metricList); - return metricList; - } + return metricList; + } } diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/test/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImplTest.java b/worker/worker-monitor/score-worker-monitor-impl/src/test/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImplTest.java index d6e14c01e0..1b905eae6e 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/test/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImplTest.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/test/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImplTest.java @@ -60,177 +60,175 @@ @ContextConfiguration(classes = WorkerMetricsServiceImplTest.MyTestConfig.class) public class WorkerMetricsServiceImplTest { - static final String CREDENTIAL_UUID = "uuid"; - @Autowired - private WorkerMetricsService workerMetricsService; - @Autowired - private PerfMetricCollector perfMetricCollector; - - @Autowired - WorkerStateUpdateService workerStateUpdateService; - - @Autowired - private EventBus eventBus; - - @Test - public void testWorkerMetricCollectorService() throws InterruptedException { - Map metricData = createWorkerPerformanceMetrics(); - when(perfMetricCollector.collectMetrics()).thenReturn(metricData); - workerMetricsService.collectPerformanceMetrics(); - workerMetricsService.dispatchPerformanceMetrics(); - verify(eventBus, times(1)).dispatch(anyObject()); - } - - @Test - public void testNoMetricCollectionWhenDisabledFromCentral() throws InterruptedException { - reset(perfMetricCollector); - when(workerStateUpdateService.isMonitoringDisabled()).thenReturn(true); - workerMetricsService.collectPerformanceMetrics(); - verify(perfMetricCollector, times(0)).collectMetrics(); - } - - private Map createWorkerPerformanceMetrics() { - Map metric1 = new HashMap(); - metric1.put(WorkerPerformanceMetric.WORKER_ID, "123"); - metric1.put(WorkerPerformanceMetric.WORKER_MEASURED_TIME, 1603954121462L); - metric1.put(WorkerPerformanceMetric.CPU_USAGE, 32.0); - metric1.put(WorkerPerformanceMetric.MEMORY_USAGE, 8.0); - metric1.put(WorkerPerformanceMetric.DISK_READ_USAGE, 1101268201L); - metric1.put(WorkerPerformanceMetric.DISK_WRITE_USAGE, 11012601L); - metric1.put(WorkerPerformanceMetric.THREAD_UTILIZATION, 10); - metric1.put(WorkerPerformanceMetric.HEAP_SIZE, 28.0); - return metric1; - } - - @Configuration - public static class MyTestConfig { - - @Bean - public WorkerMetricsService workerMetricCollectorService() { - return new WorkerMetricsServiceImpl(); - } - - @Bean - public PerfMetricCollector perfMetricCollector() { - return mock(PerfMetricCollector.class); - } - - @Bean - public EventBus eventBus() { - return mock(EventBus.class); - } - - @Bean - public CpuUtilizationService cpuUtilizationService() { - return mock(CpuUtilizationService.class); - } - - @Bean - public DiskReadUtilizationService diskReadUtilizationService() { - return mock(DiskReadUtilizationService.class); - } - - @Bean - public DiskWriteUtilizationService diskWriteUtilizationService() { - return mock(DiskWriteUtilizationService.class); - } - - @Bean - public MemoryUtilizationService memoryUtilizationService() { - return mock(MemoryUtilizationService.class); - } - - @Bean - public HeapUtilizationService heapUtilizationService() { - return mock(HeapUtilizationService.class); - } - - @Bean - public WorkerThreadUtilization workerThreadUtilization() { - return mock(WorkerThreadUtilization.class); - } - - @Bean - SynchronizationManager synchronizationManager() { - return new SynchronizationManagerImpl(); - } - - @Bean - WorkerManager workerManager() { - return new WorkerManager(); - } - - @Bean - WorkerNodeService workerNodeService() { - return mock(WorkerNodeService.class); - } - - @Bean - WorkerConfigurationService workerConfigurationService() { - return mock(WorkerConfigurationService.class); - } - - @Bean - WorkerRecoveryManager workerRecoveryManager() { - return mock(WorkerRecoveryManager.class); - } - - @Bean - Integer numberOfExecutionThreads() { - return 2; - } - - @Bean - Long initStartUpSleep() { - return 10L; - } - - @Bean - Long maxStartUpSleep() { - return 100L; - } - - @Bean - WorkerConfigurationUtils workerConfigurationUtils() { - WorkerConfigurationUtils workerConfigurationUtils = mock(WorkerConfigurationUtils.class); - doReturn(mock(LinkedBlockingQueue.class)).when(workerConfigurationUtils).getBlockingQueue(anyInt(), anyInt()); - return workerConfigurationUtils; - } - - @Bean - WorkerStateUpdateService workerStateUpdateService() { - return mock(WorkerStateUpdateService.class); - } - - @Bean - Integer inBufferCapacity() { - return 20; - } - - @Bean - WorkerVersionService workerVersionService() { - WorkerVersionService service = mock(WorkerVersionService.class); - when(service.getWorkerVersion()).thenReturn("version"); - when(service.getWorkerVersionId()).thenReturn("123"); - return service; - } - - @Bean - EngineVersionService engineVersionService() { - EngineVersionService service = mock(EngineVersionService.class); - when(service.getEngineVersionId()).thenReturn("123"); - return service; - } - - @Bean - String workerUuid() { - return CREDENTIAL_UUID; - } - - @Bean - public WorkerQueueDetailsContainer workerQueueDetailsContainer() { - return mock(WorkerQueueDetailsContainer.class); - } - - } + static final String CREDENTIAL_UUID = "uuid"; + @Autowired + WorkerStateUpdateService workerStateUpdateService; + @Autowired + private WorkerMetricsService workerMetricsService; + @Autowired + private PerfMetricCollector perfMetricCollector; + @Autowired + private EventBus eventBus; + + @Test + public void testWorkerMetricCollectorService() throws InterruptedException { + Map metricData = createWorkerPerformanceMetrics(); + when(perfMetricCollector.collectMetrics()).thenReturn(metricData); + workerMetricsService.collectPerformanceMetrics(); + workerMetricsService.dispatchPerformanceMetrics(); + verify(eventBus, times(1)).dispatch(anyObject()); + } + + @Test + public void testNoMetricCollectionWhenDisabledFromCentral() throws InterruptedException { + reset(perfMetricCollector); + when(workerStateUpdateService.isMonitoringDisabled()).thenReturn(true); + workerMetricsService.collectPerformanceMetrics(); + verify(perfMetricCollector, times(0)).collectMetrics(); + } + + private Map createWorkerPerformanceMetrics() { + Map metric1 = new HashMap(); + metric1.put(WorkerPerformanceMetric.WORKER_ID, "123"); + metric1.put(WorkerPerformanceMetric.WORKER_MEASURED_TIME, 1603954121462L); + metric1.put(WorkerPerformanceMetric.CPU_USAGE, 32.0); + metric1.put(WorkerPerformanceMetric.MEMORY_USAGE, 8.0); + metric1.put(WorkerPerformanceMetric.DISK_READ_USAGE, 1101268201L); + metric1.put(WorkerPerformanceMetric.DISK_WRITE_USAGE, 11012601L); + metric1.put(WorkerPerformanceMetric.THREAD_UTILIZATION, 10); + metric1.put(WorkerPerformanceMetric.HEAP_SIZE, 28.0); + return metric1; + } + + @Configuration + public static class MyTestConfig { + + @Bean + public WorkerMetricsService workerMetricCollectorService() { + return new WorkerMetricsServiceImpl(); + } + + @Bean + public PerfMetricCollector perfMetricCollector() { + return mock(PerfMetricCollector.class); + } + + @Bean + public EventBus eventBus() { + return mock(EventBus.class); + } + + @Bean + public CpuUtilizationService cpuUtilizationService() { + return mock(CpuUtilizationService.class); + } + + @Bean + public DiskReadUtilizationService diskReadUtilizationService() { + return mock(DiskReadUtilizationService.class); + } + + @Bean + public DiskWriteUtilizationService diskWriteUtilizationService() { + return mock(DiskWriteUtilizationService.class); + } + + @Bean + public MemoryUtilizationService memoryUtilizationService() { + return mock(MemoryUtilizationService.class); + } + + @Bean + public HeapUtilizationService heapUtilizationService() { + return mock(HeapUtilizationService.class); + } + + @Bean + public WorkerThreadUtilization workerThreadUtilization() { + return mock(WorkerThreadUtilization.class); + } + + @Bean + SynchronizationManager synchronizationManager() { + return new SynchronizationManagerImpl(); + } + + @Bean + WorkerManager workerManager() { + return new WorkerManager(); + } + + @Bean + WorkerNodeService workerNodeService() { + return mock(WorkerNodeService.class); + } + + @Bean + WorkerConfigurationService workerConfigurationService() { + return mock(WorkerConfigurationService.class); + } + + @Bean + WorkerRecoveryManager workerRecoveryManager() { + return mock(WorkerRecoveryManager.class); + } + + @Bean + Integer numberOfExecutionThreads() { + return 2; + } + + @Bean + Long initStartUpSleep() { + return 10L; + } + + @Bean + Long maxStartUpSleep() { + return 100L; + } + + @Bean + WorkerConfigurationUtils workerConfigurationUtils() { + WorkerConfigurationUtils workerConfigurationUtils = mock(WorkerConfigurationUtils.class); + doReturn(mock(LinkedBlockingQueue.class)).when(workerConfigurationUtils).getBlockingQueue(anyInt(), anyInt()); + return workerConfigurationUtils; + } + + @Bean + WorkerStateUpdateService workerStateUpdateService() { + return mock(WorkerStateUpdateService.class); + } + + @Bean + Integer inBufferCapacity() { + return 20; + } + + @Bean + WorkerVersionService workerVersionService() { + WorkerVersionService service = mock(WorkerVersionService.class); + when(service.getWorkerVersion()).thenReturn("version"); + when(service.getWorkerVersionId()).thenReturn("123"); + return service; + } + + @Bean + EngineVersionService engineVersionService() { + EngineVersionService service = mock(EngineVersionService.class); + when(service.getEngineVersionId()).thenReturn("123"); + return service; + } + + @Bean + String workerUuid() { + return CREDENTIAL_UUID; + } + + @Bean + public WorkerQueueDetailsContainer workerQueueDetailsContainer() { + return mock(WorkerQueueDetailsContainer.class); + } + + } } From 640eab6d0c491a4c96e04b604d4ff14f34c688f4 Mon Sep 17 00:00:00 2001 From: Akash Anand Date: Wed, 17 Feb 2021 14:59:04 +0530 Subject: [PATCH 4/6] changed to tabs instead of spaces .. --- .../monitor/mbean/WorkerMetricsMBean.java | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/mbean/WorkerMetricsMBean.java b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/mbean/WorkerMetricsMBean.java index 15165db7cf..79fa803f0d 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/mbean/WorkerMetricsMBean.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/mbean/WorkerMetricsMBean.java @@ -28,43 +28,43 @@ @ManagedResource(description = "Worker Metrics API") public class WorkerMetricsMBean { - @Autowired - private CpuUtilizationService cpuUtilizationService; - @Autowired - private DiskReadUtilizationService diskReadUtilizationService; - @Autowired - private MemoryUtilizationService memoryUtilizationService; - @Autowired - private DiskWriteUtilizationService diskWriteUtilizationService; - @Autowired - private WorkerManager workerManager; - @Autowired - @Qualifier("numberOfExecutionThreads") - private Integer numberOfThreads; + @Autowired + private CpuUtilizationService cpuUtilizationService; + @Autowired + private DiskReadUtilizationService diskReadUtilizationService; + @Autowired + private MemoryUtilizationService memoryUtilizationService; + @Autowired + private DiskWriteUtilizationService diskWriteUtilizationService; + @Autowired + private WorkerManager workerManager; + @Autowired + @Qualifier("numberOfExecutionThreads") + private Integer numberOfThreads; - @ManagedAttribute(description = "Current Cpu Usage") - public double getCpuUsage() { - return cpuUtilizationService.getCurrentValue(); - } + @ManagedAttribute(description = "Current Cpu Usage") + public double getCpuUsage() { + return cpuUtilizationService.getCurrentValue(); + } - @ManagedAttribute(description = "Current Memory Usage") - public double getMemoryUsage() { - return memoryUtilizationService.getCurrentValue(); - } + @ManagedAttribute(description = "Current Memory Usage") + public double getMemoryUsage() { + return memoryUtilizationService.getCurrentValue(); + } - @ManagedAttribute(description = "Current Disk Read Usage") - public long getDiskReadUsage() { - return diskReadUtilizationService.getCurrentValue(); - } + @ManagedAttribute(description = "Current Disk Read Usage") + public long getDiskReadUsage() { + return diskReadUtilizationService.getCurrentValue(); + } - @ManagedAttribute(description = "Current Disk Write Usage") - public long getDiskWriteUsage() { - return diskWriteUtilizationService.getCurrentValue(); - } + @ManagedAttribute(description = "Current Disk Write Usage") + public long getDiskWriteUsage() { + return diskWriteUtilizationService.getCurrentValue(); + } - @ManagedAttribute(description = "Running Tasks Count") - public double getWorkerThreadsUsage() { - return ((double) workerManager.getRunningTasksCount() * 100) / numberOfThreads; - } + @ManagedAttribute(description = "Running Tasks Count") + public double getWorkerThreadsUsage() { + return ((double) workerManager.getRunningTasksCount() * 100) / numberOfThreads; + } } \ No newline at end of file From cd6ced3a70c407c8f940e28b1ba5a531cda5d933 Mon Sep 17 00:00:00 2001 From: SAshutosh Date: Thu, 18 Feb 2021 14:41:58 +0530 Subject: [PATCH 5/6] Implement review comments --- .../node/services/WorkerNodeServiceImpl.java | 6 +- .../monitor/PerformanceMetricsCollector.java | 84 +++++++++---------- .../metrics/CpuUtilizationService.java | 38 ++++----- .../metrics/MemoryUtilizationService.java | 32 ++++--- .../service/WorkerMetricsServiceImpl.java | 24 +++--- 5 files changed, 90 insertions(+), 94 deletions(-) diff --git a/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/WorkerNodeServiceImpl.java b/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/WorkerNodeServiceImpl.java index 23bcbdc055..cfca14adc5 100644 --- a/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/WorkerNodeServiceImpl.java +++ b/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/WorkerNodeServiceImpl.java @@ -50,7 +50,7 @@ public class WorkerNodeServiceImpl implements WorkerNodeService { private static final Logger logger = LogManager.getLogger(WorkerNodeServiceImpl.class); private static final long MAX_VERSION_GAP_ALLOWED = Long.getLong("max.allowed.version.gap.worker.recovery", 2); - private static boolean disableMonitoring = Boolean.getBoolean("global.worker.monitoring.disable"); + private static final boolean disableMonitoring = Boolean.getBoolean("global.worker.monitoring.disable"); private static final String MSG_RECOVERY_VERSION_NAME = "MSG_RECOVERY_VERSION"; @Autowired @@ -77,9 +77,7 @@ void setWorkerMonitoring(){ if(disableMonitoring) { logger.info("Monitoring is disabled,setting busyness status as not available for all workers"); - transactionTemplate.executeWithoutResult(transactionStatus -> { - readAllWorkersUuids().stream().forEach(uuid -> updateWorkerBusynessValue(uuid,"NA") ); - }); + transactionTemplate.executeWithoutResult(transactionStatus -> readAllWorkersUuids().stream().forEach(uuid -> updateWorkerBusynessValue(uuid,"NA") )); } } //readAllWorkersUuids().stream().forEach(uuid -> updateWorkerBusynessValue(uuid,"NA") ); diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/PerformanceMetricsCollector.java b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/PerformanceMetricsCollector.java index 5dcc69bb5d..d11adda597 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/PerformanceMetricsCollector.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/PerformanceMetricsCollector.java @@ -38,50 +38,50 @@ @Component public class PerformanceMetricsCollector implements PerfMetricCollector { - List workerPerfMetrics; - @Autowired - private WorkerManager workerManager; - @Autowired - private CpuUtilizationService cpuUtilizationService; - @Autowired - private MemoryUtilizationService memoryUtilizationService; - @Autowired - private DiskReadUtilizationService diskReadUtilizationService; - @Autowired - private DiskWriteUtilizationService diskWriteUtilizationService; - @Autowired - private WorkerThreadUtilization workerThreadUtilization; - @Autowired - private HeapUtilizationService heapUtilizationService; + List workerPerfMetrics; + @Autowired + private WorkerManager workerManager; + @Autowired + private CpuUtilizationService cpuUtilizationService; + @Autowired + private MemoryUtilizationService memoryUtilizationService; + @Autowired + private DiskReadUtilizationService diskReadUtilizationService; + @Autowired + private DiskWriteUtilizationService diskWriteUtilizationService; + @Autowired + private WorkerThreadUtilization workerThreadUtilization; + @Autowired + private HeapUtilizationService heapUtilizationService; - public PerformanceMetricsCollector() { - } + public PerformanceMetricsCollector() { + } - @PostConstruct - public void init() { - createMetrics(); - } + @PostConstruct + public void init() { + createMetrics(); + } - private void createMetrics() { - workerPerfMetrics = new ArrayList<>(); - workerPerfMetrics.add(cpuUtilizationService); - workerPerfMetrics.add(diskReadUtilizationService); - workerPerfMetrics.add(memoryUtilizationService); - workerPerfMetrics.add(heapUtilizationService); - workerPerfMetrics.add(diskWriteUtilizationService); - workerPerfMetrics.add(workerThreadUtilization); - } + private void createMetrics() { + workerPerfMetrics = new ArrayList<>(); + workerPerfMetrics.add(cpuUtilizationService); + workerPerfMetrics.add(diskReadUtilizationService); + workerPerfMetrics.add(memoryUtilizationService); + workerPerfMetrics.add(heapUtilizationService); + workerPerfMetrics.add(diskWriteUtilizationService); + workerPerfMetrics.add(workerThreadUtilization); + } - @Override - public Map collectMetrics() { - Map currentValues = new HashMap<>(); - for (WorkerPerfMetric metric : - workerPerfMetrics) { - Pair currentPair = metric.measure(); - currentValues.put(currentPair.getKey(), currentPair.getValue()); - } - currentValues.put(WorkerPerformanceMetric.WORKER_ID, workerManager.getWorkerUuid()); - currentValues.put(WorkerPerformanceMetric.WORKER_MEASURED_TIME, System.currentTimeMillis()); - return currentValues; - } + @Override + public Map collectMetrics() { + Map currentValues = new HashMap<>(); + for (WorkerPerfMetric metric : + workerPerfMetrics) { + Pair currentPair = metric.measure(); + currentValues.put(currentPair.getKey(), currentPair.getValue()); + } + currentValues.put(WorkerPerformanceMetric.WORKER_ID, workerManager.getWorkerUuid()); + currentValues.put(WorkerPerformanceMetric.WORKER_MEASURED_TIME, System.currentTimeMillis()); + return currentValues; + } } diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/CpuUtilizationService.java b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/CpuUtilizationService.java index 5a4f28b1fb..92fcff3520 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/CpuUtilizationService.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/CpuUtilizationService.java @@ -25,26 +25,26 @@ import java.io.Serializable; public class CpuUtilizationService extends WorkerPerformanceMetricBase { - private static OSProcess oldProcess; - private int cpuNumber; + private static OSProcess oldProcess; + private int cpuNumber; - @PostConstruct - public void init() { - SystemInfo systemInfo = new SystemInfo(); - CentralProcessor processor = systemInfo.getHardware().getProcessor(); - this.cpuNumber = processor.getLogicalProcessorCount(); - } + @PostConstruct + public void init() { + SystemInfo systemInfo = new SystemInfo(); + CentralProcessor processor = systemInfo.getHardware().getProcessor(); + this.cpuNumber = processor.getLogicalProcessorCount(); + } - @Override - public Pair measure() { - Pair cpuUsage = Pair.of(WorkerPerformanceMetric.CPU_USAGE, getCurrentValue()); - return cpuUsage; - } + @Override + public Pair measure() { + Pair cpuUsage = Pair.of(WorkerPerformanceMetric.CPU_USAGE, getCurrentValue()); + return cpuUsage; + } - public double getCurrentValue() { - OSProcess osProcess = getProcess(); - double cpuUsed = (osProcess.getProcessCpuLoadBetweenTicks(oldProcess) * 100) / cpuNumber; - oldProcess = osProcess; - return formatTo2Decimal(cpuUsed); - } + public double getCurrentValue() { + OSProcess osProcess = getProcess(); + double cpuUsed = (osProcess.getProcessCpuLoadBetweenTicks(oldProcess) * 100) / cpuNumber; + oldProcess = osProcess; + return formatTo2Decimal(cpuUsed); + } } diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/MemoryUtilizationService.java b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/MemoryUtilizationService.java index be1c3bebf6..92000dc189 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/MemoryUtilizationService.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/metrics/MemoryUtilizationService.java @@ -26,27 +26,25 @@ public class MemoryUtilizationService extends WorkerPerformanceMetricBase { - private long usedRamProcess; - private OSProcess process; - private long totalRam; + private OSProcess process; + private long totalRam; - @PostConstruct - public void init() { - SystemInfo si = new SystemInfo(); - process = getProcess(); - GlobalMemory globalMemory = si.getHardware().getMemory(); - this.totalRam = globalMemory.getTotal(); - } + @PostConstruct + public void init() { + SystemInfo si = new SystemInfo(); + process = getProcess(); + GlobalMemory globalMemory = si.getHardware().getMemory(); + this.totalRam = globalMemory.getTotal(); + } - @Override - public Pair measure() { - Pair memUsage = Pair.of(WorkerPerformanceMetric.MEMORY_USAGE, getCurrentValue()); - return memUsage; - } + @Override + public Pair measure() { + return Pair.of(WorkerPerformanceMetric.MEMORY_USAGE, getCurrentValue()); + } public double getCurrentValue() { - this.usedRamProcess = process.getResidentSetSize(); - double ramUsed = ((double)usedRamProcess * 100 / totalRam); + long usedRamProcess = process.getResidentSetSize(); + double ramUsed = ((double) usedRamProcess * 100 / totalRam); return formatTo2Decimal(ramUsed); } } diff --git a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImpl.java b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImpl.java index c246025643..e4251d776e 100644 --- a/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImpl.java +++ b/worker/worker-monitor/score-worker-monitor-impl/src/main/java/io/cloudslang/worker/monitor/service/WorkerMetricsServiceImpl.java @@ -31,27 +31,27 @@ import java.util.concurrent.LinkedBlockingQueue; public class WorkerMetricsServiceImpl implements WorkerMetricsService { - protected static final Logger logger = LogManager.getLogger(WorkerMetricsServiceImpl.class); - static int capacity = Integer.getInteger("metrics.collection.sampleCount", Integer.MAX_VALUE); - boolean disabled = Boolean.getBoolean("worker.monitoring.disable"); - @Autowired - PerfMetricCollector perfMetricCollector; + protected static final Logger logger = LogManager.getLogger(WorkerMetricsServiceImpl.class); + final int capacity = Integer.getInteger("metrics.collection.sampleCount", Integer.MAX_VALUE); + final boolean disabled = Boolean.getBoolean("worker.monitoring.disable"); + @Autowired + PerfMetricCollector perfMetricCollector; @Autowired private WorkerStateUpdateService workerStateUpdateService; - private LinkedBlockingQueue> collectMetricQueue = new LinkedBlockingQueue>(capacity); - @Autowired - private EventBus eventBus; + private final LinkedBlockingQueue> collectMetricQueue = new LinkedBlockingQueue<>(capacity); + @Autowired + private EventBus eventBus; @Override public void collectPerformanceMetrics() { try { - if(!isMonitoringDisabled()) { + if (!isMonitoringDisabled()) { Map metricInfo = perfMetricCollector.collectMetrics(); collectMetricQueue.put(metricInfo); if (logger.isDebugEnabled()) { - logger.debug("Collected worker metric "+ metricInfo.size()); + logger.debug("Collected worker metric " + metricInfo.size()); } } } catch (Exception e) { @@ -67,11 +67,11 @@ private boolean isMonitoringDisabled() { public void dispatchPerformanceMetrics() { try { List> metricData = getCurrentBatch(collectMetricQueue); - if(!isMonitoringDisabled() && metricData!=null && metricData.size() > 0) { + if (!isMonitoringDisabled() && metricData.size() > 0) { ScoreEvent scoreEvent = new ScoreEvent(EventConstants.WORKER_PERFORMANCE_MONITOR, (Serializable) metricData); eventBus.dispatch(scoreEvent); if (logger.isDebugEnabled()) { - logger.debug("Dispatched worker metric "+ metricData.size()); + logger.debug("Dispatched worker metric " + metricData.size()); } } } catch (Exception e) { From aed46d4634c5620886ea7d2aec8b1a84bb9f2a93 Mon Sep 17 00:00:00 2001 From: SAshutosh Date: Tue, 23 Feb 2021 15:32:11 +0530 Subject: [PATCH 6/6] Code formatting --- .../schema/WorkerBeanDefinitionParser.java | 328 +++++++++--------- 1 file changed, 164 insertions(+), 164 deletions(-) diff --git a/package/score-worker/src/main/java/io/cloudslang/schema/WorkerBeanDefinitionParser.java b/package/score-worker/src/main/java/io/cloudslang/schema/WorkerBeanDefinitionParser.java index c33d168660..d88109260d 100644 --- a/package/score-worker/src/main/java/io/cloudslang/schema/WorkerBeanDefinitionParser.java +++ b/package/score-worker/src/main/java/io/cloudslang/schema/WorkerBeanDefinitionParser.java @@ -73,22 +73,22 @@ */ public class WorkerBeanDefinitionParser extends AbstractBeanDefinitionParser { - private Map,String> beans = new HashMap,String>(){{ - put(WorkerManager.class, "workerManager"); - put(EventBusImpl.class, null); - put(FastEventBusImpl.class, "consumptionFastEventBus"); - put(ExecutionServiceImpl.class, "agent"); - put(InBuffer.class, null); - put(WorkerConfigurationUtils.class, null); - put(WorkerStateUpdateServiceImpl.class, null); - put(OutboundBufferImpl.class, "outBuffer"); - put(RetryTemplate.class, null); - put(SimpleExecutionRunnableFactory.class, null); - put(WorkerManagerMBean.class, "io.cloudslang.worker.management.services.WorkerManagerMBean"); - put(WorkerRecoveryManagerImpl.class, null); - put(ReflectionAdapterImpl.class, null); + private final Map, String> beans = new HashMap, String>() {{ + put(WorkerManager.class, "workerManager"); + put(EventBusImpl.class, null); + put(FastEventBusImpl.class, "consumptionFastEventBus"); + put(ExecutionServiceImpl.class, "agent"); + put(InBuffer.class, null); + put(WorkerConfigurationUtils.class, null); + put(WorkerStateUpdateServiceImpl.class, null); + put(OutboundBufferImpl.class, "outBuffer"); + put(RetryTemplate.class, null); + put(SimpleExecutionRunnableFactory.class, null); + put(WorkerManagerMBean.class, "io.cloudslang.worker.management.services.WorkerManagerMBean"); + put(WorkerRecoveryManagerImpl.class, null); + put(ReflectionAdapterImpl.class, null); put(SessionDataHandlerImpl.class, "sessionDataHandler"); - put(SynchronizationManagerImpl.class, null); + put(SynchronizationManagerImpl.class, null); put(WorkerConfigurationServiceImpl.class, "workerConfiguration"); put(WorkerQueueDetailsContainer.class, "workerQueueDetailsContainer"); @@ -96,157 +96,157 @@ public class WorkerBeanDefinitionParser extends AbstractBeanDefinitionParser { put(WorkerExecutionMonitorServiceImpl.class, "workerExecutionMonitorService"); put(WorkerMonitorsImpl.class, "workerMonitorsImpl"); put(ScheduledWorkerLoadMonitor.class, "scheduledWorkerLoadMonitor"); - put(CpuUtilizationService.class, "cpuUtilizationService"); - //Metrics - put(DiskReadUtilizationService.class, "diskReadUtilizationService"); - put(DiskWriteUtilizationService.class, "diskWriteUtilizationService"); - put(MemoryUtilizationService.class, "memoryUtilizationService"); - put(PerformanceMetricsCollector.class, "perfMetricCollector"); - put(WorkerMetricsServiceImpl.class, "workerMetricCollectorService"); - put(HeapUtilizationService.class, "heapUtilizationService"); - put(WorkerThreadUtilization.class, "workerThreadUtilization"); - put(WorkerMetricsMBean.class, "io.cloudslang.worker.monitor.mbean.WorkerMetricsMBean"); - }}; - - private List configurationValues = Arrays.asList( - new ConfValue().NAME("inBufferCapacity").DEFAULT(500), - new ConfValue().NAME("numberOfExecutionThreads").DEFAULT(20), - new ConfValue().NAME("maxDeltaBetweenDrains").DEFAULT(100) - ); - - private List schedulerValues = Arrays.asList( - new ConfValue().NAME("outBufferInterval").DEFAULT(100L), - new ConfValue().NAME("keepAliveInterval").DEFAULT(10000L), - new ConfValue().NAME("configRefreshInterval").DEFAULT(1000L), - new ConfValue().NAME("interruptCanceledInterval").DEFAULT(30000L), + put(CpuUtilizationService.class, "cpuUtilizationService"); + //Metrics + put(DiskReadUtilizationService.class, "diskReadUtilizationService"); + put(DiskWriteUtilizationService.class, "diskWriteUtilizationService"); + put(MemoryUtilizationService.class, "memoryUtilizationService"); + put(PerformanceMetricsCollector.class, "perfMetricCollector"); + put(WorkerMetricsServiceImpl.class, "workerMetricCollectorService"); + put(HeapUtilizationService.class, "heapUtilizationService"); + put(WorkerThreadUtilization.class, "workerThreadUtilization"); + put(WorkerMetricsMBean.class, "io.cloudslang.worker.monitor.mbean.WorkerMetricsMBean"); + }}; + + private final List configurationValues = Arrays.asList( + new ConfValue().NAME("inBufferCapacity").DEFAULT(500), + new ConfValue().NAME("numberOfExecutionThreads").DEFAULT(20), + new ConfValue().NAME("maxDeltaBetweenDrains").DEFAULT(100) + ); + + private final List schedulerValues = Arrays.asList( + new ConfValue().NAME("outBufferInterval").DEFAULT(100L), + new ConfValue().NAME("keepAliveInterval").DEFAULT(10000L), + new ConfValue().NAME("configRefreshInterval").DEFAULT(1000L), + new ConfValue().NAME("interruptCanceledInterval").DEFAULT(30000L), new ConfValue().NAME("statisticsInterval").DEFAULT(1000L), new ConfValue().NAME("scheduledWorkerMonitorInterval").DEFAULT(10000L), new ConfValue().NAME("workerMonitorRefreshInterval").DEFAULT(300000L), - new ConfValue().NAME("scheduledPerfMetricCollectionInterval").DEFAULT(5000L), - new ConfValue().NAME("scheduledMetricDispatchInterval").DEFAULT(30000L) - ); - - @Override - protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { - registerWorkerUuid(element.getAttribute("uuid"), element.getAttribute("depends-on"), parserContext); - registerBeans(parserContext); - registerSpecialBeans(element, parserContext); - registerConfiguration(DomUtils.getChildElementByTagName(element, "configuration"), parserContext); - registerScheduler(DomUtils.getChildElementByTagName(element, "scheduler"), parserContext); - return createRootBeanDefinition(); - } - - private AbstractBeanDefinition createRootBeanDefinition(){ - return BeanDefinitionBuilder.genericBeanDefinition(Object.class).getBeanDefinition(); - } - - private void registerWorkerUuid(String uuid, String dependsOn, ParserContext parserContext) { - new BeanRegistrator(parserContext) - .NAME("workerUuid") - .CLASS(String.class) - .addConstructorArgValue(uuid) - .addDependsOn(StringUtils.hasText(dependsOn)? dependsOn.split(","): null) - .register(); - } - - private void registerBeans(ParserContext parserContext){ - BeanRegistrator beanRegistrator = new BeanRegistrator(parserContext); - for (Map.Entry,String> entry : beans.entrySet()) { - beanRegistrator - .NAME(entry.getValue()) - .CLASS(entry.getKey()) - .register(); - } - } - - private void registerSpecialBeans(Element element, ParserContext parserContext) { - if (!"false".equalsIgnoreCase(element.getAttribute("register"))) { - new BeanRegistrator(parserContext).CLASS(WorkerRegistration.class).register(); - } - - registerWorkerVersionService(element, parserContext); - registerSequentialExecution(element, parserContext); - registerRobotAvailabilityService(element, parserContext); - registerExecutionPreconditionService(element, parserContext); - registerExecutionPostconditionService(element, parserContext); - registerQueueConfigurationDataService(element, parserContext); - } - - private void registerSequentialExecution(Element element, ParserContext parserContext) { - String registerSequentialExecutionService = element.getAttribute("registerSequentialExecutionService"); - if (!FALSE.toString().equals(registerSequentialExecutionService)) { - new BeanRegistrator(parserContext) - .NAME("sequentialExecutionService") - .CLASS(DefaultSequentialExecutionServiceImpl.class) - .register(); - } - } - - private void registerWorkerVersionService(Element element, ParserContext parserContext) { - String registerWorkerVersionService = element.getAttribute("registerWorkerVersionService"); - if (!FALSE.toString().equals(registerWorkerVersionService)) { - new BeanRegistrator(parserContext).CLASS(WorkerVersionServiceImpl.class).register(); - } - } - - private void registerRobotAvailabilityService(Element element, ParserContext parserContext) { - String registerRobotAvailabilityService = element.getAttribute("registerRobotAvailabilityService"); - if (!FALSE.toString().equals(registerRobotAvailabilityService)) { - new BeanRegistrator(parserContext) - .NAME("robotAvailabilityService") - .CLASS(ScoreRobotAvailabilityServiceImpl.class) - .register(); - } - } - - private void registerExecutionPreconditionService(Element element, ParserContext parserContext) { - String registerPreconditionService = element.getAttribute("registerExecutionPreconditionService"); - if (!FALSE.toString().equals(registerPreconditionService)) { - new BeanRegistrator(parserContext) - .NAME("executionPreconditionService") - .CLASS(StubExecutionPreconditionService.class) - .register(); - } - } - - - private void registerExecutionPostconditionService(Element element, ParserContext parserContext) { - String registerPostconditionService = element.getAttribute("registerExecutionPostconditionService"); - if (!FALSE.toString().equals(registerPostconditionService)) { - new BeanRegistrator(parserContext) - .NAME("executionPostconditionService") - .CLASS(StubExecutionPostconditionService.class) - .register(); - } - } - - private void registerConfiguration(Element configurationElement, ParserContext parserContext) { - for (ConfValue configurationValue : configurationValues) { - configurationValue.register(configurationElement, parserContext); - } - } - - private void registerScheduler(Element schedulerElement, ParserContext parserContext){ - for (ConfValue value : schedulerValues) { - value.register(schedulerElement, parserContext); - } - new XmlBeanDefinitionReader(parserContext.getRegistry()) - .loadBeanDefinitions("META-INF/spring/score/context/scoreWorkerSchedulerContext.xml"); - } - - private void registerQueueConfigurationDataService(Element element, ParserContext parserContext) { - String registerQueueConfigurationDataService = element.getAttribute("registerQueueConfigurationDataService"); - if (!FALSE.toString().equals(registerQueueConfigurationDataService)) { - new BeanRegistrator(parserContext) - .NAME("queueConfigurationDataService") - .CLASS(StubQueueConfigurationDataServiceImpl.class) - .register(); - } - } - - @Override - protected boolean shouldGenerateId() { - return true; - } + new ConfValue().NAME("scheduledPerfMetricCollectionInterval").DEFAULT(5000L), + new ConfValue().NAME("scheduledMetricDispatchInterval").DEFAULT(30000L) + ); + + @Override + protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { + registerWorkerUuid(element.getAttribute("uuid"), element.getAttribute("depends-on"), parserContext); + registerBeans(parserContext); + registerSpecialBeans(element, parserContext); + registerConfiguration(DomUtils.getChildElementByTagName(element, "configuration"), parserContext); + registerScheduler(DomUtils.getChildElementByTagName(element, "scheduler"), parserContext); + return createRootBeanDefinition(); + } + + private AbstractBeanDefinition createRootBeanDefinition() { + return BeanDefinitionBuilder.genericBeanDefinition(Object.class).getBeanDefinition(); + } + + private void registerWorkerUuid(String uuid, String dependsOn, ParserContext parserContext) { + new BeanRegistrator(parserContext) + .NAME("workerUuid") + .CLASS(String.class) + .addConstructorArgValue(uuid) + .addDependsOn(StringUtils.hasText(dependsOn) ? dependsOn.split(",") : null) + .register(); + } + + private void registerBeans(ParserContext parserContext) { + BeanRegistrator beanRegistrator = new BeanRegistrator(parserContext); + for (Map.Entry, String> entry : beans.entrySet()) { + beanRegistrator + .NAME(entry.getValue()) + .CLASS(entry.getKey()) + .register(); + } + } + + private void registerSpecialBeans(Element element, ParserContext parserContext) { + if (!"false".equalsIgnoreCase(element.getAttribute("register"))) { + new BeanRegistrator(parserContext).CLASS(WorkerRegistration.class).register(); + } + + registerWorkerVersionService(element, parserContext); + registerSequentialExecution(element, parserContext); + registerRobotAvailabilityService(element, parserContext); + registerExecutionPreconditionService(element, parserContext); + registerExecutionPostconditionService(element, parserContext); + registerQueueConfigurationDataService(element, parserContext); + } + + private void registerSequentialExecution(Element element, ParserContext parserContext) { + String registerSequentialExecutionService = element.getAttribute("registerSequentialExecutionService"); + if (!FALSE.toString().equals(registerSequentialExecutionService)) { + new BeanRegistrator(parserContext) + .NAME("sequentialExecutionService") + .CLASS(DefaultSequentialExecutionServiceImpl.class) + .register(); + } + } + + private void registerWorkerVersionService(Element element, ParserContext parserContext) { + String registerWorkerVersionService = element.getAttribute("registerWorkerVersionService"); + if (!FALSE.toString().equals(registerWorkerVersionService)) { + new BeanRegistrator(parserContext).CLASS(WorkerVersionServiceImpl.class).register(); + } + } + + private void registerRobotAvailabilityService(Element element, ParserContext parserContext) { + String registerRobotAvailabilityService = element.getAttribute("registerRobotAvailabilityService"); + if (!FALSE.toString().equals(registerRobotAvailabilityService)) { + new BeanRegistrator(parserContext) + .NAME("robotAvailabilityService") + .CLASS(ScoreRobotAvailabilityServiceImpl.class) + .register(); + } + } + + private void registerExecutionPreconditionService(Element element, ParserContext parserContext) { + String registerPreconditionService = element.getAttribute("registerExecutionPreconditionService"); + if (!FALSE.toString().equals(registerPreconditionService)) { + new BeanRegistrator(parserContext) + .NAME("executionPreconditionService") + .CLASS(StubExecutionPreconditionService.class) + .register(); + } + } + + + private void registerExecutionPostconditionService(Element element, ParserContext parserContext) { + String registerPostconditionService = element.getAttribute("registerExecutionPostconditionService"); + if (!FALSE.toString().equals(registerPostconditionService)) { + new BeanRegistrator(parserContext) + .NAME("executionPostconditionService") + .CLASS(StubExecutionPostconditionService.class) + .register(); + } + } + + private void registerConfiguration(Element configurationElement, ParserContext parserContext) { + for (ConfValue configurationValue : configurationValues) { + configurationValue.register(configurationElement, parserContext); + } + } + + private void registerScheduler(Element schedulerElement, ParserContext parserContext) { + for (ConfValue value : schedulerValues) { + value.register(schedulerElement, parserContext); + } + new XmlBeanDefinitionReader(parserContext.getRegistry()) + .loadBeanDefinitions("META-INF/spring/score/context/scoreWorkerSchedulerContext.xml"); + } + + private void registerQueueConfigurationDataService(Element element, ParserContext parserContext) { + String registerQueueConfigurationDataService = element.getAttribute("registerQueueConfigurationDataService"); + if (!FALSE.toString().equals(registerQueueConfigurationDataService)) { + new BeanRegistrator(parserContext) + .NAME("queueConfigurationDataService") + .CLASS(StubQueueConfigurationDataServiceImpl.class) + .register(); + } + } + + @Override + protected boolean shouldGenerateId() { + return true; + } }