@Override public void stop(StopContext context) { ROOT_LOGGER.debugf("Stopping JCA WorkManager: ", value.getName()); //shutting down immediately (synchronous method) the workmanager and release all works value.shutdown(); if (value.getName().equals(DEFAULT_NAME)) { WorkManagerCoordinator.getInstance().setDefaultWorkManager(null); } else { WorkManagerCoordinator.getInstance().unregisterWorkManager(value); } ROOT_LOGGER.debugf("Stopped JCA WorkManager: ", value.getName()); }
@Override public void start(StartContext context) throws StartException { ROOT_LOGGER.debugf("Starting JCA WorkManager: ", value.getName()); BlockingExecutor longRunning = (BlockingExecutor) executorLong.getOptionalValue(); if (longRunning != null) { this.value.setLongRunningThreadPool(longRunning); this.value.setShortRunningThreadPool(new StatisticsExecutorImpl((BlockingExecutor) executorShort.getValue())); } else { this.value.setLongRunningThreadPool(new StatisticsExecutorImpl((BlockingExecutor) executorShort.getValue())); this.value.setShortRunningThreadPool(new StatisticsExecutorImpl((BlockingExecutor) executorShort.getValue())); } this.value.setXATerminator(new XATerminatorImpl(xaTerminator.getValue())); if (value.getName().equals(DEFAULT_NAME)) { WorkManagerCoordinator.getInstance().setDefaultWorkManager(value); } else { WorkManagerCoordinator.getInstance().registerWorkManager(value); } //this is a value.restart() equivalent if (value.isShutdown()) value.cancelShutdown(); if (this.value.isElytronEnabled()) { this.value.setSecurityIntegration(new ElytronSecurityIntegration()); } else { this.value.setSecurityIntegration(new PicketBoxSecurityIntegration()); } ROOT_LOGGER.debugf("Started JCA WorkManager: ", value.getName()); }
@Override public void stop(StopContext context) { ROOT_LOGGER.debugf("Stopping JCA DistributedWorkManager: ", value.getName()); value.prepareShutdown(); try { value.getTransport().shutdown(); } catch (Throwable throwable) { ROOT_LOGGER.trace("failed to stop DWM transport:", throwable); } value.shutdown(); WorkManagerCoordinator.getInstance().unregisterWorkManager(value); ROOT_LOGGER.debugf("Stopped JCA DistributedWorkManager: ", value.getName()); }
/** * 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); }
@Override public void start(StartContext context) throws StartException { ROOT_LOGGER.debugf("Starting JCA DistributedWorkManager: ", value.getName()); CommandDispatcherTransport transport = new CommandDispatcherTransport(this.dispatcherFactory.getValue(), this.value.getName()); this.value.setTransport(transport); BlockingExecutor longRunning = (BlockingExecutor) executorLong.getOptionalValue(); if (longRunning != null) { this.value.setLongRunningThreadPool(longRunning); this.value.setShortRunningThreadPool(new StatisticsExecutorImpl((BlockingExecutor) executorShort.getValue())); } else { this.value.setLongRunningThreadPool(new StatisticsExecutorImpl((BlockingExecutor) executorShort.getValue())); this.value.setShortRunningThreadPool(new StatisticsExecutorImpl((BlockingExecutor) executorShort.getValue())); } this.value.setXATerminator(new XATerminatorImpl(xaTerminator.getValue())); if (this.value.isElytronEnabled()) { this.value.setSecurityIntegration(new ElytronSecurityIntegration()); } else { this.value.setSecurityIntegration(new PicketBoxSecurityIntegration()); } try { transport.startup(); } catch (Throwable throwable) { ROOT_LOGGER.trace("failed to start DWM transport:", throwable); throw ROOT_LOGGER.failedToStartDWMTransport(this.value.getName()); } transport.register(new Address(value.getId(), value.getName(), transport.getId())); WorkManagerCoordinator.getInstance().registerWorkManager(value); ROOT_LOGGER.debugf("Started JCA DistributedWorkManager: ", value.getName()); }
/** * Get the work manager * @return The handle */ public WorkManager getWorkManager() { if (workManager == null) workManager = WorkManagerCoordinator.getInstance().createWorkManager(id, workManagerName); return workManager; }
/** * 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; }
/** * Remove a bootstrap context * @param id The id of the bootstrap context */ public synchronized void removeBootstrapContext(String id) { if (id == null || id.trim().equals("")) throw new IllegalArgumentException("The id of BootstrapContext is invalid: " + id); Integer i = refCountBootstrapContexts.get(id); if (i != null) { int newValue = i.intValue() - 1; if (newValue == 0) { CloneableBootstrapContext cbc = activeBootstrapContexts.remove(id); refCountBootstrapContexts.remove(id); cbc.shutdown(); WorkManagerCoordinator.getInstance().removeWorkManager(id); } else { refCountBootstrapContexts.put(id, Integer.valueOf(newValue)); } } }
DistributedWorkManager dwm = resolveDistributedWorkManager(event.getAddress()); removeWorkManager(event.getAddress().getWorkManagerId());
/** * 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); }
@Override public void stop(StopContext context) { ROOT_LOGGER.debugf("Stopping JCA DistributedWorkManager: ", value.getName()); value.prepareShutdown(); try { value.getTransport().shutdown(); } catch (Throwable throwable) { ROOT_LOGGER.trace("failed to stop DWM transport:", throwable); } value.shutdown(); WorkManagerCoordinator.getInstance().unregisterWorkManager(value); ROOT_LOGGER.debugf("Stopped JCA DistributedWorkManager: ", value.getName()); }
@Override public void start(StartContext context) throws StartException { ROOT_LOGGER.debugf("Starting JCA DistributedWorkManager: ", value.getName()); CommandDispatcherTransport transport = new CommandDispatcherTransport(this.dispatcherFactory.getValue(), this.value.getName()); this.value.setTransport(transport); BlockingExecutor longRunning = (BlockingExecutor) executorLong.getOptionalValue(); if (longRunning != null) { this.value.setLongRunningThreadPool(longRunning); this.value.setShortRunningThreadPool(new StatisticsExecutorImpl((BlockingExecutor) executorShort.getValue())); } else { this.value.setLongRunningThreadPool(new StatisticsExecutorImpl((BlockingExecutor) executorShort.getValue())); this.value.setShortRunningThreadPool(new StatisticsExecutorImpl((BlockingExecutor) executorShort.getValue())); } this.value.setXATerminator(new XATerminatorImpl(xaTerminator.getValue())); if (this.value.isElytronEnabled()) { this.value.setSecurityIntegration(new ElytronSecurityIntegration()); } else { this.value.setSecurityIntegration(new PicketBoxSecurityIntegration()); } try { transport.startup(); } catch (Throwable throwable) { ROOT_LOGGER.trace("failed to start DWM transport:", throwable); throw ROOT_LOGGER.failedToStartDWMTransport(this.value.getName()); } transport.register(new Address(value.getId(), value.getName(), transport.getId())); WorkManagerCoordinator.getInstance().registerWorkManager(value); ROOT_LOGGER.debugf("Started JCA DistributedWorkManager: ", value.getName()); }
WorkManagerCoordinator.getInstance().createWorkManager(id, bc.getWorkManagerName());
/** * 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; }
/** * localStartWork * * @param address the logical address * @param work the work * @return the start value * @throws WorkException in case of error */ public long localStartWork(Address address, DistributableWork work) throws WorkException { log.tracef("LOCAL_START_WORK(%s, %s)", address, work); WorkManagerCoordinator wmc = WorkManagerCoordinator.getInstance(); DistributedWorkManager dwm = wmc.resolveDistributedWorkManager(address); return dwm.localStartWork(work); }
@Override public void stop(StopContext context) { ROOT_LOGGER.debugf("Stopping JCA WorkManager: ", value.getName()); //shutting down immediately (synchronous method) the workmanager and release all works value.shutdown(); if (value.getName().equals(DEFAULT_NAME)) { WorkManagerCoordinator.getInstance().setDefaultWorkManager(null); } else { WorkManagerCoordinator.getInstance().unregisterWorkManager(value); } ROOT_LOGGER.debugf("Stopped JCA WorkManager: ", value.getName()); }
@Override public void start(StartContext context) throws StartException { ROOT_LOGGER.debugf("Starting JCA WorkManager: ", value.getName()); BlockingExecutor longRunning = (BlockingExecutor) executorLong.getOptionalValue(); if (longRunning != null) { this.value.setLongRunningThreadPool(longRunning); this.value.setShortRunningThreadPool(new StatisticsExecutorImpl((BlockingExecutor) executorShort.getValue())); } else { this.value.setLongRunningThreadPool(new StatisticsExecutorImpl((BlockingExecutor) executorShort.getValue())); this.value.setShortRunningThreadPool(new StatisticsExecutorImpl((BlockingExecutor) executorShort.getValue())); } this.value.setXATerminator(new XATerminatorImpl(xaTerminator.getValue())); if (value.getName().equals(DEFAULT_NAME)) { WorkManagerCoordinator.getInstance().setDefaultWorkManager(value); } else { WorkManagerCoordinator.getInstance().registerWorkManager(value); } //this is a value.restart() equivalent if (value.isShutdown()) value.cancelShutdown(); if (this.value.isElytronEnabled()) { this.value.setSecurityIntegration(new ElytronSecurityIntegration()); } else { this.value.setSecurityIntegration(new PicketBoxSecurityIntegration()); } ROOT_LOGGER.debugf("Started JCA WorkManager: ", value.getName()); }
/** * Local delta doWork accepted * @param address the logical address */ public void localDeltaDoWorkAccepted(Address address) { log.tracef("LOCAL_DELTA_DOWORK_ACCEPTED(%s)", address); WorkManagerCoordinator wmc = WorkManagerCoordinator.getInstance(); DistributedWorkManager dwm = wmc.resolveDistributedWorkManager(address); if (dwm != null) { Collection<NotificationListener> copy = new ArrayList<NotificationListener>(dwm.getNotificationListeners()); for (NotificationListener nl : copy) { nl.deltaDoWorkAccepted(); } } }
/** * Local delta doWork rejected * @param address the logical address */ public void localDeltaDoWorkRejected(Address address) { log.tracef("LOCAL_DELTA_DOWORK_REJECTED(%s)", address); WorkManagerCoordinator wmc = WorkManagerCoordinator.getInstance(); DistributedWorkManager dwm = wmc.resolveDistributedWorkManager(address); if (dwm != null) { Collection<NotificationListener> copy = new ArrayList<NotificationListener>(dwm.getNotificationListeners()); for (NotificationListener nl : copy) { nl.deltaDoWorkRejected(); } } }
/** * Local delta startWork accepted * @param address the logical address */ public void localDeltaStartWorkAccepted(Address address) { log.tracef("LOCAL_DELTA_STARTWORK_ACCEPTED(%s)", address); WorkManagerCoordinator wmc = WorkManagerCoordinator.getInstance(); DistributedWorkManager dwm = wmc.resolveDistributedWorkManager(address); if (dwm != null) { Collection<NotificationListener> copy = new ArrayList<NotificationListener>(dwm.getNotificationListeners()); for (NotificationListener nl : copy) { nl.deltaStartWorkAccepted(); } } }