Package org.apache.cassandra.thrift.Cassandra

Examples of org.apache.cassandra.thrift.Cassandra.Client


      @RequestParam("replicationFactor") int replicationFactor,
      @RequestParam("strategy") String strategy,
      ModelMap model
      ) throws Exception {
   
    Client client = clientProvider.getThriftClient();
   
    name = name.trim();
    if (name.length() == 0) {
      throw new IllegalArgumentException("Name must not be empty");
    }
   
    String strategyClass = null;
    if (strategy.equals("Simple")) {
      strategyClass ="org.apache.cassandra.locator SimpleStrategy";
    } else if (strategy.equals("NetworkTopology")) {
      strategyClass = "org.apache.cassandra.locator NetworkTopologyStrategy";
    } else if (strategy.equals("OldNetworkTopology")) {
      strategyClass = "org.apache.cassandra.locator.OldNetworkTopologyStrategy";
    }
   
    KsDef ksDef = new KsDef(name, strategyClass, new ArrayList<CfDef>());
    Map<String, String> strategyOptions = new HashMap<String, String>();
    strategyOptions.put("replication_factor", String.valueOf(replicationFactor));
    ksDef.setStrategy_options(strategyOptions);
    client.system_add_keyspace(ksDef);
   
    model.clear();
    return "redirect:/keyspace/" + name + "/";
  }
View Full Code Here


  public String dropKeyspaceExecute(
      @PathVariable("name") String keyspaceName,
      ModelMap model
      ) throws Exception {
   
    Client client = clientProvider.getThriftClient();

    client.set_keyspace(keyspaceName);;
    client.system_drop_keyspace(keyspaceName);
   
    model.clear();
    return "redirect:/";
  }
View Full Code Here

        this.connectionFactory = connectionFactory;
    }

    public List<TokenRange> getRangeMap(String keyspace)
    {
        Client client = connectionFactory.create();
        try {
            return client.describe_ring(keyspace);
        }
        catch (TException e) {
            throw new RuntimeException(e);
        }
        finally {
View Full Code Here

        }
    }

    public List<CfSplit> getSubSplits(String keyspace, String columnFamily, TokenRange range, int splitSize)
    {
        Client client = connectionFactory.create();
        try {
            client.set_keyspace(keyspace);
            try {
                return client.describe_splits_ex(columnFamily, range.start_token, range.end_token, splitSize);
            }
            catch (TApplicationException e) {
                // fallback to guessing split size if talking to a server without describe_splits_ex method
                if (e.getType() == TApplicationException.UNKNOWN_METHOD) {
                    List<String> splitPoints = client.describe_splits(columnFamily, range.start_token, range.end_token, splitSize);
                    return tokenListToSplits(splitPoints, splitSize);
                }
                throw e;
            }
        }
View Full Code Here

        String table2 = "SECONDARY_TABLE";
        String keyspace = "KunderaExamples";

        try
        {
            Client client = CassandraCli.getClient();
            KsDef ksDef = client.describe_keyspace(keyspace);
            client.set_keyspace(keyspace);

            List<CfDef> cfDefn = ksDef.getCf_defs();

            for (CfDef cfDef1 : cfDefn)
            {
                if (cfDef1.getName().equalsIgnoreCase(table2))
                {
                    client.system_drop_column_family(table2);
                }
            }
            client.execute_cql3_query(ByteBufferUtil
                    .bytes("create table \"SECONDARY_TABLE\"(\"OBJECT_ID\" text PRIMARY KEY, \"AGE\" int)"),
                    org.apache.cassandra.thrift.Compression.NONE, org.apache.cassandra.thrift.ConsistencyLevel.ANY);
        }
        catch (NotFoundException e)
        {
View Full Code Here

        String table2 = "SECONDARY_TABLE";
        String keyspace = "KunderaExamples";

        try
        {
            Client client = CassandraCli.getClient();
            KsDef ksDef = client.describe_keyspace(keyspace);
            client.set_keyspace(keyspace);

            List<CfDef> cfDefn = ksDef.getCf_defs();

            for (CfDef cfDef1 : cfDefn)
            {

                if (cfDef1.getName().equalsIgnoreCase(table1))
                {
                    client.system_drop_column_family(table1);
                }
                if (cfDef1.getName().equalsIgnoreCase(table2))
                {
                    client.system_drop_column_family(table2);
                }
            }

            client.execute_cql3_query(ByteBufferUtil.bytes("create table \"PRIMARY_TABLE\"(\"OBJECT_ID\" text PRIMARY KEY, \"NAME\" text)"),
                    org.apache.cassandra.thrift.Compression.NONE, org.apache.cassandra.thrift.ConsistencyLevel.ANY);

            client.execute_cql3_query(ByteBufferUtil.bytes("create table \"SECONDARY_TABLE\"(\"OBJECT_ID\" text PRIMARY KEY, \"AGE\" int)"),
                    org.apache.cassandra.thrift.Compression.NONE, org.apache.cassandra.thrift.ConsistencyLevel.ANY);
        }
        catch (NotFoundException e)
        {
           
View Full Code Here

        emf = Persistence.createEntityManagerFactory("CassandraCounterTest");
    }

    private void createSchema() throws InvalidRequestException, TException, SchemaDisagreementException
    {
        Client client = CassandraCli.getClient();
        CassandraCli.createKeySpace(keyspace);
        client.set_keyspace(keyspace);

        CfDef cfDef = new CfDef();
        cfDef.keyspace = keyspace;
        cfDef.name = "SuperCounters";
        cfDef.column_type = "Super";
        cfDef.default_validation_class = "CounterColumnType";
        cfDef.comparator_type = "UTF8Type";
        cfDef.subcomparator_type = "UTF8Type";
        client.system_add_column_family(cfDef);
    }
View Full Code Here

        emf = Persistence.createEntityManagerFactory("CassandraCounterTest", propertyMap);
    }

    private void createSchema() throws InvalidRequestException, TException, SchemaDisagreementException
    {
        Client client = CassandraCli.getClient();
        CassandraCli.createKeySpace(keyspace);
        client.set_keyspace(keyspace);

        CfDef cfDef = new CfDef();
        cfDef.keyspace = keyspace;
        cfDef.name = "counters";
        cfDef.default_validation_class = "CounterColumnType";
        cfDef.key_validation_class = "UTF8Type";
        ColumnDef columnDef = new ColumnDef(ByteBuffer.wrap("counter".getBytes()), "CounterColumnType");
        columnDef.index_type = IndexType.KEYS;
        cfDef.addToColumn_metadata(columnDef);
        cfDef.comparator_type = "UTF8Type";

        client.system_add_column_family(cfDef);
    }
View Full Code Here

TOP

Related Classes of org.apache.cassandra.thrift.Cassandra.Client

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.