Esempio n. 1
0
 /**
  * Adds a message if not yet received
  * @param seqno
  * @param msg
  * @return -1 if not added because seqno < next_to_remove, 0 if not added because already present,
  *          1 if added successfully
  */
 public byte add2(long seqno, Message msg) {
     Segment segment=current_segment;
     if(segment == null || !segment.contains(seqno)) {
         segment=findOrCreateSegment(seqno);
         if(segment != null)
             current_segment=segment;
     }
     if(segment == null)
         return -1;
     return segment.add(seqno, msg);
 }
Esempio n. 2
0
 public AckReceiverWindow(long initial_seqno, int segment_capacity) {
     next_to_remove=new AtomicLong(initial_seqno);
     this.segment_capacity=segment_capacity;
     long index=next_to_remove.get() / segment_capacity;
     long first_seqno=(next_to_remove.get() / segment_capacity) * segment_capacity;
     this.segments.put(index, new Segment(first_seqno, segment_capacity));
     Segment initial_segment=findOrCreateSegment(next_to_remove.get());
     current_segment=initial_segment;
     current_remove_segment=initial_segment;
     for(long i=0; i < next_to_remove.get(); i++) {
         initial_segment.add(i, TOMBSTONE);
         initial_segment.remove(i);
     }
 }