Example usage for org.apache.cassandra.tools NodeProbe getCfsProxy

List of usage examples for org.apache.cassandra.tools NodeProbe getCfsProxy

Introduction

In this page you can find the example usage for org.apache.cassandra.tools NodeProbe getCfsProxy.

Prototype

public ColumnFamilyStoreMBean getCfsProxy(String ks, String cf) 

Source Link

Usage

From source file:com.perpetumobile.bit.orm.cassandra.CliMain.java

License:Apache License

private void describeColumnFamily(KsDef ks_def, CfDef cf_def, NodeProbe probe) throws TException {
    // fetching bean for current column family store
    ColumnFamilyStoreMBean cfMBean = (probe == null) ? null
            : probe.getCfsProxy(ks_def.getName(), cf_def.getName());

    boolean isSuper = cf_def.column_type.equals("Super");
    sessionState.out.printf("    ColumnFamily: %s%s%n", cf_def.name, isSuper ? " (Super)" : "");

    if (cf_def.comment != null && !cf_def.comment.isEmpty())
        sessionState.out.printf("    \"%s\"%n", cf_def.comment);

    if (cf_def.key_validation_class != null)
        sessionState.out.printf("      Key Validation Class: %s%n", cf_def.key_validation_class);

    if (cf_def.default_validation_class != null)
        sessionState.out.printf("      Default column value validator: %s%n", cf_def.default_validation_class);

    sessionState.out.printf("      Cells sorted by: %s%s%n", cf_def.comparator_type,
            cf_def.column_type.equals("Super") ? "/" + cf_def.subcomparator_type : "");
    sessionState.out.printf("      GC grace seconds: %s%n", cf_def.gc_grace_seconds);
    sessionState.out.printf("      Compaction min/max thresholds: %s/%s%n", cf_def.min_compaction_threshold,
            cf_def.max_compaction_threshold);
    sessionState.out.printf("      Read repair chance: %s%n", cf_def.read_repair_chance);
    sessionState.out.printf("      DC Local Read repair chance: %s%n", cf_def.dclocal_read_repair_chance);
    sessionState.out.printf("      Populate IO Cache on flush: %b%n", cf_def.populate_io_cache_on_flush);
    sessionState.out.printf("      Replicate on write: %s%n", cf_def.replicate_on_write);
    sessionState.out.printf("      Caching: %s%n", cf_def.caching);
    sessionState.out.printf("      Bloom Filter FP chance: %s%n",
            cf_def.isSetBloom_filter_fp_chance() ? cf_def.bloom_filter_fp_chance : "default");

    // if we have connection to the cfMBean established
    if (cfMBean != null)
        sessionState.out.printf("      Built indexes: %s%n", cfMBean.getBuiltIndexes());

    if (cf_def.getColumn_metadataSize() != 0) {
        String leftSpace = "      ";
        String columnLeftSpace = leftSpace + "    ";

        String compareWith = isSuper ? cf_def.subcomparator_type : cf_def.comparator_type;
        AbstractType<?> columnNameValidator = getFormatType(compareWith);

        sessionState.out.println(leftSpace + "Column Metadata:");
        for (ColumnDef columnDef : cf_def.getColumn_metadata()) {
            String columnName = columnNameValidator.getString(columnDef.name);
            if (columnNameValidator instanceof BytesType) {
                try {
                    String columnString = UTF8Type.instance.getString(columnDef.name);
                    columnName = columnString + " (" + columnName + ")";
                } catch (MarshalException e) {
                    // guess it wasn't a utf8 column name after all
                }/*from  www . ja v a  2  s.  co  m*/
            }

            sessionState.out.println(leftSpace + "  Column Name: " + columnName);
            sessionState.out.println(columnLeftSpace + "Validation Class: " + columnDef.getValidation_class());

            if (columnDef.isSetIndex_name())
                sessionState.out.println(columnLeftSpace + "Index Name: " + columnDef.getIndex_name());

            if (columnDef.isSetIndex_type())
                sessionState.out.println(columnLeftSpace + "Index Type: " + columnDef.getIndex_type().name());

            if (columnDef.isSetIndex_options())
                sessionState.out.println(columnLeftSpace + "Index Options: " + columnDef.getIndex_options());
        }
    }

    sessionState.out.printf("      Compaction Strategy: %s%n", cf_def.compaction_strategy);

    if (cf_def.compaction_strategy_options != null && !cf_def.compaction_strategy_options.isEmpty()) {
        sessionState.out.println("      Compaction Strategy Options:");
        for (Map.Entry<String, String> e : cf_def.compaction_strategy_options.entrySet())
            sessionState.out.printf("        %s: %s%n", e.getKey(), e.getValue());
    }

    if (cf_def.compression_options != null && !cf_def.compression_options.isEmpty()) {
        sessionState.out.println("      Compression Options:");
        for (Map.Entry<String, String> e : cf_def.compression_options.entrySet())
            sessionState.out.printf("        %s: %s%n", e.getKey(), e.getValue());
    }
}