Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.apache.hadoop.hdds.scm.ha.SCMContext;
import org.apache.hadoop.hdds.scm.node.NodeManager;
import org.apache.hadoop.hdds.server.events.EventPublisher;
import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException;
import org.apache.hadoop.ozone.protocol.commands.CommandForDatanode;
import org.apache.hadoop.ozone.protocol.commands.DeleteContainerCommand;
import org.apache.hadoop.ozone.protocol.commands.SCMCommand;
Expand Down Expand Up @@ -107,7 +106,7 @@ public String toString() {
protected void processContainerReplica(final DatanodeDetails datanodeDetails,
final ContainerInfo containerInfo,
final ContainerReplicaProto replicaProto, final EventPublisher publisher, Object detailsForLogging)
throws IOException, InvalidStateTransitionException {
throws IOException {
getLogger().debug("Processing replica {}", detailsForLogging);
// Synchronized block should be replaced by container lock,
// once we have introduced lock inside ContainerInfo.
Expand Down Expand Up @@ -242,7 +241,7 @@ private boolean updateContainerState(final DatanodeDetails datanode,
final ContainerInfo container,
final ContainerReplicaProto replica,
final EventPublisher publisher,
Object detailsForLogging) throws IOException, InvalidStateTransitionException {
Object detailsForLogging) throws IOException {

final ContainerID containerId = container.containerID();
boolean replicaIsEmpty = replica.hasIsEmpty() && replica.getIsEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.apache.hadoop.hdds.scm.server.StorageContainerManager;
import org.apache.hadoop.hdds.server.events.EventHandler;
import org.apache.hadoop.hdds.server.events.EventPublisher;
import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException;
import org.apache.hadoop.ozone.lease.LeaseAlreadyExistException;
import org.apache.hadoop.ozone.lease.LeaseManager;
import org.apache.hadoop.ozone.protocol.commands.CloseContainerCommand;
Expand Down Expand Up @@ -135,7 +134,7 @@ public void onMessage(ContainerID containerID, EventPublisher publisher) {
} catch (NotLeaderException nle) {
LOG.warn("Skip sending close container command,"
+ " since current SCM is not leader.", nle);
} catch (IOException | InvalidStateTransitionException ex) {
} catch (IOException ex) {
LOG.error("Failed to close the container {}.", containerID, ex);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType;
import org.apache.hadoop.hdds.scm.pipeline.Pipeline;
import org.apache.hadoop.hdds.utils.db.Table;
import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException;

/**
* ContainerManager is responsible for keeping track of all Containers and
Expand Down Expand Up @@ -163,11 +162,10 @@ ContainerInfo allocateContainer(ReplicationConfig replicationConfig,
* @param containerID - Container ID
* @param event - container life cycle event
* @throws IOException
* @throws InvalidStateTransitionException
*/
void updateContainerState(ContainerID containerID,
LifeCycleEvent event)
throws IOException, InvalidStateTransitionException;
throws IOException;

/**
* Bypasses the container state machine to change a container's state from DELETING/DELETED to CLOSED/QUASI_CLOSED.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.apache.hadoop.hdds.scm.pipeline.Pipeline;
import org.apache.hadoop.hdds.scm.pipeline.PipelineManager;
import org.apache.hadoop.hdds.utils.db.Table;
import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException;
import org.apache.hadoop.util.Time;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -275,8 +274,7 @@ private ContainerInfo allocateContainer(final Pipeline pipeline,

@Override
public void updateContainerState(final ContainerID cid,
final LifeCycleEvent event)
throws IOException, InvalidStateTransitionException {
final LifeCycleEvent event) throws IOException {
HddsProtos.ContainerID protoId = cid.getProtobuf();
lock.lock();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.apache.hadoop.hdds.scm.server.SCMDatanodeProtocolServer;
import org.apache.hadoop.hdds.server.events.EventHandler;
import org.apache.hadoop.hdds.server.events.EventPublisher;
import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -234,7 +233,7 @@ private void processSingleReplica(final DatanodeDetails datanodeDetails,
}
try {
processContainerReplica(datanodeDetails, container, replicaProto, publisher, detailsForLogging);
} catch (IOException | InvalidStateTransitionException e) {
} catch (IOException e) {
getLogger().error("Failed to process {}", detailsForLogging, e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.apache.hadoop.hdds.scm.metadata.Replicate;
import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
import org.apache.hadoop.hdds.utils.db.Table;
import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException;

/**
* A ContainerStateManager is responsible for keeping track of all the
Expand Down Expand Up @@ -179,7 +178,7 @@ void addContainer(ContainerInfoProto containerInfo)
void updateContainerStateWithSequenceId(HddsProtos.ContainerID id,
HddsProtos.LifeCycleEvent event,
Long sequenceId)
throws IOException, InvalidStateTransitionException;
throws IOException;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public boolean contains(ContainerID id) {
public void updateContainerStateWithSequenceId(final HddsProtos.ContainerID containerID,
final LifeCycleEvent event,
final Long sequenceId)
throws IOException, InvalidStateTransitionException {
throws IOException {
// TODO: Remove the protobuf conversion after fixing ContainerStateMap.
final ContainerID id = ContainerID.getFromProtobuf(containerID);

Expand All @@ -404,10 +404,11 @@ public void updateContainerStateWithSequenceId(final HddsProtos.ContainerID cont
LOG.warn("Container sequenceId is {} greater than the leader container sequenceId {}",
containerInfo.getSequenceId(), sequenceId);
}

final LifeCycleState oldState = containerInfo.getState();
final LifeCycleState newState = stateMachine.getNextState(
oldState, event);

if (newState.getNumber() > oldState.getNumber()) {
ExecutionUtil.create(() -> {
containers.updateState(id, oldState, newState);
Expand All @@ -423,6 +424,9 @@ public void updateContainerStateWithSequenceId(final HddsProtos.ContainerID cont
.accept(containerInfo);
}
}
} catch (InvalidStateTransitionException e) {
LOG.warn("Failed to updateContainerStateWithSequenceId for container {} at sequenceId {}, ignoring it.",
id, sequenceId, e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.IncrementalContainerReportFromDatanode;
import org.apache.hadoop.hdds.server.events.EventHandler;
import org.apache.hadoop.hdds.server.events.EventPublisher;
import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -122,7 +121,7 @@ protected void processICR(IncrementalContainerReportFromDatanode report,
} else {
getLogger().info("Failed to process {}", detailsForLogging, ex);
}
} catch (IOException | InvalidStateTransitionException e) {
} catch (IOException e) {
getLogger().info("Failed to process {}", detailsForLogging, e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
import org.apache.hadoop.hdds.scm.server.StorageContainerManager;
import org.apache.hadoop.hdds.server.events.EventPublisher;
import org.apache.hadoop.hdds.utils.HddsServerUtil;
import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException;
import org.apache.hadoop.ozone.container.replication.ReplicationServer;
import org.apache.hadoop.ozone.protocol.commands.CloseContainerCommand;
import org.apache.hadoop.ozone.protocol.commands.DeleteContainerCommand;
Expand Down Expand Up @@ -737,7 +736,7 @@ public void updateContainerState(ContainerID containerID,
HddsProtos.LifeCycleEvent event) {
try {
containerManager.updateContainerState(containerID, event);
} catch (IOException | InvalidStateTransitionException e) {
} catch (IOException e) {
LOG.error("Failed to update the state of container {}, update Event {}",
containerID, event, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.apache.hadoop.hdds.scm.ha.SCMRatisServer;
import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
import org.apache.hadoop.hdds.utils.db.Table;
import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException;
import org.apache.ratis.protocol.Message;

/** Code generated for {@link ContainerStateManager}. Do not modify. */
Expand Down Expand Up @@ -181,7 +180,7 @@ public void updateContainerReplica(ContainerReplica arg0) {

@Override
public void updateContainerStateWithSequenceId(HddsProtos.ContainerID arg0, LifeCycleEvent arg1, Long arg2) throws
IOException, InvalidStateTransitionException {
IOException {
final Object[] args = {arg0, arg1, arg2};
invoker.invokeReplicateDirect(ReplicateMethod.updateContainerStateWithSequenceId, args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import org.apache.hadoop.hdds.utils.db.Table;
import org.apache.hadoop.metrics2.util.MBeans;
import org.apache.hadoop.ozone.ClientVersion;
import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException;
import org.apache.hadoop.util.Time;
import org.apache.ratis.protocol.exceptions.NotLeaderException;
import org.slf4j.Logger;
Expand Down Expand Up @@ -478,14 +477,13 @@ private void closeContainersForPipeline(final PipelineID pipelineId)
for (ContainerID containerID : containerIDs) {
if (containerManager.getContainer(containerID).getState()
== HddsProtos.LifeCycleState.OPEN) {
try {
containerManager.updateContainerState(containerID,
HddsProtos.LifeCycleEvent.FINALIZE);
} catch (InvalidStateTransitionException ex) {
throw new IOException(ex);
}
containerManager.updateContainerState(containerID,
HddsProtos.LifeCycleEvent.FINALIZE);
}
if (containerManager.getContainer(containerID).getState() ==
HddsProtos.LifeCycleState.CLOSING) {
eventPublisher.fireEvent(SCMEvents.CLOSE_CONTAINER, containerID);
}
eventPublisher.fireEvent(SCMEvents.CLOSE_CONTAINER, containerID);
LOG.info("Container {} closed for pipeline={}", containerID, pipelineId);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,7 @@ public static void closeContainer(ContainerManager containerManager,
* @throws IOException
*/
public static void quasiCloseContainer(ContainerManager containerManager,
ContainerID id) throws IOException,
InvalidStateTransitionException, TimeoutException {
ContainerID id) throws IOException {
containerManager.updateContainerState(
id, HddsProtos.LifeCycleEvent.FINALIZE);
containerManager.updateContainerState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void testCloseContainerEventECContainer()

private void closeContainerForValidContainer(ReplicationConfig repConfig,
int nodeCount, boolean forceClose)
throws IOException, InvalidStateTransitionException, TimeoutException {
throws IOException {
final Pipeline pipeline = createPipeline(repConfig, nodeCount);
final ContainerInfo container =
createContainer(repConfig, pipeline.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import org.apache.hadoop.hdds.scm.pipeline.PipelineManager;
import org.apache.hadoop.hdds.utils.db.DBStore;
import org.apache.hadoop.hdds.utils.db.DBStoreBuilder;
import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException;
import org.apache.hadoop.ozone.container.common.SCMTestUtils;
import org.apache.ozone.test.GenericTestUtils;
import org.junit.jupiter.api.AfterEach;
Expand Down Expand Up @@ -213,7 +212,7 @@ void testUpdateContainerState() throws Exception {
@EnumSource(value = HddsProtos.LifeCycleState.class,
names = {"DELETING", "DELETED"})
void testTransitionDeletingOrDeletedToTargetState(HddsProtos.LifeCycleState desiredState)
throws IOException, InvalidStateTransitionException {
throws IOException {
// Allocate OPEN Ratis and Ec containers, and do a series of state changes to transition them to DELETING / DELETED
final ContainerInfo container = containerManager.allocateContainer(
RatisReplicationConfig.getInstance(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
import org.apache.hadoop.hdds.server.events.EventPublisher;
import org.apache.hadoop.hdds.utils.db.DBStore;
import org.apache.hadoop.hdds.utils.db.DBStoreBuilder;
import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException;
import org.apache.hadoop.ozone.container.common.SCMTestUtils;
import org.apache.hadoop.ozone.protocol.commands.CommandForDatanode;
import org.junit.jupiter.api.AfterEach;
Expand All @@ -100,7 +99,7 @@ public class TestContainerReportHandler {
private PipelineManager pipelineManager;

@BeforeEach
void setup() throws IOException, InvalidStateTransitionException {
void setup() throws IOException {
final OzoneConfiguration conf = SCMTestUtils.getConf(testDir);
nodeManager = new MockNodeManager(true, 10);
containerManager = mock(ContainerManager.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
import org.apache.hadoop.hdds.server.events.EventPublisher;
import org.apache.hadoop.hdds.utils.db.DBStore;
import org.apache.hadoop.hdds.utils.db.DBStoreBuilder;
import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException;
import org.apache.hadoop.ozone.protocol.commands.CommandForDatanode;
import org.apache.hadoop.ozone.protocol.commands.DeleteContainerCommand;
import org.junit.jupiter.api.AfterEach;
Expand Down Expand Up @@ -94,7 +93,7 @@ public class TestContainerStateManager {
private EventPublisher publisher;

@BeforeEach
public void init() throws IOException, TimeoutException, InvalidStateTransitionException {
public void init() throws IOException, TimeoutException {
OzoneConfiguration conf = new OzoneConfiguration();
SCMHAManager scmhaManager = SCMHAManagerStub.getInstance(true);
conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, testDir.getAbsolutePath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
import org.apache.hadoop.hdds.upgrade.HDDSLayoutVersionManager;
import org.apache.hadoop.hdds.utils.db.DBStore;
import org.apache.hadoop.hdds.utils.db.DBStoreBuilder;
import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -110,7 +109,7 @@ public class TestIncrementalContainerReportHandler {
private DBStore dbStore;

@BeforeEach
public void setup() throws IOException, InvalidStateTransitionException,
public void setup() throws IOException,
TimeoutException {
final OzoneConfiguration conf = new OzoneConfiguration();
Path scmPath = Paths.get(testDir.getPath(), "scm-meta");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import org.apache.hadoop.hdds.scm.container.replication.ContainerCheckRequest;
import org.apache.hadoop.hdds.scm.container.replication.ReplicationManager;
import org.apache.hadoop.hdds.scm.container.replication.ReplicationTestUtil;
import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -63,7 +62,7 @@ public class TestEmptyContainerHandler {

@BeforeEach
public void setup()
throws IOException, InvalidStateTransitionException, TimeoutException {
throws IOException, TimeoutException {
ecReplicationConfig = new ECReplicationConfig(3, 2);
ratisReplicationConfig = RatisReplicationConfig.getInstance(
HddsProtos.ReplicationFactor.THREE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import org.apache.hadoop.hdds.scm.server.StorageContainerManager;
import org.apache.hadoop.ozone.MiniOzoneCluster;
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException;
import org.apache.hadoop.ozone.container.common.SCMTestUtils;
import org.apache.hadoop.security.authentication.client.AuthenticationException;
import org.apache.ozone.test.tag.Flaky;
Expand Down Expand Up @@ -145,8 +144,7 @@ public void testAllocateContainerWithDifferentOwner() throws IOException {

@Test
public void testContainerStateManagerRestart() throws IOException,
TimeoutException, InterruptedException, AuthenticationException,
InvalidStateTransitionException {
TimeoutException, InterruptedException, AuthenticationException {
// Allocate 5 containers in ALLOCATED state and 5 in CREATING state

for (int i = 0; i < 10; i++) {
Expand Down Expand Up @@ -271,8 +269,7 @@ void assertContainerCount(LifeCycleState state, int expected) {
}

@Test
public void testUpdateContainerState() throws IOException,
InvalidStateTransitionException {
public void testUpdateContainerState() throws IOException {
assertContainerCount(LifeCycleState.OPEN, 0);

// Allocate container1 and update its state from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.io.IOException;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeoutException;
import org.apache.hadoop.hdds.client.RatisReplicationConfig;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
Expand All @@ -33,7 +32,6 @@
import org.apache.hadoop.hdds.scm.container.ContainerManager;
import org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline;
import org.apache.hadoop.hdds.scm.server.StorageContainerManager;
import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException;
import org.apache.ozone.test.NonHATests;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -62,8 +60,7 @@ public void init() throws Exception {
}

@Test
public void testPipelineMap() throws IOException,
InvalidStateTransitionException, TimeoutException {
public void testPipelineMap() throws IOException {

Set<ContainerID> set = pipelineManager
.getContainersInPipeline(ratisContainer.getPipeline().getId());
Expand Down
Loading