Package org.apache.cassandra.thrift

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


    public void createSchema()
    {
        try
        {
            KsDef ksDef = null;

            CfDef cfDef = new CfDef();
            cfDef.name = "StudentLongWrapper";
            cfDef.keyspace = keyspace;
            cfDef.setKey_validation_class("LongType");
            cfDef.setComparator_type("UTF8Type");
            ColumnDef name = new ColumnDef(ByteBuffer.wrap("NAME".getBytes()), "UTF8Type");
            name.index_type = IndexType.KEYS;
            cfDef.addToColumn_metadata(name);
            ColumnDef age = new ColumnDef(ByteBuffer.wrap("AGE".getBytes()), "Int32Type");
            age.index_type = IndexType.KEYS;
            cfDef.addToColumn_metadata(age);
            List<CfDef> cfDefs = new ArrayList<CfDef>();
            cfDefs.add(cfDef);
            try
            {
                CassandraCli.initClient();
                ksDef = CassandraCli.client.describe_keyspace(keyspace);
                CassandraCli.client.set_keyspace(keyspace);

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

                for (CfDef cfDef1 : cfDefn)
                {

                    if (cfDef1.getName().equalsIgnoreCase("StudentLongWrapper"))
                    {

                        CassandraCli.client.system_drop_column_family("StudentLongWrapper");

                    }
                }
                CassandraCli.client.system_add_column_family(cfDef);

            }
            catch (NotFoundException e)
            {

                ksDef = new KsDef(keyspace, "org.apache.cassandra.locator.SimpleStrategy", cfDefs);
                // Set replication factor
                if (ksDef.strategy_options == null)
                {
                    ksDef.strategy_options = new LinkedHashMap<String, String>();
                }
View Full Code Here


    {
        /**
         * schema generation for cassandra.
         * */

        KsDef ksDef = null;

        CfDef pCfDef = new CfDef();
        pCfDef.name = "PHOTOGRAPHER";
        pCfDef.keyspace = "Pickr";
        pCfDef.setComparator_type("UTF8Type");
View Full Code Here

        /**
         * schema generation for cassandra.
         * */

        KsDef ksDef = null;

        CfDef pCfDef = new CfDef();
        pCfDef.name = "PHOTOGRAPHER";
        pCfDef.keyspace = "Pickr";
        pCfDef.setComparator_type("UTF8Type");
View Full Code Here

    {
        getEntityManagerFactory("create");

        Assert.assertTrue(CassandraCli.keyspaceExist("KunderaCoreExmples"));
        Assert.assertTrue(CassandraCli.columnFamilyExist("Actor", "KunderaCoreExmples"));
        org.apache.cassandra.thrift.KsDef ksDef = new KsDef();
        ksDef = client.describe_keyspace("KunderaCoreExmples");
        Assert.assertEquals(2, ksDef.getCf_defs().size());
        for (org.apache.cassandra.thrift.CfDef cfDef : ksDef.getCf_defs())
        {
            if ("Actor".equals(cfDef.getName()))
            {
                Assert.assertEquals("Super", cfDef.column_type);
            }
View Full Code Here

     */
    private void loadData() throws TException, InvalidRequestException, UnavailableException, TimedOutException,
            SchemaDisagreementException
    {

        KsDef ksDef = null;
        CfDef user_Def = new CfDef();
        user_Def.name = "TUSER";
        user_Def.keyspace = "KunderaExamples";
        user_Def.setComparator_type("UTF8Type");
        user_Def.setDefault_validation_class("UTF8Type");
        user_Def.setKey_validation_class("UTF8Type");
        ColumnDef columnDef = new ColumnDef(ByteBuffer.wrap("USER_NAME".getBytes()), "UTF8Type");
        columnDef.index_type = IndexType.KEYS;
        user_Def.addToColumn_metadata(columnDef);
        ColumnDef columnDef1 = new ColumnDef(ByteBuffer.wrap("U_NAME".getBytes()), "UTF8Type");
        columnDef1.index_type = IndexType.KEYS;
        user_Def.addToColumn_metadata(columnDef1);

        List<CfDef> cfDefs = new ArrayList<CfDef>();
        cfDefs.add(user_Def);

        try
        {
            ksDef = CassandraCli.client.describe_keyspace("KunderaExamples");
            CassandraCli.client.set_keyspace("KunderaExamples");

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

            for (CfDef cfDef1 : cfDefn)
            {

                if (cfDef1.getName().equalsIgnoreCase("TUSER"))
                {

                    CassandraCli.client.system_drop_column_family("TUSER");

                }
            }
            CassandraCli.client.system_add_column_family(user_Def);

        }
        catch (NotFoundException e)
        {

            ksDef = new KsDef("KunderaExamples", "org.apache.cassandra.locator.SimpleStrategy", cfDefs);
            // Set replication factor
            if (ksDef.strategy_options == null)
            {
                ksDef.strategy_options = new LinkedHashMap<String, String>();
            }
View Full Code Here

    public void createSchema()
    {
        try
        {
            KsDef ksDef = null;

            CfDef cfDef = new CfDef();
            cfDef.name = "StudentLongPrimitive";
            cfDef.keyspace = keyspace;
            cfDef.setKey_validation_class("LongType");
            cfDef.setComparator_type("UTF8Type");
            ColumnDef name = new ColumnDef(ByteBuffer.wrap("NAME".getBytes()), "UTF8Type");
            name.index_type = IndexType.KEYS;
            cfDef.addToColumn_metadata(name);
            ColumnDef age = new ColumnDef(ByteBuffer.wrap("AGE".getBytes()), "Int32Type");
            age.index_type = IndexType.KEYS;
            cfDef.addToColumn_metadata(age);
            List<CfDef> cfDefs = new ArrayList<CfDef>();
            cfDefs.add(cfDef);
            try
            {
                CassandraCli.initClient();
                ksDef = CassandraCli.client.describe_keyspace(keyspace);
                CassandraCli.client.set_keyspace(keyspace);

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

                for (CfDef cfDef1 : cfDefn)
                {

                    if (cfDef1.getName().equalsIgnoreCase("StudentLongPrimitive"))
                    {

                        CassandraCli.client.system_drop_column_family("StudentLongPrimitive");

                    }
                }
                CassandraCli.client.system_add_column_family(cfDef);

            }
            catch (NotFoundException e)
            {

                ksDef = new KsDef(keyspace, "org.apache.cassandra.locator.SimpleStrategy", cfDefs);
                // Set replication factor
                if (ksDef.strategy_options == null)
                {
                    ksDef.strategy_options = new LinkedHashMap<String, String>();
                }
View Full Code Here

    }

    @Override
    void createSchema() throws InvalidRequestException, SchemaDisagreementException, TException
    {
        KsDef ksDef = null;
        CfDef userCfDef = new CfDef();
        userCfDef.name = "USER";
        userCfDef.keyspace = keyspace;
        userCfDef.column_type = "Super";
        userCfDef.setComparator_type("UTF8Type");
        userCfDef.setSubcomparator_type("AsciiType");
        userCfDef.setKey_validation_class("UTF8Type");

        CfDef userIndexCfDef = new CfDef();
        userIndexCfDef.name = "USER" + Constants.INDEX_TABLE_SUFFIX;
        userIndexCfDef.column_type = "Super";
        userIndexCfDef.keyspace = keyspace;
        userCfDef.setKey_validation_class("AsciiType");

        CfDef prefrenceCfDef = new CfDef();
        prefrenceCfDef.name = "PREFERENCE";
        prefrenceCfDef.keyspace = keyspace;
        prefrenceCfDef.setComparator_type("UTF8Type");
        prefrenceCfDef.setDefault_validation_class("UTF8Type");
        prefrenceCfDef.setKey_validation_class("UTF8Type");
        ColumnDef columnDef = new ColumnDef(ByteBuffer.wrap("WEBSITE_THEME".getBytes()), "UTF8Type");
        columnDef.index_type = IndexType.KEYS;
        ColumnDef columnDef3 = new ColumnDef(ByteBuffer.wrap("PRIVACY_LEVEL".getBytes()), "UTF8Type");
        columnDef3.index_type = IndexType.KEYS;
        prefrenceCfDef.addToColumn_metadata(columnDef);
        prefrenceCfDef.addToColumn_metadata(columnDef3);

        CfDef externalLinkCfDef = new CfDef();
        externalLinkCfDef.name = "EXTERNAL_LINK";
        externalLinkCfDef.keyspace = keyspace;
        externalLinkCfDef.setComparator_type("UTF8Type");
        externalLinkCfDef.setDefault_validation_class("UTF8Type");
        externalLinkCfDef.setKey_validation_class("UTF8Type");
        ColumnDef columnDef1 = new ColumnDef(ByteBuffer.wrap("LINK_TYPE".getBytes()), "UTF8Type");
        columnDef1.index_type = IndexType.KEYS;
        ColumnDef columnDef2 = new ColumnDef(ByteBuffer.wrap("LINK_ADDRESS".getBytes()), "UTF8Type");
        columnDef2.index_type = IndexType.KEYS;
        ColumnDef columnDef4 = new ColumnDef(ByteBuffer.wrap("USER_ID".getBytes()), "UTF8Type");
        columnDef4.index_type = IndexType.KEYS;
        externalLinkCfDef.addToColumn_metadata(columnDef1);
        externalLinkCfDef.addToColumn_metadata(columnDef2);
        externalLinkCfDef.addToColumn_metadata(columnDef4);

        /*
         * CfDef userCfDef = new CfDef(); userCfDef.name = "USER";
         * userCfDef.keyspace = keyspace; userCfDef.column_type = "Super";
         * userCfDef.setComparator_type("UTF8Type");
         * userCfDef.setSubcomparator_type("AsciiType");
         * userCfDef.setKey_validation_class("UTF8Type");
         *
         * CfDef userIndexCfDef = new CfDef(); userIndexCfDef.name = "USER" +
         * Constants.INDEX_TABLE_SUFFIX; userIndexCfDef.column_type = "Super";
         * userIndexCfDef.keyspace = keyspace;
         * userIndexCfDef.setKey_validation_class("UTF8Type");
         *
         * CfDef prefrenceCfDef = new CfDef(); prefrenceCfDef.name =
         * "PREFERENCE"; prefrenceCfDef.keyspace = keyspace;
         * prefrenceCfDef.setComparator_type("UTF8Type");
         * prefrenceCfDef.setDefault_validation_class("UTF8Type"); ColumnDef
         * columnDef = new
         * ColumnDef(ByteBuffer.wrap("WEBSITE_THEME".getBytes()), "UTF8Type");
         * columnDef.index_type = IndexType.KEYS; ColumnDef columnDef3 = new
         * ColumnDef(ByteBuffer.wrap("PRIVACY_LEVEL".getBytes()), "UTF8Type");
         * columnDef3.index_type = IndexType.KEYS;
         * prefrenceCfDef.addToColumn_metadata(columnDef);
         * prefrenceCfDef.addToColumn_metadata(columnDef3);
         *
         * CfDef externalLinkCfDef = new CfDef(); externalLinkCfDef.name =
         * "EXTERNAL_LINK"; externalLinkCfDef.keyspace = keyspace;
         * externalLinkCfDef.setComparator_type("UTF8Type");
         * externalLinkCfDef.setDefault_validation_class("UTF8Type"); ColumnDef
         * columnDef1 = new ColumnDef(ByteBuffer.wrap("LINK_TYPE".getBytes()),
         * "UTF8Type"); columnDef1.index_type = IndexType.KEYS; ColumnDef
         * columnDef2 = new
         * ColumnDef(ByteBuffer.wrap("LINK_ADDRESS".getBytes()), "UTF8Type");
         * columnDef2.index_type = IndexType.KEYS; ColumnDef columnDef4 = new
         * ColumnDef(ByteBuffer.wrap("USER_ID".getBytes()), "UTF8Type");
         * columnDef4.index_type = IndexType.KEYS;
         * externalLinkCfDef.addToColumn_metadata(columnDef1);
         * externalLinkCfDef.addToColumn_metadata(columnDef2);
         * externalLinkCfDef.addToColumn_metadata(columnDef4);
         */

        List<CfDef> cfDefs = new ArrayList<CfDef>();
        cfDefs.add(userCfDef);
        cfDefs.add(userIndexCfDef);
        cfDefs.add(prefrenceCfDef);
        cfDefs.add(externalLinkCfDef);
        try
        {
            ksDef = CassandraCli.client.describe_keyspace(keyspace);
            CassandraCli.client.set_keyspace(keyspace);
            List<CfDef> cfDefn = ksDef.getCf_defs();

            for (CfDef cfDef1 : cfDefn)
            {

                if (cfDef1.getName().equalsIgnoreCase("USER"))
                {
                    CassandraCli.client.system_drop_column_family("USER");
                }
                if (cfDef1.getName().equalsIgnoreCase("USER" + Constants.INDEX_TABLE_SUFFIX))
                {
                    CassandraCli.client.system_drop_column_family("USER" + Constants.INDEX_TABLE_SUFFIX);
                }
                if (cfDef1.getName().equalsIgnoreCase("PREFERENCE"))
                {
                    CassandraCli.client.system_drop_column_family("PREFERENCE");
                }
                if (cfDef1.getName().equalsIgnoreCase("EXTERNAL_LINK"))
                {
                    CassandraCli.client.system_drop_column_family("EXTERNAL_LINK");
                }
            }
            CassandraCli.client.system_add_column_family(userCfDef);
            CassandraCli.client.system_add_column_family(userIndexCfDef);
            CassandraCli.client.system_add_column_family(externalLinkCfDef);
            CassandraCli.client.system_add_column_family(prefrenceCfDef);
        }
        catch (NotFoundException e)
        {
            ksDef = new KsDef(keyspace, SimpleStrategy.class.getSimpleName(), cfDefs);

            // Set replication factor
            if (ksDef.strategy_options == null)
            {
                ksDef.strategy_options = new LinkedHashMap<String, String>();
View Full Code Here

     *             the schema disagreement exception
     */
    private void loadData() throws TException, InvalidRequestException, UnavailableException, TimedOutException,
            SchemaDisagreementException
    {
        KsDef ksDef = null;
        CfDef user_Def = new CfDef();
        user_Def.name = "PERSON_ESINDEXER";
        user_Def.keyspace = "KunderaExamples";
        user_Def.setComparator_type("UTF8Type");
        user_Def.setDefault_validation_class("UTF8Type");
        user_Def.setKey_validation_class("UTF8Type");
        ColumnDef columnDef = new ColumnDef(ByteBuffer.wrap("PERSON_NAME".getBytes()), "UTF8Type");
        columnDef.index_type = IndexType.KEYS;
        user_Def.addToColumn_metadata(columnDef);
        ColumnDef columnDef1 = new ColumnDef(ByteBuffer.wrap("AGE".getBytes()), "IntegerType");
        columnDef1.index_type = IndexType.KEYS;
        user_Def.addToColumn_metadata(columnDef1);
        ColumnDef columnDef2 = new ColumnDef(ByteBuffer.wrap("ENUM".getBytes()), "UTF8Type");
        columnDef2.index_type = IndexType.KEYS;
        user_Def.addToColumn_metadata(columnDef2);

        List<CfDef> cfDefs = new ArrayList<CfDef>();
        cfDefs.add(user_Def);

        try
        {
            ksDef = CassandraCli.client.describe_keyspace("KunderaExamples");
            CassandraCli.client.set_keyspace("KunderaExamples");

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

            for (CfDef cfDef1 : cfDefn)
            {

                if (cfDef1.getName().equalsIgnoreCase("PERSON_ESINDEXER"))
                {

                    CassandraCli.client.system_drop_column_family("PERSON_ESINDEXER");

                }
            }
            CassandraCli.client.system_add_column_family(user_Def);

        }
        catch (NotFoundException e)
        {

            ksDef = new KsDef("KunderaExamples", "org.apache.cassandra.locator.SimpleStrategy", cfDefs);
            // Set replication factor
            if (ksDef.strategy_options == null)
            {
                ksDef.strategy_options = new LinkedHashMap<String, String>();
            }
View Full Code Here

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

            UnsupportedEncodingException
    {
        getEntityManagerFactory("create");
        Assert.assertTrue(CassandraCli.keyspaceExist("KunderaCoreExmples"));
        Assert.assertTrue(CassandraCli.columnFamilyExist("CassandraEntitySimple", "KunderaCoreExmples"));
        org.apache.cassandra.thrift.KsDef ksDef = new KsDef();
        ksDef = client.describe_keyspace("KunderaCoreExmples");
        Assert.assertEquals(2, ksDef.getCf_defs().size());
        for (org.apache.cassandra.thrift.CfDef cfDef : ksDef.getCf_defs())
        {
            if ("CassandraEntitySimple".equals(cfDef.getName()))
            {
                Assert.assertEquals("CassandraEntitySimple", cfDef.getName());
View Full Code Here

TOP

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

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.