Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*-
   * See the file LICENSE for redistribution information.
   *
   * Copyright (c) 2002, 2013 Oracle and/or its affiliates.  All rights reserved.
   *
   */
  
  package com.sleepycat.je.rep;
  
 import static com.sleepycat.je.rep.impl.node.FeederManagerStatDefinition.N_FEEDERS_CREATED;
 import static com.sleepycat.je.rep.impl.node.FeederManagerStatDefinition.N_FEEDERS_SHUTDOWN;
 import static com.sleepycat.je.rep.impl.node.FeederManagerStatDefinition.N_MAX_REPLICA_LAG;
 import static com.sleepycat.je.rep.impl.node.FeederManagerStatDefinition.N_MAX_REPLICA_LAG_NAME;
 import static com.sleepycat.je.rep.impl.node.ReplayStatDefinition.MAX_COMMIT_PROCESSING_NANOS;
 import static com.sleepycat.je.rep.impl.node.ReplayStatDefinition.MIN_COMMIT_PROCESSING_NANOS;
 import static com.sleepycat.je.rep.impl.node.ReplayStatDefinition.N_ABORTS;
 import static com.sleepycat.je.rep.impl.node.ReplayStatDefinition.N_COMMITS;
 import static com.sleepycat.je.rep.impl.node.ReplayStatDefinition.N_COMMIT_ACKS;
 import static com.sleepycat.je.rep.impl.node.ReplayStatDefinition.N_COMMIT_NO_SYNCS;
 import static com.sleepycat.je.rep.impl.node.ReplayStatDefinition.N_COMMIT_SYNCS;
 import static com.sleepycat.je.rep.impl.node.ReplayStatDefinition.N_COMMIT_WRITE_NO_SYNCS;
 import static com.sleepycat.je.rep.impl.node.ReplayStatDefinition.N_ELAPSED_TXN_TIME;
 import static com.sleepycat.je.rep.impl.node.ReplayStatDefinition.N_LNS;
 import static com.sleepycat.je.rep.impl.node.ReplayStatDefinition.N_NAME_LNS;
 import static com.sleepycat.je.rep.impl.node.ReplayStatDefinition.TOTAL_COMMIT_PROCESSING_NANOS;
 import static com.sleepycat.je.rep.impl.node.ReplicaStatDefinition.N_LAG_CONSISTENCY_WAITS;
 import static com.sleepycat.je.rep.impl.node.ReplicaStatDefinition.N_LAG_CONSISTENCY_WAIT_MS;
 import static com.sleepycat.je.rep.impl.node.ReplicaStatDefinition.N_VLSN_CONSISTENCY_WAITS;
 import static com.sleepycat.je.rep.impl.node.ReplicaStatDefinition.N_VLSN_CONSISTENCY_WAIT_MS;
 import static com.sleepycat.je.rep.stream.FeederTxnStatDefinition.ACK_WAIT_MS;
 import static com.sleepycat.je.rep.stream.FeederTxnStatDefinition.TOTAL_TXN_MS;
 import static com.sleepycat.je.rep.stream.FeederTxnStatDefinition.TXNS_ACKED;
 import static com.sleepycat.je.rep.stream.FeederTxnStatDefinition.TXNS_NOT_ACKED;
 import static com.sleepycat.je.rep.utilint.BinaryProtocolStatDefinition.BYTES_READ_RATE;
 import static com.sleepycat.je.rep.utilint.BinaryProtocolStatDefinition.BYTES_WRITE_RATE;
 import static com.sleepycat.je.rep.utilint.BinaryProtocolStatDefinition.MESSAGE_READ_RATE;
 import static com.sleepycat.je.rep.utilint.BinaryProtocolStatDefinition.MESSAGE_WRITE_RATE;
 import static com.sleepycat.je.rep.utilint.BinaryProtocolStatDefinition.N_BYTES_READ;
 import static com.sleepycat.je.rep.utilint.BinaryProtocolStatDefinition.N_BYTES_WRITTEN;
 import static com.sleepycat.je.rep.utilint.BinaryProtocolStatDefinition.N_MESSAGES_READ;
 import static com.sleepycat.je.rep.utilint.BinaryProtocolStatDefinition.N_MESSAGES_WRITTEN;
 import static com.sleepycat.je.rep.utilint.BinaryProtocolStatDefinition.N_READ_NANOS;
 import static com.sleepycat.je.rep.utilint.BinaryProtocolStatDefinition.N_WRITE_NANOS;
 
 import java.util.Map;
 
Statistics for a replicated environment.

The statistics are logically grouped into four categories. Viewing the statistics through toString() displays the values in these categories, as does viewing the stats through the /../jconsole/JConsole-plugin.html">RepJEMonitor mbean}. Viewing the stats with toStringVerbose() will provide more detailed descriptions of the stats and stat categories.

The current categories are:

  • FeederManager: A feed is the href="{@docRoot/../ReplicationGuide/introduction.html#replicationstreams">replication stream} between a master and replica. The current number of feeders gives a sense of the connectivity of the replication group.
  • BinaryProtocol: These statistics center on the network traffic engendered by the replication stream, and provide a sense of the network bandwidth seen by the replication group.
  • Replay: The act of receiving and applying the replication stream at the Replica node is called Replay. These stats give a sense of how much load the replica node is experiencing when processing the traffic from the replication group.
  • ConsistencyTracker: The tracker is invoked when consistency policies are used at a replica node. This provides a measure of delays experienced by read requests at a replica, in order to conform with the consistency specified by the application.

See also:
Viewing Statistics with JConsole
public class ReplicatedEnvironmentStats implements Serializable {
    private static final long serialVersionUID = 1L;

    
The "impossible" return value used by stats accessors to indicate the statistic is not available in this instance of ReplicatedEnvironmentStats, because it represents an earlier de-serialized instance in which this statistic was unavailable.
    private static final int VALUE_UNAVAILABLE = -1;
    private final StatGroup feederManagerStats;
    private final StatGroup feederTxnStats;
    private final StatGroup replayStats;
    private final StatGroup trackerStats;
    private final StatGroup protocolStats;
    private final StatGroup vlsnIndexStats;
    private final Map<StringStringtipsMap = new HashMap<StringString>();
    ReplicatedEnvironmentStats(RepImpl repImplStatsConfig config) {
        final RepNode repNode = repImpl.getRepNode();
        final FeederManager feederManager = repNode.feederManager();
         = feederManager.getFeederManagerStats(config);
         = repNode.getFeederTxns().getStats(config);
        final Replica replica = repNode.getReplica();
         = replica.getReplayStats(config);
         = replica.getTrackerStats(config);
         = feederManager.getProtocolStats(config);
         = repImpl.getVLSNIndex().getStats(config);
        .addAll(replica.getProtocolStats(config));
        addMessageRateStats();
        addBytesRateStats();
    }

    

Hidden:
Internal use only.
    public Collection<StatGroupgetStatGroups() {
        return ( != null) ?
            Arrays.asList(,
                          ,
                          ,
                          ,
                          ,
                          ) :
            Arrays.asList(,
                          ,
                          ,
                          ,
                          );
    }

    

Hidden:
Internal use only For JConsole plugin support.
    public static String[] getStatGroupTitles() {
        return new String[] {
            .,
            .,
            .,
            .};
    }
    private void addMessageRateStats() {
        @SuppressWarnings("unused")
        IntegralRateStat msgReadRate =
            new IntegralRateStat(,
                                 .getLongStat(),
                                 .getLongStat(),
                                 1000000000);
        @SuppressWarnings("unused")
        IntegralRateStat msgWriteRate =
            new IntegralRateStat(,
                                 ,
                                 .getLongStat(),
                                 .getLongStat(),
                                 1000000000);
    }
    private void addBytesRateStats() {
        @SuppressWarnings("unused")
        IntegralRateStat bytesReadRate =
            new IntegralRateStat(,
                                 ,
                                 .getLongStat(),
                                 .getLongStat(),
                                 1000000000);
        @SuppressWarnings("unused")
        IntegralRateStat bytesWriteRate =
            new IntegralRateStat(,
                                 ,
                                 .getLongStat(),
                                 .getLongStat(),
                                 1000000000);
    }
    /* Feeder Stats. */

    
The number of Feeder threads since this node was started. A Master supplies the Replication Stream to a Replica via a Feeder thread. The Feeder thread is created when a Replica connects to the node and is shutdown when the connection is terminated.
    public int getNFeedersCreated() {
    }

    
The number of Feeder threads that were shut down, either because this node, or the Replica terminated the connection.

    public int getNFeedersShutdown() {
    }

    
The lag (in VLSNs) associated with the replica that's farthest behind in replaying the replication stream.
    public long getNMaxReplicaLag() {
    }

    
The name of the replica that's farthest behind in replaying the replication stream.
    public String getNMaxReplicaLagName() {
    }
    /* Master transaction commit acknowledgment statistics. */

    
The number of transactions that were successfully acknowledged based upon the com.sleepycat.je.Durability.ReplicaAckPolicy policy associated with the transaction commit.
    public long getNTxnsAcked() {
        return ( == null) ?
                :
               .getAtomicLong();
    }

    
The number of transactions that were not acknowledged as required by the com.sleepycat.je.Durability.ReplicaAckPolicy policy associated with the transaction commit. These transactions resulted in InsufficientReplicasException or InsufficientAcksException.
    public long getNTxnsNotAcked() {
        return ( == null) ?
                :
               .getAtomicLong();
    }

    
The total time in milliseconds spent in replicated transactions. This represents the time from the start of the transaction until its successful commit and acknowledgment. It includes the time spent waiting for transaction commit acknowledgments, as determined by getAckWaitMs().
    public long getTotalTxnMs() {
        return ( == null) ?
                 :
                .getAtomicLong();
    }

    
The total time in milliseconds that the master spent waiting for the com.sleepycat.je.Durability.ReplicaAckPolicy to be satisfied during successful transaction commits.

See also:
getTotalTxnMs()
    public long getAckWaitMs() {
        return ( == null) ?
                 :
                .getAtomicLong();
    }
    /* Replay Stats. */

    
The number of commit log records that were replayed by this node when it was a Replica. There is one commit record record for each actual commit on the Master.
    public long getNReplayCommits() {
        return .getLong();
    }

    
The number of commit log records that needed to be acknowledged to the Master by this node when it was a Replica. The rate of change of this statistic, will show a strong correlation with that of NReplayCommits statistic, if the Durability policy used by transactions on the master calls for transaction commit acknowledgments and the Replica is current with respect to the Master.
    public long getNReplayCommitAcks() {
        return .getLong();
    }

    
The number of commitSync() calls executed when satisfying transaction commit acknowledgment requests from the Master.
    public long getNReplayCommitSyncs() {
        return .getLong();
    }

    
The number of commitNoSync() calls executed when satisfying transaction commit acknowledgment requests from the Master.
    public long getNReplayCommitNoSyncs() {
        return .getLong();
    }

    
The number of commitNoSync() calls executed when satisfying transaction commit acknowledgment requests from the Master.
    public long getNReplayCommitWriteNoSyncs() {
    }

    
The number of abort records which were replayed while the node was in the Replica state.
    public long getNReplayAborts() {
        return .getLong();
    }

    
The number of NameLN records which were replayed while the node was in the Replica state.
    public long getNReplayNameLNs() {
        return .getLong();
    }

    
The number of data records (creation, update, deletion) which were replayed while the node was in the Replica state.
    public long getNReplayLNs() {
        return .getLong();
    }

    
The total elapsed time in milliseconds spent replaying committed and aborted transactions.
    public long getReplayElapsedTxnTime() {
        return .getLong();
    }

    
The minimum time taken to replay a transaction commit operation.
    public long getReplayMinCommitProcessingNanos() {
    }

    
The maximum time taken to replay a transaction commit operation.
    public long getReplayMaxCommitProcessingNanos() {
    }

    
The total time spent to replay all commit operations.
    public long getReplayTotalCommitProcessingNanos() {
    }
    /* Protocol Stats. */

    
The number of bytes of Replication Stream read over the network. It does not include the TCP/IP overhead.

If the node has served as both a Replica and Master since it was first started, the number represents the sum total of all Feeder related network activity, as well as Replica network activity.

    public long getNProtocolBytesRead() {
        return .getLong();
    }

    
The number of Replication Stream messages read over the network.

If the node has served as both a Replica and Master since it was first started, the number represents the sum total of all Feeder related network activity, as well as Replica network activity.

    public long getNProtocolMessagesRead() {
        return .getLong();
    }

    
The number of Replication Stream bytes written over the network.

If the node has served as both a Replica and Master since it was first started, the number represents the sum total of all Feeder related network activity, as well as Replica network activity.

    public long getNProtocolBytesWritten() {
        return .getLong();
    }

    
The number of Replication Stream messages written over the network.

If the node has served as both a Replica and Master since it was first started, the number represents the sum total of all Feeder related network activity, as well as Replica network activity.

    public long getNProtocolMessagesWritten() {
        return .getLong();
    }

    
The number of nanoseconds spent reading from the network channel.

If the node has served as both a Replica and Master since it was first started, the number represents the sum total of all Feeder related network activity, as well as Replica network activity.

    public long getProtocolReadNanos() {
        return .getLong();
    }

    
The number of nanoseconds spent writing to the network channel.

If the node has served as both a Replica and Master since it was first started, the number represents the sum total of all Feeder related network activity, as well as Replica network activity.

    public long getProtocolWriteNanos() {
        return .getLong();
    }

    
Incoming replication message throughput, in terms of messages received from the replication network channels per second.

If the node has served as both a Replica and Master since it was first started, the number represents the message reading rate over all Feeder related network activity, as well as Replica network activity.

    public long getProtocolMessageReadRate() {
        return .getLong();
    }

    
Outgoing message throughput, in terms of message written to the replication network channels per second.

If the node has served as both a Replica and Master since it was first started, the number represents the message writing rate over all Feeder related network activity, as well as Replica network activity.

    public long getProtocolMessageWriteRate() {
        return .getLong();
    }

    
Bytes read throughput, in terms of bytes received from the replication network channels per second.

If the node has served as both a Replica and Master since it was first started, the number represents the bytes reading rate over all Feeder related network activity, as well as Replica network activity.

    public long getProtocolBytesReadRate() {
        return .getLong();
    }

    
Bytes written throughput, in terms of bytes written to the replication network channels per second.

If the node has served as both a Replica and Master since it was first started, the number represents the bytes writing rate over all Feeder related network activity, as well as Replica network activity.

    public long getProtocolBytesWriteRate() {
        return .getLong();
    }
    /* ConsistencyTracker Stats. */

    
    public long getTrackerLagConsistencyWaits() {
    }

    
    public long getTrackerLagConsistencyWaitMs() {
    }

    
    public long getTrackerVLSNConsistencyWaits() {
    }

    
    public long getTrackerVLSNConsistencyWaitMs() {
    }

    
Returns a string representation of the statistics.
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        for (StatGroup group : getStatGroups()) {
            sb.append(group.toString());
        }
        return sb.toString();
    }
    public String toStringVerbose() {
        StringBuilder sb = new StringBuilder();
        for (StatGroup group : getStatGroups()) {
            sb.append(group.toStringVerbose());
        }
        return sb.toString();
    }
    public Map<StringStringgetTips() {
        /* Add FeederManager stats definition. */
        for (StatGroup group : getStatGroups()) {
            .put(group.getName(), group.getDescription());
            for (StatDefinition  def : group.getStats().keySet()) {
                .put(def.getName(), def.getDescription());
            }
        }
        return ;
    }
New to GrepCode? Check out our FAQ X