/** * {@inheritDoc} * * @see org.modeshape.graph.request.Request#cancel() */ @Override public void cancel() { super.cancel(); this.availableWorkspaceNames = null; }
/** * @param timeLoaded Sets timeLoaded to the specified value. * @throws IllegalStateException if the request is frozen */ public void setTimeLoaded( DateTime timeLoaded ) { checkNotFrozen(); this.timeLoaded = timeLoaded; } }
/** * Set the supplied request to have the default cache policy and the {@link #getNowInUtc() current time in UTC}. * * @param request the cacheable request */ protected void setCacheableInfo( CacheableRequest request ) { // Set it only if the request has no cache policy already ... if (request.getCachePolicy() == null && defaultCachePolicy != null) { request.setCachePolicy(defaultCachePolicy); } request.setTimeLoaded(nowInUtc); }
@Test public void shouldIncludeTimeLoadedInReadBranchRequests() { String workspaceName = graph.getCurrentWorkspaceName(); // Don't use the graph so that we can obtain and interrogate the request ... CacheableRequest request = new ReadBranchRequest(location("/"), workspaceName, 2); execute(request); assertThat(request.getTimeLoaded(), is(notNullValue())); }
while (projectedRequest != null) { CacheableRequest fromSource = (CacheableRequest)projectedRequest.getRequest(); if (fromSource.hasError()) { projectedRequest = projectedRequest.next(); continue; if (fromSource.isCancelled()) { request.cancel(); return; if (RequestType.READ_BRANCH == fromSource.getType()) { ReadBranchRequest readFromSource = (ReadBranchRequest)fromSource; for (Location parent : readFromSource) { actualLocationsOfProxyNodes.put(locationOfProxy.getPath(), locationOfProxy); setCacheableInfo(request, fromSource.getCachePolicy()); projectedRequest = projectedRequest.next(); ++numMerged; CacheableRequest fromSource = (CacheableRequest)projectedRequest.getRequest(); Projection projection = projectedRequest.getProjection(); if (RequestType.READ_NODE == fromSource.getType()) { ReadNodeRequest readFromSource = (ReadNodeRequest)fromSource; Location parent = readFromSource.getActualLocationOfNode(); setCacheableInfo(request, fromSource.getCachePolicy()); projectedRequest = projectedRequest.next();
protected static DateTime computeExpirationTime( CacheableRequest request ) { CachePolicy policy = request.getCachePolicy(); return policy == null ? null : request.getTimeLoaded().plus(policy.getTimeToLive(), TimeUnit.MILLISECONDS); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.ReadBranchRequest) */ @Override public void process( ReadBranchRequest request ) { CacheableRequest source = (CacheableRequest)federatedRequest.getFirstProjectedRequest().getRequest(); if (checkErrorOrCancel(request, source)) return; if (RequestType.READ_BRANCH == source.getType()) { ReadBranchRequest readSource = (ReadBranchRequest)source; request.setActualLocationOfNode(readSource.getActualLocationOfNode()); for (Location node : readSource) { List<Location> children = readSource.getChildren(node); if (children != null) request.setChildren(node, children); Map<Name, Property> props = readSource.getPropertiesFor(node); if (props != null) request.setProperties(node, props.values()); } } else if (RequestType.READ_NODE == source.getType()) { ReadNodeRequest readSource = (ReadNodeRequest)source; request.setActualLocationOfNode(readSource.getActualLocationOfNode()); Location parent = readSource.getActualLocationOfNode(); request.setChildren(parent, readSource.getChildren()); request.setProperties(parent, readSource.getPropertiesByName().values()); } request.setCachePolicy(getDefaultCachePolicy()); setCacheableInfo(request, source.getCachePolicy()); }
cacheableOriginal.setCachePolicy(getDefaultCachePolicy()); while (projectedRequest != null) { Request requestToSource = projectedRequest.getRequest(); setCacheableInfo(cacheableOriginal, ((CacheableRequest)requestToSource).getCachePolicy()); projectedRequest = projectedRequest.next();
@Test public void shouldIncludeTimeLoadedInReadNextBlockOfChildrenRequests() { // Get the first child ... String workspaceName = graph.getCurrentWorkspaceName(); Location firstChild = graph.getChildren().of("/").get(0); // Don't use the graph so that we can obtain and interrogate the request ... CacheableRequest request = new ReadNextBlockOfChildrenRequest(firstChild, workspaceName, 100); execute(request); assertThat(request.getTimeLoaded(), is(notNullValue())); }
@Test public void shouldIncludeTimeLoadedInReadAllPropertiesRequests() { String workspaceName = graph.getCurrentWorkspaceName(); // Don't use the graph so that we can obtain and interrogate the request ... CacheableRequest request = new ReadAllPropertiesRequest(location("/"), workspaceName); execute(request); assertThat(request.getTimeLoaded(), is(notNullValue())); }
/** * Set the supplied request to have the supplied cache policy and the {@link #getNowInUtc() current time in UTC}. * * @param request the cacheable request * @param cachePolicy the cache policy for the request; may be null if there is to be no cache policy */ protected void setCacheableInfo( CacheableRequest request, CachePolicy cachePolicy ) { if (cachePolicy == null) cachePolicy = defaultCachePolicy; if (cachePolicy != null) { if (request.getCachePolicy() != null) { // Set the supplied only if less than the current ... if (request.getCachePolicy().getTimeToLive() > cachePolicy.getTimeToLive()) { request.setCachePolicy(cachePolicy); } } else { // There is no current policy, so set the supplied policy ... request.setCachePolicy(cachePolicy); } } request.setTimeLoaded(nowInUtc); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.Request#cancel() */ @Override public void cancel() { super.cancel(); this.actualLocation = null; }
/** * {@inheritDoc} * * @throws IllegalStateException if the request is frozen * @see org.modeshape.graph.cache.Cacheable#setCachePolicy(org.modeshape.graph.cache.CachePolicy) */ public void setCachePolicy( CachePolicy cachePolicy ) { checkNotFrozen(); policy = cachePolicy; }
@Test public void shouldIncludeTimeLoadedInReadAllChildrenRequests() { String workspaceName = graph.getCurrentWorkspaceName(); // Don't use the graph so that we can obtain and interrogate the request ... CacheableRequest request = new ReadAllChildrenRequest(location("/"), workspaceName); execute(request); assertThat(request.getTimeLoaded(), is(notNullValue())); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.Request#cancel() */ @Override public void cancel() { super.cancel(); this.actualLocation = null; this.property = null; }
@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())); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.Request#cancel() */ @Override public void cancel() { super.cancel(); this.actualOf = null; }
@Test public void shouldIncludeTimeLoadedInReadBlockOfChildrenRequests() { String workspaceName = graph.getCurrentWorkspaceName(); // Don't use the graph so that we can obtain and interrogate the request ... CacheableRequest request = new ReadBlockOfChildrenRequest(location("/"), workspaceName, 0, 100); execute(request); assertThat(request.getTimeLoaded(), is(notNullValue())); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.Request#cancel() */ @Override public void cancel() { super.cancel(); this.actualLocation = null; }
@Test public void shouldIncludeTimeLoadedInReadPropertyRequests() { // Get each of the properties on the first child ... String workspaceName = graph.getCurrentWorkspaceName(); Location firstChildLocation = graph.getChildren().of("/").get(0); Node firstChild = graph.getNodeAt(firstChildLocation); // Don't use the graph so that we can obtain and interrogate the request ... for (Property property : firstChild.getProperties()) { CacheableRequest request = new ReadPropertyRequest(firstChildLocation, workspaceName, property.getName()); execute(request); assertThat(request.getTimeLoaded(), is(notNullValue())); } }