Package org.apache.sandesha2.util

Examples of org.apache.sandesha2.util.Range


  }
 
  public void testGetAckRangesFromRangeStringOutOfOrder() {
   
    RangeString rangeString = new RangeString();
    rangeString.addRange(new Range(3));
    rangeString.addRange(new Range(6));
    rangeString.addRange(new Range(1));
    rangeString.addRange(new Range(5));
    rangeString.addRange(new Range(8));
    rangeString.addRange(new Range(2));
   
    ArrayList<Range> list = SandeshaUtil.getAckRangeArrayList(rangeString,Sandesha2Constants.SPEC_2005_02.NS_URI);
    assertNotNull(list);
    assertEquals(list.size(),3);
   
    Iterator<Range> it = list.iterator();
    Range ackRange = null;
   
    ackRange = (Range) it.next();
    assertNotNull(ackRange);
    assertEquals(ackRange.lowerValue,1);
    assertEquals(ackRange.upperValue,3);
View Full Code Here


  }
 
  public void testGetAckRangesFromRangeStringGapFilling () {
    //build a range string to represent the completed messages
    RangeString rangeString = new RangeString();
    rangeString.addRange(new Range(1,3));
    rangeString.addRange(new Range(4));
    //insert a gap - number 5 is missing
    rangeString.addRange(new Range(6));
    //insert a gap - 7 and 8 are missing
    rangeString.addRange(new Range(9, 10));
   
    ArrayList<Range> list = SandeshaUtil.getAckRangeArrayList(rangeString,Sandesha2Constants.SPEC_2005_02.NS_URI);
    assertNotNull(list);
    //we expect 3 ranges: [1-4] [6] [9-10]
    assertEquals(list.size(),3);
   
    Iterator<Range> it = list.iterator();
    Range ackRange = null;
   
    ackRange = (Range) it.next();
    assertNotNull(ackRange);
    assertEquals(ackRange.lowerValue,1);
    assertEquals(ackRange.upperValue,4);
   
    ackRange = null;
    ackRange = (Range) it.next();
    assertNotNull(ackRange);
    assertEquals(ackRange.lowerValue,6);
    assertEquals(ackRange.upperValue,6);
   
    ackRange = null;
    ackRange = (Range) it.next();
    assertNotNull(ackRange);
    assertEquals(ackRange.lowerValue,9);
    assertEquals(ackRange.upperValue,10);
   
    assertFalse(it.hasNext());
   
    //ok, now plug a gap at msg 5
    rangeString.addRange(new Range(5));
    list = SandeshaUtil.getAckRangeArrayList(rangeString,Sandesha2Constants.SPEC_2005_02.NS_URI);
    assertNotNull(list);
    //we expect 2 ranges: [1-6] [9-10]
    it = list.iterator();
    ackRange = null;
   
    ackRange = (Range) it.next();
    assertNotNull(ackRange);
    assertEquals(ackRange.lowerValue,1);
    assertEquals(ackRange.upperValue,6);
   
    ackRange = null;
    ackRange = (Range) it.next();
    assertNotNull(ackRange);
    assertEquals(ackRange.lowerValue,9);
    assertEquals(ackRange.upperValue,10);
   
    assertFalse(it.hasNext());
   
    //plug all of the gaps - 7 and 8
    rangeString.addRange(new Range(8));
    rangeString.addRange(new Range(7,8));
    list = SandeshaUtil.getAckRangeArrayList(rangeString,Sandesha2Constants.SPEC_2005_02.NS_URI);
    assertNotNull(list);
    //we expect 1 ranges: [1-10]
    it = list.iterator();
    ackRange = null;
View Full Code Here

 
  public long getNumberOfMessagesAcked() {
    long numberOfMessagesAcked = 0;
    if (clientCompletedMessages != null) {
      // Process this value based on the ClientCompletedMessages
      Range ranges[] = clientCompletedMessages.getRanges();
 
      for (int rangeIndex=0; rangeIndex < ranges.length; rangeIndex++) {
        Range range = ranges[rangeIndex];
        numberOfMessagesAcked = range.upperValue - range.lowerValue + 1;
      }
    }
    return numberOfMessagesAcked;
  }
View Full Code Here

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

    rmdBean.setSequenceID(seqID);
    rmdBean.setToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmdBean.setAcksToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmdBean.setReplyToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmdBean.setRMVersion(Sandesha2Constants.SPEC_VERSIONS.v1_1);
    rmdBean.setServerCompletedMessages(new RangeString());
    // Flag that the sequence is closed.
    rmdBean.setClosed(true);
   
    // Create a transaction and insert the RMSBean
    Transaction tran = storageManager.getTransaction();
View Full Code Here

    rmsBean.setInternalSequenceID(SandeshaUtil.getInternalSequenceID(seqID, null));
    rmsBean.setToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmsBean.setAcksToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmsBean.setReplyToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmsBean.setRMVersion(Sandesha2Constants.SPEC_VERSIONS.v1_1);
    rmsBean.setClientCompletedMessages(new RangeString());
    rmsBean.setNextMessageNumber(1);
   
    // Create a transaction and insert the RMSBean
    Transaction tran = storageManager.getTransaction();
   
View Full Code Here

    rmsBean.setInternalSequenceID(SandeshaUtil.getInternalSequenceID(seqID, null));
    rmsBean.setToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmsBean.setAcksToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmsBean.setReplyToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmsBean.setRMVersion(Sandesha2Constants.SPEC_VERSIONS.v1_1);
    rmsBean.setClientCompletedMessages(new RangeString());
    rmsBean.setNextMessageNumber(4);
    rmsBean.setHighestOutMessageNumber(3);
   
    SenderBean bean1 = getSenderBean(seqID, 1, 1);
    SenderBean bean2 = getSenderBean(seqID, 0, 2);
View Full Code Here

    }

    //In case of ack request messages RM Namespace is decided based on the sequenceId of the last
    //ack request.
    for (Iterator iter = elements.getAckRequests();iter.hasNext();) {
      AckRequested ackRequest = (AckRequested) iter.next();
      rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.ACK_REQUEST, ackRequest);
      rmNamespace = ackRequest.getNamespaceValue();
    }

    if (elements.getCloseSequence() != null) {
      rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE, elements.getCloseSequence());
      rmNamespace = elements.getCloseSequence().getNamespaceValue();
View Full Code Here

      //if there is only on sequenceAck, sequenceId will be set. Otherwise it will not be.
      if (!sequenceAcknowledgementsIter.hasNext())
        sequenceID = sequenceAcknowledgement.getIdentifier().getIdentifier();
    } else if (ackRequestedIter.hasNext()) {
      rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.ACK_REQUEST);
      AckRequested ackRequest = (AckRequested) ackRequestedIter.next();

      //if there is only on sequenceAck, sequenceId will be set. Otherwise it will not be.
      if (!ackRequestedIter.hasNext())
        sequenceID = ackRequest.getIdentifier().getIdentifier();
    } else if (closeSequence != null) {
      rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CLOSE_SEQUENCE);
      sequenceID = closeSequence.getIdentifier().getIdentifier();
    } else if (closeSequenceResponse != null) {
      rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CLOSE_SEQUENCE_RESPONSE);
View Full Code Here

    Identifier id = new Identifier(rmNamespaceValue);
    id.setIndentifer(sequenceId);
    sequenceAck.setIdentifier(id);
   
    // Set the Invalid range!
    AcknowledgementRange ackRange = new AcknowledgementRange(rmNamespaceValue);
    ackRange.setLowerValue(1);
    ackRange.setUpperValue(3);
    sequenceAck.addAcknowledgementRanges(ackRange);

    // Set the SequenceAcknowledgement part in the message
    applicationRMMsg.setMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT, sequenceAck);
    applicationRMMsg.addSOAPEnvelope();
View Full Code Here

TOP

Related Classes of org.apache.sandesha2.util.Range

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.