|
@@ -29,6 +29,7 @@ import org.apache.hadoop.hdds.protocol.proto
|
|
.StorageContainerDatanodeProtocolProtos.ContainerReportsProto;
|
|
.StorageContainerDatanodeProtocolProtos.ContainerReportsProto;
|
|
import org.apache.hadoop.hdds.protocol.proto
|
|
import org.apache.hadoop.hdds.protocol.proto
|
|
.StorageContainerDatanodeProtocolProtos.SCMRegisteredResponseProto;
|
|
.StorageContainerDatanodeProtocolProtos.SCMRegisteredResponseProto;
|
|
|
|
+import org.apache.hadoop.ozone.container.common.statemachine.StateContext;
|
|
import org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer;
|
|
import org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -50,6 +51,7 @@ public final class RegisterEndpointTask implements
|
|
private Future<EndpointStateMachine.EndPointStates> result;
|
|
private Future<EndpointStateMachine.EndPointStates> result;
|
|
private DatanodeDetails datanodeDetails;
|
|
private DatanodeDetails datanodeDetails;
|
|
private final OzoneContainer datanodeContainerManager;
|
|
private final OzoneContainer datanodeContainerManager;
|
|
|
|
+ private StateContext stateContext;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Creates a register endpoint task.
|
|
* Creates a register endpoint task.
|
|
@@ -60,10 +62,12 @@ public final class RegisterEndpointTask implements
|
|
*/
|
|
*/
|
|
@VisibleForTesting
|
|
@VisibleForTesting
|
|
public RegisterEndpointTask(EndpointStateMachine rpcEndPoint,
|
|
public RegisterEndpointTask(EndpointStateMachine rpcEndPoint,
|
|
- Configuration conf, OzoneContainer ozoneContainer) {
|
|
|
|
|
|
+ Configuration conf, OzoneContainer ozoneContainer,
|
|
|
|
+ StateContext context) {
|
|
this.rpcEndPoint = rpcEndPoint;
|
|
this.rpcEndPoint = rpcEndPoint;
|
|
this.conf = conf;
|
|
this.conf = conf;
|
|
this.datanodeContainerManager = ozoneContainer;
|
|
this.datanodeContainerManager = ozoneContainer;
|
|
|
|
+ this.stateContext = context;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -124,6 +128,7 @@ public final class RegisterEndpointTask implements
|
|
rpcEndPoint.getState().getNextState();
|
|
rpcEndPoint.getState().getNextState();
|
|
rpcEndPoint.setState(nextState);
|
|
rpcEndPoint.setState(nextState);
|
|
rpcEndPoint.zeroMissedCount();
|
|
rpcEndPoint.zeroMissedCount();
|
|
|
|
+ this.stateContext.configureHeartbeatFrequency();
|
|
} catch (IOException ex) {
|
|
} catch (IOException ex) {
|
|
rpcEndPoint.logIfNeeded(ex);
|
|
rpcEndPoint.logIfNeeded(ex);
|
|
} finally {
|
|
} finally {
|
|
@@ -150,6 +155,7 @@ public final class RegisterEndpointTask implements
|
|
private Configuration conf;
|
|
private Configuration conf;
|
|
private DatanodeDetails datanodeDetails;
|
|
private DatanodeDetails datanodeDetails;
|
|
private OzoneContainer container;
|
|
private OzoneContainer container;
|
|
|
|
+ private StateContext context;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Constructs the builder class.
|
|
* Constructs the builder class.
|
|
@@ -200,6 +206,10 @@ public final class RegisterEndpointTask implements
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public Builder setContext(StateContext stateContext) {
|
|
|
|
+ this.context = stateContext;
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
|
|
public RegisterEndpointTask build() {
|
|
public RegisterEndpointTask build() {
|
|
if (endPointStateMachine == null) {
|
|
if (endPointStateMachine == null) {
|
|
@@ -210,8 +220,9 @@ public final class RegisterEndpointTask implements
|
|
|
|
|
|
if (conf == null) {
|
|
if (conf == null) {
|
|
LOG.error("No config specified.");
|
|
LOG.error("No config specified.");
|
|
- throw new IllegalArgumentException("A valid configration is needed to" +
|
|
|
|
- " construct RegisterEndpoint task");
|
|
|
|
|
|
+ throw new IllegalArgumentException(
|
|
|
|
+ "A valid configuration is needed to construct RegisterEndpoint "
|
|
|
|
+ + "task");
|
|
}
|
|
}
|
|
|
|
|
|
if (datanodeDetails == null) {
|
|
if (datanodeDetails == null) {
|
|
@@ -223,13 +234,20 @@ public final class RegisterEndpointTask implements
|
|
if (container == null) {
|
|
if (container == null) {
|
|
LOG.error("Container is not specified");
|
|
LOG.error("Container is not specified");
|
|
throw new IllegalArgumentException("Container is not specified to " +
|
|
throw new IllegalArgumentException("Container is not specified to " +
|
|
- "constrict RegisterEndpoint task");
|
|
|
|
|
|
+ "construct RegisterEndpoint task");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (context == null) {
|
|
|
|
+ LOG.error("StateContext is not specified");
|
|
|
|
+ throw new IllegalArgumentException("Container is not specified to " +
|
|
|
|
+ "construct RegisterEndpoint task");
|
|
}
|
|
}
|
|
|
|
|
|
RegisterEndpointTask task = new RegisterEndpointTask(this
|
|
RegisterEndpointTask task = new RegisterEndpointTask(this
|
|
- .endPointStateMachine, this.conf, this.container);
|
|
|
|
|
|
+ .endPointStateMachine, this.conf, this.container, this.context);
|
|
task.setDatanodeDetails(datanodeDetails);
|
|
task.setDatanodeDetails(datanodeDetails);
|
|
return task;
|
|
return task;
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|