/** * Retrieve a vector that can be sent to another member. This clones all * of the version information to protect against concurrent modification * during serialization */ public RegionVersionVector<T> getCloneForTransmission() { Map<T,RegionVersionHolder<T>> liveHolders; liveHolders = new HashMap<T,RegionVersionHolder<T>>(this.memberToVersion); ConcurrentHashMap<T, RegionVersionHolder<T>> clonedHolders = new ConcurrentHashMap<T, RegionVersionHolder<T>>( liveHolders.size(), LOAD_FACTOR, CONCURRENCY_LEVEL); for (Map.Entry<T, RegionVersionHolder<T>> entry: liveHolders.entrySet()) { clonedHolders.put(entry.getKey(), entry.getValue().clone()); } ConcurrentHashMap<T, Long> gcVersions = new ConcurrentHashMap<T, Long>( this.memberToGCVersion.size(), LOAD_FACTOR, CONCURRENCY_LEVEL); gcVersions.putAll(this.memberToGCVersion); RegionVersionHolder<T> clonedLocalHolder; clonedLocalHolder = this.localExceptions.clone(); //Make sure the holder that we send to the peer does //have an accurate RegionVersionHolder for our local version return createCopy(this.myId, clonedHolders, this.localVersion.get(), gcVersions, this.localGCVersion.get(), false, clonedLocalHolder); }
/** * Retrieve a vector that can be used as a SnapShot information. * Basically we need low cost copy of memberToVersion and localVersion. * Also calling method should synchronize on cache level lock * if it wants consistent view of snapshot across cache */ public RegionVersionVector<T> getCloneForTransmission() { Map<T,RegionVersionHolder<T>> liveHolders; // we need to take a lock? so that memberToVersion is not modifed as we copy them // Find out liveHolders = ObjectObjectHashMap.from(this.memberToVersion); ConcurrentHashMap<T, RegionVersionHolder<T>> clonedHolders = new ConcurrentHashMap<T, RegionVersionHolder<T>>(liveHolders.size(), LOAD_FACTOR, CONCURRENCY_LEVEL); for (Map.Entry<T, RegionVersionHolder<T>> entry: liveHolders.entrySet()) { clonedHolders.put(entry.getKey(), entry.getValue().clone()); } ConcurrentHashMap<T, Long> gcVersions = new ConcurrentHashMap<T, Long>( this.memberToGCVersion.size(), LOAD_FACTOR, CONCURRENCY_LEVEL); gcVersions.putAll(this.memberToGCVersion); RegionVersionHolder<T> clonedLocalHolder; clonedLocalHolder = this.localExceptions.clone(); //Make sure the holder that we send to the peer does //have an accurate RegionVersionHolder for our local version return createCopy(this.myId, clonedHolders, this.localVersion.get(), gcVersions, this.localGCVersion.get(), false, clonedLocalHolder); }
public RegionVersionVector<T> getReinitializedSnapshotRVV() { LogWriterI18n logger = getLoggerI18n(); ConcurrentHashMap<T, RegionVersionHolder<T>> copySnapshot = new ConcurrentHashMap<T, RegionVersionHolder<T>>(memberToVersion); if (DEBUG && logger != null) { logger.info(LocalizedStrings.DEBUG, "reInitializing the snapshot rvv, current: " + copySnapshot + " with : " + memberToGCVersion); } // update the snapshot with local version too RegionVersionHolder holder = localExceptions.clone(); holder.id = myId; holder.version = localVersion.get(); copySnapshot.put(myId, holder); return createCopy(this.myId, copySnapshot, this.localVersion.get(), getMemberToGCVersionTest(), this.localGCVersion.get(), false, holder); }
/** * Retrieve a vector that can be sent to another member. This clones only * the version information for the given ID.<p> * The clone returned by this method does not have distributed garbage-collection * information. */ public RegionVersionVector<T> getCloneForTransmission(T mbr) { Map<T,RegionVersionHolder<T>> liveHolders; liveHolders = new HashMap<T, RegionVersionHolder<T>>(this.memberToVersion); RegionVersionHolder<T> holder = liveHolders.get(mbr); if (holder == null) { holder = new RegionVersionHolder<T>(-1); } else { holder = holder.clone(); } return createCopy( this.myId, new ConcurrentHashMap<T, RegionVersionHolder<T>>(Collections.singletonMap(mbr, holder)), 0, new ConcurrentHashMap<T, Long>(INITIAL_CAPACITY, LOAD_FACTOR, CONCURRENCY_LEVEL), 0, true, new RegionVersionHolder<T>(-1)); }
/** * Retrieve a vector that can be sent to another member. This clones only * the version information for the given ID.<p> * The clone returned by this method does not have distributed garbage-collection * information. */ public RegionVersionVector<T> getCloneForTransmission(T mbr) { Map<T,RegionVersionHolder<T>> liveHolders; liveHolders = ObjectObjectHashMap.from(this.memberToVersion); RegionVersionHolder<T> holder = liveHolders.get(mbr); if (holder == null) { holder = new RegionVersionHolder<T>(-1); } else { holder = holder.clone(); } return createCopy( this.myId, new ConcurrentHashMap<T, RegionVersionHolder<T>>(Collections.singletonMap(mbr, holder)), 0, new ConcurrentHashMap<T, Long>(INITIAL_CAPACITY, LOAD_FACTOR, CONCURRENCY_LEVEL), 0, true, new RegionVersionHolder<T>(-1)); }