Skip to content

Commit e543c3b

Browse files
author
Hanisha Koneru
authored
HDDS-1376. Datanode exits while executing client command when scmId is null (#724)
1 parent 3ac3e50 commit e543c3b

File tree

8 files changed

+30
-18
lines changed

8 files changed

+30
-18
lines changed

hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/DatanodeStateMachine.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ public OzoneContainer getContainer() {
166166
private void start() throws IOException {
167167
long now = 0;
168168

169-
container.start();
170169
reportManager.init();
171170
initCommandHandlerThread(conf);
172171

hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/VersionEndpointTask.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ public EndpointStateMachine.EndPointStates call() throws Exception {
106106
volumeSet.writeUnlock();
107107
}
108108

109-
ozoneContainer.getDispatcher().setScmId(scmId);
109+
// Start the container services after getting the version information
110+
ozoneContainer.start(scmId);
110111

111112
EndpointStateMachine.EndPointStates nextState =
112113
rpcEndPoint.getState().getNextState();

hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/OzoneContainer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,13 @@ private void stopContainerScrub() {
180180
*
181181
* @throws IOException
182182
*/
183-
public void start() throws IOException {
183+
public void start(String scmId) throws IOException {
184184
LOG.info("Attempting to start container services.");
185185
startContainerScrub();
186186
writeChannel.start();
187187
readChannel.start();
188188
hddsDispatcher.init();
189+
hddsDispatcher.setScmId(scmId);
189190
}
190191

191192
/**

hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestDatanodeStateMachine.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,21 @@ public void testDatanodeStateContext() throws IOException,
258258

259259
task.execute(executorService);
260260
newState = task.await(10, TimeUnit.SECONDS);
261+
262+
// Wait for GetVersion call (called by task.execute) to finish. After
263+
// Earlier task.execute called into GetVersion. Wait for the execution
264+
// to finish and the endPointState to move to REGISTER state.
265+
GenericTestUtils.waitFor(() -> {
266+
for (EndpointStateMachine endpoint :
267+
stateMachine.getConnectionManager().getValues()) {
268+
if (endpoint.getState() !=
269+
EndpointStateMachine.EndPointStates.REGISTER) {
270+
return false;
271+
}
272+
}
273+
return true;
274+
}, 1000, 50000);
275+
261276
// If we are in running state, we should be in running.
262277
Assert.assertEquals(DatanodeStateMachine.DatanodeStates.RUNNING,
263278
newState);

hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCloseContainerCommandHandler.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void testCloseContainerViaRatis()
6868
final DatanodeDetails datanodeDetails = randomDatanodeDetails();
6969
final OzoneContainer ozoneContainer =
7070
getOzoneContainer(conf, datanodeDetails);
71-
ozoneContainer.start();
71+
ozoneContainer.start(UUID.randomUUID().toString());
7272
try {
7373
final Container container =
7474
createContainer(conf, datanodeDetails, ozoneContainer);
@@ -105,7 +105,7 @@ public void testCloseContainerViaStandalone()
105105
final DatanodeDetails datanodeDetails = randomDatanodeDetails();
106106
final OzoneContainer ozoneContainer =
107107
getOzoneContainer(conf, datanodeDetails);
108-
ozoneContainer.start();
108+
ozoneContainer.start(UUID.randomUUID().toString());
109109
try {
110110
final Container container =
111111
createContainer(conf, datanodeDetails, ozoneContainer);
@@ -140,7 +140,7 @@ public void testQuasiCloseToClose() throws Exception {
140140
final DatanodeDetails datanodeDetails = randomDatanodeDetails();
141141
final OzoneContainer ozoneContainer =
142142
getOzoneContainer(conf, datanodeDetails);
143-
ozoneContainer.start();
143+
ozoneContainer.start(UUID.randomUUID().toString());
144144
try {
145145
final Container container =
146146
createContainer(conf, datanodeDetails, ozoneContainer);
@@ -188,7 +188,7 @@ public void testForceCloseOpenContainer() throws Exception {
188188
final DatanodeDetails datanodeDetails = randomDatanodeDetails();
189189
final OzoneContainer ozoneContainer =
190190
getOzoneContainer(conf, datanodeDetails);
191-
ozoneContainer.start();
191+
ozoneContainer.start(UUID.randomUUID().toString());
192192
try {
193193
final Container container =
194194
createContainer(conf, datanodeDetails, ozoneContainer);
@@ -224,7 +224,7 @@ public void testQuasiCloseClosedContainer()
224224
final DatanodeDetails datanodeDetails = randomDatanodeDetails();
225225
final OzoneContainer ozoneContainer = getOzoneContainer(
226226
conf, datanodeDetails);
227-
ozoneContainer.start();
227+
ozoneContainer.start(UUID.randomUUID().toString());
228228
try {
229229
final Container container = createContainer(
230230
conf, datanodeDetails, ozoneContainer);
@@ -277,7 +277,6 @@ private OzoneContainer getOzoneContainer(final OzoneConfiguration conf,
277277
Mockito.when(context.getParent()).thenReturn(datanodeStateMachine);
278278
final OzoneContainer ozoneContainer = new OzoneContainer(
279279
datanodeDetails, conf, context, null);
280-
ozoneContainer.getDispatcher().setScmId(UUID.randomUUID().toString());
281280
return ozoneContainer;
282281
}
283282

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,8 @@ public void testCreateOzoneContainer() throws Exception {
8282
Mockito.when(dsm.getDatanodeDetails()).thenReturn(datanodeDetails);
8383
Mockito.when(context.getParent()).thenReturn(dsm);
8484
container = new OzoneContainer(datanodeDetails, conf, context, null);
85-
//Setting scmId, as we start manually ozone container.
86-
container.getDispatcher().setScmId(UUID.randomUUID().toString());
87-
container.start();
85+
//Set scmId and manually start ozone container.
86+
container.start(UUID.randomUUID().toString());
8887

8988
XceiverClientGrpc client = new XceiverClientGrpc(pipeline, conf);
9089
client.connect();

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainerWithTLS.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,8 @@ public void testCreateOzoneContainer() throws Exception {
155155
OzoneConfigKeys.DFS_CONTAINER_IPC_RANDOM_PORT, false);
156156

157157
container = new OzoneContainer(dn, conf, getContext(dn), null);
158-
//Setting scmId, as we start manually ozone container.
159-
container.getDispatcher().setScmId(UUID.randomUUID().toString());
160-
container.start();
158+
//Set scmId and manually start ozone container.
159+
container.start(UUID.randomUUID().toString());
161160

162161
XceiverClientGrpc client = new XceiverClientGrpc(pipeline, conf);
163162
client.connect();

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestSecureOzoneContainer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,8 @@ public void testCreateOzoneContainer() throws Exception {
143143

144144
DatanodeDetails dn = TestUtils.randomDatanodeDetails();
145145
container = new OzoneContainer(dn, conf, getContext(dn), caClient);
146-
//Setting scmId, as we start manually ozone container.
147-
container.getDispatcher().setScmId(UUID.randomUUID().toString());
148-
container.start();
146+
//Set scmId and manually start ozone container.
147+
container.start(UUID.randomUUID().toString());
149148

150149
UserGroupInformation ugi = UserGroupInformation.createUserForTesting(
151150
"user1", new String[] {"usergroup"});

0 commit comments

Comments
 (0)