Package org.apache.cassandra.thrift

Examples of org.apache.cassandra.thrift.KsDef$KsDefStandardSchemeFactory


   */

  public void addKeyspace(String keyspace) throws Exception {

    List<CfDef> cfDefList = new ArrayList<CfDef>();
    KsDef ksDef = new KsDef(keyspace,
        "org.apache.cassandra.locator.SimpleStrategy", cfDefList);
    ksDef.putToStrategy_options("replication_factor", "1");
    server.system_add_keyspace(ksDef);
  }
View Full Code Here


  public void addKeyspace(String keyspace, String locatorStrategy,
      String replicationFactor) throws Exception {

    List<CfDef> cfDefList = new ArrayList<CfDef>();
    KsDef ksDef = new KsDef(keyspace, locatorStrategy, cfDefList);
    ksDef.putToStrategy_options("replication_factor", replicationFactor);
    tr = new TFramedTransport(new TSocket(cassandraHost, cassandraPort));
    proto = new TBinaryProtocol(tr);
    client = new Cassandra.Client(proto);

    tr.open();
View Full Code Here

      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);
    if (cassandraService.isSystemKeyspace(keyspaceName)) {
View Full Code Here

        //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);
        }
       
      } else {
View Full Code Here

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

      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 Migration getMigration() throws InvalidRequestException, ConfigurationException, IOException
    {
        KsDef ksd = new KsDef(name, strategyClass, Collections.<CfDef>emptyList());
        ksd.setStrategy_options(strategyOptions);
        ThriftValidation.validateKsDef(ksd);
        ThriftValidation.validateKeyspaceNotYetExisting(name);
        return new AddKeyspace(KSMetaData.fromThrift(ksd));
    }
View Full Code Here

    public KsDef toThrift()
    {
        List<CfDef> cfDefs = new ArrayList<CfDef>();
        for (CFMetaData cfm : cfMetaData().values())
            cfDefs.add(cfm.toThrift());
        KsDef ksdef = new KsDef(name, strategyClass.getName(), cfDefs);
        ksdef.setStrategy_options(strategyOptions);
        ksdef.setDurable_writes(durableWrites);

        return ksdef;
    }
View Full Code Here

        return ksdef;
    }

    public RowMutation diff(KsDef newState, long modificationTimestamp)
    {
        KsDef curState = toThrift();
        RowMutation m = new RowMutation(Table.SYSTEM_TABLE, SystemTable.getSchemaKSKey(name));

        for (KsDef._Fields field : KsDef._Fields.values())
        {
            if (field.equals(KsDef._Fields.CF_DEFS))
                continue;

            Object curValue = curState.getFieldValue(field);
            Object newValue = newState.getFieldValue(field);

            if (Objects.equal(curValue, newValue))
                continue;
View Full Code Here

     *
     * @throws IOException if deserialization failed
     */
    public static KsDef fromSchema(ColumnFamily serializedKsDef) throws IOException
    {
        KsDef ksDef = new KsDef();

        AbstractType comparator = serializedKsDef.getComparator();

        for (IColumn ksAttr : serializedKsDef.getSortedColumns())
        {
            if (ksAttr == null || ksAttr.isMarkedForDelete())
                continue;

            KsDef._Fields field = KsDef._Fields.findByName(comparator.getString(ksAttr.name()));
            ksDef.setFieldValue(field, deserializeValue(ksAttr.value(), getValueClass(KsDef.class, field.getFieldName())));
        }

        return ksDef.name == null ? null : ksDef;
    }
View Full Code Here

TOP

Related Classes of org.apache.cassandra.thrift.KsDef$KsDefStandardSchemeFactory

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.