@Override public OperationResult<SchemaChangeResult> exec(Keyspace ks) throws ConnectionException { return ks.dropKeyspace(); } });
@Test public void keyspaceDescribePartitioner() throws Exception { String keyspaceName = "AstyanaxTestKeyspaceDescribeRing".toLowerCase(); AstyanaxContext<Keyspace> context = AstyanaxContextFactory.getKeyspace(keyspaceName); context.start(); keyspace = context.getClient(); Map<String, Object> options = ImmutableMap.<String, Object>builder() .put("strategy_options", ImmutableMap.<String, Object>builder() .put("replication_factor", "1") .build()) .put("strategy_class", "SimpleStrategy") .build(); keyspace.createKeyspace(options); Thread.sleep(1000); String partitioner = keyspace.describePartitioner(); Assert.assertNotNull(partitioner); keyspace.dropKeyspace(); } }
@Test public void createAndDeleteKeyspace() throws Exception { String keyspaceName = "AstyanaxTestKeyspaceCreateDeleteKS".toLowerCase(); AstyanaxContext<Keyspace> context = AstyanaxContextFactory.getKeyspace(keyspaceName); context.start(); keyspace = context.getClient(); Map<String, Object> options = ImmutableMap.<String, Object>builder() .put("strategy_options", ImmutableMap.<String, Object>builder() .put("replication_factor", "1") .build()) .put("strategy_class", "SimpleStrategy") .build(); keyspace.createKeyspace(options); Thread.sleep(1000); KeyspaceDefinition ksDef = keyspace.describeKeyspace(); Assert.assertTrue(ksDef.getStrategyClass().contains("SimpleStrategy")); keyspace.dropKeyspace(); try { keyspace.describeKeyspace(); Assert.fail("Should have gotten KS not found ex"); } catch(RuntimeException e) { } }
Assert.assertEquals("32", String.valueOf(cfProps.get("max_compaction_threshold"))); keyspace.dropKeyspace();
@Test public void alterCFOptions() throws Exception { String keyspaceName = "AstyanaxTestKeyspaceAlterCFOptions".toLowerCase(); AstyanaxContext<Keyspace> context = AstyanaxContextFactory.getKeyspace(keyspaceName); context.start(); keyspace = context.getClient(); Map<String, Object> options = ImmutableMap.<String, Object>builder() .put("strategy_options", ImmutableMap.<String, Object>builder() .put("replication_factor", "1") .build()) .put("strategy_class", "SimpleStrategy") .build(); keyspace.createKeyspace(options); Thread.sleep(1000); ColumnFamily<String, String> cf = new ColumnFamily<String, String>("testaltercf1", StringSerializer.get(), StringSerializer.get()); keyspace.createColumnFamily(cf, null); Assert.assertEquals(0.1, keyspace.getColumnFamilyProperties("testaltercf1").get("read_repair_chance")); keyspace.updateColumnFamily(cf, ImmutableMap.<String, Object>builder() .put("read_repair_chance", 0.2) .build()); Assert.assertEquals(0.2, keyspace.getColumnFamilyProperties("testaltercf1").get("read_repair_chance")); keyspace.dropKeyspace(); }
keyspace.dropKeyspace(); verifyKeyspacePropertiesForNetworkTopology(keyspaceName, ksDef); keyspace.dropKeyspace();
Assert.assertEquals("2", ksDef.getStrategyOptions().get("replication_factor")); keyspace.dropKeyspace(); Assert.assertEquals("2", ksDef2.getStrategyOptions().get("eu-west")); keyspace.dropKeyspace();
verifyKeyspacePropertiesForSimpleStrategy(keyspaceName, ksDef); keyspace.dropKeyspace(); verifyKeyspacePropertiesForNetworkTopology(keyspaceName, ksDef); keyspace.dropKeyspace();
Assert.assertEquals(0.01, cfDef.getBloomFilterFpChance()); keyspace.dropKeyspace();
try { log.debug("dropping Cassandra keyspace "+keyspace); keyspace.dropKeyspace(); } catch (Exception e) {