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();
}
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);
}
}
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);
}
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();
}
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();
}
Aggregations