Examples of KeyspaceDefinition


Examples of com.netflix.astyanax.ddl.KeyspaceDefinition

        break;
      }
    }

    if(!exists) {
      KeyspaceDefinition def = cluster.makeKeyspaceDefinition();
      def.setName(keyspaceName);
      def.setStrategyClass("org.apache.cassandra.locator.SimpleStrategy");
      Map<String, String> map = new HashMap<String, String>();
      map.put("replication_factor", "3");
      def.setStrategyOptions(map);
      cluster.addKeyspace(def);
    }
   
    AstyanaxContext<Keyspace> context = builder.buildKeyspace(ThriftFamilyFactory.getInstance());
    context.start();
   
    keyspace = context.getEntity();

    KeyspaceDefinition keySpaceMeta = keyspace.describeKeyspace();
   
    findExistingColumnFamilies(keySpaceMeta);
    log.info("On keyspace="+keyspace.getKeyspaceName()+"Existing column families="+cfNameToCassandra.keySet()+"\nNOTE: WE WILL CREATE " +
        "new column families automatically as you save entites that have no column family");
  }
View Full Code Here

Examples of com.netflix.astyanax.ddl.KeyspaceDefinition

     
      //perhaps the schema is changing and was caused by someone else, let's wait until it stablizes
      waitForNodesToBeUpToDate(null, 300000);
     
      //NOW, the schema appears stable, let's get that column family and load it
      KeyspaceDefinition keySpaceMeta = keyspace.describeKeyspace();
      ColumnFamilyDefinition def = keySpaceMeta.getColumnFamily(realCf);
      if(def == null) {
        log.info("Well, we did NOT find any column family="+realCf+" to load in cassandra(from virt="+virtCf+")");
        return null;
      }
      log.info("coooool, we found a new column family="+realCf+"(virt="+virtCf+") to load so we are going to load that for you so every future operation is FAST");
View Full Code Here

Examples of com.netflix.astyanax.ddl.KeyspaceDefinition

  public void clearImpl() throws ConnectionException {
    Cluster cluster = columnFamilies.getCluster();
    String keyspaceName = columnFamilies.getKeyspaceName();
    log.info("Clearing keyspace="+keyspaceName+" in cassandra");
    List<KeyspaceDefinition> keyspaces = cluster.describeKeyspaces();
    KeyspaceDefinition ourDef = null;
    for(KeyspaceDefinition kDef : keyspaces) {
      if(keyspaceName.equalsIgnoreCase(kDef.getName())) {
        ourDef = kDef;
        break;
      }
View Full Code Here

Examples of me.prettyprint.hector.api.ddl.KeyspaceDefinition

    }

    private synchronized void init() {
        System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ PROVIDER INIT");
        cluster = HFactory.getOrCreateCluster(CassandraConstants.CASSANDRA_DEFAULT_CLUSTER_NAME, CASSANDRA_EP);
        KeyspaceDefinition keyspaceDef = cluster.describeKeyspace(KEYSPACE);
        if (keyspaceDef == null) {
            try {
                createSchema(cluster);
            } catch (Exception ignore) {
                System.out.println("Ignoring the exception when trying to create a already existing schema " + ignore.getMessage());
View Full Code Here

Examples of me.prettyprint.hector.api.ddl.KeyspaceDefinition

        return resource.listChildren();
    }

    private void createSchema(Cluster myCluster) {
        ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(KEYSPACE, cf, ComparatorType.BYTESTYPE);
        KeyspaceDefinition newKeyspace = HFactory.createKeyspaceDefinition(
                KEYSPACE,
                ThriftKsDef.DEF_STRATEGY_CLASS,
                replicationFactor,
                Arrays.asList(cfDef));
        myCluster.addKeyspace(newKeyspace, true);
View Full Code Here

Examples of me.prettyprint.hector.api.ddl.KeyspaceDefinition

  /**
   * Check if keyspace already exists.
   */
  public boolean keyspaceExists() {
    KeyspaceDefinition keyspaceDefinition = this.cluster.describeKeyspace(this.cassandraMapping.getKeyspaceName());
    return (keyspaceDefinition != null);
  }
View Full Code Here

Examples of me.prettyprint.hector.api.ddl.KeyspaceDefinition

   * when the Keyspace is created. Currently consistency level is .ONE which
   * permits consistency to wait until one replica has responded.
   */
  public void checkKeyspace() {
    // "describe keyspace <keyspaceName>;" query
    KeyspaceDefinition keyspaceDefinition = this.cluster.describeKeyspace(this.cassandraMapping.getKeyspaceName());
    if (keyspaceDefinition == null) {
      List<ColumnFamilyDefinition> columnFamilyDefinitions = this.cassandraMapping.getColumnFamilyDefinitions();     

      // GORA-197
      for (ColumnFamilyDefinition cfDef : columnFamilyDefinitions) {
        cfDef.setComparatorType(ComparatorType.BYTESTYPE);
      }

      keyspaceDefinition = HFactory.createKeyspaceDefinition(this.cassandraMapping.getKeyspaceName(), "org.apache.cassandra.locator.SimpleStrategy", 1, columnFamilyDefinitions);     
      this.cluster.addKeyspace(keyspaceDefinition, true);
      // LOG.info("Keyspace '" + this.cassandraMapping.getKeyspaceName() + "' in cluster '" + this.cassandraMapping.getClusterName() + "' was created on host '" + this.cassandraMapping.getHostName() + "'");
     
      // Create a customized Consistency Level
      ConfigurableConsistencyLevel configurableConsistencyLevel = new ConfigurableConsistencyLevel();
      Map<String, HConsistencyLevel> clmap = new HashMap<String, HConsistencyLevel>();

      // Define CL.ONE for ColumnFamily "ColumnFamily"
      clmap.put("ColumnFamily", HConsistencyLevel.ONE);

      // In this we use CL.ONE for read and writes. But you can use different CLs if needed.
      configurableConsistencyLevel.setReadCfConsistencyLevels(clmap);
      configurableConsistencyLevel.setWriteCfConsistencyLevels(clmap);

      // Then let the keyspace know
      HFactory.createKeyspace("Keyspace", this.cluster, configurableConsistencyLevel);

      keyspaceDefinition = null;
    }
    else {
      List<ColumnFamilyDefinition> cfDefs = keyspaceDefinition.getCfDefs();
      if (cfDefs == null || cfDefs.size() == 0) {
        LOG.warn(keyspaceDefinition.getName() + " does not have any column family.");
      }
      else {
        for (ColumnFamilyDefinition cfDef : cfDefs) {
          ComparatorType comparatorType = cfDef.getComparatorType();
          if (! comparatorType.equals(ComparatorType.BYTESTYPE)) {
View Full Code Here

Examples of me.prettyprint.hector.api.ddl.KeyspaceDefinition


  @Test
  public void testDescribeKeyspace() throws Exception {
    ThriftCluster cassandraCluster = new ThriftCluster("Test Cluster", cassandraHostConfigurator, user1Credentials);
    KeyspaceDefinition keyspaceDetail = cassandraCluster.describeKeyspace("Keyspace1");
    assertNotNull(keyspaceDetail);
    assertEquals(7, keyspaceDetail.getCfDefs().size());
  }
View Full Code Here

Examples of me.prettyprint.hector.api.ddl.KeyspaceDefinition



  @Test
  public void testDescribeKeyspace() throws Exception {
    KeyspaceDefinition keyspaceDetail = cassandraCluster.describeKeyspace("Keyspace1");
    assertNotNull(keyspaceDetail);
    assertEquals(7, keyspaceDetail.getCfDefs().size());
  }
View Full Code Here

Examples of me.prettyprint.hector.api.ddl.KeyspaceDefinition

    columnFamilyDefinition.setKeyspaceName("DynKeyspace2");
    columnFamilyDefinition.setName("DynamicCF");   
   
    ColumnFamilyDefinition cfDef = new ThriftCfDef(columnFamilyDefinition);
   
    KeyspaceDefinition keyspaceDefinition =
        HFactory.createKeyspaceDefinition("DynKeyspace2", "org.apache.cassandra.locator.SimpleStrategy", 1, Arrays.asList(cfDef));
   
    cassandraCluster.addKeyspace(keyspaceDefinition);
   
    keyspaceDefinition =
      HFactory.createKeyspaceDefinition("DynKeyspace2", "org.apache.cassandra.locator.SimpleStrategy", 2, null);
   
    cassandraCluster.updateKeyspace(keyspaceDefinition);
   
    KeyspaceDefinition fromCluster = cassandraCluster.describeKeyspace("DynKeyspace2");
    assertEquals(2,fromCluster.getReplicationFactor());
    cassandraCluster.dropKeyspace("DynKeyspace2");
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.