cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dineshjoshi <...@git.apache.org>
Subject [GitHub] cassandra pull request #244: Refactor and add samplers for CASSANDRA-14436
Date Sat, 04 Aug 2018 02:43:38 GMT
Github user dineshjoshi commented on a diff in the pull request:

    https://github.com/apache/cassandra/pull/244#discussion_r207697487
  
    --- Diff: src/java/org/apache/cassandra/metrics/Sampler.java ---
    @@ -0,0 +1,67 @@
    +package org.apache.cassandra.metrics;
    +
    +import java.io.Serializable;
    +import java.util.List;
    +import java.util.concurrent.LinkedBlockingQueue;
    +import java.util.concurrent.ThreadPoolExecutor;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.cassandra.concurrent.JMXEnabledThreadPoolExecutor;
    +import org.apache.cassandra.concurrent.NamedThreadFactory;
    +
    +import com.google.common.annotations.VisibleForTesting;
    +
    +public abstract class Sampler<T>
    +{
    +    public enum SamplerType
    +    {
    +        READS, WRITES, LOCAL_READ_TIME, WRITE_SIZE, CAS_CONTENTIONS
    +    }
    +
    +    @VisibleForTesting
    +    static final ThreadPoolExecutor samplerExecutor = new JMXEnabledThreadPoolExecutor(1,
1,
    +            TimeUnit.SECONDS,
    +            new LinkedBlockingQueue<Runnable>(),
    +            new NamedThreadFactory("Sampler"),
    +            "internal");
    +
    +    public void addSample(final T item, final int value)
    +    {
    +        if (isEnabled())
    +            samplerExecutor.execute(() -> insert(item, value));
    +    }
    +
    +    protected abstract void insert(T item, long value);
    +
    +    public abstract boolean isEnabled();
    +
    +    public abstract void beginSampling(int capacity);
    +
    +    public abstract List<Sample<T>> finishSampling(int count);
    +
    +    public abstract String toString(T value);
    +
    +    /**
    +     * Represents the ranked items collected during a sample period
    +     */
    +    public static class Sample<S> implements Serializable
    +    {
    +
    --- End diff --
    
    Extra white space?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Mime
View raw message