Package me.prettyprint.hector.api

Examples of me.prettyprint.hector.api.Cluster


    assertResultsAreSortedAccordingToComparator(results);
  }

  @Test
  public void writeAndReadFromCfCreatedUsingHector() {
    final Cluster cluster = HFactory.getOrCreateCluster("TestCluster", new CassandraHostConfigurator("localhost:9170"));
    final Keyspace keyspace = HFactory.createKeyspace(KEYSPACE_NAME, cluster);

    final String columnFamily = "manuallyCreated";
    createColumnFamily(cluster, columnFamily);
View Full Code Here


  public CassandraUnit cassandra = new CassandraUnit(new ClassPathXmlDataSet("xml/dataSetDefaultValues.xml"), "another-cassandra.yaml", "localhost:9175");
 
  @Test
    @Ignore // Does not support the start of two configurations in the same JVM Instance
    public void shouldStartCassandraServer ()  {
        Cluster cluster = HFactory.getOrCreateCluster("anotherCluster", "localhost:9175");
        KeyspaceDefinition keyspaceDefinition = cluster.describeKeyspace("system");
        assertThat(keyspaceDefinition, notNullValue());

    }
View Full Code Here

  }

  @Test
    @Ignore // Does not support the start of two configurations in the same JVM Instance
    public void shouldStartCassandraServer ()  {
        Cluster cluster = HFactory.getOrCreateCluster("anotherCluster", "localhost:9175");
        KeyspaceDefinition keyspaceDefinition = cluster.describeKeyspace("system");
        assertThat(keyspaceDefinition, notNullValue());

    }
View Full Code Here

        EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
  }

  private void testIfTheEmbeddedCassandraServerIsUpOnHost(String hostAndPort) {
        Random random = new Random();
    Cluster cluster = HFactory.getOrCreateCluster("TestCluster" + random.nextInt(), new CassandraHostConfigurator(hostAndPort));
    assertThat(cluster.getConnectionManager().getActivePools().size(), is(1));
    KeyspaceDefinition keyspaceDefinition = cluster.describeKeyspace("system");
    assertThat(keyspaceDefinition, notNullValue());
    assertThat(keyspaceDefinition.getReplicationFactor(), is(1));
  }
View Full Code Here

        String host = "localhost";
        String port = "9171";
        String[] args = {"-f", targetFileDataSet, "-h", host, "-p", port};
        CassandraUnitCommandLineLoader.main(args);

        Cluster cluster = HFactory.getOrCreateCluster(clusterName, host + ":" + port);
        Keyspace keyspace = HFactory.createKeyspace("beautifulKeyspaceName", cluster);
        assertDataSetLoaded(keyspace);
        EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
    }
View Full Code Here

        String host = "localhost";
        String port = "9171";
        String[] args = {"-f", targetFileDataSet, "-h", host, "-p", port, "-o"};
        CassandraUnitCommandLineLoader.main(args);

        Cluster cluster = HFactory.getOrCreateCluster(clusterName, host + ":" + port);
        Keyspace keyspace = HFactory.createKeyspace("beautifulKeyspaceName", cluster);
        assertDefaultValuesSchemaExist(cluster);
        assertDefaultValuesDataIsEmpty(cluster);
        EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
    }
View Full Code Here

    private static void dropKeyspaces() {
        String host = DatabaseDescriptor.getRpcAddress().getHostName();
        int port = DatabaseDescriptor.getRpcPort();
        log.debug("Cleaning cassandra keyspaces on " + host + ":" + port);
        Cluster cluster = HFactory.getOrCreateCluster("TestCluster", new CassandraHostConfigurator(host + ":" + port));
        /* get all keyspace */
        List<KeyspaceDefinition> keyspaces = cluster.describeKeyspaces();

        /* drop all keyspace except internal cassandra keyspace */
        for (KeyspaceDefinition keyspaceDefinition : keyspaces) {
            String keyspaceName = keyspaceDefinition.getName();

            if (!INTERNAL_CASSANDRA_KEYSPACE.equals(keyspaceName)
                    && !INTERNAL_CASSANDRA_AUTH_KEYSPACE.equals(keyspaceName)
                    && !INTERNAL_CASSANDRA_TRACES_KEYSPACE.equals(keyspaceName)) {
                cluster.dropKeyspace(keyspaceName);
            }
        }
    }
View Full Code Here

  @Test
  public void shouldNotBeToConnected() {
    String clusterName = "TestClusterNotConnected";
    String host = "localhost:9172";
    DataLoader dataLoader = new DataLoader(clusterName, host);
    Cluster cluster = dataLoader.getCluster();
    try {
      cluster.describeKeyspaces();
      fail();
    } catch (HectorException e) {
      /* nothing to do it's what we want */
    }
  }
 
View Full Code Here

  @Test
  public void shouldBeToConnected() {
    String clusterName = "TestCluster2";
    String host = "localhost:9171";
    DataLoader dataLoader = new DataLoader(clusterName, host);
    Cluster cluster = dataLoader.getCluster();
    assertThat(cluster.describeKeyspaces(), notNullValue());
    assertThat(cluster.describeKeyspace("system"), notNullValue());
    assertThat(cluster.describeKeyspace("system").getReplicationFactor(), is(1));
    assertThat(cluster.describeKeyspace("system").getName(), is("system"));
  }
View Full Code Here

    DataLoader dataLoader = new DataLoader(clusterName, host);

    dataLoader.load(MockDataSetHelper.getMockDataSetWithDefaultValues());

    /* test */
    Cluster cluster = HFactory.getOrCreateCluster(clusterName, host);
    assertThat(cluster.describeKeyspace("beautifulKeyspaceName"), notNullValue());
    assertThat(cluster.describeKeyspace("beautifulKeyspaceName").getReplicationFactor(), is(1));
    assertThat(cluster.describeKeyspace("beautifulKeyspaceName").getStrategyClass(),
        is("org.apache.cassandra.locator.SimpleStrategy"));

  }
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.