Search in sources :

Example 1 with ColumnFamilyStoreMBean

use of org.apache.cassandra.db.ColumnFamilyStoreMBean in project cassandra by apache.

the class ColumnFamilyStoreMBeanIterator method getPartitionSample.

public Map<Sampler, CompositeData> getPartitionSample(String ks, String cf, int capacity, int duration, int count, List<Sampler> samplers) throws OpenDataException {
    ColumnFamilyStoreMBean cfsProxy = getCfsProxy(ks, cf);
    for (Sampler sampler : samplers) {
        cfsProxy.beginLocalSampling(sampler.name(), capacity);
    }
    Uninterruptibles.sleepUninterruptibly(duration, TimeUnit.MILLISECONDS);
    Map<Sampler, CompositeData> result = Maps.newHashMap();
    for (Sampler sampler : samplers) {
        result.put(sampler, cfsProxy.finishLocalSampling(sampler.name(), count));
    }
    return result;
}
Also used : Sampler(org.apache.cassandra.metrics.TableMetrics.Sampler) CompositeData(javax.management.openmbean.CompositeData) StreamStateCompositeData(org.apache.cassandra.streaming.management.StreamStateCompositeData) ColumnFamilyStoreMBean(org.apache.cassandra.db.ColumnFamilyStoreMBean)

Example 2 with ColumnFamilyStoreMBean

use of org.apache.cassandra.db.ColumnFamilyStoreMBean in project cassandra by apache.

the class GetCompactionThreshold method execute.

@Override
public void execute(NodeProbe probe) {
    checkArgument(args.size() == 2, "getcompactionthreshold requires ks and cf args");
    String ks = args.get(0);
    String cf = args.get(1);
    ColumnFamilyStoreMBean cfsProxy = probe.getCfsProxy(ks, cf);
    System.out.println("Current compaction thresholds for " + ks + "/" + cf + ": \n" + " min = " + cfsProxy.getMinimumCompactionThreshold() + ", " + " max = " + cfsProxy.getMaximumCompactionThreshold());
}
Also used : ColumnFamilyStoreMBean(org.apache.cassandra.db.ColumnFamilyStoreMBean)

Example 3 with ColumnFamilyStoreMBean

use of org.apache.cassandra.db.ColumnFamilyStoreMBean in project cassandra by apache.

the class JMXAuthTest method writeAttribute.

@Test
public void writeAttribute() throws Throwable {
    ColumnFamilyStoreMBean proxy = JMX.newMBeanProxy(connection, ObjectName.getInstance(tableMBean.getObjectName()), ColumnFamilyStoreMBean.class);
    MBeanAction action = () -> proxy.setMinimumCompactionThreshold(4);
    // grant MODIFY on a single specific Table mbean
    assertPermissionOnResource(Permission.MODIFY, tableMBean, action);
    // grant MODIFY on all Table mbeans in named keyspace
    clearAllPermissions();
    JMXResource allTablesInKeyspace = JMXResource.mbean(String.format("org.apache.cassandra.db:type=Tables,keyspace=%s,*", KEYSPACE));
    assertPermissionOnResource(Permission.MODIFY, allTablesInKeyspace, action);
    // grant MODIFY on all Table mbeans
    clearAllPermissions();
    JMXResource allTables = JMXResource.mbean("org.apache.cassandra.db:type=Tables,*");
    assertPermissionOnResource(Permission.MODIFY, allTables, action);
    // grant MODIFY ON ALL MBEANS
    clearAllPermissions();
    assertPermissionOnResource(Permission.MODIFY, JMXResource.root(), action);
}
Also used : ColumnFamilyStoreMBean(org.apache.cassandra.db.ColumnFamilyStoreMBean) Test(org.junit.Test)

Example 4 with ColumnFamilyStoreMBean

use of org.apache.cassandra.db.ColumnFamilyStoreMBean in project eiger by wlloyd.

the class CliClient method describeColumnFamily.

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("      Columns 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("      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
                }
            }
            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());
        }
    }
    sessionState.out.printf("      Compaction Strategy: %s%n", cf_def.compaction_strategy);
    if (!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());
    }
}
Also used : ColumnFamilyStoreMBean(org.apache.cassandra.db.ColumnFamilyStoreMBean)

Example 5 with ColumnFamilyStoreMBean

use of org.apache.cassandra.db.ColumnFamilyStoreMBean in project eiger by wlloyd.

the class NodeCmd method printCfHistograms.

private void printCfHistograms(String keySpace, String columnFamily, PrintStream output) {
    ColumnFamilyStoreMBean store = this.probe.getCfsProxy(keySpace, columnFamily);
    // default is 90 offsets
    long[] offsets = new EstimatedHistogram().getBucketOffsets();
    long[] rrlh = store.getRecentReadLatencyHistogramMicros();
    long[] rwlh = store.getRecentWriteLatencyHistogramMicros();
    long[] sprh = store.getRecentSSTablesPerReadHistogram();
    long[] ersh = store.getEstimatedRowSizeHistogram();
    long[] ecch = store.getEstimatedColumnCountHistogram();
    output.println(String.format("%s/%s histograms", keySpace, columnFamily));
    output.println(String.format("%-10s%10s%18s%18s%18s%18s", "Offset", "SSTables", "Write Latency", "Read Latency", "Row Size", "Column Count"));
    for (int i = 0; i < offsets.length; i++) {
        output.println(String.format("%-10d%10s%18s%18s%18s%18s", offsets[i], (i < sprh.length ? sprh[i] : ""), (i < rwlh.length ? rwlh[i] : ""), (i < rrlh.length ? rrlh[i] : ""), (i < ersh.length ? ersh[i] : ""), (i < ecch.length ? ecch[i] : "")));
    }
}
Also used : EstimatedHistogram(org.apache.cassandra.utils.EstimatedHistogram) ColumnFamilyStoreMBean(org.apache.cassandra.db.ColumnFamilyStoreMBean)

Aggregations

ColumnFamilyStoreMBean (org.apache.cassandra.db.ColumnFamilyStoreMBean)13 Test (org.junit.Test)3 Entry (java.util.Map.Entry)2 ObjectName (javax.management.ObjectName)2 IOException (java.io.IOException)1 AbstractMap (java.util.AbstractMap)1 ArrayList (java.util.ArrayList)1 MalformedObjectNameException (javax.management.MalformedObjectNameException)1 CompositeData (javax.management.openmbean.CompositeData)1 Sampler (org.apache.cassandra.metrics.TableMetrics.Sampler)1 StreamStateCompositeData (org.apache.cassandra.streaming.management.StreamStateCompositeData)1 EstimatedHistogram (org.apache.cassandra.utils.EstimatedHistogram)1