public long next( long timestamp ) { return round( timestamp ) + interval; }
public static CounterResolution fromString( String s ) { if ( s == null ) { return ALL; } try { return CounterResolution.valueOf( s.toUpperCase() ); } catch ( IllegalArgumentException e ) { } try { return fromMinutes( Integer.valueOf( s ) ); } catch ( NumberFormatException e ) { } return ALL; } }
finish = System.currentTimeMillis(); start = resolution.round( start ); finish = resolution.round( finish ); long expected_time = start; long max_counters = ( finish - start ) / resolution.interval(); if ( max_counters > 1000 ) { finish = resolution.round( start + ( resolution.interval() * 1000 ) ); while ( count.getTimestamp() != expected_time ) { counters.add( new AggregateCounter( expected_time, 0 ) ); expected_time = resolution.next( expected_time ); expected_time = resolution.next( expected_time ); while ( expected_time <= finish ) { counters.add( new AggregateCounter( expected_time, 0 ) ); expected_time = resolution.next( expected_time );
@Test public void testCounterResolution() throws Exception { assertEquals( CounterResolution.ALL, CounterResolution.fromString( "foo" ) ); assertEquals( CounterResolution.MINUTE, CounterResolution.fromString( "MINUTE" ) ); assertEquals( CounterResolution.MINUTE, CounterResolution.fromString( "minute" ) ); assertEquals( CounterResolution.MINUTE, CounterResolution.fromString( "1" ) ); assertEquals( CounterResolution.HALF_HOUR, CounterResolution.fromString( "30" ) ); assertEquals( CounterResolution.HALF_HOUR, CounterResolution.fromString( "31" ) ); assertEquals( CounterResolution.FIVE_MINUTES, CounterResolution.fromString( "29" ) ); assertEquals( CounterResolution.HOUR, CounterResolution.fromString( "60" ) ); } }
String counterName, CounterResolution resolution, long start, long finish, boolean pad ) { start = resolution.round( start ); finish = resolution.round( finish ); long expected_time = start; Keyspace ko = cass.getApplicationKeyspace( applicationId ); while ( count.getTimestamp() != expected_time ) { counters.add( new AggregateCounter( expected_time, 0 ) ); expected_time = resolution.next( expected_time ); expected_time = resolution.next( expected_time ); while ( expected_time <= finish ) { counters.add( new AggregateCounter( expected_time, 0 ) ); expected_time = resolution.next( expected_time );
public static String rowBuilder( String name, UUID userId, UUID groupId, UUID queueId, String category, CounterResolution resolution ) { StringBuilder builder = new StringBuilder( name ); builder.append( COLON ).append( ( userId != null ? userId.toString() : STAR ) ).append( COLON ) .append( groupId != null ? groupId.toString() : STAR ).append( COLON ) .append( ( queueId != null ? queueId.toString() : STAR ) ).append( COLON ) .append( ( category != null ? category : STAR ) ).append( COLON ).append( resolution.name() ); return builder.toString(); } }
finish = System.currentTimeMillis(); start = resolution.round( start ); finish = resolution.round( finish ); long expected_time = start; long max_counters = ( finish - start ) / resolution.interval(); if ( max_counters > 1000 ) { finish = resolution.round( start + ( resolution.interval() * 1000 ) ); while ( count.getTimestamp() != expected_time ) { counters.add( new AggregateCounter( expected_time, 0 ) ); expected_time = resolution.next( expected_time ); expected_time = resolution.next( expected_time ); while ( expected_time <= finish ) { counters.add( new AggregateCounter( expected_time, 0 ) ); expected_time = resolution.next( expected_time );
resolution = CounterResolution.fromString( l.get( 0 ) );
boolean pad ) { start = resolution.round( start ); finish = resolution.round( finish ); long expected_time = start; Keyspace ko = cass.getApplicationKeyspace( applicationId ); while ( count.getTimestamp() != expected_time ) { counters.add( new AggregateCounter( expected_time, 0 ) ); expected_time = resolution.next( expected_time ); expected_time = resolution.next( expected_time ); while ( expected_time <= finish ) { counters.add( new AggregateCounter( expected_time, 0 ) ); expected_time = resolution.next( expected_time );
resolution = CounterResolution.fromString( l.get( 0 ) );
resolution = CounterResolution.fromString( l.get( 0 ) );
public void batchIncrementAggregateCounters( Mutator<ByteBuffer> m, UUID applicationId, UUID userId, UUID groupId, UUID queueId, String category, String name, long value, long counterTimestamp, long cassandraTimestamp ) { for ( CounterResolution resolution : CounterResolution.values() ) { if (logger.isTraceEnabled()) { logger.trace("BIAC for resolution {}", resolution); } batchIncrementAggregateCounters( m, userId, groupId, queueId, category, resolution, name, value, counterTimestamp, applicationId ); if (logger.isTraceEnabled()) { logger.trace("DONE BIAC for resolution {}", resolution); } } batchIncrementEntityCounter( m, applicationId, name, value, cassandraTimestamp, applicationId ); if ( userId != null ) { batchIncrementEntityCounter( m, userId, name, value, cassandraTimestamp, applicationId ); } if ( groupId != null ) { batchIncrementEntityCounter( m, groupId, name, value, cassandraTimestamp, applicationId ); } }
resolution = CounterResolution.fromString( l.get( 0 ) );