@Override public long getMinTime() { final long minimumAllowed = ( long ) (2.5 * graphFig.getShardCacheTimeout()); final long minDelta = graphFig.getShardMinDelta(); if ( minDelta < minimumAllowed ) { throw new GraphRuntimeException( String .format( "You must configure the property %s to be >= 2 x %s. Otherwise you risk losing data", GraphFig.SHARD_MIN_DELTA, GraphFig.SHARD_CACHE_TIMEOUT ) ); } return timeService.getCurrentTime() - minDelta; }
@Override public Iterator<ShardEntryGroup> getShards(final ApplicationScope scope, final DirectedEdgeMeta directedEdgeMeta) { ValidationUtils.validateApplicationScope( scope ); GraphValidation.validateDirectedEdgeMeta( directedEdgeMeta ); Iterator<Shard> existingShards; //its a new node, it doesn't need to check cassandra, it won't exist if ( isNewNode( directedEdgeMeta ) ) { existingShards = Collections.singleton( Shard.MIN_SHARD ).iterator(); } else { existingShards = edgeShardSerialization.getShardMetaData( scope, Optional.absent(), directedEdgeMeta ); /** * We didn't get anything out of cassandra, so we need to create the minimum shard */ if ( existingShards == null || !existingShards.hasNext() ) { final MutationBatch batch = edgeShardSerialization.writeShardMeta( scope, Shard.MIN_SHARD, directedEdgeMeta ); try { batch.execute(); } catch ( ConnectionException e ) { throw new RuntimeException( "Unable to connect to casandra", e ); } existingShards = Collections.singleton( Shard.MIN_SHARD ).iterator(); } } return new ShardEntryGroupIterator( existingShards, graphFig.getShardMinDelta(), shardGroupCompaction, scope, directedEdgeMeta ); }
@Before public void setup() { scope = mock( ApplicationScope.class ); Id orgId = mock( Id.class ); when( orgId.getType() ).thenReturn( "organization" ); when( orgId.getUuid() ).thenReturn( UUIDGenerator.newTimeUUID() ); when( scope.getApplication() ).thenReturn( orgId ); graphFig = mock( GraphFig.class ); when( graphFig.getShardCacheSize() ).thenReturn( 10000l ); when( graphFig.getShardSize() ).thenReturn( 20000l ); final long timeout = 30000; when( graphFig.getShardCacheTimeout() ).thenReturn( timeout ); when( graphFig.getShardMinDelta() ).thenReturn( ( long ) (timeout * 2.5) ); }
when( graphFig.getShardMinDelta() ).thenReturn( tooSmallDelta ); when( graphFig.getShardMinDelta() ).thenReturn( minDelta ); when( graphFig.getShardMinDelta() ).thenReturn( delta );
final long minExecutionTime = graphFig.getShardMinDelta() + graphFig.getShardCacheTimeout() + 120000;
final long minDelta = graphFig.getShardMinDelta();
final long minExecutionTime = graphFig.getShardMinDelta() + graphFig.getShardCacheTimeout();
final long minExecutionTime = graphFig.getShardMinDelta() + graphFig.getShardCacheTimeout();