Unverified Commit b67f2c8d authored by Fabien Viale's avatar Fabien Viale Committed by GitHub
Browse files

Merge pull request #3786 from fviale/master

Add getNodeTokens method to ResourceManage
parents 8d2379f7 3b3de1bf
......@@ -487,4 +487,9 @@ public class RMProxyUserInterface extends RMListenerProxy implements ResourceMan
public void setNodeTokens(String nodeUrl, List<String> tokens) throws RMException {
target.setNodeTokens(nodeUrl, tokens);
}
@Override
public List<String> getNodeTokens(String nodeUrl) throws RMException {
return target.getNodeTokens(nodeUrl);
}
}
......@@ -572,4 +572,6 @@ public interface ResourceManager {
void setNodeTokens(String nodeUrl, List<String> tokens) throws RMException;
List<String> getNodeTokens(String nodeUrl) throws RMException;
}
......@@ -3109,6 +3109,9 @@ public class RMCore implements ResourceManager, InitActive, RunActive {
@Override
public void addNodeToken(String nodeUrl, String token) throws RMException {
if (token == null || token.isEmpty()) {
throw new RMException("Invalid empty token");
}
if (allNodes.containsKey(nodeUrl)) {
RMNode rmNode = allNodes.get(nodeUrl);
checkNodeAdminPermission(rmNode, caller);
......@@ -3124,8 +3127,20 @@ public class RMCore implements ResourceManager, InitActive, RunActive {
}
}
public List<String> getNodeTokens(String nodeUrl) throws RMException {
if (allNodes.containsKey(nodeUrl)) {
RMNode rmNode = allNodes.get(nodeUrl);
return rmNode.getNodeTokens();
} else {
throw new RMException("Unknown node " + nodeUrl);
}
}
@Override
public void removeNodeToken(String nodeUrl, String token) throws RMException {
if (token == null || token.isEmpty()) {
throw new RMException("Invalid empty token");
}
if (allNodes.containsKey(nodeUrl)) {
RMNode rmNode = allNodes.get(nodeUrl);
checkNodeAdminPermission(rmNode, caller);
......@@ -3144,6 +3159,9 @@ public class RMCore implements ResourceManager, InitActive, RunActive {
@Override
public void setNodeTokens(String nodeUrl, List<String> tokens) throws RMException {
if (tokens.stream().anyMatch(token -> token == null || token.isEmpty())) {
throw new RMException("Invalid empty token in list " + tokens);
}
if (allNodes.containsKey(nodeUrl)) {
RMNode rmNode = allNodes.get(nodeUrl);
rmNode.setNodeTokens(nodeUrl, tokens);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment