Package org.apache.cassandra.thrift.Cassandra

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


   
    // Check usage of framed transport
    String framed = properties.getProperty(CassandraProperties.FRAMED_TRANSPORT);
    boolean isFramed = (framed != null && Boolean.valueOf(framed));
   
    Client client = th.get();
    if (client == null) {
      TTransport transport = new TSocket(host, port);
      ((TSocket) transport).setTimeout(10000);
      // wrap transport if framed transport is enabled
      if (isFramed) {
        transport = new TFramedTransport(transport);
      }
      TProtocol protocol = new TBinaryProtocol(transport);
      transport.open();
      client = new Client(protocol);
      th.set(client);
    }
    return client;
  }
View Full Code Here


      @RequestParam("comment") String comment,
      @RequestParam("keyCache") double keyCache,
      @RequestParam("rowCache") double rowCache,
      ModelMap model) throws Exception {
   
    Client client = clientProvider.getThriftClient();
    client.set_keyspace(keyspaceName);
   
    // trim name
    name = name.trim();
    if (name.length() == 0) {
      throw new IllegalArgumentException("CFName must not be empty");
    }
    // clear sub comparator if the type is Standard.
    if ("Standard".equals(type)) {
      subComparator = "";
    }
   
    // creating definition.
    CfDef cfdef = new CfDef(keyspaceName, name);
    cfdef.setComment(comment);
    cfdef.setColumn_type(type);
    cfdef.setComparator_type(comparator);
    if (subComparator != null && subComparator.length() > 0) {
      cfdef.setSubcomparator_type(subComparator);
    }
    cfdef.setKey_cache_size(keyCache);
    cfdef.setRow_cache_size(rowCache);
   
    client.system_add_column_family(cfdef);
   
    // redirecting to keyspace page.
    model.clear();
    return "redirect:/keyspace/" + keyspaceName + "/";
  }
View Full Code Here

  public String describeColumnFamily(
      @PathVariable("keyspaceName") String keyspaceName,
      @PathVariable("columnFamilyName") String columnFamilyName,
      ModelMap model) throws Exception {
   
    Client client = clientProvider.getThriftClient();
   
    // Extracting list of column families
    KsDef ksDef = client.describe_keyspace(keyspaceName);
    model.put("columnFamilies", ksDef.getCf_defs());
   
    // setting names
    model.addAttribute("keyspaceName", keyspaceName);
    model.addAttribute("columnFamilyName", columnFamilyName);
View Full Code Here

      ModelMap model) throws Exception {
   
    model.addAttribute("count", count);
    model.addAttribute("encode", encode);
   
    Client client = clientProvider.getThriftClient();
    // set target keyspace.
    client.set_keyspace(keyspaceName);
    // set target column family
    ColumnParent parent = new ColumnParent(columnFamilyName);
    // create target range
    SliceRange sliceRange = new SliceRange();
    sliceRange.setStart(new byte[0]);
    sliceRange.setFinish(new byte[0]);
    sliceRange.setCount(columnCount + 1);
   
   
    SlicePredicate slicePredicate = new SlicePredicate();
    slicePredicate.setSlice_range(sliceRange);
   
    // Set row range from request
    KeyRange range = new KeyRange(count + 1);
    if (start.length() > 0) {
      range.setStart_key(Hex.decodeHex(start.toCharArray()));
    } else {
      range.setStart_key(new byte[0]);
    }
    if (end.length() > 0) {
      range.setEnd_key(Hex.decodeHex(end.toCharArray()));
    } else {
      range.setEnd_key(new byte[0]);
    }
   
    try {
      // getting slice
      List<KeySlice> slices = client.get_range_slices(
          parent,
          slicePredicate,
          range,
          ConsistencyLevel.ONE);
     
View Full Code Here

  public String dropColumnFamilyExecute(
      @PathVariable("keyspaceName") String keyspaceName,
      @PathVariable("columnFamilyName") String columnFamilyName,
      ModelMap model) throws Exception {
   
    Client client = clientProvider.getThriftClient();
    client.set_keyspace(keyspaceName);
    client.system_drop_column_family(
        columnFamilyName
    );
    model.clear();
    return "redirect:/keyspace/" + keyspaceName + "/" + columnFamilyName + "/";
   
View Full Code Here

  public String truncateColumnFamilyExecute(
      @PathVariable("keyspaceName") String keyspaceName,
      @PathVariable("columnFamilyName") String columnFamilyName,
      ModelMap model) throws Exception {
   
    Client client = clientProvider.getThriftClient();
    client.set_keyspace(keyspaceName);
    client.truncate(
        columnFamilyName
    );
    model.clear();
    return "redirect:/keyspace/" + keyspaceName + "/" + columnFamilyName + "/";
   
View Full Code Here

  private CassandraClientProvider clientProvider;
 
  @RequestMapping(value="/info/", method=RequestMethod.GET)
  public void showInfo(ModelMap model) throws Exception {
   
    Client client = clientProvider.getThriftClient();
   
    model.put("clusterName", client.describe_cluster_name());
    model.put("version", client.describe_version());
   
    /*
    NodeProbe probe = clientProvider.getProbe();
    model.put("liveNodes", probe.getLiveNodes());
    model.put("unreachableNodes", probe.getUnreachableNodes());
View Full Code Here

      Object handler,
      ModelAndView mav) throws Exception {
   
    // If client has thrift client, closing it.
    if (clientProvider.hasThriftClient()) {
      Client client = clientProvider.getThriftClient();
      // closing transports
      client.getInputProtocol().getTransport().close();
      client.getOutputProtocol().getTransport().close();
      // clean up provider
      clientProvider.clean();
    }
   
  }
View Full Code Here

      @RequestParam("keyspace") String activeKeyspace,
      @RequestParam("columnFamily") String activeColumnFamily,
      ModelMap model) throws Exception {
   
    try {
      Client client = clientProvider.getThriftClient();
      if (client != null) {
        //Collections.sort(keyspaceSet);
        model.addAttribute("keyspaces", client.describe_keyspaces());
       
        // Get list of column families from active keyspace.
        if (activeKeyspace.length() > 0) {
          KsDef ksdef = client.describe_keyspace(activeKeyspace);
          List<CfDef> cfList = new ArrayList<CfDef>(ksdef.getCf_defs());
          Collections.sort(cfList);
          model.addAttribute("columnFamilies", cfList);
        }
       
View Full Code Here

  @RequestMapping(value="/keyspace/{name}/", method=RequestMethod.GET)
  public String describeKeyspace(
      @PathVariable("name") String keyspaceName,
      ModelMap model) throws Exception {
   
    Client client = clientProvider.getThriftClient();
   
    // Getting keyspace information
    KsDef ksDef = client.describe_keyspace(keyspaceName);
    model.put("keyspace", ksDef);
    model.put("keyspaceName", keyspaceName);
   
    // Check the system keyspace
    boolean isSystem = cassandraService.isSystemKeyspace(keyspaceName);
    if (isSystem) {
      model.put("system", true);
    } else {
      List<TokenRange> tokenRange = client.describe_ring(keyspaceName);
      Collections.sort(tokenRange);
      model.put("tokenRanges", tokenRange);
    }
   
    return "/keyspace";
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.