|
@@ -70,6 +70,8 @@ import org.apache.hadoop.util.Daemon;
|
|
|
import org.apache.hadoop.util.HostsFileReader;
|
|
|
import org.apache.hadoop.util.ReflectionUtils;
|
|
|
|
|
|
+import com.google.common.annotations.VisibleForTesting;
|
|
|
+
|
|
|
/**
|
|
|
* Manage datanodes, include decommission and other activities.
|
|
|
*/
|
|
@@ -123,6 +125,12 @@ public class DatanodeManager {
|
|
|
/** Ask Datanode only up to this many blocks to delete. */
|
|
|
final int blockInvalidateLimit;
|
|
|
|
|
|
+ /**
|
|
|
+ * Whether or not this cluster has ever consisted of more than 1 rack,
|
|
|
+ * according to the NetworkTopology.
|
|
|
+ */
|
|
|
+ private boolean hasClusterEverBeenMultiRack = false;
|
|
|
+
|
|
|
DatanodeManager(final BlockManager blockManager,
|
|
|
final Namesystem namesystem, final Configuration conf
|
|
|
) throws IOException {
|
|
@@ -328,6 +336,7 @@ public class DatanodeManager {
|
|
|
|
|
|
host2DatanodeMap.add(node);
|
|
|
networktopology.add(node);
|
|
|
+ checkIfClusterIsNowMultiRack(node);
|
|
|
|
|
|
if (LOG.isDebugEnabled()) {
|
|
|
LOG.debug(getClass().getSimpleName() + ".addDatanode: "
|
|
@@ -766,6 +775,42 @@ public class DatanodeManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @return true if this cluster has ever consisted of multiple racks, even if
|
|
|
+ * it is not now a multi-rack cluster.
|
|
|
+ */
|
|
|
+ boolean hasClusterEverBeenMultiRack() {
|
|
|
+ return hasClusterEverBeenMultiRack;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Check if the cluster now consists of multiple racks. If it does, and this
|
|
|
+ * is the first time it's consisted of multiple racks, then process blocks
|
|
|
+ * that may now be misreplicated.
|
|
|
+ *
|
|
|
+ * @param node DN which caused cluster to become multi-rack. Used for logging.
|
|
|
+ */
|
|
|
+ @VisibleForTesting
|
|
|
+ void checkIfClusterIsNowMultiRack(DatanodeDescriptor node) {
|
|
|
+ if (!hasClusterEverBeenMultiRack && networktopology.getNumOfRacks() > 1) {
|
|
|
+ String message = "DN " + node + " joining cluster has expanded a formerly " +
|
|
|
+ "single-rack cluster to be multi-rack. ";
|
|
|
+ if (namesystem.isPopulatingReplQueues()) {
|
|
|
+ message += "Re-checking all blocks for replication, since they should " +
|
|
|
+ "now be replicated cross-rack";
|
|
|
+ LOG.info(message);
|
|
|
+ } else {
|
|
|
+ message += "Not checking for mis-replicated blocks because this NN is " +
|
|
|
+ "not yet processing repl queues.";
|
|
|
+ LOG.debug(message);
|
|
|
+ }
|
|
|
+ hasClusterEverBeenMultiRack = true;
|
|
|
+ if (namesystem.isPopulatingReplQueues()) {
|
|
|
+ blockManager.processMisReplicatedBlocks();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/** For generating datanode reports */
|
|
|
public List<DatanodeDescriptor> getDatanodeListForReport(
|
|
|
final DatanodeReportType type) {
|