private ThriftKsDef toThriftImplementation(final KeyspaceDefinition cfdef) { if(cfdef instanceof ThriftKsDef) { return (ThriftKsDef) cfdef; } else { return new ThriftKsDef(cfdef); } } }
/** * Use createKeyspaceDefinition to add a new Keyspace to cluster. Example: * * String testKeyspace = "testKeyspace"; KeyspaceDefinition newKeyspace = * HFactory.createKeyspaceDefinition(testKeyspace); * cluster.addKeyspace(newKeyspace); * * @param keyspace */ public static KeyspaceDefinition createKeyspaceDefinition(String keyspace) { return new ThriftKsDef(keyspace); }
/** * Use createKeyspaceDefinition to add a new Keyspace to cluster. Example: * * String testKeyspace = "testKeyspace"; KeyspaceDefinition newKeyspace = * HFactory.createKeyspaceDefinition(testKeyspace); * cluster.addKeyspace(newKeyspace); * * @param keyspaceName * @param strategyClass * - example: * org.apache.cassandra.locator.SimpleStrategy.class.getName() * @param replicationFactor * - http://wiki.apache.org/cassandra/Operations */ public static KeyspaceDefinition createKeyspaceDefinition( String keyspaceName, String strategyClass, int replicationFactor, List<ColumnFamilyDefinition> cfDefs) { return new ThriftKsDef(keyspaceName, strategyClass, replicationFactor, cfDefs); }
public static List<KeyspaceDefinition> fromThriftList(List<KsDef> ks) { if (ks == null || ks.isEmpty()) { return Collections.emptyList(); } List<KeyspaceDefinition> l = new ArrayList<KeyspaceDefinition>(ks.size()); for (KsDef k: ks) { l.add(new ThriftKsDef(k)); } return l; }
@Override public KeyspaceDefinition execute(Cassandra.Client cassandra) throws HectorException { try { return new ThriftKsDef(cassandra.describe_keyspace(keyspace)); } catch (org.apache.cassandra.thrift.NotFoundException nfe) { setException(xtrans.translate(nfe)); return null; } catch (Exception e) { throw xtrans.translate(e); } } };
@Test public void testAddKeyspaceNTS() throws Exception { ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition("DynKeyspaceNTS", "DynCf"); cassandraCluster.addKeyspace( new ThriftKsDef("DynKeyspaceNTS", "org.apache.cassandra.locator.NetworkTopologyStrategy", 1, Arrays.asList(cfDef))); }
@Test public void testAddDropKeyspace() throws Exception { ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition("DynKeyspace", "DynCf"); cassandraCluster.addKeyspace( new ThriftKsDef("DynKeyspace", "org.apache.cassandra.locator.SimpleStrategy", 1, Arrays.asList(cfDef))); String ksid2 = cassandraCluster.dropKeyspace("DynKeyspace"); assertNotNull(ksid2); // Now let's wait for schema agreement. cassandraCluster.addKeyspace(new ThriftKsDef("DynKeyspace", "org.apache.cassandra.locator.SimpleStrategy", 1, Arrays.asList(cfDef)), true); ksid2 = cassandraCluster.dropKeyspace("DynKeyspace", true); assertNotNull(ksid2); }
public static void createKeyspace(Cluster cluster, String name, String strategy, int replicationFactor, List<CfDef> cfDefList) { try { KsDef ksDef = new KsDef(name, strategy, cfDefList); ksDef.setReplication_factor(replicationFactor); cluster.addKeyspace(new ThriftKsDef(ksDef)); return; } catch (Throwable e) { System.out.println("exception while creating keyspace, " + name + " - probably already exists : " + e.getMessage()); } for (CfDef cfDef : cfDefList) { try { cluster.addColumnFamily(new ThriftCfDef(cfDef)); } catch (Throwable e) { System.out.println("exception while creating CF, " + cfDef.getName() + " - probably already exists : " + e.getMessage()); } } }
/** * Use createKeyspaceDefinition to add a new Keyspace to cluster. Example: * * String testKeyspace = "testKeyspace"; KeyspaceDefinition newKeyspace = * HFactory.createKeyspaceDefinition(testKeyspace); * cluster.addKeyspace(newKeyspace); * * @param keyspace */ public static KeyspaceDefinition createKeyspaceDefinition(String keyspace) { return new ThriftKsDef(keyspace); }
private ThriftKsDef toThriftImplementation(final KeyspaceDefinition cfdef) { if(cfdef instanceof ThriftKsDef) { return (ThriftKsDef) cfdef; } else { return new ThriftKsDef(cfdef); } } }
/** * Use createKeyspaceDefinition to add a new Keyspace to cluster. Example: * * String testKeyspace = "testKeyspace"; KeyspaceDefinition newKeyspace = * HFactory.createKeyspaceDefinition(testKeyspace); * cluster.addKeyspace(newKeyspace); * * @param keyspace */ public static KeyspaceDefinition createKeyspaceDefinition(String keyspace) { return new ThriftKsDef(keyspace); }
private ThriftKsDef toThriftImplementation(final KeyspaceDefinition cfdef) { if(cfdef instanceof ThriftKsDef) { return (ThriftKsDef) cfdef; } else { return new ThriftKsDef(cfdef); } } }
@Test public void testAddDropKeyspace() throws Exception { ThriftCluster cassandraCluster = new ThriftCluster("Test Cluster", cassandraHostConfigurator, user1Credentials); ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition("DynKeyspace", "DynCf"); cassandraCluster.addKeyspace( new ThriftKsDef("DynKeyspace", "org.apache.cassandra.locator.SimpleStrategy", 1, Arrays.asList(cfDef))); String ksid2 = cassandraCluster.dropKeyspace("DynKeyspace"); assertNotNull(ksid2); }
@Test public void testAddEmptyKeyspace() throws Exception { cassandraCluster.addKeyspace(new ThriftKsDef("DynKeyspaceEmpty")); assertNotNull(cassandraCluster.describeKeyspace("DynKeyspaceEmpty")); String ksid2 = cassandraCluster.dropKeyspace("DynKeyspaceEmpty"); assertNotNull(ksid2); }
@Before public void setUp() throws Exception { super.setupClient(); KEYSPACE_DEV = new ThriftKsDef(new KsDef(KEYSPACE, "org.apache.cassandra.locator.SimpleStrategy", Arrays.asList(new CfDef[] { BLOB_CF_DEF }))); ((ThriftKsDef)KEYSPACE_DEV).setReplicationFactor(1); cassandraHostConfigurator = new CassandraHostConfigurator("localhost:9170"); cassandraCluster = new ThriftCluster("Test Cluster", cassandraHostConfigurator); keyspace = HFactory.createKeyspace(KEYSPACE, cassandraCluster); try { cassandraCluster.dropKeyspace(KEYSPACE); } catch (Exception e) { } cassandraCluster.addKeyspace(KEYSPACE_DEV); }
public static List<KeyspaceDefinition> fromThriftList(List<KsDef> ks) { if (ks == null || ks.isEmpty()) { return Collections.emptyList(); } List<KeyspaceDefinition> l = new ArrayList<KeyspaceDefinition>(ks.size()); for (KsDef k: ks) { l.add(new ThriftKsDef(k)); } return l; }
public static List<KeyspaceDefinition> fromThriftList(List<KsDef> ks) { if (ks == null || ks.isEmpty()) { return Collections.emptyList(); } List<KeyspaceDefinition> l = new ArrayList<KeyspaceDefinition>(ks.size()); for (KsDef k: ks) { l.add(new ThriftKsDef(k)); } return l; }
@Override public KeyspaceDefinition execute(Cassandra.Client cassandra) throws HectorException { try { return new ThriftKsDef(cassandra.describe_keyspace(keyspace)); } catch (org.apache.cassandra.thrift.NotFoundException nfe) { setException(xtrans.translate(nfe)); return null; } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public KeyspaceDefinition execute(Cassandra.Client cassandra) throws HectorException { try { return new ThriftKsDef(cassandra.describe_keyspace(keyspace)); } catch (org.apache.cassandra.thrift.NotFoundException nfe) { setException(xtrans.translate(nfe)); return null; } catch (Exception e) { throw xtrans.translate(e); } } };
public static void createKeyspace(Cluster cluster, String name, String strategy, int replicationFactor, List<CfDef> cfDefList) { try { KsDef ksDef = new KsDef(name, strategy, cfDefList); cluster.addKeyspace(new ThriftKsDef(ksDef)); return; } catch (Throwable e) { System.out.println("exception while creating keyspace, " + name + " - probably already exists : " + e.getMessage()); } /* * for (CfDef cfDef : cfDefList) { try { cluster.addColumnFamily(new * ThriftCfDef(cfDef)); } catch (Throwable e) { * System.out.println("exception while creating CF, " + cfDef.getName() + * " - probably already exists : " + e.getMessage()); } } */ }