Author: chetanm
Date: Thu Jan 23 12:34:38 2014
New Revision: 1560665
URL: http://svn.apache.org/r1560665
Log:
OAK-891 - Use DirectMemory as Level 2/Offheap cache
-- Introducing a CachedNodeDocument capturing properties required for
managing cached document
-- Sealing the NULL NodeDocument
-- Adding constructor to capture creation time. Required when NodeDocument is
constructed via deserialization
Added:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/CachedNodeDocument.java
(with props)
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/NodeDocument.java
Added:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/CachedNodeDocument.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/CachedNodeDocument.java?rev=1560665&view=auto
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/CachedNodeDocument.java
(added)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/CachedNodeDocument.java
Thu Jan 23 12:34:38 2014
@@ -0,0 +1,38 @@
+/*
+ * 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.mongomk;
+
+/**
+ * Interface defining the minimum required properties of NodeDocument
+ * which should be accessible without requiring the complete NodeDocument
+ * to be deserialized
+ */
+public interface CachedNodeDocument {
+
+ Number getModCount();
+
+ long getCreated();
+
+ long getLastCheckTime();
+
+ void markUpToDate(long checkTime);
+
+ boolean isUpToDate(long lastCheckTime);
+}
Propchange:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/CachedNodeDocument.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/NodeDocument.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/NodeDocument.java?rev=1560665&r1=1560664&r2=1560665&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/NodeDocument.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/NodeDocument.java
Thu Jan 23 12:34:38 2014
@@ -50,13 +50,17 @@ import static org.apache.jackrabbit.oak.
/**
* A document storing data about a node.
*/
-public class NodeDocument extends Document {
+public class NodeDocument extends Document implements CachedNodeDocument{
/**
* Marker document, which indicates the document does not exist.
*/
public static final NodeDocument NULL = new NodeDocument(new
MemoryDocumentStore());
+ static {
+ NULL.seal();
+ }
+
static final Logger LOG = LoggerFactory.getLogger(NodeDocument.class);
/**
@@ -168,10 +172,22 @@ public class NodeDocument extends Docume
*/
private final AtomicLong lastCheckTime = new
AtomicLong(System.currentTimeMillis());
- private final long time = System.currentTimeMillis();
+ private final long creationTime;
NodeDocument(@Nonnull DocumentStore store) {
+ this(store, System.currentTimeMillis());
+ }
+
+ /**
+ * Required for serialization
+ *
+ * @param store
+ * @param creationTime time at which it was created. Would be different
from current time
+ * in case of being resurrected from a serialized for
+ */
+ public NodeDocument(@Nonnull DocumentStore store, long creationTime) {
this.store = checkNotNull(store);
+ this.creationTime = creationTime;
}
/**
@@ -197,7 +213,7 @@ public class NodeDocument extends Docume
* @return the system time this object was created.
*/
public final long getCreated() {
- return time;
+ return creationTime;
}
/**