@Test public void testUnique() { int replicaId = 001; CsnFactory defaultCSNFactory = new CsnFactory( replicaId ); Csn[] csns = new Csn[NUM_GENERATES]; for ( int i = 0; i < NUM_GENERATES; i++ ) { csns[i] = defaultCSNFactory.newInstance(); } for ( int i = 0; i < NUM_GENERATES; i++ ) { for ( int j = i + 1; j < NUM_GENERATES; j++ ) { assertFalse( csns[i].equals( csns[j] ) ); } } }
public Csn newInstance() { int tmpChangeCount; synchronized ( lock ) { long newTimestamp = System.currentTimeMillis(); if ( lastTimestamp == newTimestamp ) { changeCount++; } else { lastTimestamp = newTimestamp; changeCount = 0; } tmpChangeCount = changeCount; } return new Csn( lastTimestamp, tmpChangeCount, replicaId, 0 ); }
CsnFactory { public Csn newInstance() { int tmpChangeCount; synchronized ( lock ) { long newTimestamp = System.currentTimeMillis(); if ( lastTimestamp == newTimestamp ) { changeCount++; } else { lastTimestamp = newTimestamp; changeCount = 0; } tmpChangeCount = changeCount; } return new Csn( lastTimestamp, tmpChangeCount, replicaId, 0 ); } }
CsnFactory { public Csn newInstance() { int tmpChangeCount; synchronized ( lock ) { long newTimestamp = System.currentTimeMillis(); if ( lastTimestamp == newTimestamp ) { changeCount++; } else { lastTimestamp = newTimestamp; changeCount = 0; } tmpChangeCount = changeCount; } return new Csn( lastTimestamp, tmpChangeCount, replicaId, 0 ); } CsnFactory( int replicaId ); }
CsnFactory { public Csn newInstance() { int tmpChangeCount; synchronized ( lock ) { long newTimestamp = System.currentTimeMillis(); if ( lastTimestamp == newTimestamp ) { changeCount++; } else { lastTimestamp = newTimestamp; changeCount = 0; } tmpChangeCount = changeCount; } return new Csn( lastTimestamp, tmpChangeCount, replicaId, 0 ); } CsnFactory( int replicaId ); Csn newInstance(); Csn newInstance( long timestamp, int changeCount ); Csn newPurgeCsn( long expirationDate ); void setReplicaId( int replicaId ); }
CsnFactory { public Csn newInstance() { int tmpChangeCount; synchronized ( lock ) { long newTimestamp = System.currentTimeMillis(); if ( lastTimestamp == newTimestamp ) { changeCount++; } else { lastTimestamp = newTimestamp; changeCount = 0; } tmpChangeCount = changeCount; } return new Csn( lastTimestamp, tmpChangeCount, replicaId, 0 ); } CsnFactory( int replicaId ); Csn newInstance(); Csn newInstance( long timestamp, int changeCount ); Csn newPurgeCsn( long expirationDate ); void setReplicaId( int replicaId );  }