PepperJo commented on a change in pull request #85:
URL: https://github.com/apache/incubator-crail/pull/85#discussion_r578410369



##########
File path: namenode/src/main/java/org/apache/crail/namenode/BlockStore.java
##########
@@ -171,9 +192,33 @@ 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);
+       }
+
        //---------------
-       
+
+       private short prepareOrRemoveDN(DataNodeInfo dn, boolean onlyMark) 
throws Exception {
+               DataNodeBlocks toBeRemoved = membership.get(dn.key());
+               if (toBeRemoved == null) {
+                       LOG.error("DataNode: " + dn.toString() + " not found");
+                       return RpcErrors.ERR_DATANODE_NOT_REGISTERED;
+               } else {
+                       if (onlyMark)
+                               toBeRemoved.scheduleForRemoval();
+                       else
+                               membership.remove(toBeRemoved.key());

Review comment:
       So in the case the datanode still has data and is forcefully removed, we 
would get file with wholes in them, correct? Blocks of this datanodes that are 
still used in files are not updated that the datanode has been removed? So if a 
client asks for a block he will get the datanode info of a non-existing 
datanode? Worse if someone starts a datanode with the same ip/port at a later 
point he might see different data (depending on datanode type).




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to