Skip to content

Commit 7e1f8d3

Browse files
committed
HDDS-1368. Cleanup old ReplicationManager code from SCM.
1 parent 8a95ea6 commit 7e1f8d3

File tree

20 files changed

+150
-1426
lines changed

20 files changed

+150
-1426
lines changed

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

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
import com.google.common.base.Preconditions;
2020
import com.google.protobuf.GeneratedMessage;
2121
import java.util.Map;
22-
import java.util.Optional;
2322
import java.util.concurrent.ConcurrentHashMap;
2423
import org.apache.hadoop.conf.Configuration;
24+
import org.apache.hadoop.hdds.protocol.proto
25+
.StorageContainerDatanodeProtocolProtos.SCMCommandProto;
2526
import org.apache.hadoop.hdds.protocol.proto
2627
.StorageContainerDatanodeProtocolProtos.PipelineAction;
2728
import org.apache.hadoop.hdds.protocol.proto
@@ -34,8 +35,6 @@
3435
import org.apache.hadoop.ozone.container.common.states.datanode
3536
.RunningDatanodeState;
3637
import org.apache.hadoop.ozone.protocol.commands.CommandStatus;
37-
import org.apache.hadoop.ozone.protocol.commands.CommandStatus
38-
.CommandStatusBuilder;
3938
import org.apache.hadoop.ozone.protocol.commands
4039
.DeleteBlockCommandStatus.DeleteBlockCommandStatusBuilder;
4140
import org.apache.hadoop.ozone.protocol.commands.SCMCommand;
@@ -432,27 +431,14 @@ public void addCmdStatus(Long key, CommandStatus status) {
432431
* @param cmd - {@link SCMCommand}.
433432
*/
434433
public void addCmdStatus(SCMCommand cmd) {
435-
final Optional<CommandStatusBuilder> cmdStatusBuilder;
436-
switch (cmd.getType()) {
437-
case replicateContainerCommand:
438-
cmdStatusBuilder = Optional.of(CommandStatusBuilder.newBuilder());
439-
break;
440-
case deleteBlocksCommand:
441-
cmdStatusBuilder = Optional.of(
442-
DeleteBlockCommandStatusBuilder.newBuilder());
443-
break;
444-
case deleteContainerCommand:
445-
cmdStatusBuilder = Optional.of(CommandStatusBuilder.newBuilder());
446-
break;
447-
default:
448-
cmdStatusBuilder = Optional.empty();
434+
if (cmd.getType() == SCMCommandProto.Type.deleteBlocksCommand) {
435+
addCmdStatus(cmd.getId(),
436+
DeleteBlockCommandStatusBuilder.newBuilder()
437+
.setCmdId(cmd.getId())
438+
.setStatus(Status.PENDING)
439+
.setType(cmd.getType())
440+
.build());
449441
}
450-
cmdStatusBuilder.ifPresent(statusBuilder ->
451-
addCmdStatus(cmd.getId(), statusBuilder
452-
.setCmdId(cmd.getId())
453-
.setStatus(Status.PENDING)
454-
.setType(cmd.getType())
455-
.build()));
456442
}
457443

458444
/**

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,7 @@ public void handle(final SCMCommand command,
5656
final ContainerController controller = ozoneContainer.getController();
5757
controller.deleteContainer(deleteContainerCommand.getContainerID(),
5858
deleteContainerCommand.isForce());
59-
updateCommandStatus(context, command,
60-
(cmdStatus) -> cmdStatus.setStatus(true), LOG);
6159
} catch (IOException e) {
62-
updateCommandStatus(context, command,
63-
(cmdStatus) -> cmdStatus.setStatus(false), LOG);
6460
LOG.error("Exception occurred while deleting the container.", e);
6561
} finally {
6662
totalTime += Time.monotonicNow() - startTime;

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

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,17 @@ public ReplicateContainerCommandHandler(
6161
public void handle(SCMCommand command, OzoneContainer container,
6262
StateContext context, SCMConnectionManager connectionManager) {
6363

64-
ReplicateContainerCommand replicateCommand =
64+
final ReplicateContainerCommand replicateCommand =
6565
(ReplicateContainerCommand) command;
66-
try {
67-
List<DatanodeDetails> sourceDatanodes =
68-
replicateCommand.getSourceDatanodes();
69-
long containerID = replicateCommand.getContainerID();
70-
71-
Preconditions.checkArgument(sourceDatanodes.size() > 0,
72-
String.format("Replication command is received for container %d "
73-
+ "but the size of source datanodes was 0.", containerID));
74-
75-
ReplicationTask replicationTask =
76-
new ReplicationTask(containerID, sourceDatanodes);
77-
supervisor.addTask(replicationTask);
78-
79-
} finally {
80-
updateCommandStatus(context, command,
81-
(cmdStatus) -> cmdStatus.setStatus(true), LOG);
82-
}
66+
final List<DatanodeDetails> sourceDatanodes =
67+
replicateCommand.getSourceDatanodes();
68+
final long containerID = replicateCommand.getContainerID();
69+
70+
Preconditions.checkArgument(sourceDatanodes.size() > 0,
71+
String.format("Replication command is received for container %d "
72+
+ "but the size of source datanodes was 0.", containerID));
73+
74+
supervisor.addTask(new ReplicationTask(containerID, sourceDatanodes));
8375
}
8476

8577
@Override

hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/command/CommandStatusReportHandler.java

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
package org.apache.hadoop.hdds.scm.command;
1919

2020
import com.google.common.base.Preconditions;
21+
import org.apache.hadoop.hdds.protocol.proto
22+
.StorageContainerDatanodeProtocolProtos.SCMCommandProto;
2123
import org.apache.hadoop.hdds.protocol.proto
2224
.StorageContainerDatanodeProtocolProtos.CommandStatus;
23-
import org.apache.hadoop.hdds.scm.container.replication.ReplicationManager;
2425
import org.apache.hadoop.hdds.scm.events.SCMEvents;
2526
import org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher
2627
.CommandStatusReportFromDatanode;
@@ -54,32 +55,14 @@ public void onMessage(CommandStatusReportFromDatanode report,
5455
cmdStatusList.forEach(cmdStatus -> {
5556
LOGGER.trace("Emitting command status for id:{} type: {}", cmdStatus
5657
.getCmdId(), cmdStatus.getType());
57-
switch (cmdStatus.getType()) {
58-
case replicateContainerCommand:
59-
publisher.fireEvent(SCMEvents.REPLICATION_STATUS, new
60-
ReplicationStatus(cmdStatus));
61-
if (cmdStatus.getStatus() == CommandStatus.Status.EXECUTED) {
62-
publisher.fireEvent(SCMEvents.REPLICATION_COMPLETE,
63-
new ReplicationManager.ReplicationCompleted(
64-
cmdStatus.getCmdId()));
65-
}
66-
break;
67-
case deleteBlocksCommand:
58+
if (cmdStatus.getType() == SCMCommandProto.Type.deleteBlocksCommand) {
6859
if (cmdStatus.getStatus() == CommandStatus.Status.EXECUTED) {
6960
publisher.fireEvent(SCMEvents.DELETE_BLOCK_STATUS,
7061
new DeleteBlockStatus(cmdStatus));
7162
}
72-
break;
73-
case deleteContainerCommand:
74-
if (cmdStatus.getStatus() == CommandStatus.Status.EXECUTED) {
75-
publisher.fireEvent(SCMEvents.DELETE_CONTAINER_COMMAND_COMPLETE,
76-
new ReplicationManager.DeleteContainerCommandCompleted(
77-
cmdStatus.getCmdId()));
78-
}
79-
default:
63+
} else {
8064
LOGGER.debug("CommandStatus of type:{} not handled in " +
8165
"CommandStatusReportHandler.", cmdStatus.getType());
82-
break;
8366
}
8467
});
8568
}
@@ -109,24 +92,6 @@ public long getId() {
10992
}
11093
}
11194

112-
/**
113-
* Wrapper event for Replicate Command.
114-
*/
115-
public static class ReplicationStatus extends CommandStatusEvent {
116-
public ReplicationStatus(CommandStatus cmdStatus) {
117-
super(cmdStatus);
118-
}
119-
}
120-
121-
/**
122-
* Wrapper event for CloseContainer Command.
123-
*/
124-
public static class CloseContainerStatus extends CommandStatusEvent {
125-
public CloseContainerStatus(CommandStatus cmdStatus) {
126-
super(cmdStatus);
127-
}
128-
}
129-
13095
/**
13196
* Wrapper event for DeleteBlock Command.
13297
*/

hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/DeleteContainerCommandWatcher.java

Lines changed: 0 additions & 56 deletions
This file was deleted.

hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ReplicationCommandWatcher.java

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)