/** * {@inheritDoc} */ public void localDoWork(Work work) throws WorkException { if (transport != null) { checkTransport(); if (getLongRunningThreadPool() != null && WorkManagerUtil.isLongRunning(work)) { transport.updateLongRunningFree(getLocalAddress(), getLongRunningThreadPool().getNumberOfFreeThreads() - 1); } else { transport.updateShortRunningFree(getLocalAddress(), getShortRunningThreadPool().getNumberOfFreeThreads() - 1); } WorkEventListener wel = new WorkEventListener(WorkManagerUtil.isLongRunning(work), getShortRunningThreadPool(), getLongRunningThreadPool(), getLocalAddress(), transport); super.doWork(work, WorkManager.INDEFINITE, null, wel); } else { super.doWork(work); } }
/** * {@inheritDoc} */ @Override public long startWork(Work work) throws WorkException { if (policy == null || selector == null || transport == null || work == null || !(work instanceof DistributableWork) || !startWorkDistributionEnabled) { return localStartWork(work); } else { doFirstChecks(work, WorkManager.INDEFINITE, null); checkTransport(); DistributableWork dw = (DistributableWork)work; if (policy.shouldDistribute(this, dw)) { Address dwmAddress = selector.selectDistributedWorkManager(getLocalAddress(), dw); if (dwmAddress != null && !getLocalAddress().equals(dwmAddress)) { return transport.startWork(dwmAddress, dw); } } return localStartWork(work); } }
/** * Clone the WorkManager implementation * @return A copy of the implementation * @exception CloneNotSupportedException Thrown if the copy operation isn't supported * */ @Override public org.jboss.jca.core.api.workmanager.WorkManager clone() throws CloneNotSupportedException { DistributedWorkManagerImpl wm = (DistributedWorkManagerImpl)super.clone(); wm.listeners = Collections.synchronizedList(new ArrayList<NotificationListener>(3)); wm.setPolicy(getPolicy()); wm.setSelector(getSelector()); wm.setTransport(getTransport()); wm.setDistributedStatisticsEnabled(isDistributedStatisticsEnabled()); wm.setDoWorkDistributionEnabled(isDoWorkDistributionEnabled()); wm.setStartWorkDistributionEnabled(isStartWorkDistributionEnabled()); wm.setScheduleWorkDistributionEnabled(isScheduleWorkDistributionEnabled()); return wm; }
work == null || !(work instanceof DistributableWork) || !doWorkDistributionEnabled) localDoWork(work); doFirstChecks(work, WorkManager.INDEFINITE, null); checkTransport(); Address dwmAddress = selector.selectDistributedWorkManager(getLocalAddress(), dw); if (dwmAddress != null && !getLocalAddress().equals(dwmAddress)) localDoWork(work);
work == null || !(work instanceof DistributableWork) || !scheduleWorkDistributionEnabled) localScheduleWork(work); doFirstChecks(work, WorkManager.INDEFINITE, null); checkTransport(); Address dwmAddress = selector.selectDistributedWorkManager(getLocalAddress(), dw); if (dwmAddress != null && !getLocalAddress().equals(dwmAddress)) localScheduleWork(work);
/** * {@inheritDoc} */ @Override protected void deltaStartWorkAccepted() { log.trace("deltaStartWorkAccepted"); super.deltaStartWorkAccepted(); if (distributedStatisticsEnabled && distributedStatistics != null && transport != null) { try { checkTransport(); distributedStatistics.sendDeltaStartWorkAccepted(); } catch (WorkException we) { log.debugf("deltaStartWorkAccepted: %s", we.getMessage(), we); } } }
/** * Initialize */ public void initialize() { if (distributedStatistics != null) { distributedStatistics.setOwnId(getLocalAddress()); distributedStatistics.setTransport(transport); } }
/** * {@inheritDoc} */ @Override protected void deltaScheduleWorkRejected() { log.trace("deltaScheduleWorkRejected"); super.deltaScheduleWorkRejected(); if (distributedStatisticsEnabled && distributedStatistics != null && transport != null) { try { checkTransport(); distributedStatistics.sendDeltaScheduleWorkRejected(); } catch (WorkException we) { log.debugf("deltaScheduleWorkRejected: %s", we.getMessage(), we); } } }
/** * {@inheritDoc} */ public long localStartWork(Work work) throws WorkException { if (transport != null) { checkTransport(); if (getLongRunningThreadPool() != null && WorkManagerUtil.isLongRunning(work)) { transport.updateLongRunningFree(getLocalAddress(), getLongRunningThreadPool().getNumberOfFreeThreads() - 1); } else { transport.updateShortRunningFree(getLocalAddress(), getShortRunningThreadPool().getNumberOfFreeThreads() - 1); } WorkEventListener wel = new WorkEventListener(WorkManagerUtil.isLongRunning(work), getShortRunningThreadPool(), getLongRunningThreadPool(), getLocalAddress(), transport); return super.startWork(work, WorkManager.INDEFINITE, null, wel); } else { return super.startWork(work); } }
/** * {@inheritDoc} */ @Override protected void deltaDoWorkRejected() { log.trace("deltaDoWorkRejected"); super.deltaDoWorkRejected(); if (distributedStatisticsEnabled && distributedStatistics != null && transport != null) { try { checkTransport(); distributedStatistics.sendDeltaDoWorkRejected(); } catch (WorkException we) { log.debugf("deltaDoWorkRejected: %s", we.getMessage(), we); } } }
/** * {@inheritDoc} */ public void localScheduleWork(Work work) throws WorkException { if (transport != null) { checkTransport(); if (getLongRunningThreadPool() != null && WorkManagerUtil.isLongRunning(work)) { transport.updateLongRunningFree(getLocalAddress(), getLongRunningThreadPool().getNumberOfFreeThreads() - 1); } else { transport.updateShortRunningFree(getLocalAddress(), getShortRunningThreadPool().getNumberOfFreeThreads() - 1); } WorkEventListener wel = new WorkEventListener(WorkManagerUtil.isLongRunning(work), getShortRunningThreadPool(), getLongRunningThreadPool(), getLocalAddress(), transport); super.scheduleWork(work, WorkManager.INDEFINITE, null, wel); } else { super.scheduleWork(work); } }
/** * {@inheritDoc} */ @Override protected void deltaWorkSuccessful() { log.trace("deltaWorkSuccessful"); super.deltaWorkSuccessful(); if (distributedStatisticsEnabled && distributedStatistics != null && transport != null) { try { checkTransport(); distributedStatistics.sendDeltaWorkSuccessful(); } catch (WorkException we) { log.debugf("deltaWorkSuccessful: %s", we.getMessage(), we); } } }
/** * {@inheritDoc} */ @Override protected void deltaDoWorkAccepted() { log.trace("deltaDoWorkAccepted"); super.deltaDoWorkAccepted(); if (distributedStatisticsEnabled && distributedStatistics != null && transport != null) { try { checkTransport(); distributedStatistics.sendDeltaDoWorkAccepted(); } catch (WorkException we) { log.debugf("deltaDoWorkAccepted: %s", we.getMessage(), we); } } }
/** * {@inheritDoc} */ @Override protected void deltaStartWorkRejected() { log.trace("deltaStartWorkRejected"); super.deltaStartWorkRejected(); if (distributedStatisticsEnabled && distributedStatistics != null && transport != null) { try { checkTransport(); distributedStatistics.sendDeltaStartWorkRejected(); } catch (WorkException we) { log.debugf("deltaStartWorkRejected: %s", we.getMessage(), we); } } }
/** * {@inheritDoc} */ @Override protected void deltaScheduleWorkAccepted() { log.trace("deltaScheduleWorkAccepted"); super.deltaScheduleWorkAccepted(); if (distributedStatisticsEnabled && distributedStatistics != null && transport != null) { try { checkTransport(); distributedStatistics.sendDeltaScheduleWorkAccepted(); } catch (WorkException we) { log.debugf("deltaScheduleWorkAccepted: %s", we.getMessage(), we); } } }
/** * {@inheritDoc} */ @Override protected void deltaWorkFailed() { log.trace("deltaWorkFailed"); super.deltaWorkFailed(); if (distributedStatisticsEnabled && distributedStatistics != null && transport != null) { try { checkTransport(); distributedStatistics.sendDeltaWorkFailed(); } catch (WorkException we) { log.debugf("deltaWorkFailed: %s", we.getMessage(), we); } } }