Search in sources :

Example 1 with PnfsFlagMessage

use of diskCacheV111.vehicles.PnfsFlagMessage in project dcache by dCache.

the class LegacyAdminShell method ac_set_deletable_$_1.

public String ac_set_deletable_$_1(Args args) throws Exception {
    checkPermission("*.*.*");
    PnfsId pnfsId = new PnfsId(args.argv(0));
    StringBuilder sb = new StringBuilder();
    PnfsFlagMessage pfm = new PnfsFlagMessage(pnfsId, "d", PnfsFlagMessage.FlagOperation.SET);
    pfm.setValue("true");
    try {
        pfm = (PnfsFlagMessage) sendObject("PnfsManager", pfm);
    } catch (Exception ee) {
        sb.append("Attempt to set 'd' flag reported an Exception : ").append(ee);
        sb.append("\n");
        sb.append("Operation aborted\n");
        return sb.toString();
    }
    if (pfm.getReturnCode() != 0) {
        sb.append("set 'd' flag reported  : ").append(pfm.getErrorObject());
        return sb.toString();
    }
    sb.append("Setting 'd' succeeded\n");
    PnfsGetCacheLocationsMessage locations = new PnfsGetCacheLocationsMessage(pnfsId);
    try {
        locations = (PnfsGetCacheLocationsMessage) sendObject("PnfsManager", locations);
    } catch (Exception ee) {
        sb.append("Attempt to get cache locations reported an Exception : ").append(ee);
        sb.append("\n");
        sb.append("Operation aborted\n");
        return sb.toString();
    }
    if (locations.getReturnCode() != 0) {
        sb.append("Problem in getting cache location(s) : ").append(locations.getErrorObject());
        return sb.toString();
    }
    List<String> assumedLocations = locations.getCacheLocations();
    sb.append("Assumed cache locations : ").append(assumedLocations.toString()).append("\n");
    for (Object assumedLocation : assumedLocations) {
        String poolName = assumedLocation.toString();
        PoolModifyPersistencyMessage p = new PoolModifyPersistencyMessage(poolName, pnfsId, false);
        try {
            p = (PoolModifyPersistencyMessage) sendObject(poolName, p);
        } catch (Exception ee) {
            sb.append("Attempt to contact ").append(poolName).append(" reported an Exception : ").append(ee.toString()).append("\n").append("  Operation continues\n");
            continue;
        }
        if (locations.getReturnCode() != 0) {
            sb.append("Set 'cached' reply from ").append(poolName).append(" : ").append(p.getErrorObject()).append("\n");
        } else {
            sb.append("Set 'cached' OK for ").append(poolName).append("\n");
        }
    }
    return sb.toString();
}
Also used : PnfsGetCacheLocationsMessage(diskCacheV111.vehicles.PnfsGetCacheLocationsMessage) PoolModifyPersistencyMessage(diskCacheV111.vehicles.PoolModifyPersistencyMessage) PnfsId(diskCacheV111.util.PnfsId) AuthorizedString(dmg.util.AuthorizedString) CommandThrowableException(dmg.util.CommandThrowableException) AclException(dmg.util.AclException) CommandException(dmg.util.CommandException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) FileNotFoundException(java.io.FileNotFoundException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) CommandExitException(dmg.util.CommandExitException) SerializationException(dmg.cells.nucleus.SerializationException) CacheException(diskCacheV111.util.CacheException) CommandSyntaxException(dmg.util.CommandSyntaxException) ExecutionException(java.util.concurrent.ExecutionException) PnfsFlagMessage(diskCacheV111.vehicles.PnfsFlagMessage)

Example 2 with PnfsFlagMessage

use of diskCacheV111.vehicles.PnfsFlagMessage in project dcache by dCache.

the class PnfsManagerV3 method updateFlag.

private void updateFlag(PnfsFlagMessage pnfsMessage) {
    PnfsId pnfsId = pnfsMessage.getPnfsId();
    PnfsFlagMessage.FlagOperation operation = pnfsMessage.getOperation();
    String flagName = pnfsMessage.getFlagName();
    String value = pnfsMessage.getValue();
    Subject subject = pnfsMessage.getSubject();
    LOGGER.info("update flag " + operation + " flag=" + flagName + " value=" + value + " for " + pnfsId);
    try {
        // Note that dcap clients may bypass restrictions by not
        // specifying a path when interacting via mounted namespace.
        checkRestriction(pnfsMessage, UPDATE_METADATA);
        if (operation == PnfsFlagMessage.FlagOperation.GET) {
            pnfsMessage.setValue(updateFlag(subject, pnfsId, operation, flagName, value));
        } else {
            updateFlag(subject, pnfsId, operation, flagName, value);
        }
    } catch (FileNotFoundCacheException e) {
        pnfsMessage.setFailed(e.getRc(), e.getMessage());
    } catch (CacheException e) {
        LOGGER.warn("Exception in updateFlag: " + e);
        pnfsMessage.setFailed(e.getRc(), e.getMessage());
    } catch (RuntimeException e) {
        LOGGER.error("Exception in updateFlag", e);
        pnfsMessage.setFailed(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e);
    }
}
Also used : MissingResourceCacheException(diskCacheV111.util.MissingResourceCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) CacheException(diskCacheV111.util.CacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) PnfsId(diskCacheV111.util.PnfsId) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) Subject(javax.security.auth.Subject) PnfsFlagMessage(diskCacheV111.vehicles.PnfsFlagMessage)

Example 3 with PnfsFlagMessage

use of diskCacheV111.vehicles.PnfsFlagMessage in project dcache by dCache.

the class LegacyAdminShell method setPnfsFlag.

private PnfsFlagReply setPnfsFlag(String destination, String key, String value, boolean mode) throws Exception {
    PnfsId pnfsId;
    if (destination.startsWith("/pnfs")) {
        PnfsGetFileAttributes map = new PnfsGetFileAttributes(destination, EnumSet.of(FileAttribute.PNFSID));
        map.setFollowSymlink(false);
        map = (PnfsGetFileAttributes) sendObject("PnfsManager", map);
        if (map.getReturnCode() != 0) {
            Object o = map.getErrorObject();
            if (o instanceof Exception) {
                throw (Exception) o;
            } else {
                throw new Exception(o.toString());
            }
        }
        pnfsId = map.getFileAttributes().getPnfsId();
    } else {
        pnfsId = new PnfsId(destination);
    }
    checkPermission("pnfs.*.update");
    PnfsFlagMessage pfm = new PnfsFlagMessage(pnfsId, key, mode ? PnfsFlagMessage.FlagOperation.SET : PnfsFlagMessage.FlagOperation.REMOVE);
    pfm.setValue(value);
    PnfsFlagMessage result = (PnfsFlagMessage) sendObject("PnfsManager", pfm);
    if (result.getReturnCode() != 0) {
        Object o = result.getErrorObject();
        if (o instanceof Exception) {
            throw (Exception) o;
        } else {
            throw new Exception(o.toString());
        }
    }
    return new PnfsFlagReply(pnfsId, result);
}
Also used : PnfsId(diskCacheV111.util.PnfsId) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) CommandThrowableException(dmg.util.CommandThrowableException) AclException(dmg.util.AclException) CommandException(dmg.util.CommandException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) FileNotFoundException(java.io.FileNotFoundException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) CommandExitException(dmg.util.CommandExitException) SerializationException(dmg.cells.nucleus.SerializationException) CacheException(diskCacheV111.util.CacheException) CommandSyntaxException(dmg.util.CommandSyntaxException) ExecutionException(java.util.concurrent.ExecutionException) PnfsFlagMessage(diskCacheV111.vehicles.PnfsFlagMessage)

Example 4 with PnfsFlagMessage

use of diskCacheV111.vehicles.PnfsFlagMessage in project dcache by dCache.

the class LegacyAdminShell method ac_flags_ls_$_2.

public Object ac_flags_ls_$_2(Args args) throws Exception {
    PnfsId pnfsId;
    if (args.argv(0).startsWith("/pnfs")) {
        PnfsGetFileAttributes map = new PnfsGetFileAttributes(args.argv(0), EnumSet.of(FileAttribute.PNFSID));
        map.setFollowSymlink(false);
        map = (PnfsGetFileAttributes) sendObject("PnfsManager", map);
        if (map.getReturnCode() != 0) {
            Object o = map.getErrorObject();
            if (o instanceof Exception) {
                throw (Exception) o;
            } else {
                throw new Exception(o.toString());
            }
        }
        pnfsId = map.getFileAttributes().getPnfsId();
    } else {
        pnfsId = new PnfsId(args.argv(0));
    }
    String key = args.argv(1);
    PnfsFlagMessage pfm = new PnfsFlagMessage(pnfsId, key, PnfsFlagMessage.FlagOperation.GET);
    PnfsFlagMessage result = (PnfsFlagMessage) sendObject("PnfsManager", pfm);
    return result.getReturnCode() == 0 ? (key + " -> " + result.getValue()) : result.getErrorObject().toString();
}
Also used : PnfsId(diskCacheV111.util.PnfsId) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) AuthorizedString(dmg.util.AuthorizedString) CommandThrowableException(dmg.util.CommandThrowableException) AclException(dmg.util.AclException) CommandException(dmg.util.CommandException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) FileNotFoundException(java.io.FileNotFoundException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) CommandExitException(dmg.util.CommandExitException) SerializationException(dmg.cells.nucleus.SerializationException) CacheException(diskCacheV111.util.CacheException) CommandSyntaxException(dmg.util.CommandSyntaxException) ExecutionException(java.util.concurrent.ExecutionException) PnfsFlagMessage(diskCacheV111.vehicles.PnfsFlagMessage)

Example 5 with PnfsFlagMessage

use of diskCacheV111.vehicles.PnfsFlagMessage in project dcache by dCache.

the class LegacyAdminShell method ac_flags_remove_$_2.

public Object ac_flags_remove_$_2(Args args) throws Exception {
    PnfsId pnfsId;
    if (args.argv(0).startsWith("/pnfs")) {
        PnfsGetFileAttributes map = new PnfsGetFileAttributes(args.argv(0), EnumSet.of(FileAttribute.PNFSID));
        map.setFollowSymlink(false);
        map = (PnfsGetFileAttributes) sendObject("PnfsManager", map);
        if (map.getReturnCode() != 0) {
            Object o = map.getErrorObject();
            if (o instanceof Exception) {
                throw (Exception) o;
            } else {
                throw new Exception(o.toString());
            }
        }
        pnfsId = map.getFileAttributes().getPnfsId();
    } else {
        pnfsId = new PnfsId(args.argv(0));
    }
    String key = args.argv(1);
    checkPermission("pnfs.*.update");
    PnfsFlagMessage pfm = new PnfsFlagMessage(pnfsId, key, PnfsFlagMessage.FlagOperation.REMOVE);
    PnfsFlagMessage result = (PnfsFlagMessage) sendObject("PnfsManager", pfm);
    if (result.getReturnCode() != 0) {
        Object o = result.getErrorObject();
        if (o instanceof Exception) {
            throw (Exception) o;
        } else {
            throw new Exception(o.toString());
        }
    }
    return result.getReturnCode() == 0 ? "" : result.getErrorObject().toString();
}
Also used : PnfsId(diskCacheV111.util.PnfsId) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) AuthorizedString(dmg.util.AuthorizedString) CommandThrowableException(dmg.util.CommandThrowableException) AclException(dmg.util.AclException) CommandException(dmg.util.CommandException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) FileNotFoundException(java.io.FileNotFoundException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) CommandExitException(dmg.util.CommandExitException) SerializationException(dmg.cells.nucleus.SerializationException) CacheException(diskCacheV111.util.CacheException) CommandSyntaxException(dmg.util.CommandSyntaxException) ExecutionException(java.util.concurrent.ExecutionException) PnfsFlagMessage(diskCacheV111.vehicles.PnfsFlagMessage)

Aggregations

PnfsFlagMessage (diskCacheV111.vehicles.PnfsFlagMessage)9 CacheException (diskCacheV111.util.CacheException)5 PnfsId (diskCacheV111.util.PnfsId)5 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)4 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)4 SerializationException (dmg.cells.nucleus.SerializationException)4 AclException (dmg.util.AclException)4 AuthorizedString (dmg.util.AuthorizedString)4 CommandException (dmg.util.CommandException)4 CommandExitException (dmg.util.CommandExitException)4 CommandSyntaxException (dmg.util.CommandSyntaxException)4 CommandThrowableException (dmg.util.CommandThrowableException)4 FileNotFoundException (java.io.FileNotFoundException)4 ExecutionException (java.util.concurrent.ExecutionException)4 PnfsGetFileAttributes (org.dcache.vehicles.PnfsGetFileAttributes)3 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)1 InvalidMessageCacheException (diskCacheV111.util.InvalidMessageCacheException)1 MissingResourceCacheException (diskCacheV111.util.MissingResourceCacheException)1 NotDirCacheException (diskCacheV111.util.NotDirCacheException)1 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)1