javax.resource.spi.work.WorkException Java Examples
The following examples show how to use
javax.resource.spi.work.WorkException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DistributedWorkManagerImpl.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected void deltaWorkSuccessful() { if (trace) 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); } } }
Example #2
Source File: AbstractRemoteTransport.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void deltaStartWorkAccepted(Address address) { if (trace) log.tracef("DELTA_STARTWORK_ACCEPTED(%s)", address); if (address.getTransportId() != null && !getId().equals(address.getTransportId())) { try { T addr = nodes.get(address); sendMessage(addr, Request.DELTA_STARTWORK_ACCEPTED, address); } catch (WorkException e1) { if (log.isDebugEnabled()) { log.debug("Error", e1); } } } }
Example #3
Source File: AbstractRemoteTransport.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void deltaDoWorkAccepted(Address address) { if (trace) log.tracef("DELTA_DOWORK_ACCEPTED(%s)", address); if (address.getTransportId() != null && !getId().equals(address.getTransportId())) { try { T addr = nodes.get(address); sendMessage(addr, Request.DELTA_DOWORK_ACCEPTED, address); } catch (WorkException e1) { if (log.isDebugEnabled()) { log.debug("Error", e1); } } } }
Example #4
Source File: AbstractRemoteTransport.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void deltaWorkFailed(Address address) { if (trace) log.tracef("DELTA_WORK_FAILED(%s)", address); if (address.getTransportId() != null && !getId().equals(address.getTransportId())) { try { T addr = nodes.get(address); sendMessage(addr, Request.DELTA_WORK_FAILED, address); } catch (WorkException e1) { if (log.isDebugEnabled()) { log.debug("Error", e1); } } } }
Example #5
Source File: WorkInterfaceTestCase.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * Test for paragraph 5 * Both the run and release methods in the Work implementation may contain synchronization * synchronization but they must not be declared as synchronized methods. * @throws Throwable throwable exception */ @Test(expected = WorkException.class) public void testCannotDeclaredSynchronizedRunMethodWork() throws Throwable { SynchronizedRunWork sw = new SynchronizedRunWork(); WorkConnection wc = wcf.getConnection(); try { wc.doWork(sw); fail("Synchronized method not catched"); } finally { wc.close(); } }
Example #6
Source File: DistributedWorkManagerImpl.java From lams with GNU General Public License v2.0 | 6 votes |
/** * {@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); } } }
Example #7
Source File: DistributedWorkManagerImpl.java From lams with GNU General Public License v2.0 | 6 votes |
/** * {@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); } } }
Example #8
Source File: DistributedWorkManagerImpl.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected void deltaDoWorkAccepted() { if (trace) 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); } } }
Example #9
Source File: DistributedWorkManagerImpl.java From lams with GNU General Public License v2.0 | 6 votes |
/** * {@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); } } }
Example #10
Source File: WorkManagerImpl.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Check and verify work before submitting. * @param work the work instance * @param executionContext any execution context that is passed by apadater * @throws WorkException if any exception occurs */ private void checkAndVerifyWork(Work work, ExecutionContext executionContext) throws WorkException { if (specCompliant) { verifyWork(work); } if (work instanceof WorkContextProvider) { //Implements WorkContextProvider and not-null ExecutionContext if (executionContext != null) { throw new WorkRejectedException(bundle.workExecutionContextMustNullImplementsWorkContextProvider()); } } }
Example #11
Source File: AbstractRemoteTransport.java From lams with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public long ping(Address address) { log.tracef("PING(%s)", address); if (address.getTransportId() == null || getId().equals(address.getTransportId())) return localPing(); long start = System.currentTimeMillis(); try { T addr = nodes.get(address); sendMessage(addr, Request.PING); } catch (WorkException e1) { if (log.isDebugEnabled()) { log.debug("Error", e1); } return Long.MAX_VALUE; } return System.currentTimeMillis() - start; }
Example #12
Source File: AbstractRemoteTransport.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public long getLongRunningFree(Address address) { log.tracef("GET_LONGRUNNING_FREE(%s)", address); if (address.getTransportId() == null || getId().equals(address.getTransportId())) return localGetLongRunningFree(address); try { T addr = nodes.get(address); return (long)sendMessage(addr, Request.GET_LONGRUNNING_FREE, address); } catch (WorkException e1) { if (log.isDebugEnabled()) { log.debug("Error", e1); } return 0L; } }
Example #13
Source File: AbstractRemoteTransport.java From lams with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void deltaDoWorkAccepted(Address address) { log.tracef("DELTA_DOWORK_ACCEPTED(%s)", address); if (address.getTransportId() != null && !getId().equals(address.getTransportId())) { try { T addr = nodes.get(address); sendMessage(addr, Request.DELTA_DOWORK_ACCEPTED, address); } catch (WorkException e1) { if (log.isDebugEnabled()) { log.debug("Error", e1); } } } }
Example #14
Source File: AbstractRemoteTransport.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void deltaScheduleWorkRejected(Address address) { if (trace) log.tracef("DELTA_SCHEDULEWORK_REJECTED(%s)", address); if (address.getTransportId() != null && !getId().equals(address.getTransportId())) { try { T addr = nodes.get(address); sendMessage(addr, Request.DELTA_SCHEDULEWORK_REJECTED, address); } catch (WorkException e1) { if (log.isDebugEnabled()) { log.debug("Error", e1); } } } }
Example #15
Source File: DistributedWorkManagerImpl.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected void deltaStartWorkAccepted() { if (trace) 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); } } }
Example #16
Source File: AbstractRemoteTransport.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
@Override public long getShortRunningFree(Address address) { if (trace) log.tracef("GET_SHORT_RUNNING_FREE(%s)", address); if (address.getTransportId() == null || getId().equals(address.getTransportId())) return localGetShortRunningFree(address); try { T addr = nodes.get(address); return (long)sendMessage(addr, Request.GET_SHORTRUNNING_FREE, address); } catch (WorkException e1) { if (log.isDebugEnabled()) { log.debug("Error", e1); } return 0L; } }
Example #17
Source File: AbstractRemoteTransport.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
@Override public long getLongRunningFree(Address address) { if (trace) log.tracef("GET_LONGRUNNING_FREE(%s)", address); if (address.getTransportId() == null || getId().equals(address.getTransportId())) return localGetLongRunningFree(address); try { T addr = nodes.get(address); return (long)sendMessage(addr, Request.GET_LONGRUNNING_FREE, address); } catch (WorkException e1) { if (log.isDebugEnabled()) { log.debug("Error", e1); } return 0L; } }
Example #18
Source File: WorkManagerImpl.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * Verify the given work instance. * @param work The work * @throws WorkException Thrown if a spec compliant issue is found */ private void verifyWork(Work work) throws WorkException { Class<? extends Work> workClass = work.getClass(); String className = workClass.getName(); if (!validatedWork.contains(className)) { if (isWorkMethodSynchronized(workClass, RUN_METHOD_NAME)) throw new WorkException(bundle.runMethodIsSynchronized(className)); if (isWorkMethodSynchronized(workClass, RELEASE_METHOD_NAME)) throw new WorkException(bundle.releaseMethodIsSynchronized(className)); validatedWork.add(className); } }
Example #19
Source File: WorkManagerImpl.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Checks work completed status. * @param wrapper work wrapper instance * @throws {@link WorkException} if work is completed with an exception */ private void checkWorkCompletionException(WorkWrapper wrapper) throws WorkException { if (wrapper.getWorkException() != null) { log.tracef("Exception %s for %s", wrapper.getWorkException(), this); deltaWorkFailed(); throw wrapper.getWorkException(); } deltaWorkSuccessful(); }
Example #20
Source File: SimpleWorkManager.java From tomee with Apache License 2.0 | 5 votes |
public void workRejected(final WorkEvent event) { // Don't log doWork or startWork since exception is propagated to caller if (workType == WorkType.DO || workType == WorkType.START) { return; } final WorkException exception = event.getException(); if (exception != null) { if (WorkException.START_TIMED_OUT.equals(exception.getErrorCode())) { logger.error(exception.getMessage()); } } }
Example #21
Source File: AbstractRemoteTransport.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * 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 { if (trace) log.tracef("LOCAL_DO_WORK(%s, %s)", address, work); DistributedWorkManager dwm = workManagerCoordinator.resolveDistributedWorkManager(address); dwm.localDoWork(work); }
Example #22
Source File: DistributedWorkManagerImpl.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * {@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); } }
Example #23
Source File: AbstractRemoteTransport.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public long ping(Address address) { if (trace) log.tracef("PING(%s)", address); if (address.getTransportId() == null || getId().equals(address.getTransportId())) return localPing(); long start = System.currentTimeMillis(); try { T addr = nodes.get(address); sendMessage(addr, Request.PING); } catch (WorkException e1) { if (log.isDebugEnabled()) { log.debug("Error", e1); } return Long.MAX_VALUE; } return System.currentTimeMillis() - start; }
Example #24
Source File: JcaWorkManagerExecutorService.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected boolean scheduleLongRunning(Runnable runnable) { try { workManager.scheduleWork(new JcaWorkRunnableAdapter(runnable)); return true; } catch (WorkException e) { logger.log(Level.WARNING, "Could not schedule : "+e.getMessage(), e); return false; } }
Example #25
Source File: WorkManagerImpl.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Check and verify work before submitting. * @param work the work instance * @param executionContext any execution context that is passed by apadater * @throws WorkException if any exception occurs */ private void checkAndVerifyWork(Work work, ExecutionContext executionContext) throws WorkException { if (specCompliant) { verifyWork(work); } if (work instanceof WorkContextProvider && executionContext != null) { //Implements WorkContextProvider and not-null ExecutionContext throw new WorkRejectedException(bundle.workExecutionContextMustNullImplementsWorkContextProvider()); } }
Example #26
Source File: ActiveMQRATestBase.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public long startWork(Work work, long l, ExecutionContext executionContext, WorkListener workListener) throws WorkException { return 0; }
Example #27
Source File: AbstractRemoteTransport.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
@Override public void updateShortRunningFree(Address address, long freeCount) { if (trace) log.tracef("UPDATE_SHORT_RUNNING_FREE(%s, %d)", address, freeCount); localUpdateShortRunningFree(address, freeCount); if (address.getTransportId() != null && getId().equals(address.getTransportId())) { for (Entry<Address, T> entry : nodes.entrySet()) { Address a = entry.getKey(); if (!getId().equals(a.getTransportId())) { try { sendMessage(entry.getValue(), Request.UPDATE_SHORTRUNNING_FREE, address, freeCount); } catch (WorkException e1) { if (log.isDebugEnabled()) { log.debug("Error", e1); } } } } } }
Example #28
Source File: DistributedWorkManagerImpl.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void scheduleWork(Work work) throws WorkException { if (policy == null || selector == null || transport == null || work == null || !(work instanceof DistributableWork) || !scheduleWorkDistributionEnabled) { localScheduleWork(work); } else { doFirstChecks(work, WorkManager.INDEFINITE, null); checkTransport(); DistributableWork dw = (DistributableWork)work; boolean executed = false; if (policy.shouldDistribute(this, dw)) { Address dwmAddress = selector.selectDistributedWorkManager(getLocalAddress(), dw); if (dwmAddress != null && !getLocalAddress().equals(dwmAddress)) { transport.scheduleWork(dwmAddress, dw); executed = true; } } if (!executed) { localScheduleWork(work); } } }
Example #29
Source File: DistributedWorkManagerImpl.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * {@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); } }
Example #30
Source File: AbstractRemoteTransport.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * 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 { if (trace) log.tracef("LOCAL_START_WORK(%s, %s)", address, work); DistributedWorkManager dwm = workManagerCoordinator.resolveDistributedWorkManager(address); return dwm.localStartWork(work); }