public void init() throws Exception { SYSTEM_KEYSPACE = properties.getProperty( "cassandra.system.keyspace" ,"Usergrid"); STATIC_APPLICATION_KEYSPACE = properties.getProperty( "cassandra.application.keyspace","Usergrid_Applications" ); if ( consistencyLevelPolicy == null ) { consistencyLevelPolicy = new ConfigurableConsistencyLevel(); ( ( ConfigurableConsistencyLevel ) consistencyLevelPolicy ) .setDefaultReadConsistencyLevel( HConsistencyLevel.ONE ); } accessMap = new HashMap<String, String>( 2 ); accessMap.put( "username", properties.getProperty( "cassandra.username" ) ); accessMap.put( "password", properties.getProperty( "cassandra.password" ) ); systemKeyspace = HFactory.createKeyspace( getApplicationKeyspace() , cluster, consistencyLevelPolicy, ON_FAIL_TRY_ALL_AVAILABLE, accessMap ); final int flushSize = getIntValue( properties, "cassandra.mutation.flushsize", 2000 ); CountingMutator.MAX_SIZE = flushSize; }
@Override public HColumnFamily<K, N> setReadConsistencyLevel(HConsistencyLevel readLevel) { consistencyLevelPolicy.setDefaultReadConsistencyLevel(readLevel); return this; }
private Keyspace keyspace(final String host, final String clusterName, final String keyspaceName, final String consistency) { if (clusterName == null) { throw new IllegalArgumentException("cluster name can't be null"); } if (keyspaceName == null) { throw new IllegalArgumentException("keyspace name can't be null"); } if (host == null) { throw new IllegalArgumentException("host can't be null"); } final ConfigurableConsistencyLevel consistencyLevelPolicy = new ConfigurableConsistencyLevel(); if (consistency == null) { consistencyLevelPolicy.setDefaultReadConsistencyLevel(HConsistencyLevel.QUORUM); } else { consistencyLevelPolicy.setDefaultReadConsistencyLevel(HConsistencyLevel.valueOf(consistency.toUpperCase())); } final ThriftCluster cluster = new ThriftCluster(clusterName, new CassandraHostConfigurator(host)); return HFactory.createKeyspace(keyspaceName, cluster, consistencyLevelPolicy); }
@Override public HColumnFamily<K, N> setReadConsistencyLevel(HConsistencyLevel readLevel) { consistencyLevelPolicy.setDefaultReadConsistencyLevel(readLevel); return this; }
@Override public HColumnFamily<K, N> setReadConsistencyLevel(HConsistencyLevel readLevel) { consistencyLevelPolicy.setDefaultReadConsistencyLevel(readLevel); return this; }
protected static void init() { properties = new Properties(); try { properties.load(TutorialBase.class.getResourceAsStream("/tutorial.properties")); } catch (IOException ioe) { ioe.printStackTrace(); } // To modify the default ConsistencyLevel of QUORUM, create a // me.prettyprint.hector.api.ConsistencyLevelPolicy and use the overloaded form: // tutorialKeyspace = HFactory.createKeyspace("Tutorial", tutorialCluster, consistencyLevelPolicy); // see also me.prettyprint.cassandra.model.ConfigurableConsistencyLevelPolicy[Test] for details tutorialCluster = HFactory.getOrCreateCluster(properties.getProperty("cluster.name", "TutorialCluster"), properties.getProperty("cluster.hosts", "127.0.0.1:9160")); ConfigurableConsistencyLevel ccl = new ConfigurableConsistencyLevel(); ccl.setDefaultReadConsistencyLevel(HConsistencyLevel.ONE); tutorialKeyspace = HFactory.createKeyspace(properties.getProperty("tutorial.keyspace", "Tutorial"), tutorialCluster, ccl); } }
clc = new ConfigurableConsistencyLevel(); try { clc.setDefaultReadConsistencyLevel(HConsistencyLevel.valueOf(levels[0])); clc.setDefaultWriteConsistencyLevel(HConsistencyLevel.valueOf(levels[1])); } catch (Exception e) {
ccl.setDefaultReadConsistencyLevel(HConsistencyLevel.valueOf(opConsisLvl)); LOG.debug("Hector read consistency configured to '" + opConsisLvl + "'."); opConsisLvl = (writeOpConsLvl!=null || !writeOpConsLvl.isEmpty())?writeOpConsLvl:DEFAULT_HECTOR_CONSIS_LEVEL;
consistencyLevelPolicy.setDefaultReadConsistencyLevel(builder.getReadConsistencyLevel()); consistencyLevelPolicy.setDefaultWriteConsistencyLevel(builder.getWriteConsistencyLevel()); keyspace = HFactory.createKeyspace(keyspaceName, cluster, consistencyLevelPolicy);
consistencyLevelPolicy.setDefaultReadConsistencyLevel(builder.getReadConsistencyLevel()); consistencyLevelPolicy.setDefaultWriteConsistencyLevel(builder.getWriteConsistencyLevel()); keyspace = HFactory.createKeyspace(keyspaceName, cluster, consistencyLevelPolicy);
consistencyLevelPolicy.setDefaultReadConsistencyLevel( HConsistencyLevel.valueOf( readConsistencyLevel ) ); consistencyLevelPolicy.setDefaultWriteConsistencyLevel( HConsistencyLevel.valueOf( writeConsistencyLevel ) ); keyspace = HFactory.createKeyspace( keyspaceName, cluster, consistencyLevelPolicy );