/** * * @return */ public ActivityContext getActivityContext() { return sleeContainer.getActivityContextFactory().getActivityContext(getActivityContextHandle()); }
/** * */ public void startActivity() { sleeContainer.getActivityContextFactory().createActivityContext(getActivityContextHandle(),ActivityFlags.NO_FLAGS); }
.getAllActivityContextsHandles(ActivityType.PTABLE)) { try { if (logger.isDebugEnabled()) { .getActivityContext(handle); if (ac != null) { ac.endActivity(); for (ActivityContextHandle handle : sleeContainer .getActivityContextFactory() .getAllActivityContextsHandles(ActivityType.PTABLE)) { logger.info("Waiting for profile table activity "+handle+" to end..."); loop = true;
/** * Checks if the entity has activities besides the one passed as parameter (if not null). * @param exceptHandle * @return */ private boolean hasActivities() { try { for (ActivityContextHandle handle : sleeContainer .getActivityContextFactory() .getAllActivityContextsHandles()) { if (handle.getActivityType() == ActivityType.RA) { ResourceAdaptorActivityContextHandle raHandle = (ResourceAdaptorActivityContextHandle) handle; if (raHandle.getResourceAdaptorEntity().equals(this)) { logger.debug("**** AllActivityContextsHandles: "+sleeContainer .getActivityContextFactory() .getAllActivityContextsHandles()); if (logger.isDebugEnabled()) { logger.debug("RA entity "+name+" has (at least) activity "+handle.getActivityHandle()); } return true; } } } } catch (Throwable e) { logger.error(e.getMessage(), e); } return false; }
private boolean activityExists(ActivityHandle handle,boolean checkHandleRef) throws IllegalStateException, NullPointerException, SLEEException { if (handle == null) throw new NullPointerException("handle is null"); // get ref handle if we are in cluster and the handle is to be not // replicated final ActivityHandle ah = checkHandleRef && raEntity.getHandleReferenceFactory() != null ? raEntity .getHandleReferenceFactory().getReferenceTransacted(handle) : handle; final ActivityContextHandle ach = new ResourceAdaptorActivityContextHandleImpl( raEntity, ah); return acFactory.activityContextExists(ach); }
.getAllActivityContextsHandles(ActivityType.SERVICE)) { endServiceActivity(((ServiceActivityContextHandle) ach) .getActivityHandle().getServiceID()); try { for (ActivityContextHandle ach : acf .getAllActivityContextsHandles(ActivityType.SERVICE)) { logger.info("Waiting for " + ach.getActivityHandle() + " to stop...");
public void run() { try { activityEndingTasks.remove(serviceID); if (sleeContainer.getSleeState() != null) { final ActivityContext ac = sleeContainer .getActivityContextFactory() .getActivityContext(ach); if (ac != null) { // if (logger.isDebugEnabled()) { logger.info("Forcing the end of " + ach); // } ac.activityEnded(); } } } catch (Exception e) { logger.error(e.getMessage(), e); } } };
public void failOverClusterMember(Address arg0) { // lets search and end all ACs that were local to the node which failed final ActivityContextFactory acFactory = resourceManagement.getSleeContainer() .getActivityContextFactory(); // ouch, this is going to be expensive for (ActivityContextHandle ach : acFactory.getAllActivityContextsHandles(ActivityType.RA)) { final ResourceAdaptorActivityContextHandleImpl raach = (ResourceAdaptorActivityContextHandleImpl) ach; if (raach.getActivityHandle().getClass() == ActivityHandleReference.class) { final ActivityHandleReference reference = (ActivityHandleReference) raach.getActivityHandle(); if (reference.getAddress().equals(arg0)) { final ActivityContext ac = acFactory.getActivityContext(raach); if (ac != null) { ac.endActivity(); } } } } }
public NullActivityImpl createNullActivity( NullActivityHandle nullActivityHandle, boolean mandateTransaction) throws TransactionRequiredLocalException, FactoryException { // check mandated by SLEE TCK test CreateActivityWhileStoppingTest if (sleeContainer.getSleeState() != SleeState.RUNNING) { return null; } if (mandateTransaction) { sleeContainer.getTransactionManager().mandateTransaction(); } // create activity NullActivityImpl nullActivity = new NullActivityImpl(nullActivityHandle); // get an activity context for it try { sleeContainer.getActivityContextFactory().createActivityContext( new NullActivityContextHandle(nullActivityHandle), ActivityFlags.REQUEST_ACTIVITY_UNREFERENCED_CALLBACK); } catch (ActivityAlreadyExistsException e) { throw new FactoryException(e.getMessage(), e); } if (logger.isDebugEnabled()) { logger .debug("NullActivityFactory.createNullActivity() Created null activity " + nullActivity); } return nullActivity; }
public void endActivity() throws TransactionRequiredLocalException, SLEEException { // Check if in valid context. if (logger.isDebugEnabled()) { logger.debug("NullActivity.endActivity()"); } sleeContainer.getTransactionManager().mandateTransaction(); sleeContainer.getActivityContextFactory().getActivityContext( new NullActivityContextHandle(handle)) .endActivity(); }
for (ActivityContextHandle handle : sleeContainer .getActivityContextFactory() .getAllActivityContextsHandles()) { if (handle.getActivityType() == ActivityType.RA) { final ResourceAdaptorActivityContextHandle raHandle = (ResourceAdaptorActivityContextHandle) handle; .getActivityContext(handle); if (ac != null) { for (ActivityContextHandle handle : sleeContainer .getActivityContextFactory() .getAllActivityContextsHandles()) { if (handle.getActivityType() == ActivityType.RA) { final ResourceAdaptorActivityContextHandle raHandle = (ResourceAdaptorActivityContextHandle) handle; .getActivityContext(handle); if (ac != null) { for(SbbEntityID sbbEntityId : ac.getSbbAttachmentSet()) {
private void startActivity(final ServiceComponent serviceComponent) { // create ac for the activity ActivityContextHandle ach = new ServiceActivityContextHandle( new ServiceActivityHandleImpl(serviceComponent.getServiceID())); ActivityContext ac = sleeContainer.getActivityContextFactory() .createActivityContext(ach, ActivityFlags.NO_FLAGS); if (logger.isDebugEnabled()) { logger.debug("Starting " + serviceComponent.getServiceID() + " activity."); } serviceComponent.setActivityEnded(false); // fire slee 1.0 and 1.1 service started events ServiceStartedEventImpl event = new ServiceStartedEventImpl( serviceComponent.getServiceID()); ac.fireEvent(ServiceStartedEventImpl.SLEE_10_EVENT_TYPE_ID, event, null, null, null, null, null); ac.fireEvent(ServiceStartedEventImpl.SLEE_11_EVENT_TYPE_ID, event, null, event.getService(), null, null, null); }
public ActivityContextInterface[] getActivities() throws TransactionRequiredLocalException, IllegalStateException, SLEEException { if (logger.isTraceEnabled()) { logger.trace("getActivities() " + this.sbbObject.getState()); } if (SbbObjectState.READY != this.sbbObject.getState()) { throw new IllegalStateException( "Cannot call SbbContext.getActivities() in " + this.sbbObject.getState()); } ActivityContextFactory acf = sleeContainer.getActivityContextFactory(); List<ActivityContextInterface> result = new ArrayList<ActivityContextInterface>(); ActivityContext ac = null; for (ActivityContextHandle ach : sbbObject.getSbbEntity() .getActivityContexts()) { ac = acf.getActivityContext(ach); if (ac != null) { result.add(ac.getActivityContextInterface()); } } return result.toArray(EMPTY_ACI_ARRAY); }
try { ac = acFactory.createActivityContext( new ResourceAdaptorActivityContextHandleImpl(raEntity, reference), activityFlags); ac = acFactory.createActivityContext( new ResourceAdaptorActivityContextHandleImpl(raEntity, handle), activityFlags);
public ActivityContextInterface getActivityContextInterface() { return factory.getSleeContainer().getActivityContextFactory().getActivityContext(getActivityContextHandle()).getActivityContextInterface(); }
public ActivityContextInterface getActivityContextInterface( NullActivity nullActivity) throws NullPointerException, TransactionRequiredLocalException, UnrecognizedActivityException, FactoryException { if (nullActivity == null ) throw new NullPointerException ("null NullActivity ! huh!!"); if (! (nullActivity instanceof NullActivityImpl)) throw new UnrecognizedActivityException ("unrecognized activity"); NullActivityImpl nullActivityImpl = (NullActivityImpl) nullActivity; ActivityContextHandle ach = new NullActivityContextHandle(nullActivityImpl.getHandle()); ActivityContext ac = sleeContainer.getActivityContextFactory().getActivityContext(ach); if (ac == null) { throw new UnrecognizedActivityException(nullActivity); } return ac.getActivityContextInterface(); }
ActivityContextHandle ach = cacheData.unbindName(); ActivityContext ac = sleeContainer. getActivityContextFactory().getActivityContext(ach); if ( ac != null ) ac.removeNameBinding(aciName);
public void cancelTimer(TimerID timerID, boolean detachAC) { // cancel task in scheduler final TimerFacilityTimerTask task = (TimerFacilityTimerTask) scheduler.cancel(timerID); if (detachAC && task != null) { // detach this timer from the ac ActivityContext ac = sleeContainer.getActivityContextFactory() .getActivityContext(task.getTimerFacilityTimerTaskData().getActivityContextHandle()); if (ac != null) { ac.detachTimer(timerID); } } }
public ActivityContextInterface getActivityContextInterface(TimerID timerID) throws NullPointerException, TransactionRequiredLocalException, FacilityException { if (timerID == null) { throw new NullPointerException("null timerID"); } sleeContainer.getTransactionManager().mandateTransaction(); TimerFacilityTimerTaskData taskData = (TimerFacilityTimerTaskData) scheduler.getTimerTaskData(timerID); if (taskData != null) { try { return sleeContainer.getActivityContextFactory().getActivityContext(taskData.getActivityContextHandle()).getActivityContextInterface(); } catch (Exception e) { throw new FacilityException(e.getMessage(),e); } } else { return null; } }
protected void remove() { // remove from scheduler super.removeFromScheduler(); // detach this timer from the ac final ActivityContext ac = sleeContainer.getActivityContextFactory() .getActivityContext(data.getActivityContextHandle()); if (ac != null) { ac.detachTimer(data.getTimerID()); } }