Package org.apache.cassandra.thrift

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.isThriftCompatible())
                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


    @PooledConnection
    public void addKeyspace(String keyspace) throws InvalidRequestException, TException, SchemaDisagreementException {
        // TODO: Take key space in via JSON/XML. (Replace hard-coded values)
        List<CfDef> cfDefList = new ArrayList<CfDef>();
        KsDef ksDef = new KsDef(keyspace, "org.apache.cassandra.locator.SimpleStrategy", cfDefList);
        ksDef.putToStrategy_options("replication_factor", "1");
        getConnection(null).system_add_keyspace(ksDef);
    }
View Full Code Here

    public static KsDef createKeySpace() throws IOException {
        try {
            logger.info("Creating keyspace: " + KEYSPACE_NAME);
            Thread.sleep(new Random().nextInt(5000));

            KsDef cfsKs = checkKeyspace();

            if (cfsKs != null) {
                logger.info("keyspace already exists. Skipping creation.");
                return cfsKs;
            }

            List<CfDef> cfs = new ArrayList<CfDef>();

            CfDef cf = new CfDef();
            cf.setName(JOB_TRACKER_CF);
            cf.setComparator_type("BytesType");
            // there is only one row and one column.
            cf.setKey_cache_size(10);
            cf.setRow_cache_size(10);
            cf.setGc_grace_seconds(60);
            cf.setComment("Stores the current JobTracker node");
            cf.setKeyspace(KEYSPACE_NAME);

            cfs.add(cf);

            Map<String, String> stratOpts = new HashMap<String, String>();
            stratOpts.put(BriskSimpleSnitch.BRISK_DC, System.getProperty("cfs.replication", "1"));
            stratOpts.put(BriskSimpleSnitch.CASSANDRA_DC, "0");

            cfsKs = new KsDef().setName(KEYSPACE_NAME)
                    .setStrategy_class("org.apache.cassandra.locator.NetworkTopologyStrategy")
                    .setStrategy_options(stratOpts).setCf_defs(cfs);

            client.system_add_keyspace(cfsKs);
            waitForSchemaAgreement(client);
View Full Code Here

        CfDef cf = new CfDef(cassandraClientHolder.getKeyspaceName(),
                cassandraClientHolder.getColumnFamily());
        cf.setKey_validation_class("UTF8Type");
        cf.setComparator_type("UTF8Type");
        KsDef ks = new KsDef(cassandraClientHolder.getKeyspaceName(),
                "org.apache.cassandra.locator.SimpleStrategy",
                Arrays.asList(cf));
        ks.setStrategy_options(KSMetaData.optsWithRF(configuration.getInt(CassandraClientHolder.CONF_PARAM_REPLICATION_FACTOR, 1)));
        try
        {
            cassandraClientHolder.getClient().system_add_keyspace(ks);
            return true;
        }
View Full Code Here

        {
            defs = cassandraClientHolder.getClient().describe_keyspaces();

            for (Iterator<KsDef> iterator = defs.iterator(); iterator.hasNext();)
            {
                KsDef ksDef = iterator.next();
                String name = ksDef.name;
                log.debug("Found ksDef name: {}",name);
                if ( StringUtils.indexOfAny(name, SYSTEM_KEYSPACES) > -1 || isKeyspaceMapped(name))
                {
                    log.debug("REMOVING ksDef name from unmapped List: {}",name);
View Full Code Here

    public void testAutoCreateFromKeyspace() throws Exception
    {
        CassandraHiveMetaStore metaStore = new CassandraHiveMetaStore();
        Configuration conf = buildConfiguration();
        CassandraClientHolder clientHolder = new CassandraClientHolder(conf);
        KsDef ksDef = setupOtherKeyspace(conf,"AutoCreatedFromKeyspace", false);
        clientHolder.getClient().system_add_keyspace(ksDef);
        conf.setBoolean("cassandra.autoCreateHiveSchema", true);
        metaStore.setConf(conf);       
        Database foundDb = metaStore.getDatabase("AutoCreatedFromKeyspace");
        assertNotNull(foundDb);
View Full Code Here

            cf.addToColumn_metadata(new ColumnDef(ByteBufferUtil.bytes("col_name_bytes"), BytesType.class.getName()));
            cf.addToColumn_metadata(new ColumnDef(ByteBufferUtil.bytes("col_name_int"), IntegerType.class.getName()));
            cf.addToColumn_metadata(new ColumnDef(ByteBufferUtil.bytes("col_name_long"), LongType.class.getName()));
            cf.addToColumn_metadata(new ColumnDef(ByteBufferUtil.bytes("col_name_timeuuid"), TimeUUIDType.class.getName()));
        }
        KsDef ks = new KsDef(ksName,
                "org.apache.cassandra.locator.SimpleStrategy"
                Arrays.asList(cf));
        ks.setStrategy_options(KSMetaData.optsWithRF(configuration.getInt(CassandraClientHolder.CONF_PARAM_REPLICATION_FACTOR, 1)));
        return ks;                
   
View Full Code Here

   

    @Test
    public void testCreateKeyspaceSchema() throws Exception
    {
        KsDef ksDef = setupOtherKeyspace(configuration,"CreatedKeyspace", false);
        cassandraClientHolder.getClient().system_add_keyspace(ksDef);
        schemaManagerService.createKeyspaceSchema(ksDef);
        List<KsDef> keyspaces = schemaManagerService.findUnmappedKeyspaces();
       
        // don't impose a keyspace maintenance burden. Looking for specifics is good enough
View Full Code Here

    }
   
    @Test
    public void testSkipCreateOnConfig() throws Exception
    {
        KsDef ksDef = setupOtherKeyspace(configuration,"SkipCreatedKeyspace", false);
        cassandraClientHolder.getClient().system_add_keyspace(ksDef);              
       
        schemaManagerService.createKeyspaceSchemasIfNeeded();
        List<KsDef> keyspaces = schemaManagerService.findUnmappedKeyspaces();
        boolean skipped = false;
View Full Code Here

    }
   
    @Test
    public void testCreateOnConfig() throws Exception
    {
        KsDef ksDef = setupOtherKeyspace(configuration,"ConfigCreatedKeyspace", false);
        cassandraClientHolder.getClient().system_add_keyspace(ksDef);

        configuration.setBoolean("cassandra.autoCreateHiveSchema", true);       
       
        schemaManagerService.createKeyspaceSchemasIfNeeded();
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.