コード例 #1
0
ファイル: SEQUENCER.java プロジェクト: DevFactory/JGroups
 protected void deliver(Message msg, Event evt, SequencerHeader hdr) {
   Address sender = msg.getSrc();
   if (sender == null) {
     if (log.isErrorEnabled())
       log.error(local_addr + ": sender is null, cannot deliver " + "::" + hdr.getSeqno());
     return;
   }
   long msg_seqno = hdr.getSeqno();
   if (sender.equals(local_addr)) {
     forward_table.remove(msg_seqno);
     if (hdr.flush_ack) {
       ack_promise.setResult(msg_seqno);
       if (ack_mode && !flushing && threshold > 0 && ++num_acks >= threshold) {
         ack_mode = false;
         num_acks = 0;
       }
     }
   }
   if (!canDeliver(sender, msg_seqno)) {
     if (log.isWarnEnabled())
       log.warn(local_addr + ": dropped duplicate message " + sender + "::" + msg_seqno);
     return;
   }
   if (log.isTraceEnabled()) log.trace(local_addr + ": delivering " + sender + "::" + msg_seqno);
   up_prot.up(evt);
   delivered_bcasts++;
 }
コード例 #2
0
ファイル: SnapshotMap.java プロジェクト: sboobna/bookkeeper
 /**
  * Removes the mapping for the key from this map if it is present.
  *
  * @param key Key whose mapping is to be removed from this map.
  */
 public void remove(K key) {
   this.lock.readLock().lock();
   try {
     // first remove updates
     updates.remove(key);
     updatesToMerge.remove(key);
     // then remove snapshot
     snapshot.remove(key);
   } finally {
     this.lock.readLock().unlock();
   }
 }
コード例 #3
0
 public void testStandardLastEntry() {
   NavigableMap<String, Integer> forwarding =
       new StandardLastEntryForwardingNavigableMap<String, Integer>(
           new SafeTreeMap<String, Integer>());
   assertNull(forwarding.lastEntry());
   forwarding.put("b", 2);
   assertEquals(immutableEntry("b", 2), forwarding.lastEntry());
   forwarding.put("c", 3);
   assertEquals(immutableEntry("c", 3), forwarding.lastEntry());
   forwarding.put("a", 1);
   assertEquals(immutableEntry("c", 3), forwarding.lastEntry());
   forwarding.remove("c");
   assertEquals(immutableEntry("b", 2), forwarding.lastEntry());
 }
コード例 #4
0
ファイル: OCPAgent.java プロジェクト: ccbon/ocp
 public Contact removeContact(Contact contact) {
   ContactMap contactMap = ds().getComponent(ContactMap.class);
   OCPContact c = (OCPContact) contactMap.remove(contact);
   try {
     Iterator<Id> it = c.nodeIdSet.iterator();
     while (it.hasNext()) {
       Id id = it.next();
       LOG.info("removing node to nodeMap");
       nodeMap.remove(id);
     }
     return c;
   } catch (Exception e) {
     return null;
   }
 }
コード例 #5
0
 public void removeRange(Range range) {
   RangeGroup rangeGroup = rangeMap.get(range.start);
   if (range.isEmpty()) {
     if (rangeGroup.emptyRangesAtStart <= 0) {
       throw new IllegalStateException();
     }
     rangeGroup.emptyRangesAtStart--;
   } else {
     if (rangeGroup.nonEmptyRangeMapping == null
         || !range.equals(rangeGroup.nonEmptyRangeMapping.sourceRange)) {
       throw new IllegalStateException();
     }
     rangeGroup.nonEmptyRangeMapping = null;
   }
   if (rangeGroup.nonEmptyRangeMapping == null && rangeGroup.emptyRangesAtStart == 0) {
     rangeMap.remove(range.start);
   }
 }
コード例 #6
0
ファイル: StorageLayer.java プロジェクト: jaasilva/TomP2P
 // iterative version
 private NavigableMap<Number640, Data> deletePredecessors(
     Number640 key, NavigableMap<Number640, Data> sortedMap) {
   final List<Number640> toRemove = new ArrayList<Number640>();
   final NavigableMap<Number640, Data> removed = new TreeMap<Number640, Data>();
   toRemove.add(key);
   while (!toRemove.isEmpty()) {
     final Number640 key2 = toRemove.remove(0);
     final Data version = sortedMap.remove(key2);
     if (version != null) {
       removed.put(key2, version);
       // check if version has been already deleted && // check if version is initial version
       if (!version.basedOnSet().isEmpty()) {
         for (final Number160 basedOnKey : version.basedOnSet()) {
           toRemove.add(new Number640(key.locationAndDomainAndContentKey(), basedOnKey));
         }
       }
     }
   }
   return removed;
 }
コード例 #7
0
  private void decrementBitmapOfSize(Integer size, Bitmap removed) {
    Bitmap.Config config = removed.getConfig();
    NavigableMap<Integer, Integer> sizes = getSizesForConfig(config);
    Integer current = sizes.get(size);
    if (current == null) {
      throw new NullPointerException(
          "Tried to decrement empty size"
              + ", size: "
              + size
              + ", removed: "
              + logBitmap(removed)
              + ", this: "
              + this);
    }

    if (current == 1) {
      sizes.remove(size);
    } else {
      sizes.put(size, current - 1);
    }
  }
コード例 #8
0
  private void remove(
      NavigableMap<Interval, TimelineEntry> timeline, Interval interval, boolean incompleteOk) {
    timeline.remove(interval);

    for (Map.Entry<Interval, TreeMap<VersionType, TimelineEntry>> versionEntry :
        allTimelineEntries.entrySet()) {
      if (versionEntry.getKey().overlap(interval) != null) {
        if (incompleteOk) {
          add(timeline, versionEntry.getKey(), versionEntry.getValue().lastEntry().getValue());
        } else {
          for (VersionType ver : versionEntry.getValue().descendingKeySet()) {
            TimelineEntry timelineEntry = versionEntry.getValue().get(ver);
            if (timelineEntry.getPartitionHolder().isComplete()) {
              add(timeline, versionEntry.getKey(), timelineEntry);
              break;
            }
          }
        }
      }
    }
  }
コード例 #9
0
ファイル: FlowScript.java プロジェクト: sugiii8/asakusafw
 private static Map<String, NavigableMap<String, String>> partitioning(
     NavigableMap<String, String> map) {
   assert map != null;
   Map<String, NavigableMap<String, String>> results =
       new TreeMap<String, NavigableMap<String, String>>();
   while (map.isEmpty() == false) {
     String name = map.firstKey();
     int index = name.indexOf('.');
     if (index >= 0) {
       name = name.substring(0, index);
     }
     String first = name + '.';
     String last = name + (char) ('.' + 1);
     NavigableMap<String, String> partition = new TreeMap<String, String>();
     for (Map.Entry<String, String> entry : map.subMap(first, last).entrySet()) {
       String key = entry.getKey();
       partition.put(key.substring(name.length() + 1), entry.getValue());
     }
     results.put(name, partition);
     map.remove(name);
     map.subMap(first, last).clear();
   }
   return results;
 }
コード例 #10
0
 @Override
 public Object remove(Object key) {
   return configMap.remove(key);
 }
コード例 #11
0
 /**
  * Removes a Page (if it exists)
  *
  * @param pageNum Page number
  */
 public void removePage(int pageNum) {
   pages.remove(pageNum);
 }
コード例 #12
0
  /**
   * @param timeline
   * @param key
   * @param entry
   * @return boolean flag indicating whether or not we inserted or discarded something
   */
  private boolean addAtKey(
      NavigableMap<Interval, TimelineEntry> timeline, Interval key, TimelineEntry entry) {
    boolean retVal = false;
    Interval currKey = key;
    Interval entryInterval = entry.getTrueInterval();

    if (!currKey.overlaps(entryInterval)) {
      return false;
    }

    while (entryInterval != null && currKey != null && currKey.overlaps(entryInterval)) {
      Interval nextKey = timeline.higherKey(currKey);

      int versionCompare =
          versionComparator.compare(entry.getVersion(), timeline.get(currKey).getVersion());

      if (versionCompare < 0) {
        if (currKey.contains(entryInterval)) {
          return true;
        } else if (currKey.getStart().isBefore(entryInterval.getStart())) {
          entryInterval = new Interval(currKey.getEnd(), entryInterval.getEnd());
        } else {
          addIntervalToTimeline(
              new Interval(entryInterval.getStart(), currKey.getStart()), entry, timeline);

          if (entryInterval.getEnd().isAfter(currKey.getEnd())) {
            entryInterval = new Interval(currKey.getEnd(), entryInterval.getEnd());
          } else {
            entryInterval = null; // discard this entry
          }
        }
      } else if (versionCompare > 0) {
        TimelineEntry oldEntry = timeline.remove(currKey);

        if (currKey.contains(entryInterval)) {
          addIntervalToTimeline(
              new Interval(currKey.getStart(), entryInterval.getStart()), oldEntry, timeline);
          addIntervalToTimeline(
              new Interval(entryInterval.getEnd(), currKey.getEnd()), oldEntry, timeline);
          addIntervalToTimeline(entryInterval, entry, timeline);

          return true;
        } else if (currKey.getStart().isBefore(entryInterval.getStart())) {
          addIntervalToTimeline(
              new Interval(currKey.getStart(), entryInterval.getStart()), oldEntry, timeline);
        } else if (entryInterval.getEnd().isBefore(currKey.getEnd())) {
          addIntervalToTimeline(
              new Interval(entryInterval.getEnd(), currKey.getEnd()), oldEntry, timeline);
        }
      } else {
        if (timeline.get(currKey).equals(entry)) {
          // This occurs when restoring segments
          timeline.remove(currKey);
        } else {
          throw new UnsupportedOperationException(
              String.format(
                  "Cannot add overlapping segments [%s and %s] with the same version [%s]",
                  currKey, entryInterval, entry.getVersion()));
        }
      }

      currKey = nextKey;
      retVal = true;
    }

    addIntervalToTimeline(entryInterval, entry, timeline);

    return retVal;
  }