/** create a live version vector for a region */ public RegionVersionVector(T ownerId, LocalRegion owner) { this.myId = ownerId; this.isLiveVector = true; this.regionName = owner == null? "" : "region " + owner.getFullPath(); this.localExceptions = new RegionVersionHolder<T>(0); this.memberToVersion = new ConcurrentHashMap<T, RegionVersionHolder<T>>(INITIAL_CAPACITY, LOAD_FACTOR, CONCURRENCY_LEVEL); this.memberToGCVersion = new ConcurrentHashMap<T, Long> (INITIAL_CAPACITY, LOAD_FACTOR, CONCURRENCY_LEVEL); }
private boolean isGCVersionDominatedByHolder(Long gcVersion, RegionVersionHolder<T>otherHolder) { if (gcVersion == null || gcVersion.longValue() == 0) { return true; } else { RegionVersionHolder<T> holder = new RegionVersionHolder<T>(gcVersion.longValue()); return !holder.isNewerThanOrCanFillExceptionsFor(otherHolder); } }
/** create a live version vector for a region */ public RegionVersionVector(T ownerId) { this.myId = ownerId; this.isLiveVector = true; this.localExceptions = new RegionVersionHolder<T>(0); this.memberToVersionSnapshot = new CopyOnWriteHashMap<T, RegionVersionHolder<T>>(); this.memberToVersion = new ConcurrentHashMap<T, RegionVersionHolder<T>>(INITIAL_CAPACITY, LOAD_FACTOR, CONCURRENCY_LEVEL); this.memberToGCVersion = new ConcurrentHashMap<T, Long> (INITIAL_CAPACITY, LOAD_FACTOR, CONCURRENCY_LEVEL); }
private boolean isGCVersionDominatedByHolder(Long gcVersion, RegionVersionHolder<T>otherHolder) { if (gcVersion == null || gcVersion.longValue() == 0) { return true; } else { RegionVersionHolder<T> holder = new RegionVersionHolder<T>(gcVersion.longValue()); return !holder.isNewerThanOrCanFillExceptionsFor(otherHolder); } }
/** * 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)); }
public void fromData(DataInput in) throws IOException, ClassNotFoundException { this.myId = readMember(in); int flags = in.readInt(); this.singleMember = ((flags & 0x01) == 0x01); this.localVersion.set(in.readLong()); this.localGCVersion.set(in.readLong()); int numHolders = in.readInt(); for (int i=0; i<numHolders; i++) { T key = readMember(in); RegionVersionHolder<T> holder = new RegionVersionHolder<T>(in); holder.id = key; this.memberToVersion.put(key, holder); } int numGCVersions = in.readInt(); for (int i=0; i<numGCVersions; i++) { T key = readMember(in); RegionVersionHolder<T> holder = this.memberToVersion.get(key); if (holder != null) { key = holder.id; } // else it could go in canonicalIds, but that's not used in copies of RVVs long value = in.readLong(); this.memberToGCVersion.put(key, value); } this.localExceptions = new RegionVersionHolder<T>(in); }
public void fromData(DataInput in) throws IOException, ClassNotFoundException { this.myId = readMember(in); int flags = in.readInt(); this.singleMember = ((flags & 0x01) == 0x01); this.localVersion.set(in.readLong()); this.localGCVersion.set(in.readLong()); int numHolders = in.readInt(); for (int i=0; i<numHolders; i++) { T key = readMember(in); RegionVersionHolder<T> holder = new RegionVersionHolder<T>(in); holder.id = key; this.memberToVersion.put(key, holder); } int numGCVersions = in.readInt(); for (int i=0; i<numGCVersions; i++) { T key = readMember(in); RegionVersionHolder<T> holder = this.memberToVersion.get(key); if (holder != null) { key = holder.id; } // else it could go in canonicalIds, but that's not used in copies of RVVs long value = in.readLong(); this.memberToGCVersion.put(key, value); } this.localExceptions = new RegionVersionHolder<T>(in); }
@Override public synchronized RegionVersionHolder<T> clone() { RegionVersionHolder<T> clone = new RegionVersionHolder<T>(this.version); clone.id = this.id; clone.isDepartedMember = this.isDepartedMember; if (this.exceptions != null) { clone.exceptions = new LinkedList<RVVException>(); for (RVVException e: this.exceptions) { clone.exceptions.add(e.clone()); } } if (this.bitSet != null) { clone.bitSet = (BitSet)this.bitSet.clone(); clone.bitSetVersion = this.bitSetVersion; clone.mergeBitSet(); } return clone; }
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { fromDataPre_GFE_8_0_0_0(in); this.isDeltaGII = in.readBoolean(); this.hasHolderToSend = in.readBoolean(); if (this.hasHolderToSend) { this.holderToSend = new RegionVersionHolder(in); } int gcVersionsLength = in.readShort(); if(gcVersionsLength >= 0) { gcVersions = new HashMap<VersionSource, Long>(gcVersionsLength); } for(int i =0; i < gcVersionsLength; i++) { VersionSource key = InternalDataSerializer.readObject(in); long value = InternalDataSerializer.readUnsignedVL(in); gcVersions.put(key, value); } }
/** * 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)); }
/** * Construct a region version holder that matches the seen revisions * passed in the bit set. * */ private RegionVersionHolder buildHolder(BitSet bs) { //Createa version holder RegionVersionHolder vh = new RegionVersionHolder(member); //Record all of the version in the holder recordVersions(vh, bs); //Make sure the holder looks matches the bitset. compareWithBitSet(bs, vh); return vh; }
@Override public synchronized RegionVersionHolder<T> clone() { RegionVersionHolder<T> clone = new RegionVersionHolder<T>(this.version); clone.id = this.id; clone.isDepartedMember = this.isDepartedMember;
public void testInitialize3() { RegionVersionHolder vh1 = new RegionVersionHolder(member); for(int i=0;i<=1074; i++) { vh1.recordVersion(i, null); } RegionVersionHolder vh2 = new RegionVersionHolder(member); vh2.recordVersion(1075,null); vh1.makeReadyForRecording(); vh2.initializeFrom(vh1.clone()); vh2.makeReadyForRecording(); vh2.recordVersion(1075,null); System.out.println("vh1" + vh2.clone()); // vh2.recordVersion(1098, null); // // System.out.println("vh1" + vh2.clone()); // System.out.println(vh2.contains(1097)); }
public void test48066_1() { RegionVersionHolder vh1 = new RegionVersionHolder(member); for (int i=1; i<=3; i++) { vh1.recordVersion(i, null); RegionVersionHolder vh3 = new RegionVersionHolder(member); for (int i=10; i<=10; i++) { vh3.recordVersion(i, null);
public void test1() { RegionVersionHolder vh1 = new RegionVersionHolder(member); vh1.recordVersion(15, null); RegionVersionHolder vh2 = vh1.clone(); RegionVersionHolder vh3 = new RegionVersionHolder(member); for (int i=1; i<=10; i++) { vh3.recordVersion(i, null);
public void testInitialize2() { RegionVersionHolder vh1 = new RegionVersionHolder(member); vh1.recordVersion(1093, null); vh1.recordVersion(2000, null); System.out.println("vh2" + vh1.clone()); RegionVersionHolder vh3 = new RegionVersionHolder(member); for (int i = 1; i <= 1094; i++) { vh3.recordVersion(i, null);
if (holder == null) { mbr = getCanonicalId(mbr); holder = new RegionVersionHolder<T>(mbr); memberToVersion.put(holder.id, holder);
public void testInitialized() { RegionVersionHolder vh1 = new RegionVersionHolder(member); vh1.recordVersion(56, null); vh1.recordVersion(57, null); vh1.recordVersion(58, null); vh1.recordVersion(59, null); vh1.recordVersion(60, null); vh1 = vh1.clone(); System.out.println("This node init, vh1="+vh1); RegionVersionHolder vh2 = new RegionVersionHolder(member); for(int i=1;i<57;i++) { vh2.recordVersion(i,null); } vh2 = vh2.clone(); System.out.println("GII node init, vh2="+vh2); vh1.initializeFrom(vh2); vh1 = vh1.clone(); System.out.println("After initialize, vh1="+vh1); //vh1.recordVersion(57,null); vh1.recordVersion(58,null); vh1.recordVersion(59,null); vh1.recordVersion(60,null); System.out.println("After initialize and record version, vh1="+vh1); vh1 = vh1.clone(); vh1.recordVersion(57,null); System.out.println("After initialize and record version after clone, vh1="+vh1); assertTrue(vh1.contains(58)); }
RegionVersionHolder dummyHolder = new RegionVersionHolder(1); try { dummyHolder.toData(out);
RegionVersionHolder vh1 = new RegionVersionHolder(member); RegionVersionHolder vh2 = new RegionVersionHolder(member);