me.prettyprint.cassandra.serializers.BytesArraySerializer Java Examples
The following examples show how to use
me.prettyprint.cassandra.serializers.BytesArraySerializer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CassandraPersistentActorRepository.java From elasticactors with Apache License 2.0 | 6 votes |
private HColumn<String,byte[]> querySingleColumnWithRetry(final ShardKey shard,final String actorId) { // try three times, and log a warning when we exceed the readExecutionThreshold final long startTime = currentTimeMillis(); int attemptsRemaining = 3; try { while (true) { attemptsRemaining--; try { return columnFamilyTemplate.querySingleColumn(createKey(shard), actorId, BytesArraySerializer.get()); } catch (HTimedOutException | HPoolRecoverableException e) { if (attemptsRemaining <= 0) { throw e; } } } } finally { final long endTime = currentTimeMillis(); if((endTime - startTime) > readExecutionThresholdMillis) { logger.warn("Cassandra read operation took {} msecs ({} retries) for actorId [{}] on shard [{}]", (endTime - startTime), (2 - attemptsRemaining), actorId, shard); } } }
Example #2
Source File: Cassandra12xMapDAO.java From cumulusrdf with Apache License 2.0 | 5 votes |
@Override public void createRequiredSchemaEntities() throws DataAccessLayerException { final String keyspace_name = _keyspace.getKeyspaceName(); final KeyspaceDefinition ksdef = _factory.getCluster().describeKeyspace(keyspace_name); if (!hasColumnFamily(ksdef, _cf_name)) { final ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(keyspace_name, _cf_name); final Map<String, String> compressionOptions = new HashMap<String, String>(); compressionOptions.put("sstable_compression", "SnappyCompressor"); cfDef.setCompressionOptions(compressionOptions); cfDef.setColumnType(ColumnType.STANDARD); cfDef.setKeyValidationClass(ComparatorType.BYTESTYPE.getClassName()); cfDef.setDefaultValidationClass(ComparatorType.BYTESTYPE.getClassName()); cfDef.setCompactionStrategy("LeveledCompactionStrategy"); if (_isBidirectional) { BasicColumnDefinition colDef = new BasicColumnDefinition(); colDef.setName(BytesArraySerializer.get().toByteBuffer(COLUMN_NAME)); colDef.setValidationClass(ComparatorType.BYTESTYPE.getClassName()); colDef.setIndexType(ColumnIndexType.KEYS); colDef.setIndexName(_cf_name + "_val_idx"); cfDef.addColumnDefinition(colDef); } _factory.getCluster().addColumnFamily(new ThriftCfDef(cfDef), true); } }