activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1031632 - /activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala
Date Fri, 05 Nov 2010 15:41:32 GMT
Author: chirino
Date: Fri Nov  5 15:41:32 2010
New Revision: 1031632

URL: http://svn.apache.org/viewvc?rev=1031632&view=rev
Log:
load changes to the config file made between restarts.

Modified:
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala?rev=1031632&r1=1031631&r2=1031632&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala
Fri Nov  5 15:41:32 2010
@@ -89,7 +89,6 @@ class FileConfigStore extends ConfigStor
   var file:File = new File("activemq.xml")
   @volatile
   var latest:StoredBrokerModel = null
-  var readOnly = false
 
   val dispatchQueue = createQueue("config store")
 
@@ -131,23 +130,23 @@ class FileConfigStore extends ConfigStor
     revs = revs.sortWith((x,y)=> x < y)
 
     val last = revs.lastOption.map{ rev=>
-      read(rev, fileRev(rev))
-    } match {
-      case None =>
-        if( !file.exists ) {
-          if( readOnly ) {
-            throw new Exception("file does not exsit: "+file)
-          } else {
-            write(StoredBrokerModel(defaultConfig(1)))
-          }
+      val r = read(rev, fileRev(rev))
+      if( !file.exists ) {
+        write(r)
+      } else {
+        val x = read(rev, file)
+        if ( !Arrays.equals(r.data, x.data) ) {
+          write(StoredBrokerModel(x.id, x.rev+1, x.data, x.lastModified))
         } else {
-          if( readOnly ) {
-            read(1, file)
-          } else {
-            write(read(1, file))
-          }
+          x
         }
-      case Some(x)=> x
+      }
+    } getOrElse {
+      if( file.exists ) {
+        write(read(1, file))
+      } else {
+        write(StoredBrokerModel(defaultConfig(1)))
+      }
     }
 
     dispatchQueue {



Mime
View raw message