Package org.apache.cassandra.thrift

Examples of org.apache.cassandra.thrift.KsDef


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

        assert ksDef != null;

        Map<String, CfDef> cfs = deserializeColumnFamilies(serializedCFs);

View Full Code Here


        {
            // Don't expose CF that cannot be correctly handle by thrift; see CASSANDRA-4377 for further details
            if (!cfm.isThriftIncompatible())
                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

        {
            // Don't expose CF that cannot be correctly handle by thrift; see CASSANDRA-4377 for further details
            if (!cfm.isThriftIncompatible())
                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

    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);
        if (strategyOptions != null && strategyOptions.containsKey("replication_factor"))
            ksdef.setReplication_factor(Integer.parseInt(strategyOptions.get("replication_factor")));
        ksdef.setDurable_writes(durableWrites);

        return ksdef;
    }
View Full Code Here

    public KsDef toThrift()
    {
        List<CfDef> cfDefs = new ArrayList<CfDef>(cfMetaData.size());
        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

    public static KsDef toThrift(KSMetaData ksm)
    {
        List<CfDef> cfDefs = new ArrayList<CfDef>();
        for (CFMetaData cfm : ksm.cfMetaData().values())
            cfDefs.add(CFMetaData.convertToThrift(cfm));
        KsDef ksdef = new KsDef(ksm.name, ksm.strategyClass.getName(), cfDefs);
        ksdef.setStrategy_options(ksm.strategyOptions);
        if (ksm.strategyOptions != null && ksm.strategyOptions.containsKey("replication_factor"))
            ksdef.setReplication_factor(Integer.parseInt(ksm.strategyOptions.get("replication_factor")));
        ksdef.setDurable_writes(ksm.durable_writes);

        return ksdef;
    }
View Full Code Here

    }

    public synchronized void createKeyspace() throws Exception
    {
        // create Keyspace if it doesnt exist.
        KsDef ksd;
        try
        {
            ksd = client.describe_keyspace(ksName);
            client.set_keyspace(ksName);
            createColumnFamily(ksd, false);
        }
        catch (NotFoundException ex)
        {
            ksd = new KsDef(ksName, STATEGY_CLASS, new ArrayList<CfDef>());
            Map<String, String> strategy_options = Maps.newHashMap();
            String[] splits = Properties.instance.getSchemas().get(0).getStrategy_options().split(",");
            for (String split : splits)
            {
                String[] replication = split.split(":");
                assert replication.length == 2;
                strategy_options.put(replication[0], replication[1]);
            }
            ksd.setStrategy_options(strategy_options);
            createColumnFamily(ksd, true);
            client.send_system_add_keyspace(ksd);
        }
    }
View Full Code Here

    public KsDef toThrift()
    {
        List<CfDef> cfDefs = new ArrayList<CfDef>(cfMetaData.size());
        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

  }

  public static void createKeyspace(Cluster cluster, String name, String strategy, int replicationFactor,
      List<CfDef> cfDefList) {
    try {
      KsDef ksDef = new KsDef(name, strategy, replicationFactor, cfDefList);
      cluster.addKeyspace(new ThriftKsDef(ksDef));
      return;
    }
    catch (Throwable e) {
      System.out.println("exception while creating keyspace, " + name + " - probably already exists : "
View Full Code Here

  public List<ColumnFamilyDefinition> getCfDefs() {
    return Collections.unmodifiableList(cfDefs);
  }

  public KsDef toThrift() {
    return new KsDef(name, strategyClass, replicationFactor, ThriftCfDef.toThriftList(cfDefs));
  }
View Full Code Here

TOP

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

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.