Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cavern: tweaks for PosixMapperClient exceptions #183

Merged
merged 1 commit into from
Sep 28, 2023
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 @@ -148,7 +148,7 @@ public Node get(VOSURI uri, boolean allowPartialPath, boolean resolveMetadata) t
}
log.debug("[get] " + ret);
return ret;
} catch (IOException ex) {
} catch (IOException | InterruptedException ex) {
throw new RuntimeException("oops", ex);
}
}
Expand Down Expand Up @@ -184,7 +184,7 @@ public void getChildren(ContainerNode cn, VOSURI start, Integer limit, boolean b
cn.getNodes().add(cur);
log.debug("[getChildren] " + cur);
}
} catch (IOException ex) {
} catch (IOException | InterruptedException ex) {
throw new RuntimeException("oops", ex);
}
}
Expand Down Expand Up @@ -243,7 +243,7 @@ public Node put(Node node) throws NodeNotSupportedException, TransientException
NodeUtil.setOwner(node, new NodeID(null, caller, owner));
nut.create(node);
return nut.get(node.getUri());
} catch (IOException ex) {
} catch (IOException | InterruptedException ex) {
throw new RuntimeException("oops", ex);
}
}
Expand Down Expand Up @@ -283,7 +283,7 @@ public Node updateProperties(Node node, List<NodeProperty> properties) throws Tr
iter.remove();
}
}
} catch (IOException ex) {
} catch (IOException | InterruptedException ex) {
throw new RuntimeException("oops", ex);
}
return node;
Expand Down
66 changes: 45 additions & 21 deletions cavern/src/main/java/org/opencadc/cavern/nodes/NodeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@

import ca.nrc.cadc.auth.PosixPrincipal;
import ca.nrc.cadc.date.DateUtil;
import ca.nrc.cadc.net.ResourceAlreadyExistsException;
import ca.nrc.cadc.net.ResourceNotFoundException;
import ca.nrc.cadc.reg.Standards;
import ca.nrc.cadc.reg.client.LocalAuthority;
import ca.nrc.cadc.vos.ContainerNode;
Expand Down Expand Up @@ -208,7 +210,7 @@ public static VOSURI pathToURI(Path root, Path p, VOSURI rootURI) {
}

public Path create(Node node)
throws IOException {
throws IOException, InterruptedException {
Path np = nodeToPath(root, node);
log.debug("[create] path: " + node.getUri() + " -> " + np);

Expand Down Expand Up @@ -283,7 +285,7 @@ public static void setPosixOwnerGroup(Path p, Integer owner, Integer group) thro
* @param node The VOSpace Node input.
* @throws IOException If any I/O errors occur.
*/
public void setNodeProperties(Path path, Node node) throws IOException {
public void setNodeProperties(Path path, Node node) throws IOException, InterruptedException {
log.debug("setNodeProperties: " + node);
if (!node.getProperties().isEmpty() && !(node instanceof LinkNode)) {

Expand Down Expand Up @@ -311,6 +313,7 @@ public void setNodeProperties(Path path, Node node) throws IOException {
} else {
// ugh: raw multi-valued node prop is space-separated
String val = rop.getPropertyValue();
log.warn("raw read-only prop: " + val);
if (val != null) {
String[] vals = val.split(" ");
if (vals.length > 0) {
Expand All @@ -321,10 +324,15 @@ public void setNodeProperties(Path path, Node node) throws IOException {
guris.add(guri);
}
if (!guris.isEmpty()) {
List<PosixGroup> pgs = posixMapper.getGID(guris);
// TODO: check if any input groups were not resolved/acceptable and do what??
for (PosixGroup pg : pgs) {
readGroupPrincipals.add(pg.getGID());
try {
List<PosixGroup> pgs = posixMapper.getGID(guris);
// TODO: check if any input groups were not resolved/acceptable and do what??
for (PosixGroup pg : pgs) {
readGroupPrincipals.add(pg.getGID());
}
} catch (ResourceNotFoundException | ResourceAlreadyExistsException ex) {
throw new RuntimeException("failed to map GroupURI(s) to numeric GID(s): "
+ ex.toString(), ex);
}
}
} else {
Expand All @@ -344,6 +352,7 @@ public void setNodeProperties(Path path, Node node) throws IOException {
} else {
// ugh: raw multi-valued node prop is space-separated
String val = rwp.getPropertyValue();
log.warn("raw read-write prop: " + val);
if (val != null) {
String[] vals = val.split(" ");
if (vals.length > 0) {
Expand All @@ -354,10 +363,15 @@ public void setNodeProperties(Path path, Node node) throws IOException {
guris.add(guri);
}
if (!guris.isEmpty()) {
List<PosixGroup> pgs = posixMapper.getGID(guris);
// TODO: check if any input groups were not resolved/acceptable and do what??
for (PosixGroup pg : pgs) {
writeGroupPrincipals.add(pg.getGID());
try {
List<PosixGroup> pgs = posixMapper.getGID(guris);
// TODO: check if any input groups were not resolved/acceptable and do what??
for (PosixGroup pg : pgs) {
writeGroupPrincipals.add(pg.getGID());
}
} catch (ResourceNotFoundException | ResourceAlreadyExistsException ex) {
throw new RuntimeException("failed to map GroupURI(s) to numeric GID(s): "
+ ex.toString(), ex);
}
}
} else {
Expand Down Expand Up @@ -415,11 +429,12 @@ public Path update(Path root, Node node) throws IOException {
throw new UnsupportedOperationException();
}

public Node get(VOSURI uri) throws IOException {
public Node get(VOSURI uri) throws IOException, InterruptedException {
return get(uri, false);
}

public Node get(VOSURI uri, boolean allowPartialPath) throws IOException {
public Node get(VOSURI uri, boolean allowPartialPath)
throws IOException, InterruptedException {
LinkedList<String> nodeNames = new LinkedList<String>();
nodeNames.add(uri.getName());
VOSURI parent = uri.getParentURI();
Expand Down Expand Up @@ -506,14 +521,14 @@ public void copy(VOSURI source, VOSURI destDir, PosixPrincipal owner) throws IOE
}

Node pathToNode(Path p, VOSURI rootURI)
throws IOException, NoSuchFileException {
throws IOException, InterruptedException, NoSuchFileException {
boolean getAttrs = System.getProperty(NodeUtil.class.getName() + ".disable-get-attrs") == null;
return pathToNode(p, rootURI, getAttrs);
}

// getAttrs == false needed in MountedContainerTest
Node pathToNode(Path p, VOSURI rootURI, boolean getAttrs)
throws IOException, NoSuchFileException {
throws IOException, InterruptedException, NoSuchFileException {
Node ret = null;
VOSURI nuri = pathToURI(root, p, rootURI);
PosixFileAttributes attrs = Files.readAttributes(p,
Expand Down Expand Up @@ -575,9 +590,13 @@ Node pathToNode(Path p, VOSURI rootURI, boolean getAttrs)
StringBuilder sb = new StringBuilder();
List<Integer> rogids = acl.getReadOnlyACL(attrs.isDirectory());
if (!rogids.isEmpty()) {
List<PosixGroup> pgs = posixMapper.getURI(rogids);
for (PosixGroup pg : pgs) {
sb.append(pg.getGroupURI().getURI().toASCIIString()).append(" ");
try {
List<PosixGroup> pgs = posixMapper.getURI(rogids);
for (PosixGroup pg : pgs) {
sb.append(pg.getGroupURI().getURI().toASCIIString()).append(" ");
}
} catch (ResourceNotFoundException | ResourceAlreadyExistsException ex) {
throw new RuntimeException("failed to map numeric GID(s) to GroupURI(s): " + ex.toString(), ex);
}
}
sb.trimToSize();
Expand All @@ -589,9 +608,13 @@ Node pathToNode(Path p, VOSURI rootURI, boolean getAttrs)

List<Integer> rwgids = acl.getReadWriteACL(attrs.isDirectory());
if (!rwgids.isEmpty()) {
List<PosixGroup> pgs = posixMapper.getURI(rwgids);
for (PosixGroup pg : pgs) {
sb.append(pg.getGroupURI().getURI().toASCIIString()).append(" ");
try {
List<PosixGroup> pgs = posixMapper.getURI(rwgids);
for (PosixGroup pg : pgs) {
sb.append(pg.getGroupURI().getURI().toASCIIString()).append(" ");
}
} catch (ResourceNotFoundException | ResourceAlreadyExistsException ex) {
throw new RuntimeException("failed to map numeric GID(s) to GroupURI(s): " + ex.toString(), ex);
}
}
sb.trimToSize();
Expand Down Expand Up @@ -718,7 +741,8 @@ public FileVisitResult postVisitDirectory(Path t, IOException ioe)
}
}

public Iterator<Node> list(ContainerNode node, VOSURI start, Integer limit) throws IOException {
public Iterator<Node> list(ContainerNode node, VOSURI start, Integer limit)
throws IOException, InterruptedException {
Path np = nodeToPath(root, node);
log.debug("[list] " + node.getUri() + " -> " + np);
VOSURI rootURI = node.getUri();
Expand Down
24 changes: 12 additions & 12 deletions cavern/src/main/java/org/opencadc/cavern/probe/FileSystemProbe.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public boolean doCreateDir(boolean depth) {
log.error(sb.toString());
return false;
}
} catch (IOException ex) {
} catch (IOException | InterruptedException ex) {
log.error("FAIL", ex);
return false;
}
Expand Down Expand Up @@ -401,7 +401,7 @@ public boolean doCreateFile(boolean depth) {
log.error(sb.toString());
return false;
}
} catch (IOException ex) {
} catch (IOException | InterruptedException ex) {
log.error("FAIL", ex);
return false;
}
Expand Down Expand Up @@ -497,7 +497,7 @@ public boolean doCreateSymlink() {
log.error(sb.toString());
return false;
}
} catch (IOException ex) {
} catch (IOException | InterruptedException ex) {
log.error("FAIL", ex);
return false;
}
Expand Down Expand Up @@ -559,7 +559,7 @@ public boolean doSetAttribute() {
log.error(sb.toString());
return false;
}
} catch (IOException ex) {
} catch (IOException | InterruptedException ex) {
log.error("FAIL", ex);
return false;
}
Expand Down Expand Up @@ -633,7 +633,7 @@ public boolean doCopyFile() {
log.error(sb.toString());
return false;
}
} catch (IOException ex) {
} catch (IOException | InterruptedException ex) {
log.error("FAIL", ex);
return false;
}
Expand Down Expand Up @@ -700,7 +700,7 @@ public boolean doMoveFile() {
log.error(sb.toString());
return false;
}
} catch (IOException ex) {
} catch (IOException | InterruptedException ex) {
log.error("FAIL", ex);
return false;
}
Expand Down Expand Up @@ -749,7 +749,7 @@ public boolean doRenameFile() {
log.error(sb.toString());
return false;
}
} catch (IOException ex) {
} catch (IOException | InterruptedException ex) {
log.error("FAIL", ex);
return false;
}
Expand Down Expand Up @@ -823,7 +823,7 @@ public boolean doCopyDir() {
log.error(sb.toString());
return false;
}
} catch (IOException ex) {
} catch (IOException | InterruptedException ex) {
log.error("FAIL", ex);
return false;
}
Expand Down Expand Up @@ -892,7 +892,7 @@ public boolean doMoveDir() {
log.error(sb.toString());
return false;
}
} catch (IOException ex) {
} catch (IOException | InterruptedException ex) {
log.error("FAIL", ex);
return false;
}
Expand Down Expand Up @@ -941,7 +941,7 @@ public boolean doRenameDir() {
log.error(sb.toString());
return false;
}
} catch (IOException ex) {
} catch (IOException | InterruptedException ex) {
log.error("FAIL", ex);
return false;
}
Expand Down Expand Up @@ -1026,7 +1026,7 @@ public boolean doCopySymlink() {
log.error(sb.toString());
return false;
}
} catch (IOException ex) {
} catch (IOException | InterruptedException ex) {
log.error("FAIL", ex);
return false;
}
Expand Down Expand Up @@ -1104,7 +1104,7 @@ public boolean doMoveSymlink() {
log.error(sb.toString());
return false;
}
} catch (IOException ex) {
} catch (IOException | InterruptedException ex) {
log.error("FAIL", ex);
return false;
}
Expand Down