/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.ReadNodeRequest) */ @Override public void process( ReadNodeRequest request ) { WorkspaceType workspace = getWorkspace(request, request.inWorkspace()); NodeType node = getTargetNode(workspace, request, request.at()); if (node == null) { assert request.hasError(); return; } Location actualLocation = getActualLocation(workspace, request.at(), node); assert actualLocation != null; // Get the locations of the children ... List<Location> childLocations = txn.getChildrenLocations(workspace, node); request.addChildren(childLocations); // Get the properties of the node ... request.addProperty(propertyFactory.create(ModeShapeLexicon.UUID, node.getUuid())); request.addProperties(node.getProperties().values()); request.setActualLocationOfNode(actualLocation); setCacheableInfo(request); }
placeholderRequest.setActualLocationOfNode(placeholder.location()); federatedRequest.add(placeholderRequest, true, true, null); if (maxDepth > 1) {
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.ReadNodeRequest) */ @Override public void process( ReadNodeRequest request ) { ReadNodeRequest source = (ReadNodeRequest)federatedRequest.getFirstProjectedRequest().getRequest(); if (checkErrorOrCancel(request, source)) return; request.setActualLocationOfNode(source.getActualLocationOfNode()); for (Location childInSource : source.getChildren()) { request.addChild(childInSource); } for (Property propertyInSource : source.getProperties()) { request.addProperties(propertyInSource); } request.setCachePolicy(getDefaultCachePolicy()); setCacheableInfo(request, source.getCachePolicy()); }
placeholderRequest.addProperties(placeholder.properties().values()); placeholderRequest.setActualLocationOfNode(placeholder.location()); federatedRequest.add(placeholderRequest, true, true, null); children = new LinkedList<Location>(); placeholderRequest.addProperties(placeholder.properties().values()); placeholderRequest.setActualLocationOfNode(placeholder.location()); federatedRequest.add(placeholderRequest, true, true, null);
@Override public void process( ReadNodeRequest request ) { PathWorkspace workspace = getWorkspace(request, request.inWorkspace()); if (workspace == null) return; PathNode node = getTargetNode(workspace, request, request.at()); if (node == null) { request.setError(new PathNotFoundException(request.at(), workspace.getLowestExistingPath(request.at().getPath()))); return; } // Get the names of the children ... for (Path.Segment childSegment : node.getChildSegments()) { request.addChild(Location.create(pathFactory.create(node.getPath(), childSegment))); } // Get the properties of the node ... request.addProperties(node.getProperties().values()); request.setActualLocationOfNode(Location.create(node.getPath(), node.getUuid())); setCacheableInfo(request); }
@Test public void shouldCancelFederatedRequestIfOneOfSeveralMultipleReadNodeRequestIsCancelled() { // Create the original read node request ... final ReadNodeRequest original = new ReadNodeRequest(location("/a/b/c"), "workspaceM"); // Create a single federated request using the mirror projection... final FederatedRequest request = new FederatedRequest(original); // And "fork" the original request into the first source request ... final ReadNodeRequest projected1 = new ReadNodeRequest(location("/b/c"), "workspaceM"); projected1.setActualLocationOfNode(Location.create(projected1.at().getPath(), UUID.randomUUID())); projected1.addProperty(property("propA", "valueA")); projected1.addProperty(property("propB", "valueB")); projected1.addChild(child(projected1.getActualLocationOfNode(), "child1")); projected1.addChild(child(projected1.getActualLocationOfNode(), "child2")); request.add(projected1, false, false, projectionA); // And a second source request (that was cancelled)... final ReadNodeRequest projected2 = new ReadNodeRequest(location("/a/b/c"), "workspaceM"); projected2.cancel(); request.add(projected2, true, false, mirrorProjection); request.freeze(); request.getLatch().countDown(); request.getLatch().countDown(); joinQueue.add(request); // Add a terminating request and join the request... joinQueue.add(new NoMoreFederatedRequests()); joinProcessor.process(joinQueue); // Check the results of the original has the same results of the projected... assertThat(original.getProperties().isEmpty(), is(true)); assertThat(original.getChildren().isEmpty(), is(true)); assertThat(original.isCancelled(), is(true)); }
@Test public void shouldJoinSingleOffsetReadNodeRequest() { // Create the original read node request ... final ReadNodeRequest original = new ReadNodeRequest(location("/a/b/c"), "workspaceM"); // Create a single federated request using the mirror projection... final FederatedRequest request = new FederatedRequest(original); // And "fork" the original request by creating a mirror final ReadNodeRequest projected = new ReadNodeRequest(location("/b/c"), "workspaceM"); projected.setActualLocationOfNode(Location.create(projected.at().getPath(), UUID.randomUUID())); projected.addProperty(property("propA", "valueA")); projected.addProperty(property("propB", "valueB")); projected.addChild(child(projected.getActualLocationOfNode(), "child1")); projected.addChild(child(projected.getActualLocationOfNode(), "child2")); request.add(projected, false, false, projectionA); request.freeze(); request.getLatch().countDown(); joinQueue.add(request); // Add a terminating request and join the request... joinQueue.add(new NoMoreFederatedRequests()); joinProcessor.process(joinQueue); // Check the results of the original has the same results of the projected... assertThat(original.getPropertiesByName(), is(projected.getPropertiesByName())); assertThat(original.getActualLocationOfNode().getPath(), is(path("/a/b/c"))); assertThat(original.getChildren().get(0).getPath(), is(path("/a/b/c/child1"))); assertThat(original.getChildren().get(1).getPath(), is(path("/a/b/c/child2"))); }
@Test public void shouldJoinSingleMirroredReadNodeRequest() { // Create the original read node request ... final ReadNodeRequest original = new ReadNodeRequest(location("/a/b/c"), "workspaceM"); // Create a single federated request... final FederatedRequest request = new FederatedRequest(original); // And "fork" the original request ... final ReadNodeRequest projected = new ReadNodeRequest(location("/a/b/c"), "workspaceM"); projected.setActualLocationOfNode(Location.create(projected.at().getPath(), UUID.randomUUID())); projected.addProperty(property("propA", "valueA")); projected.addProperty(property("propB", "valueB")); projected.addChild(child(projected.getActualLocationOfNode(), "child1")); projected.addChild(child(projected.getActualLocationOfNode(), "child2")); request.add(projected, true, false, mirrorProjection); request.freeze(); request.getLatch().countDown(); joinQueue.add(request); // Add a terminating request and join the request... joinQueue.add(new NoMoreFederatedRequests()); joinProcessor.process(joinQueue); // Check the results of the original has the same results of the projected... assertThat(original.getChildren(), is(projected.getChildren())); assertThat(original.getPropertiesByName(), is(projected.getPropertiesByName())); assertThat(original.getActualLocationOfNode(), is(projected.getActualLocationOfNode())); }
projected1.setActualLocationOfNode(Location.create(projected1.at().getPath(), UUID.randomUUID())); projected1.addProperty(property("propA", "valueA")); projected1.addProperty(property("propB", "valueB")); projected2.setActualLocationOfNode(Location.create(projected2.at().getPath(), UUID.randomUUID())); projected2.addProperty(property("propC", "valueC")); projected2.addProperty(property("propD", "valueD"));
request.setActualLocationOfNode(readProperties.getActualLocationOfNode());
request.setActualLocationOfNode(actualLocation);