|
@@ -18,17 +18,11 @@
|
|
|
|
|
|
package org.apache.hadoop.ozone.freon;
|
|
package org.apache.hadoop.ozone.freon;
|
|
|
|
|
|
|
|
+import org.apache.hadoop.hdds.HddsConfigKeys;
|
|
import org.apache.hadoop.hdds.client.ReplicationFactor;
|
|
import org.apache.hadoop.hdds.client.ReplicationFactor;
|
|
import org.apache.hadoop.hdds.client.ReplicationType;
|
|
import org.apache.hadoop.hdds.client.ReplicationType;
|
|
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
|
|
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
|
|
-import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
|
|
|
|
import org.apache.hadoop.ozone.MiniOzoneCluster;
|
|
import org.apache.hadoop.ozone.MiniOzoneCluster;
|
|
-import org.apache.hadoop.ozone.container.common.transport.server.XceiverServerSpi;
|
|
|
|
-import org.apache.hadoop.ozone.container.common.transport.server.ratis.ContainerStateMachine;
|
|
|
|
-import org.apache.hadoop.ozone.container.common.transport.server.ratis.XceiverServerRatis;
|
|
|
|
-import org.apache.ratis.server.protocol.TermIndex;
|
|
|
|
-import org.apache.ratis.statemachine.impl.SimpleStateMachineStorage;
|
|
|
|
-import org.apache.ratis.statemachine.impl.SingleFileSnapshotInfo;
|
|
|
|
import org.junit.AfterClass;
|
|
import org.junit.AfterClass;
|
|
import org.junit.Assert;
|
|
import org.junit.Assert;
|
|
import org.junit.BeforeClass;
|
|
import org.junit.BeforeClass;
|
|
@@ -36,7 +30,10 @@ import org.junit.Test;
|
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
-import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_STALENODE_INTERVAL;
|
|
|
|
|
|
+import static org.apache.hadoop.hdds.scm.ScmConfigKeys
|
|
|
|
+ .OZONE_SCM_CONTAINER_CREATION_LEASE_TIMEOUT;
|
|
|
|
+import static org.apache.hadoop.hdds.scm.ScmConfigKeys
|
|
|
|
+ .OZONE_SCM_STALENODE_INTERVAL;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Tests Freon with Datanode restarts.
|
|
* Tests Freon with Datanode restarts.
|
|
@@ -56,6 +53,12 @@ public class TestFreonWithDatanodeRestart {
|
|
public static void init() throws Exception {
|
|
public static void init() throws Exception {
|
|
conf = new OzoneConfiguration();
|
|
conf = new OzoneConfiguration();
|
|
conf.setTimeDuration(OZONE_SCM_STALENODE_INTERVAL, 5, TimeUnit.SECONDS);
|
|
conf.setTimeDuration(OZONE_SCM_STALENODE_INTERVAL, 5, TimeUnit.SECONDS);
|
|
|
|
+ conf.setTimeDuration(HddsConfigKeys.HDDS_CONTAINER_REPORT_INTERVAL, 1,
|
|
|
|
+ TimeUnit.SECONDS);
|
|
|
|
+ conf.setTimeDuration(HddsConfigKeys.HDDS_PIPELINE_REPORT_INTERVAL, 1,
|
|
|
|
+ TimeUnit.SECONDS);
|
|
|
|
+ conf.setTimeDuration(OZONE_SCM_CONTAINER_CREATION_LEASE_TIMEOUT, 5,
|
|
|
|
+ TimeUnit.SECONDS);
|
|
cluster = MiniOzoneCluster.newBuilder(conf)
|
|
cluster = MiniOzoneCluster.newBuilder(conf)
|
|
.setHbProcessorInterval(1000)
|
|
.setHbProcessorInterval(1000)
|
|
.setHbInterval(1000)
|
|
.setHbInterval(1000)
|
|
@@ -76,6 +79,12 @@ public class TestFreonWithDatanodeRestart {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testRestart() throws Exception {
|
|
public void testRestart() throws Exception {
|
|
|
|
+ startFreon();
|
|
|
|
+ cluster.restartHddsDatanode(0, true);
|
|
|
|
+ startFreon();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void startFreon() throws Exception {
|
|
RandomKeyGenerator randomKeyGenerator =
|
|
RandomKeyGenerator randomKeyGenerator =
|
|
new RandomKeyGenerator((OzoneConfiguration) cluster.getConf());
|
|
new RandomKeyGenerator((OzoneConfiguration) cluster.getConf());
|
|
randomKeyGenerator.setNumOfVolumes(1);
|
|
randomKeyGenerator.setNumOfVolumes(1);
|
|
@@ -90,33 +99,5 @@ public class TestFreonWithDatanodeRestart {
|
|
Assert.assertEquals(1, randomKeyGenerator.getNumberOfBucketsCreated());
|
|
Assert.assertEquals(1, randomKeyGenerator.getNumberOfBucketsCreated());
|
|
Assert.assertEquals(1, randomKeyGenerator.getNumberOfKeysAdded());
|
|
Assert.assertEquals(1, randomKeyGenerator.getNumberOfKeysAdded());
|
|
Assert.assertEquals(0, randomKeyGenerator.getUnsuccessfulValidationCount());
|
|
Assert.assertEquals(0, randomKeyGenerator.getUnsuccessfulValidationCount());
|
|
-
|
|
|
|
- ContainerStateMachine sm = getStateMachine();
|
|
|
|
- TermIndex termIndexBeforeRestart = sm.getLastAppliedTermIndex();
|
|
|
|
- cluster.restartHddsDatanode(0);
|
|
|
|
- sm = getStateMachine();
|
|
|
|
- SimpleStateMachineStorage storage =
|
|
|
|
- (SimpleStateMachineStorage)sm.getStateMachineStorage();
|
|
|
|
- SingleFileSnapshotInfo snapshotInfo = storage.getLatestSnapshot();
|
|
|
|
- TermIndex termInSnapshot = snapshotInfo.getTermIndex();
|
|
|
|
- String expectedSnapFile =
|
|
|
|
- storage.getSnapshotFile(termIndexBeforeRestart.getTerm(),
|
|
|
|
- termIndexBeforeRestart.getIndex()).getAbsolutePath();
|
|
|
|
- Assert.assertEquals(snapshotInfo.getFile().getPath().toString(),
|
|
|
|
- expectedSnapFile);
|
|
|
|
- Assert.assertEquals(termInSnapshot, termIndexBeforeRestart);
|
|
|
|
-
|
|
|
|
- // After restart the term index might have progressed to apply pending
|
|
|
|
- // transactions.
|
|
|
|
- TermIndex termIndexAfterRestart = sm.getLastAppliedTermIndex();
|
|
|
|
- Assert.assertTrue(termIndexAfterRestart.getIndex() >=
|
|
|
|
- termIndexBeforeRestart.getIndex());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private ContainerStateMachine getStateMachine() {
|
|
|
|
- XceiverServerSpi server =
|
|
|
|
- cluster.getHddsDatanodes().get(0).getDatanodeStateMachine().
|
|
|
|
- getContainer().getServer(HddsProtos.ReplicationType.RATIS);
|
|
|
|
- return ((XceiverServerRatis)server).getStateMachine();
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|