Package me.prettyprint.hector.api

Examples of me.prettyprint.hector.api.Cluster


                        .withCassandaYamlFile(cassandraYaml)
                        .build();
            }

            CassandraHostConfigurator configurator = new CassandraHostConfigurator(cassandraHostname + ":" + cassandraPort);
            Cluster cluster = HFactory.getOrCreateCluster(cassandraClusterName, configurator);
            me.prettyprint.hector.api.Keyspace keyspace = HFactory.createKeyspace(cassandraKeySpaceName, cluster);
            return keyspace;
        }
        catch (Exception e) {
            throw new RuntimeException("Error configuring access", e);
View Full Code Here


        cfDefList.add(new CfDef("TestKeyspace", "TestBeanColumnFamily").setComparator_type(BytesType.class.getSimpleName())
            .setKey_cache_size(0).setRow_cache_size(0).setGc_grace_seconds(86400));
        cfDefList.add(new CfDef("TestKeyspace", "CustomIdColumnFamily").setComparator_type(BytesType.class.getSimpleName())
            .setKey_cache_size(0).setRow_cache_size(0).setGc_grace_seconds(86400));
     
        Cluster cluster = HFactory.getOrCreateCluster("TestPool", "localhost:9161");
        createKeyspace(cluster, "TestKeyspace", "org.apache.cassandra.locator.SimpleStrategy", 1, cfDefList);
        keyspace = HFactory.createKeyspace("TestKeyspace", cluster);
      }
View Full Code Here

  }

  public static Cluster getOrCreateCluster(String clusterName,
      CassandraHostConfigurator cassandraHostConfigurator) {
    synchronized (clusters) {
      Cluster c = clusters.get(clusterName);
      if (c == null) {
        c = createCluster(clusterName, cassandraHostConfigurator);
        clusters.put(clusterName, c);
      }
      return c;
View Full Code Here

    embedded.teardown();
  }

  @Test
  public void testInsertGetDelete() throws HectorException {
    Cluster c = getOrCreateCluster("MyCluster", "localhost:9170");
    ExampleDaoV2 dao = new ExampleDaoV2(createKeyspace("Keyspace1", c));
    assertNull(dao.get("key", StringSerializer.get()));
    dao.insert("key", "value", StringSerializer.get());
    assertEquals("value", dao.get("key", StringSerializer.get()));
    dao.delete(StringSerializer.get(), "key");
View Full Code Here

    assertNull(dao.get("key", StringSerializer.get()));
  }

  @Test
  public void testMultiInsertGetDelete() throws HectorException {
    Cluster c = getOrCreateCluster("MyCluster", "localhost:9170");
    ExampleDaoV2 dao = new ExampleDaoV2(createKeyspace("Keyspace1", c));

    // Get non-existing values
    Map<String, String> ret = dao.getMulti(StringSerializer.get(), "key1", "key2");
    assertNotNull(ret);
View Full Code Here


public class MainProg {

  public static void main(String[] args) {
    Cluster cluster = HFactory.getOrCreateCluster("TestPool", "localhost:9160");
    Keyspace keyspace = HFactory.createKeyspace("TestKeyspace", cluster);

    EntityManagerImpl em = new EntityManagerImpl(keyspace, "com.mycompany");

    MyPojo pojo1 = new MyPojo();
View Full Code Here

    startCassandraInstance("target/cassandra-data");
    ArrayList<CfDef> cfDefList = new ArrayList<CfDef>(2);
    cfDefList.add(new CfDef("TestKeyspace", "Furniture").setComparator_type(BytesType.class.getSimpleName())
        .setKey_cache_size(0).setRow_cache_size(0).setGc_grace_seconds(86400));

    Cluster cluster = HFactory.getOrCreateCluster("TestPool", "localhost:9170");
    createKeyspace(cluster, "TestKeyspace", "org.apache.cassandra.locator.SimpleStrategy", 1, cfDefList);
    keyspace = HFactory.createKeyspace("TestKeyspace", cluster);

    entityMgr = new EntityManagerImpl(keyspace, "com.mycompany.furniture");
  }
View Full Code Here

        out.close();
    }

    private Keyspace getKeyspace() {
        Cluster cassandraCluster = HFactory.createCluster(
                Constants.CLUSTER_NAME, new CassandraHostConfigurator(Constants.CLUSTER_HOST), credentials);

        if (cassandraCluster.describeKeyspace(Constants.KEYSPACE_NAME) == null) {
            BasicColumnFamilyDefinition columnFamilyDefinition = new BasicColumnFamilyDefinition();
            columnFamilyDefinition.setKeyspaceName(Constants.KEYSPACE_NAME);
            columnFamilyDefinition.setName(Constants.COL_FAMILY_NAME);
            columnFamilyDefinition.setComparatorType(ComparatorType.LONGTYPE);

            ColumnFamilyDefinition cfDef = new ThriftCfDef(columnFamilyDefinition);

            KeyspaceDefinition keyspaceDefinition =
                    HFactory.createKeyspaceDefinition(Constants.KEYSPACE_NAME,
                                                      SimpleStrategy.class.getName(), 1, Arrays.asList(cfDef));

            cassandraCluster.addKeyspace(keyspaceDefinition);
        }

        Keyspace friendListKS = HFactory.createKeyspace(Constants.KEYSPACE_NAME, cassandraCluster);
        //cassandraCluster.getConnectionManager().shutdown(); // shutdown the connection 
        return friendListKS;
View Full Code Here

        }

        String username = clusterInformation.getUsername();
        String clusterName = clusterInformation.getClusterName();

        Cluster cluster = clusterRepository.getCluster(username, clusterName);
        if (cluster == null) {

            synchronized (lock) {
                cluster = clusterRepository.getCluster(username, clusterName);
                if (cluster != null) {
View Full Code Here

     */
    public boolean deleteKeyspace(String keyspaceName) throws CassandraServerManagementException {

        validateKeyspace(keyspaceName);
        try {
            Cluster cluster = getCluster(null);
            cluster.dropKeyspace(keyspaceName.trim());
        } catch (HectorException e) {
            throw new CassandraServerManagementException("Error removing a keyspace with the name :" + keyspaceName, e, log);
        }
        return true;
    }
View Full Code Here

TOP

Related Classes of me.prettyprint.hector.api.Cluster

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.