Author: chetanm
Date: Fri Mar 28 09:44:55 2014
New Revision: 1582657
URL: http://svn.apache.org/r1582657
Log:
OAK-1341 - DocumentNodeStore: Implement revision garbage collection (WIP)
Fix the modifiedTime calculation logic
Added:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitTest.java
(with props)
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java?rev=1582657&r1=1582656&r2=1582657&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
Fri Mar 28 09:44:55 2014
@@ -22,6 +22,7 @@ import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
@@ -85,7 +86,9 @@ public class Commit {
public static long getModified(long timestamp) {
// 5 second resolution
- return timestamp / 1000 / 5;
+ long timeInSec = TimeUnit.MILLISECONDS.toSeconds(timestamp);
+ timeInSec = timeInSec - timeInSec % 5;
+ return TimeUnit.SECONDS.toMillis(timeInSec);
}
/**
@@ -212,8 +215,7 @@ public class Commit {
DocumentStore store = this.nodeStore.getDocumentStore();
for (String path : this.nodesWithBinaries) {
- NodeDocument nd =
- (NodeDocument) store.getIfCached(Collection.NODES,
Utils.getIdFromPath(path));
+ NodeDocument nd = store.getIfCached(Collection.NODES,
Utils.getIdFromPath(path));
if ((nd == null) || (nd.hasBinary() != 1)) {
UpdateOp updateParentOp = getUpdateOperationForNode(path);
NodeDocument.setHasBinary(updateParentOp);
Added:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitTest.java?rev=1582657&view=auto
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitTest.java
(added)
+++
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitTest.java
Fri Mar 28 09:44:55 2014
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.jackrabbit.oak.plugins.document;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class CommitTest {
+
+ @Test
+ public void testModifiedTime(){
+ assertEquals(10000, Commit.getModified(10000));
+ assertEquals(10000, Commit.getModified(10003));
+ assertEquals(10000, Commit.getModified(12000));
+ assertEquals(15000, Commit.getModified(15000));
+ assertEquals(15000, Commit.getModified(15006));
+ }
+}
Propchange:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitTest.java
------------------------------------------------------------------------------
svn:eol-style = native