@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 protected void runWork() throws WorkCompletedException { // if there is security and elytron is enabled, we need to let the context run the remainder of the work // so the context can run the work as the specified Elytron identity if (securityIntegration.getSecurityContext() != null && ((CallbackImpl) workManager.getCallbackSecurity()).isElytronEnabled()) ((ElytronSecurityContext) securityIntegration.getSecurityContext()).runWork(() -> { try { WildflyWorkWrapper.super.runWork(); } catch (WorkCompletedException e) { ConnectorLogger.ROOT_LOGGER.unexceptedWorkerCompletionError(e.getLocalizedMessage(),e); } }); // delegate to super class if there is no elytron enabled else super.runWork(); } }
@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 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 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; }
/** * Initialize */ public void initialize() { if (distributedStatistics != null) { distributedStatistics.setOwnId(getLocalAddress()); distributedStatistics.setTransport(transport); } }
/** * Get the executor * @param work The work instance * @return The executor */ private BlockingExecutor getExecutor(Work work) { BlockingExecutor executor = shortRunningExecutor; if (longRunningExecutor != null && WorkManagerUtil.isLongRunning(work)) { executor = longRunningExecutor; } fireHintsComplete(work); return executor; }
/** * {@inheritDoc} */ public void prepareShutdown() { prepareShutdown(0, null); }
/** * {@inheritDoc} */ @Override public void workCompleted(WorkEvent e) { done(); }
/** * {@inheritDoc} */ public void doWork(Work work) throws WorkException { doWork(work, WorkManager.INDEFINITE, null, null); }
/** * {@inheritDoc} */ public void scheduleWork(Work work) throws WorkException { scheduleWork(work, WorkManager.INDEFINITE, null, null); }
/** * Delta doWork accepted */ protected void deltaDoWorkAccepted() { if (statisticsEnabled) statistics.deltaDoWorkAccepted(); }
/** * Delta work failed */ protected void deltaWorkFailed() { if (statisticsEnabled) statistics.deltaWorkFailed(); }
public WorkClassLoader run() { return new WorkClassLoader(cb); } });
/** * Delta doWork rejected */ protected void deltaDoWorkRejected() { if (statisticsEnabled) statistics.deltaDoWorkRejected(); }
/** * Delta startWork accepted */ protected void deltaStartWorkAccepted() { if (statisticsEnabled) statistics.deltaStartWorkAccepted(); }
/** * {@inheritDoc} */ public void prepareShutdown(int seconds) { prepareShutdown(seconds, null); }
/** * {@inheritDoc} */ @Override public void workRejected(WorkEvent e) { done(); }
/** * {@inheritDoc} */ public void prepareShutdown(GracefulCallback cb) { prepareShutdown(0, cb); }