public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { wm.getStatistics().clear(); context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }, OperationContext.Stage.RUNTIME);
case ModelDescriptionConstants.STATISTICS_ENABLED: { if (distributed) { ((DistributedWorkManager) wm).setDistributedStatisticsEnabled(resolvedValue.asBoolean()); } else { wm.setStatisticsEnabled(resolvedValue.asBoolean()); wm.setStatisticsEnabled(resolvedValue.asBoolean()); break; ((DistributedWorkManager) wm).setDistributedStatisticsEnabled(resolvedValue.asBoolean()); break; ((DistributedWorkManager) wm).setDoWorkDistributionEnabled(resolvedValue.asBoolean()); break; ((DistributedWorkManager) wm).setStartWorkDistributionEnabled(resolvedValue.asBoolean()); break; ((DistributedWorkManager) wm).setScheduleWorkDistributionEnabled(resolvedValue.asBoolean()); break;
result.set(wmStat.getWorkActive()); break; result.set(wmStat.getWorkFailed()); break; result.set(wmStat.getWorkSuccessful()); break; result.set(wmStat.getDoWorkAccepted()); break; result.set(wmStat.getDoWorkRejected()); break; result.set(wmStat.getScheduleWorkAccepted()); break; result.set(wmStat.getScheduleWorkRejected()); break; result.set(wmStat.getStartWorkAccepted()); break; result.set(wmStat.getStartWorkRejected()); break; result.set(((DistributedWorkManager) wm).isDistributedStatisticsEnabled()); } else {
/** * {@inheritDoc} */ public void initialize(DistributedWorkManagerStatisticsValues values) { successful.set(values.getWorkSuccessful()); failed.set(values.getWorkFailed()); doWorkAccepted.set(values.getDoWorkAccepted()); doWorkRejected.set(values.getDoWorkRejected()); scheduleWorkAccepted.set(values.getScheduleWorkAccepted()); scheduleWorkRejected.set(values.getScheduleWorkRejected()); startWorkAccepted.set(values.getStartWorkAccepted()); startWorkRejected.set(values.getStartWorkRejected()); initialized = true; }
/** * 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; }
/** * 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); } } }
@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)); } } }
@Override public void start(StartContext context) throws StartException { synchronized (this) { WorkManager wm = workManager.getValue(); wm.setStatisticsEnabled(statsEnabled); if (wm.getStatistics() != null) { PathElement peLocaldWm = PathElement.pathElement(Constants.STATISTICS_NAME, "local"); ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(peLocaldWm, new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME + "." + Constants.WORKMANAGER_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader())); ManagementResourceRegistration wmSubRegistration = overrideRegistration.registerSubModel(resourceBuilder.build()); OperationStepHandler metricHandler = new WorkManagerRuntimeAttributeReadHandler(wm, wm.getStatistics(), false); for (SimpleAttributeDefinition metric : Constants.WORKMANAGER_METRICS) { wmSubRegistration.registerMetric(metric, metricHandler); } OperationStepHandler readHandler = new WorkManagerRuntimeAttributeReadHandler(wm, wm.getStatistics(), false); OperationStepHandler writeHandler = new WorkManagerRuntimeAttributeWriteHandler(wm, false, Constants.WORKMANAGER_RW_ATTRIBUTES); for (SimpleAttributeDefinition attribute : Constants.WORKMANAGER_RW_ATTRIBUTES) { wmSubRegistration.registerReadWriteAttribute(attribute, readHandler, writeHandler); } wmSubRegistration.registerOperationHandler(ClearWorkManagerStatisticsHandler.DEFINITION, new ClearWorkManagerStatisticsHandler(wm)); } } }
@Override protected void setCallbackSecurity(org.jboss.jca.core.api.workmanager.WorkManager workManager, Callback cb) { if (cb instanceof CallbackImpl) { if (((CallbackImpl) cb).isElytronEnabled() != ((NamedWorkManager) workManager).isElytronEnabled()) throw ConnectorLogger.ROOT_LOGGER.invalidElytronWorkManagerSetting(); workManager.setCallbackSecurity(cb); } else { super.setCallbackSecurity(workManager, cb); } }
/** * {@inheritDoc} */ @Override public synchronized boolean shouldDistribute(DistributedWorkManager dwm, DistributableWork work) { log.tracef("Work=%s", work); Boolean override = WorkManagerUtil.getShouldDistribute(work); if (override != null) return override.booleanValue(); if (WorkManagerUtil.isLongRunning(work) && dwm.getLongRunningThreadPool() != null) { return !(dwm.getLongRunningThreadPool().getNumberOfFreeThreads() > watermark); } else { return !(dwm.getShortRunningThreadPool().getNumberOfFreeThreads() > watermark); } }
/** * {@inheritDoc} */ public void run() { wm.shutdown(); } }
/** * localGetShortRunningFree * * @param address the logical address * @return the free count */ public long localGetShortRunningFree(Address address) { log.tracef("LOCAL_GET_SHORTRUNNING_FREE(%s)", address); WorkManagerCoordinator wmc = WorkManagerCoordinator.getInstance(); WorkManager wm = wmc.resolveWorkManager(address); if (wm != null) { StatisticsExecutor executor = wm.getShortRunningThreadPool(); if (executor != null) return executor.getNumberOfFreeThreads(); } return 0L; }
/** * localGetLongRunningFree * * @param address the logical address * @return the free count */ public long localGetLongRunningFree(Address address) { log.tracef("LOCAL_GET_LONGRUNNING_FREE(%s)", address); WorkManagerCoordinator wmc = WorkManagerCoordinator.getInstance(); WorkManager wm = wmc.resolveWorkManager(address); if (wm != null) { StatisticsExecutor executor = wm.getLongRunningThreadPool(); if (executor != null) return executor.getNumberOfFreeThreads(); } return 0L; }
/** * Set the resource adapter * @param ra The handle */ public void setResourceAdapter(ResourceAdapter ra) { if (workManager != null) workManager.setResourceAdapter(ra); }
/** * Send the done signal to other nodes * We are adding 1 to the result, since the thread officially has been released yet, but will be shortly */ private void done() { if (longThreadPool != null && isLong) { transport.updateLongRunningFree(address, longThreadPool.getNumberOfFreeThreads() + 1); } else { transport.updateShortRunningFree(address, shortThreadPool.getNumberOfFreeThreads() + 1); } } }
/** * Delegator * @param logicalAddressMap The logical address * @return The value */ public Map<String, Integer> getDistributedStatistics(Map<String, String> logicalAddressMap) { return super.localGetDistributedStatistics(Address.fromMap(logicalAddressMap)).toMap(); }
/** * localScheduleWork * * @param address the logical address * @param work the work * @throws WorkException in case of error */ public void localScheduleWork(Address address, DistributableWork work) throws WorkException { log.tracef("LOCAL_SCHEDULE_WORK(%s, %s)", address, work); WorkManagerCoordinator wmc = WorkManagerCoordinator.getInstance(); DistributedWorkManager dwm = wmc.resolveDistributedWorkManager(address); dwm.localScheduleWork(work); }
/** * localDoWork * * @param address the logical address * @param work the work * @throws WorkException in case of error */ public void localDoWork(Address address, DistributableWork work) throws WorkException { log.tracef("LOCAL_DO_WORK(%s, %s)", address, work); WorkManagerCoordinator wmc = WorkManagerCoordinator.getInstance(); DistributedWorkManager dwm = wmc.resolveDistributedWorkManager(address); dwm.localDoWork(work); }
case ModelDescriptionConstants.STATISTICS_ENABLED: { if (distributed) { ((DistributedWorkManager) wm).setDistributedStatisticsEnabled(resolvedValue.asBoolean()); } else { wm.setStatisticsEnabled(resolvedValue.asBoolean()); wm.setStatisticsEnabled(resolvedValue.asBoolean()); break; ((DistributedWorkManager) wm).setDistributedStatisticsEnabled(resolvedValue.asBoolean()); break; ((DistributedWorkManager) wm).setDoWorkDistributionEnabled(resolvedValue.asBoolean()); break; ((DistributedWorkManager) wm).setStartWorkDistributionEnabled(resolvedValue.asBoolean()); break; ((DistributedWorkManager) wm).setScheduleWorkDistributionEnabled(resolvedValue.asBoolean()); break;
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { wm.getStatistics().clear(); context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }, OperationContext.Stage.RUNTIME);