Package com.netflix.astyanax.ddl

Examples of com.netflix.astyanax.ddl.KeyspaceDefinition


                     .build());
       
        keyspace.createColumnFamily(UNIQUE_CF, null);
        keyspace.createColumnFamily(CF_STANDARD1_COPY, null);
       
        KeyspaceDefinition ki = keyspaceContext.getEntity().describeKeyspace();
        System.out.println("Describe Keyspace: " + ki.getName());
       
        try {
            //
            // CF_Super :
            // 'A' :
View Full Code Here


    }
  }

  @Override
  public Properties getColumnFamilyProperties(String columnFamily) throws ConnectionException {
        KeyspaceDefinition ksDef = this.describeKeyspace();
        ColumnFamilyDefinition cfDef = ksDef.getColumnFamily(columnFamily);
        if (cfDef == null)
            throw new NotFoundException(String.format("Column family '%s' in keyspace '%s' not found", columnFamily, getKeyspaceName()));
        try {
      return cfDef.getProperties();
    } catch (Exception e) {
View Full Code Here

      return true;
    }
   
    public ColumnFamilyDefinition describe(Keyspace keyspace) throws ConnectionException {
     
    KeyspaceDefinition ksDef = keyspace.describeKeyspace();
    cfDef = ksDef.getColumnFamily(this.getName());
      return cfDef;
    }
View Full Code Here

       
    keyspace.createKeyspace(options);
   
    Thread.sleep(1000);
   
    KeyspaceDefinition ksDef = keyspace.describeKeyspace();
   
    verifyKeyspacePropertiesForSimpleStrategy(keyspaceName, ksDef);
   
    keyspace.dropKeyspace();
   
View Full Code Here

        props.setProperty("strategy_class", "SimpleStrategy");

        keyspace.createKeyspace(props);
    Thread.sleep(1000);
   
    KeyspaceDefinition ksDef = keyspace.describeKeyspace();
    verifyKeyspacePropertiesForSimpleStrategy(keyspaceName, ksDef);
   
    keyspace.dropKeyspace();
   
    /** NETWORK TOPOLOGY STRATEGY */
 
View Full Code Here

   
    keyspace.createKeyspace(options, cfs);
   
    Thread.sleep(1000);
   
    KeyspaceDefinition ksDef = keyspace.describeKeyspace();
    verifyKeyspacePropertiesForSimpleStrategy(keyspaceName, ksDef);
   
    Map<String, String> strategyOptions = ksDef.getStrategyOptions();
    Assert.assertEquals("1", strategyOptions.get("replication_factor"));

    Properties cfProps = keyspace.getColumnFamilyProperties("testcf1");

    Assert.assertEquals("0.1", String.valueOf(cfProps.get("read_repair_chance")));
View Full Code Here

    keyspace.createColumnFamily(options2);
   
    Thread.sleep(1000);
   
    KeyspaceDefinition ksDef = keyspace.describeKeyspace();
    verifyKeyspacePropertiesForSimpleStrategy(keyspaceName, ksDef);
   
    Properties cfProps = keyspace.getColumnFamilyProperties("testcf1");

    Assert.assertEquals("0.2", String.valueOf(cfProps.get("read_repair_chance")));
    Assert.assertEquals("0.01", String.valueOf(cfProps.get("bloom_filter_fp_chance")));
    Assert.assertEquals("KEYS_ONLY", String.valueOf(cfProps.get("caching")));
    Assert.assertEquals("4", String.valueOf(cfProps.get("min_compaction_threshold")));
    Assert.assertEquals("32", String.valueOf(cfProps.get("max_compaction_threshold")));

    cfProps = keyspace.getColumnFamilyProperties("testcf2");

    Assert.assertEquals("0.4", String.valueOf(cfProps.get("read_repair_chance")));
    Assert.assertEquals("0.01", String.valueOf(cfProps.get("bloom_filter_fp_chance")));
    Assert.assertEquals("KEYS_ONLY", String.valueOf(cfProps.get("caching")));
    Assert.assertEquals("4", String.valueOf(cfProps.get("min_compaction_threshold")));
    Assert.assertEquals("32", String.valueOf(cfProps.get("max_compaction_threshold")));
   
    ColumnFamilyDefinition cfDef = ksDef.getColumnFamily("testcf1");
    Assert.assertEquals("testcf1", cfDef.getName());
    Assert.assertEquals(0.2, cfDef.getReadRepairChance());
    Assert.assertEquals("KEYS_ONLY", cfDef.getCaching());
    Assert.assertTrue(32 == cfDef.getMaxCompactionThreshold());
    Assert.assertTrue(4 == cfDef.getMinCompactionThreshold());
    Assert.assertEquals(0.01, cfDef.getBloomFilterFpChance());

    cfDef = ksDef.getColumnFamily("testcf2");
    Assert.assertEquals("testcf2", cfDef.getName());
    Assert.assertEquals(0.4, cfDef.getReadRepairChance());
    Assert.assertEquals("KEYS_ONLY", cfDef.getCaching());
    Assert.assertTrue(32 == cfDef.getMaxCompactionThreshold());
    Assert.assertTrue(4 == cfDef.getMinCompactionThreshold());
    Assert.assertEquals(0.01, cfDef.getBloomFilterFpChance());

    List<ColumnFamilyDefinition> cfDefs = ksDef.getColumnFamilyList();
    Assert.assertTrue(2 == cfDefs.size());
   
    cfDef = cfDefs.get(0);
    Assert.assertEquals("testcf1", cfDef.getName());
    Assert.assertEquals(0.2, cfDef.getReadRepairChance());
View Full Code Here

          .build();
       
   
    keyspace.createKeyspace(ksOptions);

    KeyspaceDefinition ksDef = keyspace.describeKeyspace();
    Assert.assertEquals(keyspaceName, ksDef.getName());

    keyspace.createColumnFamily(CF_POPULATION, ImmutableMap.<String, Object>builder()
        .put("default_validation_class", "UTF8Type")
        .put("key_validation_class",     "UTF8Type")
        .put("comparator_type",          "CompositeType(UTF8Type, UTF8Type, UTF8Type, Int32Type, DateType)")
        .build());

    if (ClusterConfiguration.getDriver().equals(Driver.JAVA_DRIVER)) {
      List<ColumnFamilyDefinition> list = ksDef.getColumnFamilyList();
      Assert.assertTrue(1 == list.size());
   
      ColumnFamilyDefinition cfDef = list.get(0);
      Assert.assertEquals("population", cfDef.getName());
   
      List<ColumnDefinition> colDefs = cfDef.getColumnDefinitionList();
      Assert.assertTrue(7 == colDefs.size());
   
      for (int i=1; i<=5; i++) {
        ColumnDefinition colDef = colDefs.get(i-1);
        Assert.assertEquals("column" + i, colDef.getName());
        Assert.assertNotNull(colDef.getValidationClass());
      }
      ColumnDefinition colDef = colDefs.get(6);
      Assert.assertEquals("value", colDef.getName());
      Assert.assertNotNull(colDef.getValidationClass());
     
      cfDef = ksDef.getColumnFamily("population");
      Assert.assertEquals("population", cfDef.getName());
     
      colDefs = cfDef.getColumnDefinitionList();
      Assert.assertTrue(7 == colDefs.size());
   
View Full Code Here

                      .build();
       
    keyspace.createKeyspace(options);
    Thread.sleep(1000);
   
    KeyspaceDefinition ksDef = keyspace.describeKeyspace();
    verifyKeyspacePropertiesForSimpleStrategy(keyspaceName, ksDef);
   
    keyspace.updateKeyspace(ImmutableMap.<String, Object>builder()
                    .put("strategy_options", ImmutableMap.<String, Object>builder()
                                  .put("replication_factor", "2")
                                  .build())
                      .put("strategy_class",     "SimpleStrategy")
                      .build());
    ksDef = keyspace.describeKeyspace();
    Assert.assertEquals("2", ksDef.getStrategyOptions().get("replication_factor"));
   
    keyspace.dropKeyspace();
   
    /** NETWORK TOPOLOGY */
    keyspaceName = "AstyanaxTestKeyspaceAlterOptions2".toLowerCase();
   
    context = AstyanaxContextFactory.getKeyspace(keyspaceName);
    context.start();
        keyspace = context.getClient();

    options = ImmutableMap.<String, Object>builder()
                      .put("strategy_options", ImmutableMap.<String, Object>builder()
                                  .put("us-east", "3")
                                  .put("eu-west", "3")
                                  .build())
                      .put("strategy_class",     "NetworkTopologyStrategy")
                      .build();
       
    keyspace.createKeyspace(options);
    Thread.sleep(1000);
   
    KeyspaceDefinition ksDef2 = keyspace.describeKeyspace();
    verifyKeyspacePropertiesForNetworkTopology(keyspaceName, ksDef2);

    options = ImmutableMap.<String, Object>builder()
        .put("strategy_options", ImmutableMap.<String, Object>builder()
                    .put("us-east", "2")
                    .put("eu-west", "2")
                    .build())
        .put("strategy_class",     "NetworkTopologyStrategy")
        .build();

    keyspace.updateKeyspace(options);
    ksDef2 = keyspace.describeKeyspace();
   
    System.out.println(ksDef2.getStrategyOptions());
    Assert.assertEquals("2", ksDef2.getStrategyOptions().get("us-east"));
    Assert.assertEquals("2", ksDef2.getStrategyOptions().get("eu-west"));

    keyspace.dropKeyspace();
  }
View Full Code Here

                      .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");
View Full Code Here

TOP

Related Classes of com.netflix.astyanax.ddl.KeyspaceDefinition

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.