activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject git commit: Expose a JMX attribute to show when the last leveldb replication log entry was recorded.
Date Mon, 14 Oct 2013 12:52:28 GMT
Updated Branches:
  refs/heads/trunk 6d15c348b -> d44c8968c


Expose a JMX attribute to show when the last leveldb replication log entry was recorded. 


This can be used to get a time estimate of far behind a master a slave is.

Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/d44c8968
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/d44c8968
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/d44c8968

Branch: refs/heads/trunk
Commit: d44c8968c4320dde1e60685b538c58bfaef1cb9f
Parents: 6d15c34
Author: Hiram Chirino <hiram@hiramchirino.com>
Authored: Mon Oct 14 08:45:54 2013 -0400
Committer: Hiram Chirino <hiram@hiramchirino.com>
Committed: Mon Oct 14 08:45:54 2013 -0400

----------------------------------------------------------------------
 .../replicated/ReplicatedLevelDBStoreViewMBean.java  |  3 +++
 .../activemq/leveldb/replicated/dto/LogWrite.java    |  2 ++
 .../leveldb/replicated/ElectingLevelDBStore.scala    | 15 +++++++++++++++
 .../leveldb/replicated/MasterLevelDBStore.scala      |  6 +++++-
 .../leveldb/replicated/SlaveLevelDBStore.scala       |  3 +++
 5 files changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/d44c8968/activemq-leveldb-store/src/main/java/org/apache/activemq/leveldb/replicated/ReplicatedLevelDBStoreViewMBean.java
----------------------------------------------------------------------
diff --git a/activemq-leveldb-store/src/main/java/org/apache/activemq/leveldb/replicated/ReplicatedLevelDBStoreViewMBean.java
b/activemq-leveldb-store/src/main/java/org/apache/activemq/leveldb/replicated/ReplicatedLevelDBStoreViewMBean.java
index 9015242..19b2192 100644
--- a/activemq-leveldb-store/src/main/java/org/apache/activemq/leveldb/replicated/ReplicatedLevelDBStoreViewMBean.java
+++ b/activemq-leveldb-store/src/main/java/org/apache/activemq/leveldb/replicated/ReplicatedLevelDBStoreViewMBean.java
@@ -52,6 +52,9 @@ public interface ReplicatedLevelDBStoreViewMBean {
     @MBeanInfo("The current position of the replication log.")
     Long getPosition();
 
+    @MBeanInfo("When the last entry was added to the replication log.")
+    Long getPositionDate();
+
     @MBeanInfo("The directory holding the data.")
     String getDirectory();
 

http://git-wip-us.apache.org/repos/asf/activemq/blob/d44c8968/activemq-leveldb-store/src/main/java/org/apache/activemq/leveldb/replicated/dto/LogWrite.java
----------------------------------------------------------------------
diff --git a/activemq-leveldb-store/src/main/java/org/apache/activemq/leveldb/replicated/dto/LogWrite.java
b/activemq-leveldb-store/src/main/java/org/apache/activemq/leveldb/replicated/dto/LogWrite.java
index 52e126f..b3749bb 100644
--- a/activemq-leveldb-store/src/main/java/org/apache/activemq/leveldb/replicated/dto/LogWrite.java
+++ b/activemq-leveldb-store/src/main/java/org/apache/activemq/leveldb/replicated/dto/LogWrite.java
@@ -43,4 +43,6 @@ public class LogWrite {
     @XmlAttribute(name="sync")
     public boolean sync=false;
 
+    @XmlAttribute(name="date")
+    public long date;
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/d44c8968/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/ElectingLevelDBStore.scala
----------------------------------------------------------------------
diff --git a/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/ElectingLevelDBStore.scala
b/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/ElectingLevelDBStore.scala
index 53e9971..0399bd9 100644
--- a/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/ElectingLevelDBStore.scala
+++ b/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/ElectingLevelDBStore.scala
@@ -463,6 +463,21 @@ class ReplicatedLevelDBStoreView(val store:ElectingLevelDBStore) extends
Replica
     null
   }
 
+  def getPositionDate:java.lang.Long = {
+    val rc = if( slave!=null ) {
+      slave.wal_date
+    } else if( master!=null ) {
+      master.wal_date
+    } else {
+      0
+    }
+    if( rc != 0 ) {
+      return new java.lang.Long(rc)
+    } else {
+      return null
+    }
+  }
+
   def getDirectory = directory.getCanonicalPath
   def getSync = sync
 

http://git-wip-us.apache.org/repos/asf/activemq/blob/d44c8968/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBStore.scala
----------------------------------------------------------------------
diff --git a/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBStore.scala
b/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBStore.scala
index 6572aa9..b8289fc 100644
--- a/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBStore.scala
+++ b/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBStore.scala
@@ -386,6 +386,7 @@ class MasterLevelDBStore extends LevelDBStore with ReplicatedLevelDBStoreTrait
{
     false
   }
 
+  def date = System.currentTimeMillis()
 
   def replicate_wal(file:File, position:Long, offset:Long, length:Long):Unit = {
     if( length > 0 ) {
@@ -393,6 +394,8 @@ class MasterLevelDBStore extends LevelDBStore with ReplicatedLevelDBStoreTrait
{
       value.file = position;
       value.offset = offset;
       value.length = length
+      value.date = date
+      wal_date = value.date;
       value.sync = (syncToMask & SYNC_TO_REMOTE_DISK)!=0
       val frame1 = ReplicationFrame(WAL_ACTION, JsonCodec.encode(value))
       val frame2 = FileTransferFrame(file, offset, length)
@@ -412,5 +415,6 @@ class MasterLevelDBStore extends LevelDBStore with ReplicatedLevelDBStoreTrait
{
   }
 
   def wal_append_position = client.wal_append_position
-
+  @volatile
+  var wal_date = 0L
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/d44c8968/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/SlaveLevelDBStore.scala
----------------------------------------------------------------------
diff --git a/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/SlaveLevelDBStore.scala
b/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/SlaveLevelDBStore.scala
index 8c832a7..ce76230 100644
--- a/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/SlaveLevelDBStore.scala
+++ b/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/SlaveLevelDBStore.scala
@@ -134,6 +134,8 @@ class SlaveLevelDBStore extends LevelDBStore with ReplicatedLevelDBStoreTrait
{
 
   var wal_append_position = 0L
   var wal_append_offset = 0L
+  @volatile
+  var wal_date = 0L
 
   def send_wal_ack = {
     queue.assertExecuting()
@@ -173,6 +175,7 @@ class SlaveLevelDBStore extends LevelDBStore with ReplicatedLevelDBStoreTrait
{
 //              info("Slave WAL update: %s, (offset: %d, length: %d), sending ack:%s", file,
value.offset, value.length, caughtUp)
               wal_append_offset = value.offset+value.length
               wal_append_position = value.file + wal_append_offset
+              wal_date = value.date
               if( !stopped ) {
                 if( caughtUp ) {
                   client.log.current_appender.skip(value.length)


Mime
View raw message