@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)); } } }
result.set(((DistributedWorkManager) wm).isDistributedStatisticsEnabled()); } else { result.set(wm.isStatisticsEnabled()); result.set(((DistributedWorkManager) wm).isDistributedStatisticsEnabled()); break; result.set(((DistributedWorkManager) wm).isDoWorkDistributionEnabled()); break; result.set(((DistributedWorkManager) wm).isStartWorkDistributionEnabled()); break; result.set(((DistributedWorkManager) wm).isScheduleWorkDistributionEnabled()); break;
case ModelDescriptionConstants.STATISTICS_ENABLED: { if (distributed) { ((DistributedWorkManager) wm).setDistributedStatisticsEnabled(resolvedValue.asBoolean()); } else { wm.setStatisticsEnabled(resolvedValue.asBoolean()); ((DistributedWorkManager) wm).setDistributedStatisticsEnabled(resolvedValue.asBoolean()); break; ((DistributedWorkManager) wm).setDoWorkDistributionEnabled(resolvedValue.asBoolean()); break; ((DistributedWorkManager) wm).setStartWorkDistributionEnabled(resolvedValue.asBoolean()); break; ((DistributedWorkManager) wm).setScheduleWorkDistributionEnabled(resolvedValue.asBoolean()); break;
/** * 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); } } }
/** * 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; }
result.set(((DistributedWorkManager) wm).isDistributedStatisticsEnabled()); } else { result.set(wm.isStatisticsEnabled()); result.set(((DistributedWorkManager) wm).isDistributedStatisticsEnabled()); break; result.set(((DistributedWorkManager) wm).isDoWorkDistributionEnabled()); break; result.set(((DistributedWorkManager) wm).isStartWorkDistributionEnabled()); break; result.set(((DistributedWorkManager) wm).isScheduleWorkDistributionEnabled()); break;
case ModelDescriptionConstants.STATISTICS_ENABLED: { if (distributed) { ((DistributedWorkManager) wm).setDistributedStatisticsEnabled(resolvedValue.asBoolean()); } else { wm.setStatisticsEnabled(resolvedValue.asBoolean()); ((DistributedWorkManager) wm).setDistributedStatisticsEnabled(resolvedValue.asBoolean()); break; ((DistributedWorkManager) wm).setDoWorkDistributionEnabled(resolvedValue.asBoolean()); break; ((DistributedWorkManager) wm).setStartWorkDistributionEnabled(resolvedValue.asBoolean()); break; ((DistributedWorkManager) wm).setScheduleWorkDistributionEnabled(resolvedValue.asBoolean()); break;
@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)); } } }