ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1639598 - in /ace/trunk/org.apache.ace.log: src/org/apache/ace/log/server/store/impl/LogStoreImpl.java test/org/apache/ace/log/server/store/impl/ServerLogStoreTester.java
Date Fri, 14 Nov 2014 10:43:08 GMT
Author: marrs
Date: Fri Nov 14 10:43:06 2014
New Revision: 1639598

URL: http://svn.apache.org/r1639598
Log:
ACE-494 Fixed and added a test.

Modified:
    ace/trunk/org.apache.ace.log/src/org/apache/ace/log/server/store/impl/LogStoreImpl.java
    ace/trunk/org.apache.ace.log/test/org/apache/ace/log/server/store/impl/ServerLogStoreTester.java

Modified: ace/trunk/org.apache.ace.log/src/org/apache/ace/log/server/store/impl/LogStoreImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.log/src/org/apache/ace/log/server/store/impl/LogStoreImpl.java?rev=1639598&r1=1639597&r2=1639598&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.log/src/org/apache/ace/log/server/store/impl/LogStoreImpl.java
(original)
+++ ace/trunk/org.apache.ace.log/src/org/apache/ace/log/server/store/impl/LogStoreImpl.java
Fri Nov 14 10:43:06 2014
@@ -112,16 +112,20 @@ public class LogStoreImpl implements Log
             in = new BufferedReader(new FileReader(log));
             String file = log.getAbsolutePath();
             long counter = 0;
+            long lowestID = getLowestIDInternal(descriptor.getTargetID(), descriptor.getStoreID());
             for (String line = in.readLine(); line != null; line = in.readLine()) {
                 Event event = new Event(line);
                 long id = event.getID();
-                if ((counter != -1) && ++counter == id) {
-
+                if (id < lowestID) {
+                	continue;
                 }
-                else {
+                if (lowestID > 0 && id == lowestID) {
+                	counter = lowestID - 1;
+                }
+                if ((counter == -1) || ++counter != id) {
                     counter = -1;
                 }
-                if (set.contains(id) && id >= getLowestIDInternal(descriptor.getTargetID(),
descriptor.getStoreID())) {
+				if (set.contains(id)) {
                     result.add(event);
                 }
             }
@@ -155,9 +159,16 @@ public class LogStoreImpl implements Log
     
     private Descriptor getDescriptorInternal(String targetID, long logID, boolean lock) throws
IOException {
         Long high = m_fileToHighestID.get(getLogFile(targetID, logID).getAbsolutePath());
+        long lowestID = getLowestIDInternal(targetID, logID);
         if (high != null) {
-            Range r = new Range(1, high);
-            return new Descriptor(targetID, logID, new SortedRangeSet(r.toRepresentation()));
+            long low = lowestID > 0 ? lowestID : 1;
+            if (low > high) {
+                return new Descriptor(targetID, logID, new SortedRangeSet(""));
+            }
+            else {
+            	Range r = new Range(low, high);
+            	return new Descriptor(targetID, logID, new SortedRangeSet(r.toRepresentation()));
+            }
         }
         Descriptor descriptor = new Descriptor(targetID, logID, SortedRangeSet.FULL_SET);
 		List<Event> events = lock ? get(descriptor) : getInternal(descriptor);

Modified: ace/trunk/org.apache.ace.log/test/org/apache/ace/log/server/store/impl/ServerLogStoreTester.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.log/test/org/apache/ace/log/server/store/impl/ServerLogStoreTester.java?rev=1639598&r1=1639597&r2=1639598&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.log/test/org/apache/ace/log/server/store/impl/ServerLogStoreTester.java
(original)
+++ ace/trunk/org.apache.ace.log/test/org/apache/ace/log/server/store/impl/ServerLogStoreTester.java
Fri Nov 14 10:43:06 2014
@@ -164,19 +164,30 @@ public class ServerLogStoreTester {
         assert 0 == m_logStore.getLowestID("target", 0) : "Lowest ID should be 0 by default,
not: " + m_logStore.getLowestID("target", 1);
         assert 0 == m_logStore.getLowestID("target2", 1) : "Lowest ID should be 0 by default,
not: " + m_logStore.getLowestID("target", 1);
 
-        for (long id = 0; id < 20; id++) {
+        for (long id = 1; id <= 20; id++) {
             events.add(new Event("target", 1, id, System.currentTimeMillis(), AuditEvent.FRAMEWORK_STARTED,
props));
         }
         m_logStore.put(events);
-        assert m_logStore.getDescriptors().size() == 1 : "Incorrect amount of ranges returned
from store";
+        List<Descriptor> descriptors = m_logStore.getDescriptors();
+        assert descriptors.size() == 1 : "Incorrect amount of ranges returned from store";
+        String range = descriptors.get(0).getRangeSet().toRepresentation();
+        assert range.equals("10-20") : "Incorrect range in descriptor: " + range;
         List<Event> stored = getStoredEvents();
-        assert stored.size() == 10 : "Exactly 10 events should have been stored";
-        m_logStore.setLowestID("target", 1, 19);
+        assert stored.size() == 11 : "Exactly 11 events should have been stored";
+        m_logStore.setLowestID("target", 1, 20);
         stored = getStoredEvents();
         assert stored.size() == 1 : "Exactly 1 event should have been stored";
-        m_logStore.setLowestID("target", 1, 20);
+        descriptors = m_logStore.getDescriptors();
+        assert descriptors.size() == 1 : "Incorrect amount of ranges returned from store";
+        range = descriptors.get(0).getRangeSet().toRepresentation();
+        assert range.equals("20") : "Incorrect range in descriptor: " + range;
+        m_logStore.setLowestID("target", 1, 21);
         stored = getStoredEvents();
         assert stored.size() == 0 : "No events should have been stored";
+        descriptors = m_logStore.getDescriptors();
+        assert descriptors.size() == 1 : "Incorrect amount of ranges returned from store";
+        range = descriptors.get(0).getRangeSet().toRepresentation();
+        assert range.equals("") : "Incorrect range in descriptor: " + range;
         m_logStore.setLowestID("target", 1, 100);
         stored = getStoredEvents();
         assert stored.size() == 0 : "No events should have been stored";



Mime
View raw message