You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by fr...@apache.org on 2016/05/24 09:28:57 UTC
svn commit: r1745339 - in /jackrabbit/oak/trunk:
oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/
oak-run/src/main/java/org/apache/jackrabbit/oak/run/
oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/
oak-segment/src/main/java...
Author: frm
Date: Tue May 24 09:28:57 2016
New Revision: 1745339
URL: http://svn.apache.org/viewvc?rev=1745339&view=rev
Log:
OAK-4338 - Add a flag to choose between segment store implementations in the "checkpoints" command
Added:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/DocumentCheckpoints.java (with props)
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/SegmentCheckpoints.java (with props)
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/SegmentTarCheckpoints.java (with props)
Modified:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/Checkpoints.java
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/CheckpointsCommand.java
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentStore.java
jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java
Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/Checkpoints.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/Checkpoints.java?rev=1745339&r1=1745338&r2=1745339&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/Checkpoints.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/Checkpoints.java Tue May 24 09:28:57 2016
@@ -16,38 +16,33 @@
*/
package org.apache.jackrabbit.oak.checkpoint;
+import java.io.File;
+import java.io.IOException;
import java.util.List;
-import java.util.Map;
import javax.annotation.CheckForNull;
+import com.google.common.io.Closer;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.plugins.document.CheckpointsHelper;
import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
-import org.apache.jackrabbit.oak.plugins.document.Revision;
-import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeState;
-import org.apache.jackrabbit.oak.plugins.segment.file.FileStore;
-import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
-import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import org.apache.jackrabbit.oak.spi.state.NodeState;
-import com.google.common.collect.Lists;
-
-import static org.apache.jackrabbit.oak.plugins.document.CheckpointsHelper.getCheckpoints;
-import static org.apache.jackrabbit.oak.plugins.document.CheckpointsHelper.removeOlderThan;
-
/**
* A helper class to manage checkpoints on TarMK and DocumentMK.
*/
public abstract class Checkpoints {
- public static Checkpoints onTarMK(FileStore store) {
- return new TarMKCheckpoints(store);
+ public static Checkpoints onSegment(File path, Closer closer) throws IOException {
+ return SegmentCheckpoints.create(path, closer);
+ }
+
+ public static Checkpoints onSegmentTar(File path, Closer closer) throws IOException {
+ return SegmentTarCheckpoints.create(path, closer);
}
public static Checkpoints onDocumentMK(DocumentNodeStore store) {
- return new DocumentMKCheckpoints(store);
+ return new DocumentCheckpoints(store);
}
/**
@@ -81,136 +76,8 @@ public abstract class Checkpoints {
*/
public abstract int remove(String cp);
- private static final class TarMKCheckpoints extends Checkpoints {
-
- private final FileStore store;
-
- public TarMKCheckpoints(FileStore store) {
- this.store = store;
- }
-
- @Override
- public List<CP> list() {
- List<CP> list = Lists.newArrayList();
- NodeState ns = store.getHead().getChildNode("checkpoints");
- for (ChildNodeEntry cne : ns.getChildNodeEntries()) {
- NodeState cneNs = cne.getNodeState();
- list.add(new CP(cne.getName(),
- cneNs.getLong("created"), cneNs.getLong("timestamp")));
- }
- return list;
- }
-
- @Override
- public long removeAll() {
- SegmentNodeState head = store.getHead();
- NodeBuilder builder = head.builder();
-
- NodeBuilder cps = builder.getChildNode("checkpoints");
- long cnt = cps.getChildNodeCount(Integer.MAX_VALUE);
- builder.setChildNode("checkpoints");
- if (store.setHead(head, asSegmentNodeState(builder))) {
- return cnt;
- } else {
- return -1;
- }
- }
-
- @Override
- public long removeUnreferenced() {
- SegmentNodeState head = store.getHead();
-
- String ref = getReferenceCheckpoint(head.getChildNode("root"));
-
- NodeBuilder builder = head.builder();
- NodeBuilder cps = builder.getChildNode("checkpoints");
- long cnt = 0;
- for (String c : cps.getChildNodeNames()) {
- if (c.equals(ref)) {
- continue;
- }
- cps.getChildNode(c).remove();
- cnt++;
- }
-
- if (store.setHead(head, asSegmentNodeState(builder))) {
- return cnt;
- } else {
- return -1;
- }
- }
-
- @Override
- public int remove(String cp) {
- SegmentNodeState head = store.getHead();
- NodeBuilder builder = head.builder();
-
- NodeBuilder cpn = builder.getChildNode("checkpoints")
- .getChildNode(cp);
- if (cpn.exists()) {
- cpn.remove();
- if (store.setHead(head, asSegmentNodeState(builder))) {
- return 1;
- } else {
- return -1;
- }
- } else {
- return 0;
- }
- }
-
- private static SegmentNodeState asSegmentNodeState(NodeBuilder builder) {
- return (SegmentNodeState) builder.getNodeState();
- }
- }
-
- private static final class DocumentMKCheckpoints extends Checkpoints {
-
- private final DocumentNodeStore store;
-
- private DocumentMKCheckpoints(DocumentNodeStore store) {
- this.store = store;
- }
-
- @Override
- public List<CP> list() {
- List<CP> list = Lists.newArrayList();
- for (Map.Entry<Revision, Long> entry : getCheckpoints(store).entrySet()) {
- list.add(new CP(entry.getKey().toString(),
- entry.getKey().getTimestamp(),
- entry.getValue()));
- }
- return list;
- }
-
- @Override
- public long removeAll() {
- return CheckpointsHelper.removeAll(store);
- }
-
- @Override
- public long removeUnreferenced() {
- String ref = getReferenceCheckpoint(store.getRoot());
- if (ref == null) {
- return -1;
- }
- return removeOlderThan(store, Revision.fromString(ref));
- }
-
- @Override
- public int remove(String cp) {
- Revision r;
- try {
- r = Revision.fromString(cp);
- } catch (IllegalArgumentException e) {
- return 0;
- }
- return CheckpointsHelper.remove(store, r);
- }
- }
-
@CheckForNull
- private static String getReferenceCheckpoint(NodeState root) {
+ static String getReferenceCheckpoint(NodeState root) {
String ref = null;
PropertyState refPS = root.getChildNode(":async").getProperty("async");
if (refPS != null) {
@@ -229,11 +96,12 @@ public abstract class Checkpoints {
public final long created;
public final long expires;
- private CP(String id, long created, long expires) {
+ CP(String id, long created, long expires) {
this.id = id;
this.created = created;
this.expires = expires;
}
}
+
}
Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/DocumentCheckpoints.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/DocumentCheckpoints.java?rev=1745339&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/DocumentCheckpoints.java (added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/DocumentCheckpoints.java Tue May 24 09:28:57 2016
@@ -0,0 +1,75 @@
+/*
+ * 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.checkpoint;
+
+import static org.apache.jackrabbit.oak.plugins.document.CheckpointsHelper.getCheckpoints;
+import static org.apache.jackrabbit.oak.plugins.document.CheckpointsHelper.removeOlderThan;
+
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.Lists;
+import org.apache.jackrabbit.oak.plugins.document.CheckpointsHelper;
+import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
+import org.apache.jackrabbit.oak.plugins.document.Revision;
+
+class DocumentCheckpoints extends Checkpoints {
+
+ private final DocumentNodeStore store;
+
+ DocumentCheckpoints(DocumentNodeStore store) {
+ this.store = store;
+ }
+
+ @Override
+ public List<CP> list() {
+ List<CP> list = Lists.newArrayList();
+ for (Map.Entry<Revision, Long> entry : getCheckpoints(store).entrySet()) {
+ list.add(new CP(entry.getKey().toString(),
+ entry.getKey().getTimestamp(),
+ entry.getValue()));
+ }
+ return list;
+ }
+
+ @Override
+ public long removeAll() {
+ return CheckpointsHelper.removeAll(store);
+ }
+
+ @Override
+ public long removeUnreferenced() {
+ String ref = getReferenceCheckpoint(store.getRoot());
+ if (ref == null) {
+ return -1;
+ }
+ return removeOlderThan(store, Revision.fromString(ref));
+ }
+
+ @Override
+ public int remove(String cp) {
+ Revision r;
+ try {
+ r = Revision.fromString(cp);
+ } catch (IllegalArgumentException e) {
+ return 0;
+ }
+ return CheckpointsHelper.remove(store, r);
+ }
+
+}
Propchange: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/DocumentCheckpoints.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/SegmentCheckpoints.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/SegmentCheckpoints.java?rev=1745339&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/SegmentCheckpoints.java (added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/SegmentCheckpoints.java Tue May 24 09:28:57 2016
@@ -0,0 +1,117 @@
+/*
+ * 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.checkpoint;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import com.google.common.collect.Lists;
+import com.google.common.io.Closer;
+import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeState;
+import org.apache.jackrabbit.oak.plugins.segment.file.FileStore;
+import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+
+final class SegmentCheckpoints extends Checkpoints {
+
+ static Checkpoints create(File path, Closer closer) throws IOException {
+ return new SegmentCheckpoints(closer.register(FileStore.builder(path).build()));
+ }
+
+ private final FileStore store;
+
+ private SegmentCheckpoints(FileStore store) {
+ this.store = store;
+ }
+
+ @Override
+ public List<CP> list() {
+ List<CP> list = Lists.newArrayList();
+ NodeState ns = store.getHead().getChildNode("checkpoints");
+ for (ChildNodeEntry cne : ns.getChildNodeEntries()) {
+ NodeState cneNs = cne.getNodeState();
+ list.add(new CP(cne.getName(),
+ cneNs.getLong("created"), cneNs.getLong("timestamp")));
+ }
+ return list;
+ }
+
+ @Override
+ public long removeAll() {
+ SegmentNodeState head = store.getHead();
+ NodeBuilder builder = head.builder();
+
+ NodeBuilder cps = builder.getChildNode("checkpoints");
+ long cnt = cps.getChildNodeCount(Integer.MAX_VALUE);
+ builder.setChildNode("checkpoints");
+ if (store.setHead(head, asSegmentNodeState(builder))) {
+ return cnt;
+ } else {
+ return -1;
+ }
+ }
+
+ @Override
+ public long removeUnreferenced() {
+ SegmentNodeState head = store.getHead();
+
+ String ref = getReferenceCheckpoint(head.getChildNode("root"));
+
+ NodeBuilder builder = head.builder();
+ NodeBuilder cps = builder.getChildNode("checkpoints");
+ long cnt = 0;
+ for (String c : cps.getChildNodeNames()) {
+ if (c.equals(ref)) {
+ continue;
+ }
+ cps.getChildNode(c).remove();
+ cnt++;
+ }
+
+ if (store.setHead(head, asSegmentNodeState(builder))) {
+ return cnt;
+ } else {
+ return -1;
+ }
+ }
+
+ @Override
+ public int remove(String cp) {
+ SegmentNodeState head = store.getHead();
+ NodeBuilder builder = head.builder();
+
+ NodeBuilder cpn = builder.getChildNode("checkpoints")
+ .getChildNode(cp);
+ if (cpn.exists()) {
+ cpn.remove();
+ if (store.setHead(head, asSegmentNodeState(builder))) {
+ return 1;
+ } else {
+ return -1;
+ }
+ } else {
+ return 0;
+ }
+ }
+
+ private static SegmentNodeState asSegmentNodeState(NodeBuilder builder) {
+ return (SegmentNodeState) builder.getNodeState();
+ }
+}
Propchange: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/SegmentCheckpoints.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/SegmentTarCheckpoints.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/SegmentTarCheckpoints.java?rev=1745339&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/SegmentTarCheckpoints.java (added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/SegmentTarCheckpoints.java Tue May 24 09:28:57 2016
@@ -0,0 +1,118 @@
+/*
+ * 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.checkpoint;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import com.google.common.collect.Lists;
+import com.google.common.io.Closer;
+import org.apache.jackrabbit.oak.segment.SegmentNodeState;
+import org.apache.jackrabbit.oak.segment.file.FileStore;
+import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+
+class SegmentTarCheckpoints extends Checkpoints {
+
+ static Checkpoints create(File path, Closer closer) throws IOException {
+ return new SegmentTarCheckpoints(closer.register(FileStore.builder(path).build()));
+ }
+
+ private final FileStore store;
+
+ private SegmentTarCheckpoints(FileStore store) {
+ this.store = store;
+ }
+
+ @Override
+ public List<CP> list() {
+ List<CP> list = Lists.newArrayList();
+ NodeState ns = store.getHead().getChildNode("checkpoints");
+ for (ChildNodeEntry cne : ns.getChildNodeEntries()) {
+ NodeState cneNs = cne.getNodeState();
+ list.add(new CP(cne.getName(),
+ cneNs.getLong("created"), cneNs.getLong("timestamp")));
+ }
+ return list;
+ }
+
+ @Override
+ public long removeAll() {
+ SegmentNodeState head = store.getHead();
+ NodeBuilder builder = head.builder();
+
+ NodeBuilder cps = builder.getChildNode("checkpoints");
+ long cnt = cps.getChildNodeCount(Integer.MAX_VALUE);
+ builder.setChildNode("checkpoints");
+ if (store.setHead(head, asSegmentNodeState(builder))) {
+ return cnt;
+ } else {
+ return -1;
+ }
+ }
+
+ @Override
+ public long removeUnreferenced() {
+ SegmentNodeState head = store.getHead();
+
+ String ref = getReferenceCheckpoint(head.getChildNode("root"));
+
+ NodeBuilder builder = head.builder();
+ NodeBuilder cps = builder.getChildNode("checkpoints");
+ long cnt = 0;
+ for (String c : cps.getChildNodeNames()) {
+ if (c.equals(ref)) {
+ continue;
+ }
+ cps.getChildNode(c).remove();
+ cnt++;
+ }
+
+ if (store.setHead(head, asSegmentNodeState(builder))) {
+ return cnt;
+ } else {
+ return -1;
+ }
+ }
+
+ @Override
+ public int remove(String cp) {
+ SegmentNodeState head = store.getHead();
+ NodeBuilder builder = head.builder();
+
+ NodeBuilder cpn = builder.getChildNode("checkpoints")
+ .getChildNode(cp);
+ if (cpn.exists()) {
+ cpn.remove();
+ if (store.setHead(head, asSegmentNodeState(builder))) {
+ return 1;
+ } else {
+ return -1;
+ }
+ } else {
+ return 0;
+ }
+ }
+
+ private static SegmentNodeState asSegmentNodeState(NodeBuilder builder) {
+ return (SegmentNodeState) builder.getNodeState();
+ }
+
+}
Propchange: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/checkpoint/SegmentTarCheckpoints.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/CheckpointsCommand.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/CheckpointsCommand.java?rev=1745339&r1=1745338&r2=1745339&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/CheckpointsCommand.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/CheckpointsCommand.java Tue May 24 09:28:57 2016
@@ -17,55 +17,61 @@
package org.apache.jackrabbit.oak.run;
-import static org.apache.jackrabbit.oak.plugins.segment.FileStoreHelper.openFileStore;
-
+import java.io.File;
import java.sql.Timestamp;
import com.google.common.io.Closer;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.MongoURI;
+import joptsimple.OptionParser;
+import joptsimple.OptionSet;
+import joptsimple.OptionSpec;
import org.apache.jackrabbit.oak.checkpoint.Checkpoints;
import org.apache.jackrabbit.oak.plugins.document.DocumentMK;
import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
-import org.apache.jackrabbit.oak.plugins.segment.file.FileStore;
class CheckpointsCommand implements Command {
@Override
public void execute(String... args) throws Exception {
- if (args.length == 0) {
- System.out
- .println("usage: checkpoints {<path>|<mongo-uri>} [list|rm-all|rm-unreferenced|rm <checkpoint>]");
+ OptionParser parser = new OptionParser();
+ OptionSpec segmentTar = parser.accepts("segment-tar", "Use oak-segment-tar instead of oak-segment");
+ OptionSet options = parser.parse(args);
+
+ if (options.nonOptionArguments().isEmpty()) {
+ System.out.println("usage: checkpoints {<path>|<mongo-uri>} [list|rm-all|rm-unreferenced|rm <checkpoint>] [--segment-tar]");
System.exit(1);
}
+
boolean success = false;
Checkpoints cps;
Closer closer = Closer.create();
try {
String op = "list";
- if (args.length >= 2) {
- op = args[1];
+ if (options.nonOptionArguments().size() >= 2) {
+ op = options.nonOptionArguments().get(1).toString();
if (!"list".equals(op) && !"rm-all".equals(op) && !"rm-unreferenced".equals(op) && !"rm".equals(op)) {
failWith("Unknown command.");
}
}
- if (args[0].startsWith(MongoURI.MONGODB_PREFIX)) {
- MongoClientURI uri = new MongoClientURI(args[0]);
+ String connection = options.nonOptionArguments().get(0).toString();
+ if (connection.startsWith(MongoURI.MONGODB_PREFIX)) {
+ MongoClientURI uri = new MongoClientURI(connection);
MongoClient client = new MongoClient(uri);
final DocumentNodeStore store = new DocumentMK.Builder()
.setMongoDB(client.getDB(uri.getDatabase()))
.getNodeStore();
closer.register(Utils.asCloseable(store));
cps = Checkpoints.onDocumentMK(store);
+ } else if (options.has(segmentTar)) {
+ cps = Checkpoints.onSegmentTar(new File(connection), closer);
} else {
- FileStore store = openFileStore(args[0]);
- closer.register(Utils.asCloseable(store));
- cps = Checkpoints.onTarMK(store);
+ cps = Checkpoints.onSegment(new File(connection), closer);
}
- System.out.println("Checkpoints " + args[0]);
+ System.out.println("Checkpoints " + connection);
if ("list".equals(op)) {
int cnt = 0;
for (Checkpoints.CP cp : cps.list()) {
@@ -95,10 +101,10 @@ class CheckpointsCommand implements Comm
failWith("Failed to remove unreferenced checkpoints.");
}
} else if ("rm".equals(op)) {
- if (args.length != 3) {
+ if (options.nonOptionArguments().size() < 3) {
failWith("Missing checkpoint id");
} else {
- String cp = args[2];
+ String cp = options.nonOptionArguments().get(2).toString();
long time = System.currentTimeMillis();
int cnt = cps.remove(cp);
time = System.currentTimeMillis() - time;
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentStore.java?rev=1745339&r1=1745338&r2=1745339&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentStore.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentStore.java Tue May 24 09:28:57 2016
@@ -18,6 +18,7 @@
*/
package org.apache.jackrabbit.oak.segment;
+import java.io.Closeable;
import java.io.IOException;
import javax.annotation.CheckForNull;
@@ -29,7 +30,7 @@ import org.apache.jackrabbit.oak.spi.blo
/**
* The backend storage interface used by the segment node store.
*/
-public interface SegmentStore {
+public interface SegmentStore extends Closeable {
@Nonnull
SegmentTracker getTracker();
Modified: jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java?rev=1745339&r1=1745338&r2=1745339&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java (original)
+++ jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java Tue May 24 09:28:57 2016
@@ -16,6 +16,7 @@
*/
package org.apache.jackrabbit.oak.plugins.segment;
+import java.io.Closeable;
import java.io.IOException;
import javax.annotation.CheckForNull;
@@ -27,7 +28,7 @@ import org.apache.jackrabbit.oak.spi.blo
/**
* The backend storage interface used by the segment node store.
*/
-public interface SegmentStore {
+public interface SegmentStore extends Closeable {
SegmentTracker getTracker();