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 ...@@ -487,4 +487,9 @@ public class RMProxyUserInterface extends RMListenerProxy implements ResourceMan
public void setNodeTokens(String nodeUrl, List<String> tokens) throws RMException { public void setNodeTokens(String nodeUrl, List<String> tokens) throws RMException {
target.setNodeTokens(nodeUrl, tokens); target.setNodeTokens(nodeUrl, tokens);
} }
@Override
public List<String> getNodeTokens(String nodeUrl) throws RMException {
return target.getNodeTokens(nodeUrl);
}
} }
...@@ -572,4 +572,6 @@ public interface ResourceManager { ...@@ -572,4 +572,6 @@ public interface ResourceManager {
void setNodeTokens(String nodeUrl, List<String> tokens) throws RMException; 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 { ...@@ -3109,6 +3109,9 @@ public class RMCore implements ResourceManager, InitActive, RunActive {
@Override @Override
public void addNodeToken(String nodeUrl, String token) throws RMException { public void addNodeToken(String nodeUrl, String token) throws RMException {
if (token == null || token.isEmpty()) {
throw new RMException("Invalid empty token");
}
if (allNodes.containsKey(nodeUrl)) { if (allNodes.containsKey(nodeUrl)) {
RMNode rmNode = allNodes.get(nodeUrl); RMNode rmNode = allNodes.get(nodeUrl);
checkNodeAdminPermission(rmNode, caller); checkNodeAdminPermission(rmNode, caller);
...@@ -3124,8 +3127,20 @@ public class RMCore implements ResourceManager, InitActive, RunActive { ...@@ -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 @Override
public void removeNodeToken(String nodeUrl, String token) throws RMException { public void removeNodeToken(String nodeUrl, String token) throws RMException {
if (token == null || token.isEmpty()) {
throw new RMException("Invalid empty token");
}
if (allNodes.containsKey(nodeUrl)) { if (allNodes.containsKey(nodeUrl)) {
RMNode rmNode = allNodes.get(nodeUrl); RMNode rmNode = allNodes.get(nodeUrl);
checkNodeAdminPermission(rmNode, caller); checkNodeAdminPermission(rmNode, caller);
...@@ -3144,6 +3159,9 @@ public class RMCore implements ResourceManager, InitActive, RunActive { ...@@ -3144,6 +3159,9 @@ public class RMCore implements ResourceManager, InitActive, RunActive {
@Override @Override
public void setNodeTokens(String nodeUrl, List<String> tokens) throws RMException { 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)) { if (allNodes.containsKey(nodeUrl)) {
RMNode rmNode = allNodes.get(nodeUrl); RMNode rmNode = allNodes.get(nodeUrl);
rmNode.setNodeTokens(nodeUrl, tokens); rmNode.setNodeTokens(nodeUrl, tokens);
......
Supports Markdown
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