@Override public AstyanaxConfiguration getConfig() { return getPrimaryKS().getConfig(); }
@Override public long getCurrentTimestamp(Table tbl) { AstyanaxTable table = (AstyanaxTable) checkNotNull(tbl, "table"); AstyanaxStorage storage = table.getReadStorage(); CassandraKeyspace keyspace = storage.getPlacement().getKeyspace(); return keyspace.getAstyanaxKeyspace().getConfig().getClock().getCurrentTime(); }
private Keyspace pinToVerifiedHost(Host host) throws ConnectionException { //noinspection unchecked PinnedConnectionPool<Cassandra.Client> pinnedPool = new PinnedConnectionPool(_keyspace.getConnectionPool(), host); return new ThriftKeyspaceImpl( _keyspace.getKeyspaceName(), pinnedPool, _keyspace.getConfig(), EmptyKeyspaceTracerFactory.getInstance()); } }
private Keyspace pinToVerifiedHost(Host host) throws ConnectionException { //noinspection unchecked PinnedConnectionPool<Cassandra.Client> pinnedPool = new PinnedConnectionPool(_keyspace.getConnectionPool(), host); return new ThriftKeyspaceImpl( _keyspace.getKeyspaceName(), pinnedPool, _keyspace.getConfig(), EmptyKeyspaceTracerFactory.getInstance()); } }
/** * Gets the topology for a Cassandra keyspace as a Multimap, where the keys identify a rack (or availability zone * in Amazon) and the values are the token ranges for each host in that rack. For example, for a well distributed * ring of 12 hosts and a replication factor of 3 this method would return a Multimap with 3 keys and each key would * contain 4 token ranges. */ private Multimap<String, TokenRange> describeCassandraTopology(final Keyspace keyspace) { try { @SuppressWarnings ("unchecked") ConnectionPool<Cassandra.Client> connectionPool = (ConnectionPool<Cassandra.Client>) keyspace.getConnectionPool(); return connectionPool.executeWithFailover( new AbstractKeyspaceOperationImpl<Multimap<String, TokenRange>>(EmptyKeyspaceTracerFactory.getInstance().newTracer(CassandraOperationType.DESCRIBE_RING), keyspace.getKeyspaceName()) { @Override protected Multimap<String, TokenRange> internalExecute(Cassandra.Client client, ConnectionContext state) throws Exception { Multimap<String, TokenRange> racks = ArrayListMultimap.create(); for (org.apache.cassandra.thrift.TokenRange tokenRange : client.describe_local_ring(getKeyspace())) { // The final local endpoint "owns" the token range, the rest are for replication EndpointDetails endpointDetails = Iterables.getLast(tokenRange.getEndpoint_details()); racks.put(endpointDetails.getRack(), new TokenRangeImpl(tokenRange.getStart_token(), tokenRange.getEnd_token(), tokenRange.getEndpoints())); } return Multimaps.unmodifiableMultimap(racks); } }, keyspace.getConfig().getRetryPolicy().duplicate()).getResult(); } catch (ConnectionException e) { throw Throwables.propagate(e); } }
/** * Gets the topology for a Cassandra keyspace as a Multimap, where the keys identify a rack (or availability zone * in Amazon) and the values are the token ranges for each host in that rack. For example, for a well distributed * ring of 12 hosts and a replication factor of 3 this method would return a Multimap with 3 keys and each key would * contain 4 token ranges. */ private Multimap<String, TokenRange> describeCassandraTopology(final Keyspace keyspace) { try { @SuppressWarnings ("unchecked") ConnectionPool<Cassandra.Client> connectionPool = (ConnectionPool<Cassandra.Client>) keyspace.getConnectionPool(); return connectionPool.executeWithFailover( new AbstractKeyspaceOperationImpl<Multimap<String, TokenRange>>(EmptyKeyspaceTracerFactory.getInstance().newTracer(CassandraOperationType.DESCRIBE_RING), keyspace.getKeyspaceName()) { @Override protected Multimap<String, TokenRange> internalExecute(Cassandra.Client client, ConnectionContext state) throws Exception { Multimap<String, TokenRange> racks = ArrayListMultimap.create(); for (org.apache.cassandra.thrift.TokenRange tokenRange : client.describe_local_ring(getKeyspace())) { // The final local endpoint "owns" the token range, the rest are for replication EndpointDetails endpointDetails = Iterables.getLast(tokenRange.getEndpoint_details()); racks.put(endpointDetails.getRack(), new TokenRangeImpl(tokenRange.getStart_token(), tokenRange.getEnd_token(), tokenRange.getEndpoints())); } return Multimaps.unmodifiableMultimap(racks); } }, keyspace.getConfig().getRetryPolicy().duplicate()).getResult(); } catch (ConnectionException e) { throw Throwables.propagate(e); } }
/** * Gets the topology for a Cassandra keyspace as a Multimap, where the keys identify a rack (or availability zone * in Amazon) and the values are the token ranges for each host in that rack. For example, for a well distributed * ring of 12 hosts and a replication factor of 3 this method would return a Multimap with 3 keys and each key would * contain 4 token ranges. */ private Multimap<String, TokenRange> describeCassandraTopology(final Keyspace keyspace) { try { @SuppressWarnings ("unchecked") ConnectionPool<Cassandra.Client> connectionPool = (ConnectionPool<Cassandra.Client>) keyspace.getConnectionPool(); return connectionPool.executeWithFailover( new AbstractKeyspaceOperationImpl<Multimap<String, TokenRange>>(EmptyKeyspaceTracerFactory.getInstance().newTracer(CassandraOperationType.DESCRIBE_RING), keyspace.getKeyspaceName()) { @Override protected Multimap<String, TokenRange> internalExecute(Cassandra.Client client, ConnectionContext state) throws Exception { Multimap<String, TokenRange> racks = ArrayListMultimap.create(); for (org.apache.cassandra.thrift.TokenRange tokenRange : client.describe_local_ring(getKeyspace())) { // The final local endpoint "owns" the token range, the rest are for replication EndpointDetails endpointDetails = Iterables.getLast(tokenRange.getEndpoint_details()); racks.put(endpointDetails.getRack(), new TokenRangeImpl(tokenRange.getStart_token(), tokenRange.getEnd_token(), tokenRange.getEndpoints())); } return Multimaps.unmodifiableMultimap(racks); } }, keyspace.getConfig().getRetryPolicy().duplicate()).getResult(); } catch (ConnectionException e) { throw Throwables.propagate(e); } }
/** * Gets the topology for a Cassandra keyspace as a Multimap, where the keys identify a rack (or availability zone * in Amazon) and the values are the token ranges for each host in that rack. For example, for a well distributed * ring of 12 hosts and a replication factor of 3 this method would return a Multimap with 3 keys and each key would * contain 4 token ranges. */ private Multimap<String, TokenRange> describeCassandraTopology(final Keyspace keyspace) { try { @SuppressWarnings ("unchecked") ConnectionPool<Cassandra.Client> connectionPool = (ConnectionPool<Cassandra.Client>) keyspace.getConnectionPool(); return connectionPool.executeWithFailover( new AbstractKeyspaceOperationImpl<Multimap<String, TokenRange>>(EmptyKeyspaceTracerFactory.getInstance().newTracer(CassandraOperationType.DESCRIBE_RING), keyspace.getKeyspaceName()) { @Override protected Multimap<String, TokenRange> internalExecute(Cassandra.Client client, ConnectionContext state) throws Exception { Multimap<String, TokenRange> racks = ArrayListMultimap.create(); for (org.apache.cassandra.thrift.TokenRange tokenRange : client.describe_local_ring(getKeyspace())) { // The final local endpoint "owns" the token range, the rest are for replication EndpointDetails endpointDetails = Iterables.getLast(tokenRange.getEndpoint_details()); racks.put(endpointDetails.getRack(), new TokenRangeImpl(tokenRange.getStart_token(), tokenRange.getEnd_token(), tokenRange.getEndpoints())); } return Multimaps.unmodifiableMultimap(racks); } }, keyspace.getConfig().getRetryPolicy().duplicate()).getResult(); } catch (ConnectionException e) { throw Throwables.propagate(e); } }
/** * Initialize the client */ @Override public void init(DataGenerator dataGenerator) throws Exception { try { this.dataGenerator = dataGenerator; this.cluster = cassA6XManager.registerCluster(config.getCluster(), config.getHost(), config.getHostPort()); this.keyspace = cassA6XManager.registerKeyspace(config.getCluster(), config.getKeyspace(), config.getHost(), config.getHostPort()); AstyanaxConfigurationImpl aci = (AstyanaxConfigurationImpl) this.keyspace.getConfig(); aci.setDefaultReadConsistencyLevel(ConsistencyLevel.valueOf(config.getReadConsistencyLevel())) .setDefaultWriteConsistencyLevel(ConsistencyLevel.valueOf(config.getWriteConsistencyLevel())); CF = new ColumnFamily<>(config.getCfname(), StringSerializer.get(), IntegerSerializer.get(), StringSerializer.get()); if (config.getCreateSchema()) { logger.info("Trying to upsert schema"); preInit(); } } catch (ConnectionException e) { logger.error("Failed to initialize Astyanax driver"); throw e; } logger.info("Registered keyspace : " + this.keyspace.getKeyspaceName()); logger.info("Initialized CassAstyanaxPlugin"); }
/** * Initialize the client */ @Override public void init(DataGenerator dataGenerator) throws Exception { try { this.dataGenerator = dataGenerator; this.cluster = cassA6XManager.registerCluster(config.getCluster(), config.getHost(), config.getHostPort()); this.keyspace = cassA6XManager.registerKeyspace(config.getCluster(), config.getKeyspace(), config.getHost(), config.getHostPort()); AstyanaxConfigurationImpl aci = (AstyanaxConfigurationImpl) this.keyspace.getConfig(); aci.setDefaultReadConsistencyLevel(ConsistencyLevel.valueOf(config.getReadConsistencyLevel())) .setDefaultWriteConsistencyLevel(ConsistencyLevel.valueOf(config.getWriteConsistencyLevel())); CF = new ColumnFamily<>(config.getCfname(), StringSerializer.get(), IntegerSerializer.get(), StringSerializer.get()); if (config.getCreateSchema()) { logger.info("Trying to upsert schema"); preInit(); } } catch (ConnectionException e) { logger.error("Failed to initialize Astyanax driver"); throw e; } logger.info("Registered keyspace : " + this.keyspace.getKeyspaceName()); logger.info("Initialized CassAstyanaxPlugin"); }