@Test( expected = IllegalArgumentException.class ) public void failsInsertionOrder() { final long delta = 10000; Shard secondShard = new Shard( 20000, 10000, false ); Shard firstShard = new Shard( 10000, 10000, false ); Shard rootShard = new Shard( 0, 0, false ); ShardEntryGroup shardEntryGroup = new ShardEntryGroup( delta ); boolean result = shardEntryGroup.addShard( secondShard ); assertTrue( "Shard added", result ); result = shardEntryGroup.addShard( rootShard ); assertTrue( "Shard added", result ); shardEntryGroup.addShard( firstShard ); }
public boolean addShard( final Shard shard ) { Preconditions.checkNotNull( "shard cannot be null", shard ); final int size = shards.size(); if ( size == 0 ) { addShardInternal( shard ); return true; } final Shard minShard = shards.get( size - 1 ); Preconditions.checkArgument( minShard.compareTo( shard ) > 0, "shard must be less than the current max" ); if ( !minShard.isCompacted() ) { addShardInternal( shard ); return true; } return false; }
ShardEntryGroup { public boolean addShard( final Shard shard ) { Preconditions.checkNotNull( "shard cannot be null", shard ); final int size = shards.size(); if ( size == 0 ) { addShardInternal( shard ); return true; } final Shard minShard = shards.get( size - 1 ); Preconditions.checkArgument( minShard.compareTo( shard ) > 0, "shard must be less than the current max" ); if ( !minShard.isCompacted() ) { addShardInternal( shard ); return true; } return false; } }
ShardEntryGroup { public boolean addShard( final Shard shard ) { Preconditions.checkNotNull( "shard cannot be null", shard ); final int size = shards.size(); if ( size == 0 ) { addShardInternal( shard ); return true; } final Shard minShard = shards.get( size - 1 ); Preconditions.checkArgument( minShard.compareTo( shard ) > 0, "shard must be less than the current max" ); if ( !minShard.isCompacted() ) { addShardInternal( shard ); return true; } return false; } ShardEntryGroup( final long delta ); }
ShardEntryGroup { public boolean addShard( final Shard shard ) { Preconditions.checkNotNull( "shard cannot be null", shard ); final int size = shards.size(); if ( size == 0 ) { addShardInternal( shard ); return true; } final Shard minShard = shards.get( size - 1 ); Preconditions.checkArgument( minShard.compareTo( shard ) > 0, "shard must be less than the current max" ); if ( !minShard.isCompacted() ) { addShardInternal( shard ); return true; } return false; } ShardEntryGroup( final long delta ); boolean addShard( final Shard shard ); Shard getMinShard(); Collection<Shard> getReadShards(); Collection<Shard> getWriteShards( long currentTime ); boolean isCompactionPending(); Shard getCompactionTarget(); int entrySize(); boolean shouldCompact( final long currentTime ); boolean isNew(final long currentTime); boolean canBeDeleted( final Shard shard ); @Override String toString(); }
ShardEntryGroup { public boolean addShard( final Shard shard ) { Preconditions.checkNotNull( "shard cannot be null", shard ); final int size = shards.size(); if ( size == 0 ) { addShardInternal( shard ); return true; } final Shard minShard = shards.get( size - 1 ); Preconditions.checkArgument( minShard.compareTo( shard ) > 0, "shard must be less than the current max" ); if ( !minShard.isCompacted() ) { addShardInternal( shard ); return true; } return false; } ShardEntryGroup( final long delta ); boolean addShard( final Shard shard ); Shard getMinShard(); Collection<Shard> getReadShards(); Collection<Shard> getWriteShards( long currentTime ); boolean isCompactionPending(); Shard getCompactionTarget(); int entrySize(); boolean shouldCompact( final long currentTime ); boolean isNew(final long currentTime); boolean canBeDeleted( final Shard shard ); @Override String toString();  }