Package org.jboss.dna.graph.request

Examples of org.jboss.dna.graph.request.ReadNodeRequest


            } else if (request instanceof ReadPropertyRequest) {
                ReadPropertyRequest read = (ReadPropertyRequest)request;
                DateTime expires = computeExpirationTime(read);
                getOrCreateNode(read.getActualLocationOfNode(), expires).addProperty(read.getProperty());
            } else if (request instanceof ReadNodeRequest) {
                ReadNodeRequest read = (ReadNodeRequest)request;
                DateTime expires = computeExpirationTime(read);
                BatchResultsNode node = getOrCreateNode(read.getActualLocationOfNode(), expires);
                node.setProperties(read.getPropertiesByName());
                node.setChildren(read.getChildren());
            } else if (request instanceof ReadBlockOfChildrenRequest) {
                throw new IllegalStateException();
            } else if (request instanceof ReadAllChildrenRequest) {
                ReadAllChildrenRequest read = (ReadAllChildrenRequest)request;
                DateTime expires = computeExpirationTime(read);
                getOrCreateNode(read.getActualLocationOfNode(), expires).setChildren(read.getChildren());
            } else if (request instanceof ReadBranchRequest) {
                ReadBranchRequest read = (ReadBranchRequest)request;
                DateTime expires = computeExpirationTime(read);
                for (Location location : read) {
                    BatchResultsNode node = getOrCreateNode(location, expires);
                    node.setProperties(read.getPropertiesFor(location));
                    node.setChildren(read.getChildren(location));
                }
            }
            for (Map.Entry<Path, BatchResultsNode> entry : nodes.entrySet()) {
                entry.getValue().freeze();
            }
View Full Code Here


            // Check the depth ...
            if (read.depth > request.maximumDepth()) break;

            // Read the properties ...
            ReadNodeRequest readNode = new ReadNodeRequest(read.location, request.inWorkspace());
            process(readNode);
            if (readNode.hasError()) {
                request.setError(readNode.getError());
                return;
            }
            Location actualLocation = readNode.getActualLocationOfNode();
            if (first) {
                // Set the actual location on the original request
                request.setActualLocationOfNode(actualLocation);
                first = false;
            }

            // Record in the request the children and properties that were read on this node ...
            request.setChildren(actualLocation, readNode.getChildren());
            request.setProperties(actualLocation, readNode.getProperties());

            // Add each of the children to the list of locations that we need to read ...
            for (Location child : readNode.getChildren()) {
                locationsToRead.add(new LocationWithDepth(child, read.depth + 1));
            }
        }
        setCacheableInfo(request);
    }
View Full Code Here

                // Add two random numbers ...
                int int1 = random(this.hashCode() ^ (int)System.nanoTime() * i);
                if (i % 2 == 0) {
                    Thread.yield();
                }
                connection.execute(context, new ReadNodeRequest(Location.create(RootPath.INSTANCE), "workspace1"));
                int int2 = random(this.hashCode() ^ (int)System.nanoTime() + i);
                total += Math.min(Math.abs(Math.max(int1, int2) + int1 * int2 / 3), count);
            }
            Logger.getLogger(RepositorySourceLoadHarness.class).debug("Finishing {0} operation", this.getClass().getSimpleName());
            return total < count ? total : count; // should really always return count
View Full Code Here

    @Test
    public void shouldIncludeTimeLoadedInReadNodeRequests() {
        String workspaceName = graph.getCurrentWorkspaceName();
        // Don't use the graph so that we can obtain and interrogate the request ...
        CacheableRequest request = new ReadNodeRequest(location("/"), workspaceName);
        execute(request);
        assertThat(request.getTimeLoaded(), is(notNullValue()));
    }
View Full Code Here

    }

    protected void assertNextRequestReadNode( Location at ) {
        Request request = executedRequests.poll();
        assertThat(request, is(instanceOf(ReadNodeRequest.class)));
        ReadNodeRequest read = (ReadNodeRequest)request;
        assertThat(read.at(), is(at));
    }
View Full Code Here

    }

    @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()));
    }
View Full Code Here

    }

    @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")));
    }
View Full Code Here

    }

    @Test
    public void shouldJoinMultipleReadNodeRequest() {
        // 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 ...
        final ReadNodeRequest projected2 = new ReadNodeRequest(location("/a/b/c"), "workspaceM");
        projected2.setActualLocationOfNode(Location.create(projected2.at().getPath(), UUID.randomUUID()));
        projected2.addProperty(property("propC", "valueC"));
        projected2.addProperty(property("propD", "valueD"));
        projected2.addChild(child(projected2.getActualLocationOfNode(), "child2"));
        projected2.addChild(child(projected2.getActualLocationOfNode(), "child3"));
        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().containsAll(projected1.getProperties()), is(true));
        assertThat(original.getProperties().containsAll(projected2.getProperties()), is(true));
        assertThat(original.getActualLocationOfNode().getPath(), is(path("/a/b/c")));
        assertThat(original.getActualLocationOfNode().getUuid(), is(projected1.getActualLocationOfNode().getUuid()));
        assertThat(original.getActualLocationOfNode().getIdProperty(DnaLexicon.UUID).isMultiple(), is(true));
        assertThat(original.getActualLocationOfNode().getIdProperty(DnaLexicon.UUID).getValuesAsArray()[0],
                   is((Object)projected1.getActualLocationOfNode().getUuid()));
        assertThat(original.getActualLocationOfNode().getIdProperty(DnaLexicon.UUID).getValuesAsArray()[1],
                   is((Object)projected2.getActualLocationOfNode().getUuid()));
        assertThat(original.getChildren().get(0).getPath(), is(path("/a/b/c/child1")));
        assertThat(original.getChildren().get(1).getPath(), is(path("/a/b/c/child2")));
        assertThat(original.getChildren().get(2).getPath(), is(path("/a/b/c/child2[2]")));
        assertThat(original.getChildren().get(3).getPath(), is(path("/a/b/c/child3")));
    }
View Full Code Here

    }

    @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);
View Full Code Here

    public void shouldNotReadNodesInWorkspacesThatDoNotExist() {
        // Generate the name of a workspace that is not an existing node ...
        String nonExistantWorkspaceName = generateNonExistantWorkspaceName();

        // Now try to get the root ...
        ReadNodeRequest request = new ReadNodeRequest(location("/"), nonExistantWorkspaceName);
        execute(request);
    }
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.request.ReadNodeRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.