Examples of KeyspaceDefinition


Examples of com.netflix.astyanax.ddl.KeyspaceDefinition

    }
   
    public static void createColumnFamily(AstyanaxContext<Cluster> ctx,String ks, String cf, String comparator,
        String keyValidator, String defValidator, boolean dropFirst) throws ConnectionException{
        Cluster cluster = ctx.getEntity();
        KeyspaceDefinition keyspace = cluster.describeKeyspace(ks);
        if(keyspace != null){
            LOG.warn("Keyspace {} already exists.", ks);
        } else{
            LOG.warn("Creating keyspace '{}'", ks);
            KeyspaceDefinition ksDef = cluster.makeKeyspaceDefinition();
            Map<String, String> stratOptions = new HashMap<String, String>();
            stratOptions.put("replication_factor", "1");
            ksDef.setName(ks)
                    .setStrategyClass("SimpleStrategy")
                    .setStrategyOptions(stratOptions);
            cluster.addKeyspace(ksDef);
        }
       
View Full Code Here

Examples of com.netflix.astyanax.ddl.KeyspaceDefinition

        Cluster cluster = ctx.getEntity();
        Keyspace keyspace = cluster.getKeyspace(ks);
        if(keyspace != null){
            LOG.warn("Keyspace {} already exists.", ks);
        }
        KeyspaceDefinition ksDef = cluster.makeKeyspaceDefinition();

        Map<String, String> stratOptions = new HashMap<String, String>();
        stratOptions.put("replication_factor", "1");
        ksDef.setName(ks)
                .setStrategyClass("SimpleStrategy")
                .setStrategyOptions(stratOptions)
                .addColumnFamily(
                        cluster.makeColumnFamilyDefinition().setName(cf).setComparatorType("UTF8Type")
                                .setKeyValidationClass("UTF8Type").setDefaultValidationClass("CounterColumnType"));
View Full Code Here

Examples of com.netflix.astyanax.ddl.KeyspaceDefinition

    Cluster cluster = columnFamilies.getCluster();
    String keyspaceName = columnFamilies.getKeyspaceName();
    if (log.isInfoEnabled())
      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 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);
    }
   
    context = builder.buildKeyspace(ThriftFamilyFactory.getInstance());
    context.start();
   
    keyspace = context.getEntity();

    KeyspaceDefinition keySpaceMeta = keyspace.describeKeyspace();
   
    findExistingColumnFamilies(keySpaceMeta);
    if (log.isInfoEnabled())
      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) {
        if (log.isInfoEnabled())
          log.info("Well, we did NOT find any column family="+realCf+" to load in cassandra(from virt="+virtCf+")");
        return null;
      }
View Full Code Here

Examples of com.netflix.astyanax.ddl.KeyspaceDefinition

        // test if the namespace already exists if exception or null create it
        boolean keyspaceExists = false;
        try
        {
            KeyspaceDefinition keyspaceDefinition = keyspace.describeKeyspace();
            if ( keyspaceDefinition != null )
            {
                keyspaceExists = true;
            }
View Full Code Here

Examples of com.netflix.astyanax.ddl.KeyspaceDefinition

      }
    }

    log.info("your keyspace="+keyspaceName+" keyspaces="+keyspaceNames+" exists="+exists);
    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);
      if(callback != null)
        def = (KeyspaceDefinition) callback.configureKeySpace(keyspaceName, def);
      cluster.addKeyspace(def);
      log.info("added keyspace="+keyspaceName+" so it now exists");
    }
   
    context = builder.buildKeyspace(ThriftFamilyFactory.getInstance());
    context.start();
   
    keyspace = context.getClient();

    //for some reason, the keyspace is not always created fast enough so sleep 3 seconds and try again
    KeyspaceDefinition keySpaceMeta = null;
    BadRequestException holdExc = null;
    for(int i = 0; i < 3; i++) {
      try {
        keySpaceMeta = keyspace.describeKeyspace();
      } catch(BadRequestException e) {
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) {
        if (log.isInfoEnabled())
          log.info("Well, we did NOT find any column family="+realCf+" to load in cassandra(from virt="+virtCf+")");
        return null;
      }
View Full Code Here

Examples of com.netflix.astyanax.ddl.KeyspaceDefinition

    Cluster cluster = columnFamilies.getCluster();
    String keyspaceName = columnFamilies.getKeyspaceName();
    if (log.isInfoEnabled())
      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 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
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.