Package com.ericsson.ssa.sip.persistence

Examples of com.ericsson.ssa.sip.persistence.ReplicationUnitOfWork


     *
     * Creates Unit-of-work and locks SAS if present.
     */
    public void beginPipelineInvoke(Session sess) {
        // Initialize new unit-of-work and store it as threadlocal
        new ReplicationUnitOfWork();

        if (sess == null) {
            return;
        }

        // Lock SAS if one is being referenced
        ConvergedHttpSessionFacade chs = (ConvergedHttpSessionFacade)
            createSessionFacade((StandardSession) sess);
        if (chs != null) {
            SipApplicationSessionImpl sas = (SipApplicationSessionImpl)
                chs.getApplicationSession(false);
            if (sas != null) {
                ReplicationUnitOfWork uow =
                    ReplicationUnitOfWork.getThreadLocalUnitOfWork();
                if (uow != null) {
                    uow.lockApplicationSession(sas);
                } else {
                    throw new IllegalStateException(
                        "Missing Unit-of-work when there should be one");
                }
            }
View Full Code Here


     * pipeline invocation.
     *
     * Unlocks Unit-of-work.
     */
    public void endPipelineInvoke() {
        ReplicationUnitOfWork uow =
            ReplicationUnitOfWork.getThreadLocalUnitOfWork();
        if (uow != null) {
            uow.unlock();
        } else {
            throw new IllegalStateException(
                "Missing Unit-of-work when there should be one");
        }
    }
View Full Code Here

    protected void addToUnitOfWork(boolean checkConsistency) {
        if (isConfirmed() && isReplicable()) {
            if (checkConsistency) {
                getDialogLifeCycle().checkUnitOfWork();
            }
            ReplicationUnitOfWork uow
                = ReplicationUnitOfWork.getThreadLocalUnitOfWork();
            if(uow != null) {
                uow.add(this);
            } else {
                throw new IllegalStateException("HADialogFragment>>addToUnitOfWork: unit of work missing");
            }           
        }
    }
View Full Code Here

    public void invalidate(boolean hasTimedOut) {
        super.invalidate(hasTimedOut);

        // remove from unit-of-work due its already gone from SessionManager
        if (isConfirmed() && isReplicable()) {
            ReplicationUnitOfWork uow
                = ReplicationUnitOfWork.getThreadLocalUnitOfWork();
            if(uow != null) {
                uow.remove(this);
            }
        }
    }
View Full Code Here

            // Trigger J2EEInstanceListener
            getInstanceSupport()
                .fireInstanceEvent(InstanceEvent.BEFORE_INIT_EVENT, target);

            ReplicationUnitOfWork uow = ReplicationUnitOfWork.getThreadLocalUnitOfWork();

            if (uow == null) {
                /**
                 * If load-on-startup=true, then it will be OOB access and UOW
                 * will be null. So, we create a new UOW and save it after the
                 * Servlet's init method is called and all the
                 * SipServletListener's are called.
                 */
                uow = new ReplicationUnitOfWork();

                try {
                    initialize(facade, target);
                    uow.saveAndUnlock(); // TODO : check whether Replication Framework is ready.
                } finally {
                    uow.clearThreadLocal();
                }
            } else {
                /**
                 * If load-on-startup=false, then the Servlet initialization
                 * happens during the first traffic to the Servlet.
View Full Code Here

                // Instantiate a unit-of-work to collect any entities/artifacts
                // modified during TimerListener invocation.
                // If unit-of-work already exists, leverage it instead of
                // creating a new one
                if (ReplicationUnitOfWork.getThreadLocalUnitOfWork() == null) {
                    ReplicationUnitOfWork unitOfWork =
                        new ReplicationUnitOfWork();
                    unitOfWork.lockApplicationSession(sas);
                    try {
                        // fire timer
                        return fireTimer();
                    } finally {
                        // Save modified entities (if any), and unlock the
                        // uow
                        unitOfWork.saveAndUnlock();
                    }
                } else {
                    // reuse the current uow
                    return fireTimer();
                }
View Full Code Here

        return isInvokeServlet;
    }

    public void dispatch(SipServletRequestImpl req, UA uas) {
      // Workaround for issue 1457
      ReplicationUnitOfWork oldUOW = ReplicationUnitOfWork.getThreadLocalUnitOfWork();
      boolean servletMustBeInvoked = doRequestUAS(req, uas);
      // if a response was sent on the original invite request in this same thread
      // then the UOW got lost in the replication manager when handling that response.
      // Therefore we have to restore the UOW here if we do not want to get into
      // problems later in this thread.
      ReplicationUnitOfWork newUOW = ReplicationUnitOfWork.getThreadLocalUnitOfWork();
      if ((oldUOW != null && newUOW == null)) {
        if (m_INVITE != null && m_INVITE.getDialog() != null) {
          oldUOW.lockDialog(m_INVITE.getDialog());
        }
        oldUOW.setThreadLocal();
View Full Code Here

            break;

        case TimerLong:

            SipServletRequest byeRequest = null;
            ReplicationUnitOfWork uow = new ReplicationUnitOfWork();
            try {
                synchronized (this) {
                    if (m_State == CONFIRMED_UAS) {
                        m_State = TIMEOUT_UAS;
                        if (m_TimerShort != null) {
                            m_TimerShort.cancel();
                            m_TimerShort = null;
                        }
                        if (m_Log.isLoggable(Level.FINE)) {
                            m_Log.log(Level.FINE,
                                    "Timer fired after 64*T1s - end dialog");
                        }
                        // Lock the DS for the entire duration.
                        SipSession session = m_RetransmitResponse.getSession();
                        DialogFragment dialog = ((SipSessionImplBase) session).getDF();
                        if (dialog != null) { // to be on the safe side
                            uow.lockDialog(dialog);
                        }
                        // issue 1085 :: create byeRequest before invoking the listeners.
                        // issue 1350 :: check that session is still valid. If app is undeployed it will not be
                        if(session.isValid()){
                          byeRequest = session.createRequest("BYE");
                        }
                        else {
                          if (m_Log.isLoggable(Level.FINE)) {
                                m_Log.log(Level.FINE,
                                        "Skipping to send BYE since SipSession is no longer valid");
                            }
                        }
                        // invoke the listeners first, then they will still be done if anything
                        // goes wrong later with the actual creating or sending of the bye
                        // XXX ? should we not check if the SAS is still valid at this point?
                        SipApplicationSessionImpl sas = m_RetransmitResponse.getSessionImpl().getApplicationSessionImpl();
                        if(sas!=null){
                          SipApplicationListeners sipAppListeners = sas.getSipApplicationListeners();
                          if (sipAppListeners != null) {
                              ArrayList<SipErrorListener> sipErrorList =
                                      sipAppListeners.getSipErrorListeners();
                              for (SipErrorListener listener : sipErrorList) {
                                  try {
                                      listener.noAckReceived(new SipErrorEvent(
                                              m_RetransmitResponse.getRequest(),
                                              m_RetransmitResponse));
                                  } catch (Throwable t) {
                                      m_Log.log(Level.WARNING, t.getMessage(), t);
                                  }
                              }
                          }
                      }
                    }
                }
                // send after synchronization...
                if (byeRequest != null) {
                    if (disableByeOnNoAckReceived) {
                        if (m_Log.isLoggable(Level.FINE)) {
                            m_Log.log(Level.FINE, "BYE is not automatically sent by the container for no ACK recieved.");
                        }
                    } else {
                        byeRequest.send();
                    }
                }
            } catch (IncompleteDialogException e) { // uow.lockdialog can cause this.
                if (m_Log.isLoggable(Level.FINE)) {
                    m_Log.log(Level.FINE, "The dialog was incomplete while handling TimerLong. Skipping send", e);
                }
            } catch (RemoteLockRuntimeException e) { // uow.lockdialog or getSASImpl() can cause this.
                if (m_Log.isLoggable(Level.FINE)) {
                    m_Log.log(Level.FINE, "The dialog was remotely locked  while handling TimerLong. Skipping send", e);
                }
            } catch (IOException e) { /// bye.send can cause this.
                m_Log.log(Level.WARNING, "Problem sending BYE", e);
            } finally {
                uow.saveAndUnlock();
            }
            break;

        case TimerShortProvRsp:

View Full Code Here

    /**
     * checks/adds this entity to unitOfWork
     */
    protected void addToUnitOfWork() {
        if (shouldBePersisted()) {
            ReplicationUnitOfWork uow =
                ReplicationUnitOfWork.getThreadLocalUnitOfWork();
            if(uow != null) {
                uow.add(this);
            } else {
                throw new IllegalStateException("HASipSession>>addToUnitOfWork: unit of work missing");
            }
        }
    }
View Full Code Here

    public void invalidate(boolean hasTimedOut) {
        super.invalidate(hasTimedOut);

        // remove from unit-of-work due its already gone from SessionManager
        if (shouldBePersisted()) {
            ReplicationUnitOfWork uow =
                ReplicationUnitOfWork.getThreadLocalUnitOfWork();
            if (uow != null) {
                uow.remove(this);
            }
        }        
    }
View Full Code Here

TOP

Related Classes of com.ericsson.ssa.sip.persistence.ReplicationUnitOfWork

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.