public void destroy() throws Exception { if (cluster != null) { HConnectionManager connectionManager = cluster.getConnectionManager(); if (connectionManager != null) { connectionManager.shutdown(); } } cluster = null; } }
public static <E> Keyspace createVirtualKeyspace(String keyspace, E keyPrefix, Serializer<E> keyPrefixSerializer, Cluster cluster, ConsistencyLevelPolicy consistencyLevelPolicy, FailoverPolicy failoverPolicy, Map<String, String> credentials) { return new ExecutingVirtualKeyspace<E>(keyspace, keyPrefix, keyPrefixSerializer, cluster.getConnectionManager(), consistencyLevelPolicy, failoverPolicy, credentials); }
/** * Creates a Keyspace with the given consistency level, fail over policy * and user credentials. For a reference to the consistency level, please * refer to http://wiki.apache.org/cassandra/API. * * @param keyspace * @param cluster * @param consistencyLevelPolicy * @param credentials * @return */ public static Keyspace createKeyspace(String keyspace, Cluster cluster, ConsistencyLevelPolicy consistencyLevelPolicy, FailoverPolicy failoverPolicy, Map<String, String> credentials) { return new ExecutingKeyspace(keyspace, cluster.getConnectionManager(), consistencyLevelPolicy, failoverPolicy, credentials); }
/** * Shutdown this cluster, removing it from the Map. This operation is * extremely expensive and should not be done lightly. * @param cluster */ public static void shutdownCluster(Cluster cluster) { synchronized (clusters) { String clusterName = cluster.getName(); if (clusters.get(clusterName) != null ) { cluster.getConnectionManager().shutdown(); clusters.remove(clusterName); } } }
public static <E> Keyspace createVirtualKeyspace(String keyspace, E keyPrefix, Serializer<E> keyPrefixSerializer, Cluster cluster, ConsistencyLevelPolicy consistencyLevelPolicy, FailoverPolicy failoverPolicy) { return new ExecutingVirtualKeyspace<E>(keyspace, keyPrefix, keyPrefixSerializer, cluster.getConnectionManager(), consistencyLevelPolicy, failoverPolicy, cluster.getCredentials()); }
/** * Creates a Keyspace with the given consistency level. For a reference * to the consistency level, please refer to http://wiki.apache.org/cassandra/API. * * @param keyspace * @param cluster * @param consistencyLevelPolicy * @param failoverPolicy * @return */ public static Keyspace createKeyspace(String keyspace, Cluster cluster, ConsistencyLevelPolicy consistencyLevelPolicy, FailoverPolicy failoverPolicy) { return new ExecutingKeyspace(keyspace, cluster.getConnectionManager(), consistencyLevelPolicy, failoverPolicy, cluster.getCredentials()); }
public static void main(String[] args) { Cluster cluster = HFactory.getOrCreateCluster("TestPool", "localhost:9160"); Keyspace keyspace = HFactory.createKeyspace("TestKeyspace", cluster); try { EntityManagerImpl em = new EntityManagerImpl(keyspace, "com.mycompany"); MyPojo pojo1 = new MyPojo(); pojo1.setId(UUID.randomUUID()); pojo1.setLongProp1(123L); pojo1.setColor(Colors.RED); em.persist(pojo1); // do some stuff MyPojo pojo2 = em.find(MyPojo.class, pojo1.getId()); // do some more stuff System.out.println("Color = " + pojo2.getColor()); } finally { cluster.getConnectionManager().shutdown(); } } }
public static <E> Keyspace createVirtualKeyspace(String keyspace, E keyPrefix, Serializer<E> keyPrefixSerializer, Cluster cluster, ConsistencyLevelPolicy consistencyLevelPolicy, FailoverPolicy failoverPolicy, Map<String, String> credentials) { return new ExecutingVirtualKeyspace<E>(keyspace, keyPrefix, keyPrefixSerializer, cluster.getConnectionManager(), consistencyLevelPolicy, failoverPolicy, credentials); }
public static <E> Keyspace createVirtualKeyspace(String keyspace, E keyPrefix, Serializer<E> keyPrefixSerializer, Cluster cluster, ConsistencyLevelPolicy consistencyLevelPolicy, FailoverPolicy failoverPolicy, Map<String, String> credentials) { return new ExecutingVirtualKeyspace<E>(keyspace, keyPrefix, keyPrefixSerializer, cluster.getConnectionManager(), consistencyLevelPolicy, failoverPolicy, credentials); }
/** * Creates a Keyspace with the given consistency level, fail over policy * and user credentials. For a reference to the consistency level, please * refer to http://wiki.apache.org/cassandra/API. * * @param keyspace * @param cluster * @param consistencyLevelPolicy * @param credentials * @return */ public static Keyspace createKeyspace(String keyspace, Cluster cluster, ConsistencyLevelPolicy consistencyLevelPolicy, FailoverPolicy failoverPolicy, Map<String, String> credentials) { return new ExecutingKeyspace(keyspace, cluster.getConnectionManager(), consistencyLevelPolicy, failoverPolicy, credentials); }
/** * Creates a Keyspace with the given consistency level, fail over policy * and user credentials. For a reference to the consistency level, please * refer to http://wiki.apache.org/cassandra/API. * * @param keyspace * @param cluster * @param consistencyLevelPolicy * @param credentials * @return */ public static Keyspace createKeyspace(String keyspace, Cluster cluster, ConsistencyLevelPolicy consistencyLevelPolicy, FailoverPolicy failoverPolicy, Map<String, String> credentials) { return new ExecutingKeyspace(keyspace, cluster.getConnectionManager(), consistencyLevelPolicy, failoverPolicy, credentials); }
/** * Shutdown this cluster, removing it from the Map. This operation is * extremely expensive and should not be done lightly. * @param cluster */ public static void shutdownCluster(Cluster cluster) { synchronized (clusters) { String clusterName = cluster.getName(); if (clusters.get(clusterName) != null ) { cluster.getConnectionManager().shutdown(); clusters.remove(clusterName); } } }
/** * Shutdown this cluster, removing it from the Map. This operation is * extremely expensive and should not be done lightly. * @param cluster */ public static void shutdownCluster(Cluster cluster) { synchronized (clusters) { String clusterName = cluster.getName(); if (clusters.get(clusterName) != null ) { cluster.getConnectionManager().shutdown(); clusters.remove(clusterName); } } }
public static <E> Keyspace createVirtualKeyspace(String keyspace, E keyPrefix, Serializer<E> keyPrefixSerializer, Cluster cluster, ConsistencyLevelPolicy consistencyLevelPolicy, FailoverPolicy failoverPolicy) { return new ExecutingVirtualKeyspace<E>(keyspace, keyPrefix, keyPrefixSerializer, cluster.getConnectionManager(), consistencyLevelPolicy, failoverPolicy, cluster.getCredentials()); }
public static <E> Keyspace createVirtualKeyspace(String keyspace, E keyPrefix, Serializer<E> keyPrefixSerializer, Cluster cluster, ConsistencyLevelPolicy consistencyLevelPolicy, FailoverPolicy failoverPolicy) { return new ExecutingVirtualKeyspace<E>(keyspace, keyPrefix, keyPrefixSerializer, cluster.getConnectionManager(), consistencyLevelPolicy, failoverPolicy, cluster.getCredentials()); }
/** * Creates a Keyspace with the given consistency level. For a reference * to the consistency level, please refer to http://wiki.apache.org/cassandra/API. * * @param keyspace * @param cluster * @param consistencyLevelPolicy * @param failoverPolicy * @return */ public static Keyspace createKeyspace(String keyspace, Cluster cluster, ConsistencyLevelPolicy consistencyLevelPolicy, FailoverPolicy failoverPolicy) { return new ExecutingKeyspace(keyspace, cluster.getConnectionManager(), consistencyLevelPolicy, failoverPolicy, cluster.getCredentials()); }
/** * Creates a Keyspace with the given consistency level. For a reference * to the consistency level, please refer to http://wiki.apache.org/cassandra/API. * * @param keyspace * @param cluster * @param consistencyLevelPolicy * @param failoverPolicy * @return */ public static Keyspace createKeyspace(String keyspace, Cluster cluster, ConsistencyLevelPolicy consistencyLevelPolicy, FailoverPolicy failoverPolicy) { return new ExecutingKeyspace(keyspace, cluster.getConnectionManager(), consistencyLevelPolicy, failoverPolicy, cluster.getCredentials()); }
public static void main(String[] args) throws Exception { Cluster cluster = HFactory.getOrCreateCluster("TestCluster", "localhost:9160"); Keyspace keyspaceOperator = HFactory.createKeyspace("Keyspace1", cluster); try { Mutator<String> mutator = HFactory.createMutator(keyspaceOperator, stringSerializer); mutator.insert("billing", "Super1", HFactory.createSuperColumn("jsmith", Arrays.asList(HFactory.createStringColumn("first", "John")), stringSerializer, stringSerializer, stringSerializer)); SuperColumnQuery<String, String, String, String> superColumnQuery = HFactory.createSuperColumnQuery(keyspaceOperator, stringSerializer, stringSerializer, stringSerializer, stringSerializer); superColumnQuery.setColumnFamily("Super1").setKey("billing").setSuperName("jsmith"); QueryResult<HSuperColumn<String, String, String>> result = superColumnQuery.execute(); System.out.println("Read HSuperColumn from cassandra: " + result.get()); System.out.println("Verify on CLI with: get Keyspace1.Super1['billing']['jsmith'] "); } catch (HectorException e) { e.printStackTrace(); } cluster.getConnectionManager().shutdown(); } }
public static void main(String[] args) throws Exception { Cluster cluster = HFactory.getOrCreateCluster("TestCluster", "localhost:9160"); Keyspace keyspaceOperator = HFactory.createKeyspace("Keyspace1", cluster); try { Mutator<String> mutator = HFactory.createMutator(keyspaceOperator, StringSerializer.get()); mutator.insert("jsmith", "Standard1", HFactory.createStringColumn("first", "John")); ColumnQuery<String, String, String> columnQuery = HFactory.createStringColumnQuery(keyspaceOperator); columnQuery.setColumnFamily("Standard1").setKey("jsmith").setName("first"); QueryResult<HColumn<String, String>> result = columnQuery.execute(); System.out.println("Read HColumn from cassandra: " + result.get()); System.out.println("Verify on CLI with: get Keyspace1.Standard1['jsmith'] "); } catch (HectorException e) { e.printStackTrace(); } cluster.getConnectionManager().shutdown(); }
he.printStackTrace(); cluster.getConnectionManager().shutdown();