tools/stress/src/org/apache/cassandra/stress/Session.java
/**
     * Create Keyspace1 with Standard1 and Super1 column families
     */
Create Keyspace1 with Standard1 and Super1 column families
Create Keyspace1 with Standard1 and Super1 column families
public void createKeySpaces()
    {
        KsDef keyspace = new KsDef();
        String defaultComparator = comparator == null ? DEFAULT_COMPARATOR : comparator;
        CfDef standardCfDef = new CfDef("Keyspace1", "Standard1");
        Map<String, String> compressionOptions = new HashMap<String, String>();
        if (compression != null)
            compressionOptions.put("sstable_compression", compression);
        standardCfDef.setComparator_type(defaultComparator)
                     .setDefault_validation_class(DEFAULT_VALIDATOR)
                     .setCompression_options(compressionOptions);
        standardCfDef.setCaching("all");
        standardCfDef.setRead_repair_chance(0);
        if (indexType != null)
        {
            ColumnDef standardColumn = new ColumnDef(ByteBufferUtil.bytes("C1"), "BytesType");
            standardColumn.setIndex_type(indexType).setIndex_name("Idx1");
            standardCfDef.setColumn_metadata(Arrays.asList(standardColumn));
        }
        CfDef superCfDef = new CfDef("Keyspace1", "Super1").setColumn_type("Super");
        superCfDef.setComparator_type(DEFAULT_COMPARATOR)
                  .setSubcomparator_type(defaultComparator)
                  .setDefault_validation_class(DEFAULT_VALIDATOR)
                  .setCompression_options(compressionOptions)
                  .setRead_repair_chance(0);
        CfDef counterCfDef = new CfDef("Keyspace1", "Counter1");
        counterCfDef.setDefault_validation_class("CounterColumnType")
                    .setReplicate_on_write(replicateOnWrite)
                    .setCompression_options(compressionOptions)
                    .setRead_repair_chance(0);
        CfDef counterSuperCfDef = new CfDef("Keyspace1", "SuperCounter1");
        counterSuperCfDef.setDefault_validation_class("CounterColumnType")
                         .setReplicate_on_write(replicateOnWrite)
                         .setColumn_type("Super")
                         .setCompression_options(compressionOptions)
                         .setRead_repair_chance(0);
        keyspace.setName("Keyspace1");
        keyspace.setStrategy_class(replicationStrategy);
        if (!replicationStrategyOptions.isEmpty())
        {
            keyspace.setStrategy_options(replicationStrategyOptions);
        }
        if (compactionStrategy != null)
        {
            standardCfDef.setCompaction_strategy(compactionStrategy);
            superCfDef.setCompaction_strategy(compactionStrategy);
            counterCfDef.setCompaction_strategy(compactionStrategy);
            counterSuperCfDef.setCompaction_strategy(compactionStrategy);
        }
        keyspace.setCf_defs(new ArrayList<CfDef>(Arrays.asList(standardCfDef, superCfDef, counterCfDef, counterSuperCfDef)));
        Cassandra.Client client = getClient(false);
        try
        {
            client.system_add_keyspace(keyspace);
	    int sleepTime = 5;
            System.out.println(String.format("Created keyspaces. Sleeping %ss for propagation.", sleepTime));
            Thread.sleep(sleepTime * 1000); 
        }
        catch (InvalidRequestException e)
        {
            System.err.println("Unable to create stress keyspace: " + e.getWhy());
        }
        catch (Exception e)
        {
            System.err.println(e.getMessage());
        }
    }
public void createKeySpaces ( ) { KsDef keyspace = new KsDef ( ) ; String defaultComparator = comparator == null ? DEFAULT_COMPARATOR : comparator ; CfDef standardCfDef = new CfDef ( "Keyspace1" , "Standard1" ) ; Map < String , String > compressionOptions = new HashMap < String , String > ( ) ; if ( compression != null ) compressionOptions . put ( "sstable_compression" , compression ) ; standardCfDef . setComparator_type ( defaultComparator ) . setDefault_validation_class ( DEFAULT_VALIDATOR ) . setCompression_options ( compressionOptions ) ; standardCfDef . setCaching ( "all" ) ; standardCfDef . setRead_repair_chance ( 0 ) ; if ( indexType != null ) { ColumnDef standardColumn = new ColumnDef ( ByteBufferUtil . bytes ( "C1" ) , "BytesType" ) ; standardColumn . setIndex_type ( indexType ) . setIndex_name ( "Idx1" ) ; standardCfDef . setColumn_metadata ( Arrays . asList ( standardColumn ) ) ; } CfDef superCfDef = new CfDef ( "Keyspace1" , "Super1" ) . setColumn_type ( "Super" ) ; superCfDef . setComparator_type ( DEFAULT_COMPARATOR ) . setSubcomparator_type ( defaultComparator ) . setDefault_validation_class ( DEFAULT_VALIDATOR ) . setCompression_options ( compressionOptions ) . setRead_repair_chance ( 0 ) ; CfDef counterCfDef = new CfDef ( "Keyspace1" , "Counter1" ) ; counterCfDef . setDefault_validation_class ( "CounterColumnType" ) . setReplicate_on_write ( replicateOnWrite ) . setCompression_options ( compressionOptions ) . setRead_repair_chance ( 0 ) ; CfDef counterSuperCfDef = new CfDef ( "Keyspace1" , "SuperCounter1" ) ; counterSuperCfDef . setDefault_validation_class ( "CounterColumnType" ) . setReplicate_on_write ( replicateOnWrite ) . setColumn_type ( "Super" ) . setCompression_options ( compressionOptions ) . setRead_repair_chance ( 0 ) ; keyspace . setName ( "Keyspace1" ) ; keyspace . setStrategy_class ( replicationStrategy ) ; if ( ! replicationStrategyOptions . isEmpty ( ) ) { keyspace . setStrategy_options ( replicationStrategyOptions ) ; } if ( compactionStrategy != null ) { standardCfDef . setCompaction_strategy ( compactionStrategy ) ; superCfDef . setCompaction_strategy ( compactionStrategy ) ; counterCfDef . setCompaction_strategy ( compactionStrategy ) ; counterSuperCfDef . setCompaction_strategy ( compactionStrategy ) ; } keyspace . setCf_defs ( new ArrayList < CfDef > ( Arrays . asList ( standardCfDef , superCfDef , counterCfDef , counterSuperCfDef ) ) ) ; Cassandra . Client client = getClient ( false ) ; try { client . system_add_keyspace ( keyspace ) ; int sleepTime = 5 ; System . out . println ( String . format ( "Created keyspaces. Sleeping %ss for propagation." , sleepTime ) ) ; Thread . sleep ( sleepTime * 1000 ) ; } catch ( InvalidRequestException e ) { System . err . println ( "Unable to create stress keyspace: " + e . getWhy ( ) ) ; } catch ( Exception e ) { System . err . println ( e . getMessage ( ) ) ; } }
Create Keyspace1 with Standard1 and Super1 column families
Create Keyspace1 with Standard1 and Super1 column families
// column family for standard columns // column family with super columns // column family for standard counters // column family with counter super columns // seconds