/** * Initialize this version holder from another version holder This is called during GII. * * <p>It's more likely that the other holder has seen most of the versions, and this version * holder only has a few updates that happened since the GII started. So we apply our seen * versions to the other version holder and then initialize this version holder from the other * version holder. */ public synchronized void initializeFrom(RegionVersionHolder<T> source) { // Make sure the bitsets are merged in both the source // and this vector mergeBitSet(); RegionVersionHolder<T> other = source.clone(); other.mergeBitSet(); // Get a copy of the local version and exceptions long myVersion = this.version; // initialize our version and exceptions to match the others this.exceptions = other.exceptions; this.version = other.version; // Initialize the bit set to be empty. Merge bit set should // have already done this, but just to be sure. if (this.bitSet != null) { this.bitSetVersion = this.version; // Make sure the bit set is empty except for the first, bit, indicating // that the version has been received. this.bitSet.set(0); } // Now if this.version/exceptions overlap with myVersion/myExceptions, use this' // The only case needs special handling is: if myVersion is newer than this.version, // should create an exception (this.version+1, myversion) and set this.version=myversion if (myVersion > this.version) { RVVException e = RVVException.createException(this.version, myVersion + 1); // add special exception if (this.exceptions == null) { this.exceptions = new LinkedList<RVVException>(); } int i = 0; for (RVVException exception : this.exceptions) { if (e.compareTo(exception) >= 0) { break; } i++; } this.exceptions.add(i, e); this.version = myVersion; } }