@NotNull @Override public NodeState getRoot() { return getNodeStore().getRoot(); }
private void verify() { final NodeState sourceRoot = source.getRoot(); final NodeState targetRoot = target.getRoot(); final NodeState reportingSource = ReportingNodeState.wrap(sourceRoot, new LoggingReporter(LOG, "Verifying", LOG_NODE_COPY, -1)); LOG.info("Verifying whether repositories are identical"); if (targetRoot.compareAgainstBaseState(reportingSource, new LoggingEqualsDiff(LOG, "/"))) { LOG.info("Verification result: both repositories are identical"); } else { LOG.warn("Verification result: repositories are not identical"); } }
@Override public IndexInfo getInfo(String indexPath) throws IOException { NodeState idxState = NodeStateUtils.getNode(nodeStore.getRoot(), indexPath); checkArgument(PropertyIndexEditorProvider.TYPE.equals(idxState.getString(IndexConstants.TYPE_PROPERTY_NAME)), "Index definition at [%s] is not of type 'property'", indexPath); PropertyIndexInfo info = new PropertyIndexInfo(indexPath); computeCountEstimate(info, idxState); return info; }
private FilterImpl createFilter(String nodeTypeName) { NodeTypeInfoProvider nodeTypes = new NodeStateNodeTypeInfoProvider(nodeStore.getRoot()); NodeTypeInfo type = nodeTypes.getNodeTypeInfo(nodeTypeName); SelectorImpl selector = new SelectorImpl(type, nodeTypeName); return new FilterImpl(selector, "SELECT * FROM [" + nodeTypeName + "]", settings); }
void switchLanes() throws CommitFailedException, IOException { NodeState root = nodeStore.getRoot(); NodeBuilder builder = root.builder(); for (IndexInfo indexInfo : asyncLaneToIndexMapping.values()){ if (!indexInfo.newIndex) { NodeBuilder idxBuilder = NodeStoreUtils.childBuilder(builder, indexInfo.indexPath); AsyncLaneSwitcher.switchLane(idxBuilder, AsyncLaneSwitcher.getTempLaneName(indexInfo.asyncLaneName)); } } mergeWithConcurrentCheck(nodeStore, builder); }
private static void testContent(NodeStore store) throws Exception { NodeBuilder builder = store.getRoot().builder(); builder.child("testRoot").setProperty("foo", "abc " + System.currentTimeMillis()); store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); }
private static void modify(NodeStore store) throws CommitFailedException { NodeBuilder root = store.getRoot().builder(); root.setChildNode("added"); store.merge(root, EmptyHook.INSTANCE, CommitInfo.EMPTY); }
private static void addTestNode(NodeStore store, String name) throws CommitFailedException { NodeBuilder builder = store.getRoot().builder(); builder.child(name); store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); }
protected void delete(String nodeId, NodeStore nodeStore) throws CommitFailedException { NodeBuilder builder = nodeStore.getRoot().builder(); builder.child(nodeId).remove(); nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); }
@Test public void isReplacedBehaviour() throws Exception{ NodeBuilder nb = store.getRoot().builder(); nb.child("a").setProperty("foo", "bar"); store.merge(nb, EmptyHook.INSTANCE, CommitInfo.EMPTY); nb = store.getRoot().builder(); nb.child("a").child("b"); assertFalse(nb.getChildNode("a").isReplaced("foo")); }
private void createNodes(NodeStore ns) throws CommitFailedException { NodeBuilder root = ns.getRoot().builder(); NodeBuilder nb = root; for (String s : PathUtils.elements(parentPath)) { nb = nb.child(s); } nb.child(nodeName); ns.merge(root, EmptyHook.INSTANCE, CommitInfo.EMPTY); }
@Before public void setup() throws Exception { provider = new PropertyIndexEditorProvider(); NodeBuilder builder = store.getRoot().builder(); createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null) .setProperty(ASYNC_PROPERTY_NAME, name); builder.child("testRoot").setProperty("foo", "abc"); store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); executed.set(false); }
@Before public void setUp() throws CommitFailedException { NodeBuilder builder = store.getRoot().builder(); builder.setProperty("a", 1); for (int i = 0; i <= N; i++) { builder.child("x" + i); } state = store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); }
@Test public void checkpoint() throws CommitFailedException { String cp = store.checkpoint(Long.MAX_VALUE); NodeBuilder builder = store.getRoot().builder(); builder.setChildNode("new"); store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); assertFalse(root.equals(store.getRoot())); assertEquals(root, store.retrieve(cp)); assertTrue(store.release(cp)); assertNull(store.retrieve(cp)); }
@Test public void contentBelongingToAnotherMountIsIgnored() throws Exception { // create a /tmp/oops child on the root store // these two nodes must be ignored NodeBuilder builder = globalStore.getRoot().builder(); builder.child("tmp").child("oops"); globalStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); assertTrue(globalStore.getRoot().getChildNode("tmp").hasChildNode("oops")); assertFalse(store.getRoot().getChildNode("tmp").hasChildNode("oops")); }
private void verifyMetadata() { NodeState root = destination.getRoot(); assertTrue(root.hasProperty(PROP_REVISION)); assertTrue(root.hasProperty(PROP_LAST_REV)); RevisionVector.fromString(root.getString(PROP_REVISION)); Revision.fromString(root.getString(PROP_LAST_REV)); NodeState appsNode = destination.getRoot().getChildNode("apps"); assertTrue(appsNode.hasProperty(PROP_LAST_REV)); Revision.fromString(appsNode.getString(PROP_LAST_REV)); }
@Test public void rebaseInvariant() { NodeBuilder root = store.getRoot().builder(); NodeBuilder added = root.setChildNode("added"); NodeState base = root.getBaseState(); store.rebase(root); assertEquals(base, root.getBaseState()); }
private static void addTestContent(@NotNull String parent, @NotNull NodeStore nodeStore) throws CommitFailedException, IOException { NodeBuilder rootBuilder = nodeStore.getRoot().builder(); NodeBuilder parentBuilder = rootBuilder.child(parent); parentBuilder.setChildNode("a").setChildNode("aa").setProperty("p", 42); parentBuilder.getChildNode("a").setChildNode("bb").setChildNode("bbb"); parentBuilder.setChildNode("b").setProperty("bin", createBlob(nodeStore, 42)); parentBuilder.setChildNode("c").setProperty(binaryPropertyFromBlob("bins", createBlobs(nodeStore, 42, 43, 44))); nodeStore.merge(rootBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY); }
@Test public void move() { NodeBuilder test = store.getRoot().builder().getChildNode("test"); NodeBuilder x = test.getChildNode("x"); NodeBuilder y = test.getChildNode("y"); assertTrue(x.moveTo(y, "xx")); assertFalse(x.exists()); assertTrue(y.exists()); assertFalse(test.hasChildNode("x")); assertTrue(y.hasChildNode("xx")); }
private static void createContent(NodeStore nodeStore) throws IOException, CommitFailedException { NodeBuilder rootBuilder = nodeStore.getRoot().builder(); rootBuilder.child("node1").setProperty("prop", createBlob(nodeStore)); rootBuilder.child("node2").setProperty("prop", createBlob(nodeStore)); PropertyBuilder<Blob> builder = PropertyBuilder.array(Type.BINARY, "prop"); builder.addValue(createBlob(nodeStore)); builder.addValue(createBlob(nodeStore)); builder.addValue(createBlob(nodeStore)); rootBuilder.child("node3").setProperty(builder.getPropertyState()); nodeStore.merge(rootBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY); }