@Override public RVVExceptionB clone() { RVVExceptionB clone = new RVVExceptionB(previousVersion, nextVersion); if (this.received != null) { clone.received = (BitSet) this.received.clone(); clone.receivedBaseVersion = this.receivedBaseVersion; } return clone; }
/** Use this method to create a new RVVException */ static RVVException createException(long previousVersion, long nextVersion, long initialExceptionCount) { // arbitrary cutoff of 100 bytes to use a treeSet instead of bitSet // But if we are deserializing an exception too many received versions use a // bitset anyway. long delta = nextVersion - previousVersion; if (UseTreeSetsForTesting || (delta > RVV_MAX_BITSET_SPAN && initialExceptionCount * 512 < delta)) { return new RVVExceptionT(previousVersion, nextVersion); } return new RVVExceptionB(previousVersion, nextVersion); }
@Override public RVVException changeForm() { // Convert the exception to a bitset exception RVVExceptionB ex = new RVVExceptionB(previousVersion, nextVersion); for (ReceivedVersionsReverseIterator it = this.receivedVersionsReverseIterator(); it .hasNext();) { long next = it.next(); ex.add(next); } return ex; }
@Test public void testRVVExceptionBOutput() throws Exception { testExceptionOutput(new RVVExceptionB(50, 100)); }
@Test public void testRVVExceptionB() { RVVExceptionB ex = new RVVExceptionB(5, 10); ex.add(8); ex.add(6); assertEquals(8, ex.getHighestReceivedVersion()); ex.add(5); assertEquals(8, ex.getHighestReceivedVersion()); }