@Override public void start(StartContext context) throws StartException { synchronized (this) { DistributedWorkManager dwm = distributedWorkManager.getValue(); dwm.setDistributedStatisticsEnabled(statsEnabled); if (dwm.getDistributedStatistics() != null) { PathElement peDistributedWm = PathElement.pathElement(Constants.STATISTICS_NAME, "distributed"); ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(peDistributedWm, new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME + "." + Constants.WORKMANAGER_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader())); ManagementResourceRegistration dwmSubRegistration = overrideRegistration.registerSubModel(resourceBuilder.build()); OperationStepHandler metricHandler = new WorkManagerRuntimeAttributeReadHandler(dwm, dwm.getDistributedStatistics(), false); for (SimpleAttributeDefinition metric : Constants.WORKMANAGER_METRICS) { dwmSubRegistration.registerMetric(metric, metricHandler); } OperationStepHandler readHandler = new WorkManagerRuntimeAttributeReadHandler(dwm, dwm.getDistributedStatistics(), false); OperationStepHandler writeHandler = new WorkManagerRuntimeAttributeWriteHandler(dwm, false, Constants.DISTRIBUTED_WORKMANAGER_RW_ATTRIBUTES); for (SimpleAttributeDefinition attribute : Constants.DISTRIBUTED_WORKMANAGER_RW_ATTRIBUTES) { dwmSubRegistration.registerReadWriteAttribute(attribute, readHandler, writeHandler); } dwmSubRegistration.registerOperationHandler(ClearWorkManagerStatisticsHandler.DEFINITION, new ClearWorkManagerStatisticsHandler(dwm)); } } }
/** * localGetDistributedStatistics * * @param address the logical address * @return The value */ public DistributedWorkManagerStatisticsValues localGetDistributedStatistics(Address address) { log.tracef("LOCAL_GET_DISTRIBUTED_STATISTICS(%s)", address); WorkManagerCoordinator wmc = WorkManagerCoordinator.getInstance(); DistributedWorkManager dwm = wmc.resolveDistributedWorkManager(address); if (dwm != null) { DistributedWorkManagerStatisticsValues values = new DistributedWorkManagerStatisticsValues(dwm.getDistributedStatistics().getWorkSuccessful(), dwm.getDistributedStatistics().getWorkFailed(), dwm.getDistributedStatistics().getDoWorkAccepted(), dwm.getDistributedStatistics().getDoWorkRejected(), dwm.getDistributedStatistics().getScheduleWorkAccepted(), dwm.getDistributedStatistics().getScheduleWorkRejected(), dwm.getDistributedStatistics().getStartWorkAccepted(), dwm.getDistributedStatistics().getStartWorkRejected()); return values; } return null; }
@Override public void start(StartContext context) throws StartException { synchronized (this) { DistributedWorkManager dwm = distributedWorkManager.getValue(); dwm.setDistributedStatisticsEnabled(statsEnabled); if (dwm.getDistributedStatistics() != null) { PathElement peDistributedWm = PathElement.pathElement(Constants.STATISTICS_NAME, "distributed"); ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(peDistributedWm, new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME + "." + Constants.WORKMANAGER_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader())); ManagementResourceRegistration dwmSubRegistration = overrideRegistration.registerSubModel(resourceBuilder.build()); OperationStepHandler metricHandler = new WorkManagerRuntimeAttributeReadHandler(dwm, dwm.getDistributedStatistics(), false); for (SimpleAttributeDefinition metric : Constants.WORKMANAGER_METRICS) { dwmSubRegistration.registerMetric(metric, metricHandler); } OperationStepHandler readHandler = new WorkManagerRuntimeAttributeReadHandler(dwm, dwm.getDistributedStatistics(), false); OperationStepHandler writeHandler = new WorkManagerRuntimeAttributeWriteHandler(dwm, false, Constants.DISTRIBUTED_WORKMANAGER_RW_ATTRIBUTES); for (SimpleAttributeDefinition attribute : Constants.DISTRIBUTED_WORKMANAGER_RW_ATTRIBUTES) { dwmSubRegistration.registerReadWriteAttribute(attribute, readHandler, writeHandler); } dwmSubRegistration.registerOperationHandler(ClearWorkManagerStatisticsHandler.DEFINITION, new ClearWorkManagerStatisticsHandler(dwm)); } } }
/** * localClearDistributedStatistics * * @param logicalAddress the logical address */ public void localClearDistributedStatistics(Address logicalAddress) { log.tracef("LOCAL_CLEAR_DISTRIBUTED_STATISTICS(%s)", logicalAddress); WorkManagerCoordinator wmc = WorkManagerCoordinator.getInstance(); DistributedWorkManager dwm = wmc.resolveDistributedWorkManager(logicalAddress); if (dwm != null) { if (dwm.isDistributedStatisticsEnabled()) { DistributedWorkManagerStatisticsValues v = new DistributedWorkManagerStatisticsValues(0, 0, 0, 0, 0, 0, 0, 0); dwm.getDistributedStatistics().initialize(v); } } }