private void handleAggregateCounterRow( Mutator<ByteBuffer> m, String key, long column, long value, UUID applicationId ) { if ( logger.isTraceEnabled() ) { logger.trace( "HACR: aggregateRow for app {} with key {} column {} and value {}", applicationId, key, column, value ); } if ( "o".equals( counterType ) || "p".equals( counterType ) ) { if ( m != null ) { HCounterColumn<Long> c = createCounterColumn( column, value, le ); m.addCounter( bytebuffer( key ), APPLICATION_AGGREGATE_COUNTERS.toString(), c ); } } if ( "n".equals( counterType ) || "p".equals( counterType ) ) { // create and add Count PrefixedSerializer ps = new PrefixedSerializer( applicationId, ue, se ); batcher.add( new Count( APPLICATION_AGGREGATE_COUNTERS.toString(), ps.toByteBuffer( key ), column, value ) ); } }
private Mutator<ByteBuffer> batchIncrementEntityCounter( Mutator<ByteBuffer> m, UUID entityId, String name, Long value, long timestamp, UUID applicationId ) { if ( logger.isTraceEnabled() ) { logger.trace( "BIEC: Incrementing property {} of entity {} by value {}", name, entityId, value ); } addInsertToMutator( m, ENTITY_DICTIONARIES, key( entityId, DICTIONARY_COUNTERS ), name, null, timestamp ); if ( "o".equals( counterType ) || "p".equals( counterType ) ) { HCounterColumn<String> c = createCounterColumn( name, value ); m.addCounter( bytebuffer( entityId ), ENTITY_COUNTERS.toString(), c ); } if ( "n".equals( counterType ) || "p".equals( counterType ) ) { PrefixedSerializer ps = new PrefixedSerializer( applicationId, ue, ue ); batcher.add( new Count( ENTITY_COUNTERS.toString(), ps.toByteBuffer( entityId ), name, value ) ); } return m; }
public Mutator<ByteBuffer> batchIncrementQueueCounter( Mutator<ByteBuffer> m, UUID queueId, String name, long value, long timestamp, UUID applicationId ) { if ( logger.isTraceEnabled() ) { logger.trace( "BIQC: Incrementing property {} of queue {} by value {}", name, queueId, value ); } m.addInsertion( bytebuffer( key( queueId, DICTIONARY_COUNTERS ).toString() ), QueuesCF.QUEUE_DICTIONARIES.toString(), createColumn( name, ByteBuffer.allocate( 0 ), timestamp, se, be ) ); if ( "o".equals( counterType ) || "p".equals( counterType ) ) { HCounterColumn<String> c = createCounterColumn( name, value ); ByteBuffer keybytes = bytebuffer( queueId ); m.addCounter( keybytes, QueuesCF.COUNTERS.toString(), c ); } if ( "n".equals( counterType ) || "p".equals( counterType ) ) { PrefixedSerializer ps = new PrefixedSerializer( applicationId, ue, ue ); batcher.add( new Count( QueuesCF.COUNTERS.toString(), ps.toByteBuffer( queueId ), name, value ) ); } return m; }
public VirtualKeyspaceCassandraClient(Client client, ByteBuffer prefixBytes) { super(client); this.prefixBytes = prefixBytes; ps = new PrefixedSerializer<ByteBuffer, ByteBuffer>(prefixBytes, be, be); }
public <E> VirtualKeyspaceServiceImpl(String keyspaceName, E keyPrefix, Serializer<E> keyPrefixSerializer, ConsistencyLevelPolicy consistencyLevel, HConnectionManager connectionManager, FailoverPolicy failoverPolicy, Map<String, String> credentials) throws HectorTransportException { super(keyspaceName, consistencyLevel, connectionManager, failoverPolicy, credentials); prefixBytes = keyPrefixSerializer.toByteBuffer(keyPrefix); ps = new PrefixedSerializer<ByteBuffer, ByteBuffer>(prefixBytes, be, be); }
public <E> VirtualKeyspaceServiceImpl(String keyspaceName, E keyPrefix, Serializer<E> keyPrefixSerializer, ConsistencyLevelPolicy consistencyLevel, HConnectionManager connectionManager, FailoverPolicy failoverPolicy) throws HectorTransportException { super(keyspaceName, consistencyLevel, connectionManager, failoverPolicy); prefixBytes = keyPrefixSerializer.toByteBuffer(keyPrefix); ps = new PrefixedSerializer<ByteBuffer, ByteBuffer>(prefixBytes, be, be); }
@Test public void testBadPrefix() { if (str == null) { // null serialization is always null, // so no prefix comparison takes place to test return; } UUIDSerializer ue = new UUIDSerializer(); StringSerializer se = new StringSerializer(); PrefixedSerializer<UUID, String> pe1 = new PrefixedSerializer<UUID, String>( prefixUUID, ue, se); UUID testUUID = UUID.randomUUID(); Assert.assertNotSame(prefixUUID, testUUID); PrefixedSerializer<UUID, String> pe2 = new PrefixedSerializer<UUID, String>( testUUID, ue, se); String result = pe2.fromByteBuffer(pe1.toByteBuffer(str)); Assert.assertNull("Different prefixes should fail comparison", result); }
@Test public void testNoPrefix() { if (str == null) { // null serialization is always null, // so no prefix comparison takes place to test return; } UUIDSerializer ue = new UUIDSerializer(); StringSerializer se = new StringSerializer(); PrefixedSerializer<UUID, String> pe1 = new PrefixedSerializer<UUID, String>( prefixUUID, ue, se); UUID testUUID = UUID.randomUUID(); Assert.assertNotSame(prefixUUID, testUUID); PrefixedSerializer<UUID, String> pe2 = new PrefixedSerializer<UUID, String>( testUUID, ue, se); try { ByteBuffer bb = pe1.toByteBuffer(str); bb.limit(5); // bb.get(new byte[bb.limit() - 5]); pe2.fromByteBuffer(bb); Assert.fail("Lack of prefix should raise exception"); } catch (HectorSerializationException e) { // yea } } }
public VirtualKeyspaceCassandraClient(Client client, ByteBuffer prefixBytes) { super(client); this.prefixBytes = prefixBytes; ps = new PrefixedSerializer<ByteBuffer, ByteBuffer>(prefixBytes, be, be); }
public VirtualKeyspaceCassandraClient(Client client, ByteBuffer prefixBytes) { super(client); this.prefixBytes = prefixBytes; ps = new PrefixedSerializer<ByteBuffer, ByteBuffer>(prefixBytes, be, be); }
@Test public void test() { UUIDSerializer ue = new UUIDSerializer(); StringSerializer se = new StringSerializer(); PrefixedSerializer<UUID, String> pe = new PrefixedSerializer<UUID, String>( prefixUUID, ue, se); Assert.assertEquals(str, pe.fromByteBuffer(pe.toByteBuffer(str))); }
public <E> VirtualKeyspaceServiceImpl(String keyspaceName, E keyPrefix, Serializer<E> keyPrefixSerializer, ConsistencyLevelPolicy consistencyLevel, HConnectionManager connectionManager, FailoverPolicy failoverPolicy) throws HectorTransportException { super(keyspaceName, consistencyLevel, connectionManager, failoverPolicy); prefixBytes = keyPrefixSerializer.toByteBuffer(keyPrefix); ps = new PrefixedSerializer<ByteBuffer, ByteBuffer>(prefixBytes, be, be); }
public <E> VirtualKeyspaceServiceImpl(String keyspaceName, E keyPrefix, Serializer<E> keyPrefixSerializer, ConsistencyLevelPolicy consistencyLevel, HConnectionManager connectionManager, FailoverPolicy failoverPolicy) throws HectorTransportException { super(keyspaceName, consistencyLevel, connectionManager, failoverPolicy); prefixBytes = keyPrefixSerializer.toByteBuffer(keyPrefix); ps = new PrefixedSerializer<ByteBuffer, ByteBuffer>(prefixBytes, be, be); }
public <E> VirtualKeyspaceServiceImpl(String keyspaceName, E keyPrefix, Serializer<E> keyPrefixSerializer, ConsistencyLevelPolicy consistencyLevel, HConnectionManager connectionManager, FailoverPolicy failoverPolicy, Map<String, String> credentials) throws HectorTransportException { super(keyspaceName, consistencyLevel, connectionManager, failoverPolicy, credentials); prefixBytes = keyPrefixSerializer.toByteBuffer(keyPrefix); ps = new PrefixedSerializer<ByteBuffer, ByteBuffer>(prefixBytes, be, be); }
public <E> VirtualKeyspaceServiceImpl(String keyspaceName, E keyPrefix, Serializer<E> keyPrefixSerializer, ConsistencyLevelPolicy consistencyLevel, HConnectionManager connectionManager, FailoverPolicy failoverPolicy, Map<String, String> credentials) throws HectorTransportException { super(keyspaceName, consistencyLevel, connectionManager, failoverPolicy, credentials); prefixBytes = keyPrefixSerializer.toByteBuffer(keyPrefix); ps = new PrefixedSerializer<ByteBuffer, ByteBuffer>(prefixBytes, be, be); }