Author: tomekr
Date: Wed Jun 7 15:04:34 2017
New Revision: 1797938
URL: http://svn.apache.org/viewvc?rev=1797938&view=rev
Log:
OAK-6315: Create CheckpointMBean implementation for the composite node store
Basic implementation, no created and lifetime dates support.
Added:
jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeCheckpointMBean.java
Modified:
jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreService.java
Added:
jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeCheckpointMBean.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeCheckpointMBean.java?rev=1797938&view=auto
==============================================================================
---
jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeCheckpointMBean.java
(added)
+++
jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeCheckpointMBean.java
Wed Jun 7 15:04:34 2017
@@ -0,0 +1,53 @@
+/*
+ * 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.composite;
+
+import org.apache.jackrabbit.oak.commons.jmx.AbstractCheckpointMBean;
+
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.TabularDataSupport;
+
+public class CompositeCheckpointMBean extends AbstractCheckpointMBean {
+
+ private final CompositeNodeStore store;
+
+ public CompositeCheckpointMBean(CompositeNodeStore store) {
+ this.store = store;
+ }
+
+ @Override
+ public String createCheckpoint(long lifetime) {
+ return store.checkpoint(lifetime);
+ }
+
+ @Override
+ public boolean releaseCheckpoint(String id) {
+ return store.release(id);
+ }
+
+ @Override
+ protected void collectCheckpoints(TabularDataSupport tab) throws
OpenDataException {
+ for (String id : store.checkpoints()) {
+ tab.put(id, toCompositeData(id, "", "", store.checkpointInfo(id)));
+ }
+ }
+
+ @Override
+ public long getOldestCheckpointCreationTimestamp() {
+ return 0;
+ }
+}
Modified:
jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreService.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreService.java?rev=1797938&r1=1797937&r2=1797938&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreService.java
(original)
+++
jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreService.java
Wed Jun 7 15:04:34 2017
@@ -25,12 +25,16 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
+import org.apache.jackrabbit.oak.api.jmx.CheckpointMBean;
import org.apache.jackrabbit.oak.commons.PropertiesUtil;
+import org.apache.jackrabbit.oak.osgi.OsgiWhiteboard;
import org.apache.jackrabbit.oak.spi.commit.ObserverTracker;
import org.apache.jackrabbit.oak.spi.mount.Mount;
import org.apache.jackrabbit.oak.spi.mount.MountInfoProvider;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
import org.apache.jackrabbit.oak.spi.state.NodeStoreProvider;
+import org.apache.jackrabbit.oak.spi.whiteboard.Registration;
+import org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
@@ -46,6 +50,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import static
org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.registerMBean;
+
@Component(policy = ConfigurationPolicy.REQUIRE)
public class CompositeNodeStoreService {
@@ -71,6 +77,8 @@ public class CompositeNodeStoreService {
private ServiceRegistration nsReg;
+ private Registration checkpointReg;
+
private ObserverTracker observerTracker;
private String[] ignoreReadOnlyWritePaths;
@@ -142,8 +150,14 @@ public class CompositeNodeStoreService {
observerTracker = new ObserverTracker(store);
observerTracker.start(context.getBundleContext());
- LOG.info("Registering the composite node store");
+ Whiteboard whiteboard = new OsgiWhiteboard(context.getBundleContext());
+ checkpointReg = registerMBean(whiteboard,
+ CheckpointMBean.class,
+ new CompositeCheckpointMBean(store),
+ CheckpointMBean.TYPE,
+ "Composite node store checkpoint management");
+ LOG.info("Registering the composite node store");
nsReg = context.getBundleContext().registerService(
new String[]{
NodeStore.class.getName()
@@ -177,6 +191,10 @@ public class CompositeNodeStoreService {
nsReg.unregister();
nsReg = null;
}
+ if (checkpointReg != null) {
+ checkpointReg.unregister();
+ checkpointReg = null;
+ }
if (observerTracker != null) {
observerTracker.stop();
observerTracker = null;