Package org.apache.sandesha2.storage.beans

Examples of org.apache.sandesha2.storage.beans.RMDBean


        rmsBeans = storageManager.getRMSBeanMgr().find(finderBean);
             
        deleteRMSBeans(rmsBeans, propertyBean, deleteTime);
       
        // Remove any terminated RMDBeans.
        RMDBean finderRMDBean = new RMDBean();
        finderRMDBean.setTerminated(true);
       
        List rmdBeans = storageManager.getRMDBeanMgr().find(finderRMDBean);
 
        Iterator beans = rmdBeans.iterator();
        while (beans.hasNext()) {
          RMDBean rmdBean = (RMDBean)beans.next();
         
          long timeNow = System.currentTimeMillis();
          long lastActivated = rmdBean.getLastActivatedTime();
 
          // delete sequences that have been timedout or deleted for more than
          // the SequenceRemovalTimeoutInterval
          if ((lastActivated + deleteTime) < timeNow) {
            if (log.isDebugEnabled())
              log.debug("Deleting RMDBean " + deleteTime + " : " + rmdBean);
            storageManager.getRMDBeanMgr().delete(rmdBean.getSequenceID());
          }               
        }
      }

      // Terminate RMD Sequences that have been inactive.     
      if (propertyBean.getInactivityTimeoutInterval() > 0) {
        RMDBean finderRMDBean = new RMDBean();
        finderRMDBean.setTerminated(false);
       
        List rmdBeans = storageManager.getRMDBeanMgr().find(finderRMDBean);
     
        Iterator beans = rmdBeans.iterator();
        while (beans.hasNext()) {
          RMDBean rmdBean = (RMDBean)beans.next();
         
          long timeNow = System.currentTimeMillis();
          long lastActivated = rmdBean.getLastActivatedTime();
         
          if ((lastActivated + propertyBean.getInactivityTimeoutInterval()) < timeNow) {
            // Terminate
            rmdBean.setTerminated(true);
            rmdBean.setLastActivatedTime(timeNow);
            if (log.isDebugEnabled())
              log.debug(System.currentTimeMillis() + "Marking RMDBean as terminated " + rmdBean);
            storageManager.getRMDBeanMgr().update(rmdBean);
          }               
        }
View Full Code Here


            log.warn(message);
          }
          // If the message is a reply, then the request may need to be acked. Rather
          // than just return a HTTP 202, we should try to send an ack.
          boolean sendAck = false;
          RMDBean inbound = null;
          String inboundSeq = bean.getInboundSequenceId();
          if(inboundSeq != null)
            inbound = SandeshaUtil.getRMDBeanFromSequenceId(manager, inboundSeq);
         
          if(inbound != null) {
            String acksTo = inbound.getAcksToEPR();
            EndpointReference acksToEPR = new EndpointReference(acksTo);
            if(acksTo == null || acksToEPR.hasAnonymousAddress())
              sendAck = true;
          }
         
          if(sendAck) {
            RMMsgContext rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
            RMMsgContext ackRMMsgCtx = AcknowledgementManager.generateAckMessage(
                rmMsgCtx, inbound, inbound.getSequenceID(), storageManager, true);
            AcknowledgementManager.sendAckNow(ackRMMsgCtx);
            TransportUtils.setResponseWritten(msgCtx, true);
          } else {
            TransportUtils.setResponseWritten(msgCtx, false);
          }
View Full Code Here

  public boolean insert(RMDBean bean) throws SandeshaStorageException {
   
    //checking weather there are any conflicting entries in the current table.
    List findBeanList = new ArrayList ();
   
    RMDBean findBean = new RMDBean ();
   
    if (bean.getSequenceID()!=null) {
      findBean.setSequenceID(bean.getSequenceID());
      findBeanList.add(findBean);
    }
   
    checkKeys (findBeanList);
View Full Code Here

    try {
      transaction = storageManager.getTransaction();
   
      // Check that both the Sequence header and message body have been secured properly
      RMDBeanMgr mgr = storageManager.getRMDBeanMgr();
      RMDBean bean = mgr.retrieve(sequenceId);
     
      if(bean != null && bean.getSecurityTokenData() != null) {
        SecurityManager secManager = SandeshaUtil.getSecurityManager(rmMsgCtx.getConfigurationContext());
       
        QName seqName = new QName(rmMsgCtx.getRMNamespaceValue(), Sandesha2Constants.WSRM_COMMON.SEQUENCE);
       
        SOAPEnvelope envelope = rmMsgCtx.getSOAPEnvelope();
        OMElement body = envelope.getBody();
        OMElement seqHeader = envelope.getHeader().getFirstChildWithName(seqName);
       
        SecurityToken token = secManager.recoverSecurityToken(bean.getSecurityTokenData());
       
        secManager.checkProofOfPossession(token, seqHeader, rmMsgCtx.getMessageContext());
        secManager.checkProofOfPossession(token, body, rmMsgCtx.getMessageContext());
      }
     
      MessageContext messageContext = rmMsgCtx.getMessageContext();
   
      if (bean != null) {
       
        if (msgNo == 0) {
          String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.invalidMsgNumber, Long
              .toString(msgNo));
          log.debug(message);
          throw new SandeshaException(message);
        }
   
        // Get the server completed message ranges list
        RangeString serverCompletedMessageRanges = bean.getServerCompletedMessages();
   
        // See if the message is in the list of completed ranges
        boolean msgNoPresentInList =
          serverCompletedMessageRanges.isMessageNumberInRanges(msgNo);
         
        if (!msgNoPresentInList) {
          serverCompletedMessageRanges.addRange(new Range(msgNo));
         
          storageManager.getRMDBeanMgr().update(bean);
        }
        else {
          
          if (log.isDebugEnabled())
              log.debug("Detected duplicate message " + msgNo);
           
          boolean isDuplicate = true;
          //still allow this msg if we have no corresponding invoker bean for it and we are inOrder
          boolean isInOrder =
            SandeshaUtil.getDefaultPropertyBean(rmMsgCtx.getConfigurationContext().getAxisConfiguration()).isInOrder();
          if(isInOrder)
          {
            InvokerBean finderBean = new InvokerBean();
            finderBean.setMsgNo(msgNo);
            finderBean.setSequenceID(sequenceId);
            List invokerBeanList = storageManager.getInvokerBeanMgr().find(finderBean);
            if((invokerBeanList==null || invokerBeanList.size()==0)
                && bean.getNextMsgNoToProcess()<=msgNo){
              isDuplicate = false;
              if (log.isDebugEnabled())
                log.debug("Allowing completed message on sequence " + sequenceId + ", msgNo " + msgNo);
            }
          }
View Full Code Here

          .getProperty(Sandesha2Constants.MessageContextProperties.SEQUENCE_ID);
      service = null;
      if (sequenceID != null) {

        //If this is the RMD of the sequence        
        RMDBean rmdBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, sequenceID);
        if (rmdBean != null) {
                                        String serviceName = null;
                                        if (rmdBean != null ) {
                                                serviceName = rmdBean.getServiceName();
                                        }

          if (serviceName != null) {
            service = configurationContext.getAxisConfiguration()
                .getService(serviceName);
View Full Code Here

    try{
      //get all invoker beans for the sequence
      InvokerBeanMgr storageMapMgr = storageManager
          .getInvokerBeanMgr();
      RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
      RMDBean rMDBean = rmdBeanMgr.retrieve(sequenceID);
     
      if (rMDBean != null) {
       
        //The outOfOrder window is the set of known sequence messages (including those
        //that are missing) at the time the button is pressed.
        long firstMessageInOutOfOrderWindow = rMDBean.getNextMsgNoToProcess();
     
        InvokerBean selector = new InvokerBean();
        selector.setSequenceID(sequenceID);
        Iterator stMapIt = storageMapMgr.find(selector).iterator();
       
        long highestMsgNumberInvoked = 0;
        Transaction transaction = null;
       
        //invoke each bean in turn.
        //NOTE: here we are breaking ordering
        while(stMapIt.hasNext()){
          //invoke the app
          try{
            transaction = storageManager.getTransaction();
            InvokerBean invoker = (InvokerBean)stMapIt.next();
           
            // start a new worker thread and let it do the invocation.
            String workId = sequenceID + "::" + invoker.getMsgNo(); //creating a workId to uniquely identify the
             //piece of work that will be assigned to the Worker.
           
            String messageContextKey = invoker.getMessageContextRefKey();
            InvokerWorker worker = new InvokerWorker(context,
                messageContextKey,
                true); //want to ignore the enxt msg number
           
            worker.setLock(getWorkerLock());
            worker.setWorkId(workId);
           
            // Wrap the invoker worker with the correct context, if needed.
            Runnable work = worker;
            ContextManager contextMgr = SandeshaUtil.getContextManager(context);
            if(contextMgr != null) {
              work = contextMgr.wrapWithContext(work, invoker.getContext());
            }
           
            threadPool.execute(work);
         
            //adding the workId to the lock after assigning it to a thread makes sure
            //that all the workIds in the Lock are handled by threads.
            getWorkerLock().addWork(workId);

            long msgNumber = invoker.getMsgNo();
            //if necessary, update the "next message number" bean under this transaction
            if(msgNumber>highestMsgNumberInvoked){
              highestMsgNumberInvoked = invoker.getMsgNo();
              rMDBean.setNextMsgNoToProcess(highestMsgNumberInvoked+1);
             
              if(allowLaterDeliveryOfMissingMessages){
                //we also need to update the sequence OUT_OF_ORDER_RANGES property
                //so as to include our latest view of this outOfOrder range.
                //We do that here (rather than once at the end) so that we reamin
                //transactionally consistent
                Range r = new Range(firstMessageInOutOfOrderWindow,highestMsgNumberInvoked);
                   
                RangeString rangeString = null;
                if(rMDBean.getOutOfOrderRanges()==null){
                  //insert a new blank one one
                  rangeString = new RangeString();
                }
                else{
                  rangeString = rMDBean.getOutOfOrderRanges();
                }
                //update the range String with the new value
                rangeString.addRange(r);
                rMDBean.setOutOfOrderRanges(rangeString);
              }
             
              rmdBeanMgr.update(rMDBean);
            }
           
View Full Code Here

  private void addOutOfOrderInvokerBeansToList(String sequenceID,
      StorageManager storageManager, List list)throws SandeshaException{
    if (log.isDebugEnabled())
      log.debug("Enter: InOrderInvoker::addOutOfOrderInvokerBeansToList " + sequenceID + ", " + list);
   
    RMDBean rmdBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, sequenceID);
   
    if(rmdBean != null && rmdBean.getOutOfOrderRanges() != null){
      RangeString rangeString = rmdBean.getOutOfOrderRanges();
      //we now have the set of ranges that can be delivered out of order.
      //Look for any invokable message that lies in one of those ranges
      InvokerBean selector = new InvokerBean();
      selector.setSequenceID(sequenceID);
      Iterator invokerBeansIterator =
View Full Code Here

      SequenceEntry entry = (SequenceEntry) allSequencesList.get(nextIndex++);
      String sequenceId = entry.getSequenceId();
      log.debug("Chose sequence " + sequenceId);

      RMDBean nextMsgBean = nextMsgMgr.retrieve(sequenceId);
      if (nextMsgBean == null) {
        log.debug("Next message not set correctly. Removing invalid entry.");

        stopThreadForSequence(sequenceId, entry.isRmSource());
        allSequencesList = getSequences();
        if (allSequencesList.size() == 0)
          sleep = true;

        if (log.isDebugEnabled()) log.debug("Exit: Invoker::internalRun, sleep " + sleep);
       
        if(transaction != null && transaction.isActive()) transaction.commit();
        transaction = null;

        return sleep;
      }

      long nextMsgno = nextMsgBean.getNextMsgNoToProcess();
      if (nextMsgno <= 0) {
        // Make sure we sleep on the next loop, so that we don't spin in a tight loop
        sleep = true;
        if (log.isDebugEnabled())
          log.debug("Invalid Next Message Number " + nextMsgno);
View Full Code Here

     
      // Update the bean in the map
      storageManager.getRMSBeanMgr().update(rmsBean);
    }
    else {
      RMDBean rmdBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, sequenceID);
      if (rmdBean != null) {
        rmMsgCtx.pause();
       
        // Cleanup sending side.
        if (log.isDebugEnabled())
          log.debug("Terminating sending sequence " + rmdBean);
        TerminateManager.cleanReceivingSideOnTerminateMessage(configCtx, rmdBean.getSequenceID(), storageManager);
       
        // Update the last activated time.
        rmdBean.setLastActivatedTime(System.currentTimeMillis());
       
        // Update the bean in the map
        storageManager.getRMDBeanMgr().update(rmdBean);
     
      }
View Full Code Here

      log.debug("Enter: SequenceManager::setupNewSequence");
   
    String sequenceId = SandeshaUtil.getUUID();

    // Generate the new RMD Bean
    RMDBean rmdBean = new RMDBean();

    EndpointReference to = createSequenceMsg.getTo();
    if (to == null) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
      log.debug(message);
      throw new AxisFault(message);
    }

    EndpointReference replyTo = createSequenceMsg.getReplyTo();

    CreateSequence createSequence = (CreateSequence) createSequenceMsg
        .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
    if (createSequence == null) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.createSeqEntryNotFound);
      log.debug(message);
      throw new AxisFault(message);
    }

    EndpointReference acksTo = createSequence.getAcksTo().getEPR();

    if (acksTo == null) {
      FaultManager.makeCreateSequenceRefusedFault(createSequenceMsg, SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcksToPartInCreateSequence), new Exception());
    } else if (acksTo.getAddress().equals(AddressingConstants.Final.WSA_NONE_URI)){
      FaultManager.makeCreateSequenceRefusedFault(createSequenceMsg, "AcksTo can not be " + AddressingConstants.Final.WSA_NONE_URI, new Exception());
    }

    MessageContext createSeqContext = createSequenceMsg.getMessageContext();
   
    // If this create is the result of a MakeConnection, then we must have a related
    // outbound sequence.
    SequenceEntry entry = (SequenceEntry) createSeqContext.getProperty(Sandesha2Constants.MessageContextProperties.MAKECONNECTION_ENTRY);
    if(log.isDebugEnabled()) log.debug("This message is associated with sequence entry: " + entry);
    if(entry != null && entry.isRmSource()) {
      rmdBean.setOutboundInternalSequence(entry.getSequenceId());
    }

    rmdBean.setServerCompletedMessages(new RangeString());
   
    rmdBean.setReplyToEPR(to.getAddress());
    rmdBean.setAcksToEPR(acksTo.getAddress());

    // If no replyTo value. Send responses as sync.
    if (replyTo != null)
      rmdBean.setToEPR(replyTo.getAddress());

    // Store the security token alongside the sequence
    if(token != null) {
      String tokenData = securityManager.getTokenRecoveryData(token);
      rmdBean.setSecurityTokenData(tokenData);
    }   
   
    rmdBean.setSequenceID(sequenceId);
    rmdBean.setNextMsgNoToProcess(1);
   
    rmdBean.setToAddress(to.getAddress());
   
    // If this sequence has a 'To' address that is anonymous then we must have got the
    // message as a response to a poll. We need to make sure that we keep polling until
    // the sequence is closed.
    if(to.hasAnonymousAddress()) {
      String newKey = SandeshaUtil.getUUID();
      rmdBean.setPollingMode(true);
      rmdBean.setReferenceMessageKey(newKey);
      storageManager.storeMessageContext(newKey, createSeqContext);
    }

    String messageRMNamespace = createSequence.getNamespaceValue();

    String specVersion = null;
    if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(messageRMNamespace)) {
      specVersion = Sandesha2Constants.SPEC_VERSIONS.v1_0;
    } else if (Sandesha2Constants.SPEC_2007_02.NS_URI.equals(messageRMNamespace)) {
      specVersion = Sandesha2Constants.SPEC_VERSIONS.v1_1;
    } else {
      throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotDecideRMVersion));
    }

    rmdBean.setRMVersion(specVersion);
    rmdBean.setLastActivatedTime(System.currentTimeMillis());

    storageManager.getRMDBeanMgr().insert(rmdBean);

    // TODO get the SOAP version from the create seq message.
View Full Code Here

TOP

Related Classes of org.apache.sandesha2.storage.beans.RMDBean

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.