parent
dd4a7633ec
commit
e188bb12b0
@ -30,7 +30,7 @@
|
|||||||
import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
|
import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
|
||||||
import org.apache.hadoop.hdds.scm.node.states.NodeAlreadyExistsException;
|
import org.apache.hadoop.hdds.scm.node.states.NodeAlreadyExistsException;
|
||||||
import org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException;
|
import org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException;
|
||||||
import org.apache.hadoop.hdds.scm.server.StorageContainerManager;
|
import org.apache.hadoop.hdds.scm.server.SCMStorageConfig;
|
||||||
import org.apache.hadoop.hdds.scm.VersionInfo;
|
import org.apache.hadoop.hdds.scm.VersionInfo;
|
||||||
import org.apache.hadoop.hdds.scm.container.placement.metrics.SCMNodeMetric;
|
import org.apache.hadoop.hdds.scm.container.placement.metrics.SCMNodeMetric;
|
||||||
import org.apache.hadoop.hdds.scm.container.placement.metrics.SCMNodeStat;
|
import org.apache.hadoop.hdds.scm.container.placement.metrics.SCMNodeStat;
|
||||||
@ -94,13 +94,12 @@ public class SCMNodeManager implements NodeManager {
|
|||||||
LoggerFactory.getLogger(SCMNodeManager.class);
|
LoggerFactory.getLogger(SCMNodeManager.class);
|
||||||
|
|
||||||
private final NodeStateManager nodeStateManager;
|
private final NodeStateManager nodeStateManager;
|
||||||
private final String clusterID;
|
|
||||||
private final VersionInfo version;
|
private final VersionInfo version;
|
||||||
private final CommandQueue commandQueue;
|
private final CommandQueue commandQueue;
|
||||||
private final SCMNodeMetrics metrics;
|
private final SCMNodeMetrics metrics;
|
||||||
// Node manager MXBean
|
// Node manager MXBean
|
||||||
private ObjectName nmInfoBean;
|
private ObjectName nmInfoBean;
|
||||||
private final StorageContainerManager scmManager;
|
private final SCMStorageConfig scmStorageConfig;
|
||||||
private final NetworkTopology clusterMap;
|
private final NetworkTopology clusterMap;
|
||||||
private final DNSToSwitchMapping dnsToSwitchMapping;
|
private final DNSToSwitchMapping dnsToSwitchMapping;
|
||||||
private final boolean useHostname;
|
private final boolean useHostname;
|
||||||
@ -108,18 +107,17 @@ public class SCMNodeManager implements NodeManager {
|
|||||||
/**
|
/**
|
||||||
* Constructs SCM machine Manager.
|
* Constructs SCM machine Manager.
|
||||||
*/
|
*/
|
||||||
public SCMNodeManager(OzoneConfiguration conf, String clusterID,
|
public SCMNodeManager(OzoneConfiguration conf,
|
||||||
StorageContainerManager scmManager, EventPublisher eventPublisher)
|
SCMStorageConfig scmStorageConfig, EventPublisher eventPublisher,
|
||||||
throws IOException {
|
NetworkTopology networkTopology) {
|
||||||
this.nodeStateManager = new NodeStateManager(conf, eventPublisher);
|
this.nodeStateManager = new NodeStateManager(conf, eventPublisher);
|
||||||
this.clusterID = clusterID;
|
|
||||||
this.version = VersionInfo.getLatestVersion();
|
this.version = VersionInfo.getLatestVersion();
|
||||||
this.commandQueue = new CommandQueue();
|
this.commandQueue = new CommandQueue();
|
||||||
this.scmManager = scmManager;
|
this.scmStorageConfig = scmStorageConfig;
|
||||||
LOG.info("Entering startup safe mode.");
|
LOG.info("Entering startup safe mode.");
|
||||||
registerMXBean();
|
registerMXBean();
|
||||||
this.metrics = SCMNodeMetrics.create(this);
|
this.metrics = SCMNodeMetrics.create(this);
|
||||||
this.clusterMap = scmManager.getClusterMap();
|
this.clusterMap = networkTopology;
|
||||||
Class<? extends DNSToSwitchMapping> dnsToSwitchMappingClass =
|
Class<? extends DNSToSwitchMapping> dnsToSwitchMappingClass =
|
||||||
conf.getClass(DFSConfigKeys.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY,
|
conf.getClass(DFSConfigKeys.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY,
|
||||||
TableMapping.class, DNSToSwitchMapping.class);
|
TableMapping.class, DNSToSwitchMapping.class);
|
||||||
@ -221,9 +219,8 @@ public VersionResponse getVersion(SCMVersionRequestProto versionRequest) {
|
|||||||
return VersionResponse.newBuilder()
|
return VersionResponse.newBuilder()
|
||||||
.setVersion(this.version.getVersion())
|
.setVersion(this.version.getVersion())
|
||||||
.addValue(OzoneConsts.SCM_ID,
|
.addValue(OzoneConsts.SCM_ID,
|
||||||
this.scmManager.getScmStorageConfig().getScmId())
|
this.scmStorageConfig.getScmId())
|
||||||
.addValue(OzoneConsts.CLUSTER_ID, this.scmManager.getScmStorageConfig()
|
.addValue(OzoneConsts.CLUSTER_ID, this.scmStorageConfig.getClusterID())
|
||||||
.getClusterID())
|
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +271,7 @@ public RegisteredCommand register(
|
|||||||
|
|
||||||
return RegisteredCommand.newBuilder().setErrorCode(ErrorCode.success)
|
return RegisteredCommand.newBuilder().setErrorCode(ErrorCode.success)
|
||||||
.setDatanodeUUID(datanodeDetails.getUuidString())
|
.setDatanodeUUID(datanodeDetails.getUuidString())
|
||||||
.setClusterID(this.clusterID)
|
.setClusterID(this.scmStorageConfig.getClusterID())
|
||||||
.setHostname(datanodeDetails.getHostName())
|
.setHostname(datanodeDetails.getHostName())
|
||||||
.setIpAddress(datanodeDetails.getIpAddress())
|
.setIpAddress(datanodeDetails.getIpAddress())
|
||||||
.build();
|
.build();
|
||||||
|
@ -378,7 +378,7 @@ private void initializeSystemManagers(OzoneConfiguration conf,
|
|||||||
scmNodeManager = configurator.getScmNodeManager();
|
scmNodeManager = configurator.getScmNodeManager();
|
||||||
} else {
|
} else {
|
||||||
scmNodeManager = new SCMNodeManager(
|
scmNodeManager = new SCMNodeManager(
|
||||||
conf, scmStorageConfig.getClusterID(), this, eventQueue);
|
conf, scmStorageConfig, eventQueue, clusterMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainerPlacementPolicy containerPlacementPolicy =
|
ContainerPlacementPolicy containerPlacementPolicy =
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
import org.apache.hadoop.hdds.scm.events.SCMEvents;
|
import org.apache.hadoop.hdds.scm.events.SCMEvents;
|
||||||
import org.apache.hadoop.hdds.scm.pipeline.PipelineManager;
|
import org.apache.hadoop.hdds.scm.pipeline.PipelineManager;
|
||||||
import org.apache.hadoop.hdds.scm.pipeline.SCMPipelineManager;
|
import org.apache.hadoop.hdds.scm.pipeline.SCMPipelineManager;
|
||||||
|
import org.apache.hadoop.hdds.scm.server.SCMStorageConfig;
|
||||||
import org.apache.hadoop.hdds.server.events.EventQueue;
|
import org.apache.hadoop.hdds.server.events.EventQueue;
|
||||||
import org.apache.hadoop.ozone.OzoneConsts;
|
import org.apache.hadoop.ozone.OzoneConsts;
|
||||||
import org.apache.hadoop.test.PathUtils;
|
import org.apache.hadoop.test.PathUtils;
|
||||||
@ -48,7 +49,6 @@
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import static org.apache.hadoop.hdds.scm.ScmConfigKeys
|
import static org.apache.hadoop.hdds.scm.ScmConfigKeys
|
||||||
@ -94,8 +94,12 @@ SCMNodeManager createNodeManager(OzoneConfiguration config)
|
|||||||
Mockito.mock(StaleNodeHandler.class));
|
Mockito.mock(StaleNodeHandler.class));
|
||||||
eventQueue.addHandler(SCMEvents.DEAD_NODE,
|
eventQueue.addHandler(SCMEvents.DEAD_NODE,
|
||||||
Mockito.mock(DeadNodeHandler.class));
|
Mockito.mock(DeadNodeHandler.class));
|
||||||
|
|
||||||
|
SCMStorageConfig storageConfig = Mockito.mock(SCMStorageConfig.class);
|
||||||
|
Mockito.when(storageConfig.getClusterID()).thenReturn("cluster1");
|
||||||
|
|
||||||
SCMNodeManager nodeManager = new SCMNodeManager(config,
|
SCMNodeManager nodeManager = new SCMNodeManager(config,
|
||||||
UUID.randomUUID().toString(), null, eventQueue);
|
storageConfig, eventQueue, null);
|
||||||
return nodeManager;
|
return nodeManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,9 @@
|
|||||||
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.StorageReportProto;
|
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.StorageReportProto;
|
||||||
import org.apache.hadoop.hdds.scm.TestUtils;
|
import org.apache.hadoop.hdds.scm.TestUtils;
|
||||||
import org.apache.hadoop.hdds.scm.container.placement.metrics.SCMNodeMetric;
|
import org.apache.hadoop.hdds.scm.container.placement.metrics.SCMNodeMetric;
|
||||||
|
import org.apache.hadoop.hdds.scm.net.NetworkTopology;
|
||||||
import org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.NodeReportFromDatanode;
|
import org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.NodeReportFromDatanode;
|
||||||
|
import org.apache.hadoop.hdds.scm.server.SCMStorageConfig;
|
||||||
import org.apache.hadoop.hdds.server.events.Event;
|
import org.apache.hadoop.hdds.server.events.Event;
|
||||||
import org.apache.hadoop.hdds.server.events.EventPublisher;
|
import org.apache.hadoop.hdds.server.events.EventPublisher;
|
||||||
import org.apache.hadoop.hdds.server.events.EventQueue;
|
import org.apache.hadoop.hdds.server.events.EventQueue;
|
||||||
@ -32,6 +34,7 @@
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -50,7 +53,11 @@ public class TestNodeReportHandler implements EventPublisher {
|
|||||||
@Before
|
@Before
|
||||||
public void resetEventCollector() throws IOException {
|
public void resetEventCollector() throws IOException {
|
||||||
OzoneConfiguration conf = new OzoneConfiguration();
|
OzoneConfiguration conf = new OzoneConfiguration();
|
||||||
nodeManager = new SCMNodeManager(conf, "cluster1", null, new EventQueue());
|
SCMStorageConfig storageConfig = Mockito.mock(SCMStorageConfig.class);
|
||||||
|
Mockito.when(storageConfig.getClusterID()).thenReturn("cluster1");
|
||||||
|
nodeManager =
|
||||||
|
new SCMNodeManager(conf, storageConfig, new EventQueue(), Mockito.mock(
|
||||||
|
NetworkTopology.class));
|
||||||
nodeReportHandler = new NodeReportHandler(nodeManager);
|
nodeReportHandler = new NodeReportHandler(nodeManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user