BernardMetzler commented on a change in pull request #86:
URL: https://github.com/apache/incubator-crail/pull/86#discussion_r576252695
##########
File path: namenode/src/main/java/org/apache/crail/namenode/BlockStore.java
##########
@@ -171,9 +273,61 @@ short addDataNode(DataNodeBlocks dataNode) {
return RpcErrors.ERR_OK;
}
-
+
+ short prepareForRemovalDatanode(DataNodeInfo dn) throws Exception {
+ // this will only mark it for removal
+ return _prepareOrRemoveDN(dn, true);
+ }
+
+ short removeDatanode(DataNodeInfo dn) throws Exception {
+ // this will remove it as well
+ return _prepareOrRemoveDN(dn, false);
+ }
+
//---------------
-
+
+ public long getTotalCapacity() {
+ long capacity = 0;
+
+ for(DataNodeBlocks datanode : membership.values()) {
+ capacity += datanode.getMaxBlockCount();
+ }
+
+ return capacity;
+ }
+
+ public long getFreeCapacity() {
+ long capacity = 0;
+
+ for(DataNodeBlocks datanode : membership.values()) {
+ capacity += datanode.getBlockCount();
+ }
+
+ return capacity;
+ }
+
+ public Collection<DataNodeBlocks> getDataNodeBlocks() {
+ return this.membership.values();
+ }
+
+ public int getRunningDatanodes() {
+ return this.membership.size();
+ }
+
+ private short _prepareOrRemoveDN(DataNodeInfo dn, boolean onlyMark)
throws Exception {
Review comment:
Minor nit: I'd prefer to have two methods for the two tasks implemented
here, one for preparing a DN for removal, and one to execute DN removal.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]