Examples of KsDef


Examples of org.apache.cassandra.thrift.KsDef

    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

Examples of org.apache.cassandra.thrift.KsDef

        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

Examples of org.apache.cassandra.thrift.KsDef

     *
     * @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

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

Examples of org.apache.cassandra.thrift.KsDef

        {
            // 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

Examples of org.apache.cassandra.thrift.KsDef

        {
            // 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

Examples of org.apache.cassandra.thrift.KsDef

    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

Examples of org.apache.cassandra.thrift.KsDef

    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

Examples of org.apache.cassandra.thrift.KsDef

    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

Examples of org.apache.cassandra.thrift.KsDef

    }

    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
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.