Examples of RMDBeanMgr


Examples of org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr

    seqPropMgr.insert(acksToBean);

    if (toBean != null)
      seqPropMgr.insert(toBean);

    RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
    rmdBeanMgr.insert(new RMDBean(sequenceId, 1)); // 1 will be the
                              // next

    // message to invoke. This will apply for only in-order invocations.

    SandeshaUtil.startSenderForTheSequence(configurationContext, sequenceId);
View Full Code Here

Examples of org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr

    if(log.isDebugEnabled()) log.debug("Exit: PollingManager::pollRMSSide");
  }

  private void pollRMDSide(SequenceEntry entry, boolean force) throws AxisFault {
    if(log.isDebugEnabled()) log.debug("Enter: PollingManager::pollRMDSide, force: " + force);
    RMDBeanMgr nextMsgMgr = storageManager.getRMDBeanMgr();
    RMDBean findBean = new RMDBean();
    findBean.setPollingMode(true);
    findBean.setTerminated(false);
    findBean.setSequenceID(entry.getSequenceId());
    RMDBean nextMsgBean = nextMsgMgr.findUnique(findBean);
   
    if(nextMsgBean == null) {
      // This sequence must have been terminated, or deleted
      stopThreadForSequence(entry.getSequenceId(), false);
    } else {
View Full Code Here

Examples of org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr

   
    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);
View Full Code Here

Examples of org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr

    blockForPause();
    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);
            }
           
            if(transaction != null && transaction.isActive()) transaction.commit();
            transaction = null;
          }
View Full Code Here

Examples of org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr

   
    boolean sleep = false;
    Transaction transaction = null;

    try {
      RMDBeanMgr nextMsgMgr = storageManager.getRMDBeanMgr();

      InvokerBeanMgr storageMapMgr = storageManager
          .getInvokerBeanMgr();

      transaction = storageManager.getTransaction();
     
      // Pick a sequence using a round-robin approach
      ArrayList allSequencesList = getSequences();
      int size = allSequencesList.size();
      log.debug("Choosing one from " + size + " sequences");
      if(nextIndex >= size) {
        nextIndex = 0;

        // We just looped over the set of sequences. If we didn't process any
        // messages on this loop then we sleep before the next one
        if(size == 0 || !processedMessage) {
          sleep = true;
        }
        processedMessage = false;
       
        if (log.isDebugEnabled()) log.debug("Exit: Invoker::internalRun, looped over all sequences, sleep " + sleep);
       
        if(transaction != null && transaction.isActive()) transaction.commit();
        transaction = null;
       
        return sleep;
      }

      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();
View Full Code Here

Examples of org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr

    rmsBean.setLastActivatedTime(System.currentTimeMillis());

    //adding a MakeConnection for the response sequence if needed.
    if (rmsBean.getOfferedSequence() != null) {

      RMDBeanMgr rMDBeanMgr = storageManager.getRMDBeanMgr();
      RMDBean rMDBean = rMDBeanMgr.retrieve(outSequenceId);
     
      if (rMDBean!=null && rMDBean.isPollingMode()) {
        PollingManager manager = storageManager.getPollingManager();
        if(manager != null) manager.schedulePollingRequest(rMDBean.getSequenceID(), false);
      }
View Full Code Here

Examples of org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr

     
      if (toEPR!=null)
        rMDBean.setToAddress(toEPR.getAddress());
     
      rMDBean.setServerCompletedMessages(new RangeString());
      RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();

      // Store the security token for the offered sequence
      rMDBean.setSecurityTokenData(rmsBean.getSecurityTokenData());
     
      rMDBean.setLastActivatedTime(System.currentTimeMillis());
     
      rmdBeanMgr.insert(rMDBean);
      SandeshaUtil.startWorkersForSequence(configCtx, rMDBean);
    }
   
    rmsBean.setLastActivatedTime(System.currentTimeMillis());
    rmsBeanMgr.update(rmsBean);
View Full Code Here

Examples of org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr

    String sequenceId = sequence.getIdentifier().getIdentifier();
    long msgNo = sequence.getMessageNumber().getMessageNumber();
    boolean lastMessage = sequence.getLastMessage() != null;
   
    // 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(msgCtx.getConfigurationContext());
     
      QName seqName = new QName(rmMsgCtx.getRMNamespaceValue(), Sandesha2Constants.WSRM_COMMON.SEQUENCE);
     
      SOAPEnvelope envelope = msgCtx.getEnvelope();
      OMElement body = envelope.getBody();
      OMElement seqHeader = envelope.getHeader().getFirstChildWithName(seqName);
     
      SecurityToken token = secManager.recoverSecurityToken(bean.getSecurityTokenData());
     
      secManager.checkProofOfPossession(token, seqHeader, msgCtx);
      secManager.checkProofOfPossession(token, body, msgCtx);
    }
   
    // Store the inbound sequence id, number and lastMessage onto the operation context
    OperationContext opCtx = msgCtx.getOperationContext();
    if(opCtx != null) {
      opCtx.setProperty(Sandesha2Constants.MessageContextProperties.INBOUND_SEQUENCE_ID, sequenceId);
      opCtx.setProperty(Sandesha2Constants.MessageContextProperties.INBOUND_MESSAGE_NUMBER, new Long(msgNo));
      if(lastMessage) opCtx.setProperty(Sandesha2Constants.MessageContextProperties.INBOUND_LAST_MESSAGE, Boolean.TRUE);
    }
   
    // setting acked msg no range
    ConfigurationContext configCtx = rmMsgCtx.getMessageContext().getConfigurationContext();
    if (configCtx == null) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.configContextNotSet);
      log.debug(message);
      throw new SandeshaException(message);
    }

    if (FaultManager.checkForUnknownSequence(rmMsgCtx, sequenceId, storageManager, false)) {
      if (log.isDebugEnabled())
        log.debug("Exit: SequenceProcessor::processReliableMessage, Unknown sequence");
      return InvocationResponse.ABORT;
    }

    // throwing a fault if the sequence is terminated
    if (FaultManager.checkForSequenceTerminated(rmMsgCtx, sequenceId, bean, false)) {
      if (log.isDebugEnabled())
        log.debug("Exit: SequenceProcessor::processReliableMessage, Sequence terminated");
      return InvocationResponse.ABORT;
    }
   
    // throwing a fault if the sequence is closed.
    if (FaultManager.checkForSequenceClosed(rmMsgCtx, sequenceId, bean, false)) {
      if (log.isDebugEnabled())
        log.debug("Exit: SequenceProcessor::processReliableMessage, Sequence closed");
      return InvocationResponse.ABORT;
    }
    FaultManager.checkForLastMsgNumberExceeded(rmMsgCtx, storageManager);
   
    if (FaultManager.checkForMessageRolledOver(rmMsgCtx, sequenceId, msgNo)) {
     
      if (log.isDebugEnabled())
        log.debug("Exit: SequenceProcessor::processReliableMessage, Message rolled over " + msgNo);
     
      return InvocationResponse.ABORT;
    }

    // Pause the messages bean if not the right message to invoke.
   
    // updating the last activated time of the sequence.
    bean.setLastActivatedTime(System.currentTimeMillis());
   
    if (lastMessage) {
      //setting this as the LastMessage number
      bean.setLastInMessageId(msgCtx.getMessageID());
    }
   
    EndpointReference replyTo = rmMsgCtx.getReplyTo();
    String key = SandeshaUtil.getUUID(); // key to store the message.
    // updating the Highest_In_Msg_No property which gives the highest
    // message number retrieved from this sequence.
    long highestInMsgNo = bean.getHighestInMessageNumber();

    if (msgNo > highestInMsgNo) {
      // If WS-Addressing is turned off there may not be a message id written into the SOAP
      // headers, but we can still fake one up to help us match up requests and replies within
      // this end of the connection.
      String messageId = msgCtx.getMessageID();
      if(messageId == null) {
        messageId = SandeshaUtil.getUUID();
        msgCtx.setMessageID(messageId);
      }
     
      bean.setHighestInMessageId(messageId);
      bean.setHighestInMessageNumber(msgNo);
    }
   
    String specVersion = rmMsgCtx.getRMSpecVersion();
    if ((SandeshaUtil.isDuplicateInOnlyMessage(rmMsgCtx.getMessageContext())
            ||
          SandeshaUtil.isDuplicateInOutMessage(rmMsgCtx.getMessageContext()))
        && (Sandesha2Constants.QOS.InvocationType.DEFAULT_INVOCATION_TYPE == Sandesha2Constants.QOS.InvocationType.EXACTLY_ONCE)) {
     
      // this is a duplicate message and the invocation type is EXACTLY_ONCE. We try to return
      // ack messages at this point, as if someone is sending duplicates then they may have
      // missed earlier acks. We also have special processing for sync 2-way with RM 1.0
      if((replyTo==null || replyTo.hasAnonymousAddress()) &&
         (specVersion!=null && specVersion.equals(Sandesha2Constants.SPEC_VERSIONS.v1_0))) {

        SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();
        SenderBean findSenderBean = new SenderBean ();
       
        if (rmMsgCtx.getMessageType()==Sandesha2Constants.MessageTypes.LAST_MESSAGE)
          findSenderBean.setMessageType(Sandesha2Constants.MessageTypes.LAST_MESSAGE);
        else
          findSenderBean.setMessageType(Sandesha2Constants.MessageTypes.APPLICATION);
       
        findSenderBean.setInboundSequenceId(sequence.getIdentifier().getIdentifier());
        findSenderBean.setInboundMessageNumber(sequence.getMessageNumber().getMessageNumber());
        findSenderBean.setSend(true);
   
        SenderBean replyMessageBean = senderBeanMgr.findUnique(findSenderBean);
         
        // this is effectively a poll for the replyMessage, so re-use the logic in the MakeConnection
        // processor. This will use this thread to re-send the reply, writing it into the transport.
        // As the reply is now written we do not want to continue processing, or suspend, so we abort.
        if(replyMessageBean != null) {
          if(log.isDebugEnabled()) log.debug("Found matching reply for replayed message");
           MakeConnectionProcessor.replyToPoll(rmMsgCtx, replyMessageBean, storageManager, false, null, transaction);
          result = InvocationResponse.ABORT;
          if (log.isDebugEnabled())
            log.debug("Exit: SequenceProcessor::processReliableMessage, replayed message: " + result);
          return result;
        }
      }
     
      EndpointReference acksTo = new EndpointReference (bean.getAcksToEPR());
     
      // Send an Ack if needed.
      //We are not sending acks for duplicate messages in the RM 1.0 anon InOut case.
      //If a standalone ack get sent before the actualy message (I.e. before the original msg get
      //replied), the client may take this as a InOnly message and may avoid looking for the application
      //response.
      if (!(Sandesha2Constants.SPEC_VERSIONS.v1_0.equals(rmMsgCtx.getRMSpecVersion()) &&
          rmMsgCtx.getReplyTo().hasAnonymousAddress())) {
        sendAckIfNeeded(bean, sequenceId, rmMsgCtx, storageManager, true, acksTo.hasAnonymousAddress())
      }
     
      result = InvocationResponse.ABORT;
      if (log.isDebugEnabled())
        log.debug("Exit: SequenceProcessor::processReliableMessage, dropping duplicate: " + result);
      return result;
    }
   
    // If the message is a reply to an outbound message then we can update the RMSBean that
    // matches.
    EndpointReference toEPR = msgCtx.getTo();
    if(toEPR == null || toEPR.hasAnonymousAddress()) {
      RMSBean outBean = null;

      // Look for the correct outbound sequence by checking the anon uuid (if there is one)
      String toAddress = (toEPR == null) ? null : toEPR.getAddress();
      if(SandeshaUtil.isWSRMAnonymous(toAddress)) {
        RMSBean finderBean = new RMSBean();
        finderBean.setAnonymousUUID(toAddress);
        outBean = storageManager.getRMSBeanMgr().findUnique(finderBean);
      }
     
      // Fall back to the sequence that may have been offered at sequence creation time
      if(outBean == null) {
        String outboundSequence = bean.getOutboundInternalSequence();
        if(outboundSequence != null) {
          outBean = SandeshaUtil.getRMSBeanFromInternalSequenceId(storageManager, outboundSequence);
        }
      }
     
      // Update the reply count
      if(outBean != null && outBean.getExpectedReplies() > 0 ) {
        outBean.setExpectedReplies(outBean.getExpectedReplies() - 1);
        RMSBeanMgr outMgr = storageManager.getRMSBeanMgr();
        outMgr.update(outBean);
      }
    }
   
    // Set the last activated time
    bean.setLastActivatedTime(System.currentTimeMillis());
   
    // Update the RMD bean
    mgr.update(bean);
   
    // If we are doing sync 2-way over WSRM 1.0, then we may just have received one of
    // the reply messages that we were looking for. If so we can remove the matching sender bean.
    int mep = msgCtx.getAxisOperation().getAxisSpecificMEPConstant();
    if(specVersion!=null && specVersion.equals(Sandesha2Constants.SPEC_VERSIONS.v1_0) &&
View Full Code Here

Examples of org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr

            // setting the OfferedEndpoint
            rMSBean.setOfferedEndPoint(endpoint.getEPR().getAddress());
          }
   
          rmdBean.setOutboundInternalSequence(outgoingSideInternalSequenceId);
          RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
          rmdBeanMgr.update(rmdBean);
 
          // Store the inbound token (if any) with the new sequence
          rMSBean.setSecurityTokenData(rmdBean.getSecurityTokenData());
         
          // If this new sequence has anonymous acksTo, then we must poll for the acks
View Full Code Here

Examples of org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr

  }

  public static RMDBean getRMDBeanFromSequenceId(StorageManager storageManager, String sequenceID)
 
  throws SandeshaException {
    RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
    RMDBean bean = new RMDBean();
    bean.setSequenceID(sequenceID);
   
    bean = rmdBeanMgr.findUnique(bean);

    return bean;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.