Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import org.dcache.pinmanager.PinManagerPinMessage;
import org.dcache.services.bulk.BulkServiceException;
Expand Down Expand Up @@ -123,11 +122,6 @@ public ListenableFuture<Message> perform(String rid, long tid, String prefix, Fs
lifetimeInMillis);
message.setSubject(subject);

Optional<ListenableFuture<Message>> skipOption = skipIfOnline(attributes, message);
if (skipOption.isPresent()) {
return skipOption.get();
}

return pinManager.send(message, Long.MAX_VALUE);
} catch (URISyntaxException | CacheException e) {
return Futures.immediateFailedFuture(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
import static org.dcache.services.bulk.util.BulkRequestTarget.computeFsPath;
import static org.dcache.services.bulk.util.BulkRequestTarget.State.SKIPPED;

import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import diskCacheV111.util.AccessLatency;
import diskCacheV111.util.CacheException;
import diskCacheV111.util.FsPath;
import diskCacheV111.util.NamespaceHandlerAware;
Expand Down Expand Up @@ -145,23 +142,16 @@ protected PinManagerUnpinMessage unpinMessage(String id, PnfsId pnfsId) {
return message;
}

/**
* Only regular files get pinned
* @param attributes
* @throws CacheException
*/
protected void checkPinnable(FileAttributes attributes) throws CacheException {
switch(attributes.getFileType()) {
case SPECIAL:
case DIR:
throw new CacheException(INVALID_ARGS, "Not a regular file.");
}
}

protected Optional<ListenableFuture<Message>> skipIfOnline(FileAttributes attributes,
PinManagerPinMessage message) {
ListenableFuture<Message> future = null;
if (attributes.getAccessLatency() == AccessLatency.ONLINE) {
message.setReply();
message.setLifetime(-1L);
future = Futures.immediateFuture(message);
}

return Optional.ofNullable(future);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ public ListenableFuture<Message> perform(String rid, long tid, String prefix, Fs

try {
/*
* refetch the attributes because RP is not stored in the bulk database.
* refetch the attributes because Retention Policy is not stored in the bulk database.
*/

FsPath absolutePath = BulkRequestTarget.computeFsPath(prefix, path.toString());
attributes = getAttributes(absolutePath);

//Checks for files' RetentionPolicy to be CUSTODIAL
checkStageable(attributes);

PinManagerPinMessage message
Expand All @@ -134,11 +135,6 @@ public ListenableFuture<Message> perform(String rid, long tid, String prefix, Fs
getLifetimeInMillis(path));
message.setSubject(subject);

Optional<ListenableFuture<Message>> skipOption = skipIfOnline(attributes, message);
if (skipOption.isPresent()) {
return skipOption.get();
}

return pinManager.send(message, Long.MAX_VALUE);
} catch (URISyntaxException | CacheException e) {
return Futures.immediateFailedFuture(e);
Expand Down Expand Up @@ -177,6 +173,7 @@ private long getLifetimeInMillis(FsPath path) {
}

private void checkStageable(FileAttributes attributes) throws CacheException {
//check if it's a regular file
checkPinnable(attributes);

if (attributes.getRetentionPolicy() != RetentionPolicy.CUSTODIAL) {
Expand Down