getCodec() {
return CODEC;
diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/container/common/helpers/ChunkInfoList.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/container/common/helpers/ChunkInfoList.java
index fdf40af9e097..ab5d39e9c3d1 100644
--- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/container/common/helpers/ChunkInfoList.java
+++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/container/common/helpers/ChunkInfoList.java
@@ -27,7 +27,7 @@
/**
* Helper class to convert between protobuf lists and Java lists of
- * {@link ContainerProtos.ChunkInfo} objects.
+ * {@link org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ChunkInfo} objects.
*
* This class is immutable.
*/
@@ -36,6 +36,7 @@ public class ChunkInfoList {
Proto3Codec.get(ContainerProtos.ChunkInfoList.getDefaultInstance()),
ChunkInfoList::getFromProtoBuf,
ChunkInfoList::getProtoBufMessage,
+ ChunkInfoList.class,
DelegatedCodec.CopyType.SHALLOW);
public static Codec getCodec() {
@@ -49,7 +50,7 @@ public ChunkInfoList(List chunks) {
}
/**
- * @return A new {@link ChunkInfoList} created from protobuf data.
+ * @return A new {@link #ChunkInfoList} created from protobuf data.
*/
public static ChunkInfoList getFromProtoBuf(
ContainerProtos.ChunkInfoList chunksProto) {
diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/upgrade/LayoutVersionInstanceFactory.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/upgrade/LayoutVersionInstanceFactory.java
index 83e63a2a322d..b94dd024b2d3 100644
--- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/upgrade/LayoutVersionInstanceFactory.java
+++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/upgrade/LayoutVersionInstanceFactory.java
@@ -37,18 +37,16 @@
/**
* Generic factory which stores different instances of Type 'T' sharded by
- * a key & version. A single key can be associated with different versions
+ * a key and version. A single key can be associated with different versions
* of 'T'.
- *
* Why does this class exist?
* A typical use case during upgrade is to have multiple versions of a class
* / method / object and chose them based on current layout
* version at runtime. Before finalizing, an older version is typically
* needed, and after finalize, a newer version is needed. This class serves
* this purpose in a generic way.
- *
* For example, we can create a Factory to create multiple versions of
- * OMRequests sharded by Request Type & Layout Version Supported.
+ * OMRequests sharded by Request Type and Layout Version Supported.
*/
public class LayoutVersionInstanceFactory {
@@ -71,7 +69,7 @@ public class LayoutVersionInstanceFactory {
/**
* Register an instance with a given factory key (key + version).
* For safety reasons we dont allow (1) re-registering, (2) registering an
- * instance with version > SLV.
+ * instance with version > SLV.
*
* @param lvm LayoutVersionManager
* @param key VersionFactoryKey key to associate with instance.
@@ -138,13 +136,15 @@ private boolean isValid(LayoutVersionManager lvm, int version) {
}
/**
+ *
* From the list of versioned instances for a given "key", this
* returns the "floor" value corresponding to the given version.
- * For example, if we have key = "CreateKey", entry -> [(1, CreateKeyV1),
- * (3, CreateKeyV2), and if the passed in key = CreateKey & version = 2, we
+ * For example, if we have key = "CreateKey", entry -> [(1, CreateKeyV1),
+ * (3, CreateKeyV2), and if the passed in key = CreateKey & version = 2, we
* return CreateKeyV1.
* Since this is a priority queue based implementation, we use a O(1) peek()
* lookup to get the current valid version.
+ *
* @param lvm LayoutVersionManager
* @param key Key and Version.
* @return instance.
diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/upgrade/LayoutVersionManager.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/upgrade/LayoutVersionManager.java
index 3137d756e6b5..a765c2c94553 100644
--- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/upgrade/LayoutVersionManager.java
+++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/upgrade/LayoutVersionManager.java
@@ -74,7 +74,6 @@ public interface LayoutVersionManager {
/**
* Generic API for returning a registered handler for a given type.
* @param type String type
- * @return
*/
default Object getHandler(String type) {
return null;
diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/upgrade/UpgradeFinalizer.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/upgrade/UpgradeFinalizer.java
index 44ae94870e35..19c0498aa7a6 100644
--- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/upgrade/UpgradeFinalizer.java
+++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/upgrade/UpgradeFinalizer.java
@@ -50,14 +50,14 @@ public interface UpgradeFinalizer {
* Represents the current state in which the service is with regards to
* finalization after an upgrade.
* The state transitions are the following:
- * ALREADY_FINALIZED - no entry no exit from this status without restart.
+ * {@code ALREADY_FINALIZED} - no entry no exit from this status without restart.
* After an upgrade:
- * FINALIZATION_REQUIRED -(finalize)-> STARTING_FINALIZATION
- * -> FINALIZATION_IN_PROGRESS -> FINALIZATION_DONE from finalization done
+ * {@code FINALIZATION_REQUIRED -(finalize)-> STARTING_FINALIZATION
+ * -> FINALIZATION_IN_PROGRESS -> FINALIZATION_DONE} from finalization done
* there is no more move possible, after a restart the service can end up in:
- * - FINALIZATION_REQUIRED, if the finalization failed and have not reached
- * FINALIZATION_DONE,
- * - or it can be ALREADY_FINALIZED if the finalization was successfully done.
+ * {@code FINALIZATION_REQUIRED}, if the finalization failed and have not reached
+ * {@code FINALIZATION_DONE},
+ * - or it can be {@code ALREADY_FINALIZED} if the finalization was successfully done.
*/
enum Status {
ALREADY_FINALIZED,
diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/upgrade/VersionFactoryKey.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/upgrade/VersionFactoryKey.java
index bda45f5a745c..6465cc855012 100644
--- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/upgrade/VersionFactoryKey.java
+++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/upgrade/VersionFactoryKey.java
@@ -20,7 +20,7 @@
/**
* "Key" element to the Version specific instance factory. Currently it has 2
- * dimensions -> a 'key' string and a version. This is to support a factory
+ * dimensions -> a 'key' string and a version. This is to support a factory
* which returns an instance for a given "key" and "version".
*/
public class VersionFactoryKey {
diff --git a/hadoop-hdds/common/src/main/resources/hdds-version-info.properties b/hadoop-hdds/common/src/main/resources/hdds-version-info.properties
index bf887021c5ba..3ba2c2cbfa2f 100644
--- a/hadoop-hdds/common/src/main/resources/hdds-version-info.properties
+++ b/hadoop-hdds/common/src/main/resources/hdds-version-info.properties
@@ -18,9 +18,6 @@
version=${declared.hdds.version}
revision=${version-info.scm.commit}
-branch=${version-info.scm.branch}
-user=${user.name}
-date=${version-info.build.time}
url=${version-info.scm.uri}
srcChecksum=${version-info.source.md5}
hadoopProtoc2Version=${proto2.hadooprpc.protobuf.version}
diff --git a/hadoop-hdds/common/src/main/resources/ozone-default.xml b/hadoop-hdds/common/src/main/resources/ozone-default.xml
index 9877427ea072..060b7cd7b49a 100644
--- a/hadoop-hdds/common/src/main/resources/ozone-default.xml
+++ b/hadoop-hdds/common/src/main/resources/ozone-default.xml
@@ -160,6 +160,13 @@
this not set. Ideally, this should be mapped to a fast disk like an SSD.
+
+ ozone.scm.container.list.max.count
+ 4096
+ OZONE, SCM, CONTAINER
+ The max number of containers info could be included in
+ response of ListContainer request.
+
hdds.datanode.dir
@@ -1570,7 +1577,7 @@
hdds.datanode.metadata.rocksdb.cache.size
- 64MB
+ 1GB
OZONE, DATANODE, MANAGEMENT
Size of the block metadata cache shared among RocksDB instances on each
@@ -3469,9 +3476,9 @@
ozone.s3g.client.buffer.size
OZONE, S3GATEWAY
- 4KB
+ 4MB
- The size of the buffer which is for read block. (4KB by default).
+ The size of the buffer which is for read block. (4MB by default).
@@ -3743,6 +3750,15 @@
+
+ ozone.snapshot.deep.cleaning.enabled
+ false
+ OZONE, PERFORMANCE, OM
+
+ Flag to enable/disable snapshot deep cleaning.
+
+
+
ozone.scm.event.ContainerReport.thread.pool.size
10
diff --git a/hadoop-hdds/config/pom.xml b/hadoop-hdds/config/pom.xml
index 1c71bf3d90a4..60c63475ae34 100644
--- a/hadoop-hdds/config/pom.xml
+++ b/hadoop-hdds/config/pom.xml
@@ -20,10 +20,10 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
org.apache.ozone
hdds
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
hdds-config
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Apache Ozone Distributed Data Store Config Tools
Apache Ozone HDDS Config
jar
diff --git a/hadoop-hdds/config/src/main/java/org/apache/hadoop/hdds/conf/ConfigurationSource.java b/hadoop-hdds/config/src/main/java/org/apache/hadoop/hdds/conf/ConfigurationSource.java
index b1a20c9aecbc..0d6c0c908786 100644
--- a/hadoop-hdds/config/src/main/java/org/apache/hadoop/hdds/conf/ConfigurationSource.java
+++ b/hadoop-hdds/config/src/main/java/org/apache/hadoop/hdds/conf/ConfigurationSource.java
@@ -108,7 +108,7 @@ default String[] getTrimmedStrings(String name) {
/**
* Gets the configuration entries where the key contains the prefix. This
* method will strip the prefix from the key in the return Map.
- * Example: somePrefix.key->value will be key->value in the returned map.
+ * Example: {@code somePrefix.key->value} will be {@code key->value} in the returned map.
* @param keyPrefix Prefix to search.
* @return Map containing keys that match and their values.
*/
diff --git a/hadoop-hdds/container-service/pom.xml b/hadoop-hdds/container-service/pom.xml
index d73bea95895e..c21ca8203b56 100644
--- a/hadoop-hdds/container-service/pom.xml
+++ b/hadoop-hdds/container-service/pom.xml
@@ -20,10 +20,10 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
org.apache.ozone
hdds
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
hdds-container-service
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Apache Ozone Distributed Data Store Container Service
Apache Ozone HDDS Container Service
jar
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeService.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeService.java
index 495204aef1bf..2f4f72eb5fb4 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeService.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeService.java
@@ -229,7 +229,6 @@ public void start() {
datanodeDetails.setSetupTime(Time.now());
datanodeDetails.setRevision(
HddsVersionInfo.HDDS_VERSION_INFO.getRevision());
- datanodeDetails.setBuildDate(HddsVersionInfo.HDDS_VERSION_INFO.getDate());
TracingUtil.initTracing(
"HddsDatanodeService." + datanodeDetails.getUuidString()
.substring(0, 8), conf);
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsPolicyProvider.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsPolicyProvider.java
index eeed4fab5f72..52217ce7f83f 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsPolicyProvider.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsPolicyProvider.java
@@ -24,7 +24,7 @@
import org.apache.hadoop.security.authorize.Service;
import org.apache.ratis.util.MemoizedSupplier;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.function.Supplier;
@@ -50,7 +50,7 @@ public static HddsPolicyProvider getInstance() {
}
private static final List DN_SERVICES =
- Arrays.asList(
+ Collections.singletonList(
new Service(
OZONE_SECURITY_RECONFIGURE_PROTOCOL_ACL,
ReconfigureProtocol.class)
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/helpers/CommandHandlerMetrics.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/helpers/CommandHandlerMetrics.java
index a6e4d6258d97..e52565952a51 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/helpers/CommandHandlerMetrics.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/helpers/CommandHandlerMetrics.java
@@ -34,6 +34,7 @@
import static org.apache.hadoop.ozone.container.common.helpers.CommandHandlerMetrics.CommandMetricsMetricsInfo.TotalRunTimeMs;
import static org.apache.hadoop.ozone.container.common.helpers.CommandHandlerMetrics.CommandMetricsMetricsInfo.QueueWaitingTaskCount;
import static org.apache.hadoop.ozone.container.common.helpers.CommandHandlerMetrics.CommandMetricsMetricsInfo.InvocationCount;
+import static org.apache.hadoop.ozone.container.common.helpers.CommandHandlerMetrics.CommandMetricsMetricsInfo.AvgRunTimeMs;
import static org.apache.hadoop.ozone.container.common.helpers.CommandHandlerMetrics.CommandMetricsMetricsInfo.ThreadPoolActivePoolSize;
import static org.apache.hadoop.ozone.container.common.helpers.CommandHandlerMetrics.CommandMetricsMetricsInfo.ThreadPoolMaxPoolSize;
import static org.apache.hadoop.ozone.container.common.helpers.CommandHandlerMetrics.CommandMetricsMetricsInfo.CommandReceivedCount;
@@ -46,6 +47,7 @@ public final class CommandHandlerMetrics implements MetricsSource {
enum CommandMetricsMetricsInfo implements MetricsInfo {
Command("The type of the SCM command"),
TotalRunTimeMs("The total runtime of the command handler in milliseconds"),
+ AvgRunTimeMs("Average run time of the command handler in milliseconds"),
QueueWaitingTaskCount("The number of queued tasks waiting for execution"),
InvocationCount("The number of times the command handler has been invoked"),
ThreadPoolActivePoolSize("The number of active threads in the thread pool"),
@@ -108,6 +110,7 @@ public void getMetrics(MetricsCollector collector, boolean all) {
commandHandler.getCommandType().name());
builder.addGauge(TotalRunTimeMs, commandHandler.getTotalRunTime());
+ builder.addGauge(AvgRunTimeMs, commandHandler.getAverageRunTime());
builder.addGauge(QueueWaitingTaskCount, commandHandler.getQueuedCount());
builder.addGauge(InvocationCount, commandHandler.getInvocationCount());
int activePoolSize = commandHandler.getThreadPoolActivePoolSize();
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerSet.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerSet.java
index fa2999c0fa8f..5335021da9ea 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerSet.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerSet.java
@@ -189,7 +189,6 @@ public int containerCount() {
* Send FCR which will not contain removed containers.
*
* @param context StateContext
- * @return
*/
public void handleVolumeFailures(StateContext context) {
AtomicBoolean failedVolume = new AtomicBoolean(false);
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/HddsDispatcher.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/HddsDispatcher.java
index c5855b38b74e..5fc971841554 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/HddsDispatcher.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/HddsDispatcher.java
@@ -647,7 +647,7 @@ public Handler getHandler(ContainerProtos.ContainerType containerType) {
@Override
public void setClusterId(String clusterId) {
- Preconditions.checkNotNull(clusterId, "clusterId Cannot be null");
+ Preconditions.checkNotNull(clusterId, "clusterId cannot be null");
if (this.clusterId == null) {
this.clusterId = clusterId;
for (Map.Entry handlerMap : handlers.entrySet()) {
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/OpenContainerBlockMap.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/OpenContainerBlockMap.java
index d6ca2d120e68..2e11cde3d9e4 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/OpenContainerBlockMap.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/OpenContainerBlockMap.java
@@ -35,7 +35,7 @@
/**
* Map: containerId {@literal ->} (localId {@literal ->} {@link BlockData}).
* The outer container map does not entail locking for a better performance.
- * The inner {@link BlockDataMap} is synchronized.
+ * The inner {@code BlockDataMap} is synchronized.
*
* This class will maintain list of open keys per container when closeContainer
* command comes, it should autocommit all open keys of a open container before
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/ContainerDeletionChoosingPolicyTemplate.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/ContainerDeletionChoosingPolicyTemplate.java
index c584ba790370..bb47b5b9b6ff 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/ContainerDeletionChoosingPolicyTemplate.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/ContainerDeletionChoosingPolicyTemplate.java
@@ -90,7 +90,7 @@ public final List chooseContainerForBlockDeletion(
/**
* Abstract step for ordering the container data to be deleted.
* Subclass need to implement the concrete ordering implementation
- * in descending order (more prioritized -> less prioritized)
+ * in descending order (more prioritized -> less prioritized)
* @param candidateContainers candidate containers to be ordered
*/
protected abstract void orderByDescendingPriority(
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/ContainerDispatcher.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/ContainerDispatcher.java
index d02bae0a35ad..f075b6f67caa 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/ContainerDispatcher.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/ContainerDispatcher.java
@@ -75,7 +75,6 @@ void validateContainerCommand(
/**
* Returns the handler for the specified containerType.
* @param containerType
- * @return
*/
Handler getHandler(ContainerProtos.ContainerType containerType);
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/EndpointStateMachine.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/EndpointStateMachine.java
index a6c3b11de926..b3854e7ecd29 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/EndpointStateMachine.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/EndpointStateMachine.java
@@ -234,12 +234,17 @@ public void logIfNeeded(Exception ex) {
}
if (missCounter == 0) {
+ long missedDurationSeconds = TimeUnit.MILLISECONDS.toSeconds(
+ this.getMissedCount() * getScmHeartbeatInterval(this.conf)
+ );
LOG.warn(
- "Unable to communicate to {} server at {} for past {} seconds.",
- serverName,
- getAddress().getHostString() + ":" + getAddress().getPort(),
- TimeUnit.MILLISECONDS.toSeconds(this.getMissedCount() *
- getScmHeartbeatInterval(this.conf)), ex);
+ "Unable to communicate to {} server at {}:{} for past {} seconds.",
+ serverName,
+ address.getAddress(),
+ address.getPort(),
+ missedDurationSeconds,
+ ex
+ );
}
if (LOG.isTraceEnabled()) {
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/CloseContainerCommandHandler.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/CloseContainerCommandHandler.java
index bc703ac6a552..cd032d4b275d 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/CloseContainerCommandHandler.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/CloseContainerCommandHandler.java
@@ -31,6 +31,8 @@
import org.apache.hadoop.hdds.protocol.proto
.StorageContainerDatanodeProtocolProtos.CloseContainerCommandProto;
import org.apache.hadoop.hdds.tracing.TracingUtil;
+import org.apache.hadoop.metrics2.lib.MetricsRegistry;
+import org.apache.hadoop.metrics2.lib.MutableRate;
import org.apache.hadoop.ozone.container.common.interfaces.Container;
import org.apache.hadoop.ozone.container.common.statemachine
.SCMConnectionManager;
@@ -58,7 +60,7 @@ public class CloseContainerCommandHandler implements CommandHandler {
private final AtomicLong invocationCount = new AtomicLong(0);
private final AtomicInteger queuedCount = new AtomicInteger(0);
private final ThreadPoolExecutor executor;
- private long totalTime;
+ private final MutableRate opsLatencyMs;
/**
* Constructs a close container command handler.
@@ -72,6 +74,9 @@ public CloseContainerCommandHandler(
new ThreadFactoryBuilder()
.setNameFormat(threadNamePrefix + "CloseContainerThread-%d")
.build());
+ MetricsRegistry registry = new MetricsRegistry(
+ CloseContainerCommandHandler.class.getSimpleName());
+ this.opsLatencyMs = registry.newRate(SCMCommandProto.Type.closeContainerCommand + "Ms");
}
/**
@@ -155,7 +160,7 @@ public void handle(SCMCommand command, OzoneContainer ozoneContainer,
LOG.error("Can't close container #{}", containerId, e);
} finally {
long endTime = Time.monotonicNow();
- totalTime += endTime - startTime;
+ this.opsLatencyMs.add(endTime - startTime);
}
}, executor).whenComplete((v, e) -> queuedCount.decrementAndGet());
}
@@ -204,15 +209,12 @@ public int getInvocationCount() {
*/
@Override
public long getAverageRunTime() {
- if (invocationCount.get() > 0) {
- return totalTime / invocationCount.get();
- }
- return 0;
+ return (long) this.opsLatencyMs.lastStat().mean();
}
@Override
public long getTotalRunTime() {
- return totalTime;
+ return (long) this.opsLatencyMs.lastStat().total();
}
@Override
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/ClosePipelineCommandHandler.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/ClosePipelineCommandHandler.java
index 241abb6f4ae1..be39277fdfa6 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/ClosePipelineCommandHandler.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/ClosePipelineCommandHandler.java
@@ -24,6 +24,8 @@
import org.apache.hadoop.hdds.ratis.RatisHelper;
import org.apache.hadoop.hdds.scm.client.HddsClientUtils;
import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
+import org.apache.hadoop.metrics2.lib.MetricsRegistry;
+import org.apache.hadoop.metrics2.lib.MutableRate;
import org.apache.hadoop.ozone.container.common.statemachine
.SCMConnectionManager;
import org.apache.hadoop.ozone.container.common.statemachine.StateContext;
@@ -60,9 +62,9 @@ public class ClosePipelineCommandHandler implements CommandHandler {
private final AtomicLong invocationCount = new AtomicLong(0);
private final AtomicInteger queuedCount = new AtomicInteger(0);
- private long totalTime;
private final Executor executor;
private final BiFunction newRaftClient;
+ private final MutableRate opsLatencyMs;
/**
* Constructs a closePipelineCommand handler.
@@ -80,6 +82,9 @@ public ClosePipelineCommandHandler(
Executor executor) {
this.newRaftClient = newRaftClient;
this.executor = executor;
+ MetricsRegistry registry = new MetricsRegistry(
+ ClosePipelineCommandHandler.class.getSimpleName());
+ this.opsLatencyMs = registry.newRate(SCMCommandProto.Type.closePipelineCommand + "Ms");
}
/**
@@ -155,7 +160,7 @@ public void handle(SCMCommand command, OzoneContainer ozoneContainer,
}
} finally {
long endTime = Time.monotonicNow();
- totalTime += endTime - startTime;
+ this.opsLatencyMs.add(endTime - startTime);
}
}, executor).whenComplete((v, e) -> queuedCount.decrementAndGet());
}
@@ -187,15 +192,12 @@ public int getInvocationCount() {
*/
@Override
public long getAverageRunTime() {
- if (invocationCount.get() > 0) {
- return totalTime / invocationCount.get();
- }
- return 0;
+ return (long) this.opsLatencyMs.lastStat().mean();
}
@Override
public long getTotalRunTime() {
- return totalTime;
+ return (long) this.opsLatencyMs.lastStat().total();
}
@Override
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/CreatePipelineCommandHandler.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/CreatePipelineCommandHandler.java
index 4a36a1987de6..62fc8a919d84 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/CreatePipelineCommandHandler.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/CreatePipelineCommandHandler.java
@@ -30,6 +30,8 @@
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMCommandProto;
import org.apache.hadoop.hdds.ratis.RatisHelper;
import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
+import org.apache.hadoop.metrics2.lib.MetricsRegistry;
+import org.apache.hadoop.metrics2.lib.MutableRate;
import org.apache.hadoop.ozone.container.common.statemachine.SCMConnectionManager;
import org.apache.hadoop.ozone.container.common.statemachine.StateContext;
import org.apache.hadoop.ozone.container.common.transport.server.XceiverServerSpi;
@@ -59,8 +61,8 @@ public class CreatePipelineCommandHandler implements CommandHandler {
private final AtomicInteger queuedCount = new AtomicInteger(0);
private final BiFunction newRaftClient;
- private long totalTime;
private final Executor executor;
+ private final MutableRate opsLatencyMs;
/**
* Constructs a createPipelineCommand handler.
@@ -75,6 +77,9 @@ public CreatePipelineCommandHandler(ConfigurationSource conf,
Executor executor) {
this.newRaftClient = newRaftClient;
this.executor = executor;
+ MetricsRegistry registry = new MetricsRegistry(
+ CreatePipelineCommandHandler.class.getSimpleName());
+ this.opsLatencyMs = registry.newRate(SCMCommandProto.Type.createPipelineCommand + "Ms");
}
/**
@@ -135,7 +140,7 @@ public void handle(SCMCommand command, OzoneContainer ozoneContainer,
}
} finally {
long endTime = Time.monotonicNow();
- totalTime += endTime - startTime;
+ this.opsLatencyMs.add(endTime - startTime);
}
}, executor).whenComplete((v, e) -> queuedCount.decrementAndGet());
}
@@ -167,15 +172,12 @@ public int getInvocationCount() {
*/
@Override
public long getAverageRunTime() {
- if (invocationCount.get() > 0) {
- return totalTime / invocationCount.get();
- }
- return 0;
+ return (long) this.opsLatencyMs.lastStat().mean();
}
@Override
public long getTotalRunTime() {
- return totalTime;
+ return (long) this.opsLatencyMs.lastStat().total();
}
@Override
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/DeleteBlocksCommandHandler.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/DeleteBlocksCommandHandler.java
index bd7431c61452..136c58058210 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/DeleteBlocksCommandHandler.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/DeleteBlocksCommandHandler.java
@@ -32,6 +32,8 @@
import org.apache.hadoop.hdds.protocol.proto
.StorageContainerDatanodeProtocolProtos.DeletedBlocksTransaction;
import org.apache.hadoop.hdds.utils.db.Table;
+import org.apache.hadoop.metrics2.lib.MetricsRegistry;
+import org.apache.hadoop.metrics2.lib.MutableRate;
import org.apache.hadoop.ozone.container.common.helpers.BlockData;
import org.apache.hadoop.ozone.container.common.helpers.BlockDeletingServiceMetrics;
import org.apache.hadoop.ozone.container.common.helpers.ChunkInfoList;
@@ -91,7 +93,6 @@ public class DeleteBlocksCommandHandler implements CommandHandler {
private final ContainerSet containerSet;
private final ConfigurationSource conf;
private int invocationCount;
- private long totalTime;
private final ThreadPoolExecutor executor;
private final LinkedBlockingQueue deleteCommandQueues;
private final Daemon handlerThread;
@@ -99,6 +100,7 @@ public class DeleteBlocksCommandHandler implements CommandHandler {
private final BlockDeletingServiceMetrics blockDeleteMetrics;
private final long tryLockTimeoutMs;
private final Map schemaHandlers;
+ private final MutableRate opsLatencyMs;
public DeleteBlocksCommandHandler(OzoneContainer container,
ConfigurationSource conf, DatanodeConfiguration dnConf,
@@ -121,6 +123,9 @@ public DeleteBlocksCommandHandler(OzoneContainer container,
dnConf.getBlockDeleteThreads(), threadFactory);
this.deleteCommandQueues =
new LinkedBlockingQueue<>(dnConf.getBlockDeleteQueueLimit());
+ MetricsRegistry registry = new MetricsRegistry(
+ DeleteBlocksCommandHandler.class.getSimpleName());
+ this.opsLatencyMs = registry.newRate(SCMCommandProto.Type.deleteBlocksCommand + "Ms");
long interval = dnConf.getBlockDeleteCommandWorkerInterval().toMillis();
handlerThread = new Daemon(new DeleteCmdWorker(interval));
handlerThread.start();
@@ -354,10 +359,11 @@ private void processCmd(DeleteCmdInfo cmd) {
DeletedContainerBlocksSummary summary =
DeletedContainerBlocksSummary.getFrom(containerBlocks);
LOG.info("Summary of deleting container blocks, numOfTransactions={}, "
- + "numOfContainers={}, numOfBlocks={}",
+ + "numOfContainers={}, numOfBlocks={}, commandId={}.",
summary.getNumOfTxs(),
summary.getNumOfContainers(),
- summary.getNumOfBlocks());
+ summary.getNumOfBlocks(),
+ cmd.getCmd().getId());
if (LOG.isDebugEnabled()) {
LOG.debug("Start to delete container blocks, TXIDs={}",
summary.getTxIDSummary());
@@ -384,7 +390,8 @@ private void processCmd(DeleteCmdInfo cmd) {
LOG.debug("Sending following block deletion ACK to SCM");
for (DeleteBlockTransactionResult result : blockDeletionACK
.getResultsList()) {
- LOG.debug("{} : {}", result.getTxID(), result.getSuccess());
+ LOG.debug("TxId = {} : ContainerId = {} : {}",
+ result.getTxID(), result.getContainerID(), result.getSuccess());
}
}
}
@@ -403,7 +410,7 @@ private void processCmd(DeleteCmdInfo cmd) {
};
updateCommandStatus(cmd.getContext(), cmd.getCmd(), statusUpdater, LOG);
long endTime = Time.monotonicNow();
- totalTime += endTime - startTime;
+ this.opsLatencyMs.add(endTime - startTime);
invocationCount++;
}
}
@@ -666,15 +673,12 @@ public int getInvocationCount() {
@Override
public long getAverageRunTime() {
- if (invocationCount > 0) {
- return totalTime / invocationCount;
- }
- return 0;
+ return (long) this.opsLatencyMs.lastStat().mean();
}
@Override
public long getTotalRunTime() {
- return totalTime;
+ return (long) this.opsLatencyMs.lastStat().total();
}
@Override
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/DeleteContainerCommandHandler.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/DeleteContainerCommandHandler.java
index b76e306e1c07..59aaacc1c802 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/DeleteContainerCommandHandler.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/DeleteContainerCommandHandler.java
@@ -22,6 +22,8 @@
import java.util.concurrent.RejectedExecutionException;
import org.apache.hadoop.hdds.protocol.proto
.StorageContainerDatanodeProtocolProtos.SCMCommandProto;
+import org.apache.hadoop.metrics2.lib.MetricsRegistry;
+import org.apache.hadoop.metrics2.lib.MutableRate;
import org.apache.hadoop.ozone.container.common.statemachine
.SCMConnectionManager;
import org.apache.hadoop.ozone.container.common.statemachine.StateContext;
@@ -39,7 +41,6 @@
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
/**
* Handler to process the DeleteContainerCommand from SCM.
@@ -51,10 +52,10 @@ public class DeleteContainerCommandHandler implements CommandHandler {
private final AtomicInteger invocationCount = new AtomicInteger(0);
private final AtomicInteger timeoutCount = new AtomicInteger(0);
- private final AtomicLong totalTime = new AtomicLong(0);
private final ThreadPoolExecutor executor;
private final Clock clock;
private int maxQueueSize;
+ private final MutableRate opsLatencyMs;
public DeleteContainerCommandHandler(
int threadPoolSize, Clock clock, int queueSize, String threadNamePrefix) {
@@ -73,6 +74,9 @@ protected DeleteContainerCommandHandler(Clock clock,
this.executor = executor;
this.clock = clock;
maxQueueSize = queueSize;
+ MetricsRegistry registry = new MetricsRegistry(
+ DeleteContainerCommandHandler.class.getSimpleName());
+ this.opsLatencyMs = registry.newRate(SCMCommandProto.Type.deleteContainerCommand + "Ms");
}
@Override
public void handle(final SCMCommand command,
@@ -124,7 +128,7 @@ private void handleInternal(SCMCommand command, StateContext context,
} catch (IOException e) {
LOG.error("Exception occurred while deleting the container.", e);
} finally {
- totalTime.getAndAdd(Time.monotonicNow() - startTime);
+ this.opsLatencyMs.add(Time.monotonicNow() - startTime);
}
}
@@ -149,14 +153,12 @@ public int getTimeoutCount() {
@Override
public long getAverageRunTime() {
- final int invocations = invocationCount.get();
- return invocations == 0 ?
- 0 : totalTime.get() / invocations;
+ return (long) this.opsLatencyMs.lastStat().mean();
}
@Override
public long getTotalRunTime() {
- return totalTime.get();
+ return (long) this.opsLatencyMs.lastStat().total();
}
@Override
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/FinalizeNewLayoutVersionCommandHandler.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/FinalizeNewLayoutVersionCommandHandler.java
index bd7ec5710d91..77e152447b95 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/FinalizeNewLayoutVersionCommandHandler.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/FinalizeNewLayoutVersionCommandHandler.java
@@ -20,6 +20,8 @@
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.FinalizeNewLayoutVersionCommandProto;
import org.apache.hadoop.hdds.protocol.proto
.StorageContainerDatanodeProtocolProtos.SCMCommandProto;
+import org.apache.hadoop.metrics2.lib.MetricsRegistry;
+import org.apache.hadoop.metrics2.lib.MutableRate;
import org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine;
import org.apache.hadoop.ozone.container.common.statemachine
.SCMConnectionManager;
@@ -42,12 +44,15 @@ public class FinalizeNewLayoutVersionCommandHandler implements CommandHandler {
LoggerFactory.getLogger(FinalizeNewLayoutVersionCommandHandler.class);
private AtomicLong invocationCount = new AtomicLong(0);
- private long totalTime;
+ private final MutableRate opsLatencyMs;
/**
* Constructs a FinalizeNewLayoutVersionCommandHandler.
*/
public FinalizeNewLayoutVersionCommandHandler() {
+ MetricsRegistry registry = new MetricsRegistry(
+ FinalizeNewLayoutVersionCommandHandler.class.getSimpleName());
+ this.opsLatencyMs = registry.newRate(SCMCommandProto.Type.finalizeNewLayoutVersionCommand + "Ms");
}
/**
@@ -82,7 +87,7 @@ public void handle(SCMCommand command, OzoneContainer ozoneContainer,
LOG.error("Exception during finalization.", e);
} finally {
long endTime = Time.monotonicNow();
- totalTime += endTime - startTime;
+ this.opsLatencyMs.add(endTime - startTime);
}
}
@@ -113,15 +118,12 @@ public int getInvocationCount() {
*/
@Override
public long getAverageRunTime() {
- if (invocationCount.get() > 0) {
- return totalTime / invocationCount.get();
- }
- return 0;
+ return (long) this.opsLatencyMs.lastStat().mean();
}
@Override
public long getTotalRunTime() {
- return totalTime;
+ return (long) this.opsLatencyMs.lastStat().total();
}
@Override
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/ReconstructECContainersCommandHandler.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/ReconstructECContainersCommandHandler.java
index 602687d7a003..030d169e9b84 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/ReconstructECContainersCommandHandler.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/ReconstructECContainersCommandHandler.java
@@ -36,6 +36,7 @@ public class ReconstructECContainersCommandHandler implements CommandHandler {
private final ReplicationSupervisor supervisor;
private final ECReconstructionCoordinator coordinator;
private final ConfigurationSource conf;
+ private String metricsName;
public ReconstructECContainersCommandHandler(ConfigurationSource conf,
ReplicationSupervisor supervisor,
@@ -52,8 +53,16 @@ public void handle(SCMCommand command, OzoneContainer container,
(ReconstructECContainersCommand) command;
ECReconstructionCommandInfo reconstructionCommandInfo =
new ECReconstructionCommandInfo(ecContainersCommand);
- this.supervisor.addTask(new ECReconstructionCoordinatorTask(
- coordinator, reconstructionCommandInfo));
+ ECReconstructionCoordinatorTask task = new ECReconstructionCoordinatorTask(
+ coordinator, reconstructionCommandInfo);
+ if (this.metricsName == null) {
+ this.metricsName = task.getMetricName();
+ }
+ this.supervisor.addTask(task);
+ }
+
+ public String getMetricsName() {
+ return this.metricsName;
}
@Override
@@ -63,23 +72,26 @@ public Type getCommandType() {
@Override
public int getInvocationCount() {
- return 0;
+ return this.metricsName == null ? 0 : (int) this.supervisor
+ .getReplicationRequestCount(metricsName);
}
@Override
public long getAverageRunTime() {
- return 0;
+ return this.metricsName == null ? 0 : (int) this.supervisor
+ .getReplicationRequestAvgTime(metricsName);
}
@Override
public long getTotalRunTime() {
- return 0;
+ return this.metricsName == null ? 0 : this.supervisor
+ .getReplicationRequestTotalTime(metricsName);
}
@Override
public int getQueuedCount() {
- return supervisor
- .getInFlightReplications(ECReconstructionCoordinatorTask.class);
+ return this.metricsName == null ? 0 : (int) this.supervisor
+ .getReplicationQueuedCount(metricsName);
}
public ConfigurationSource getConf() {
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/RefreshVolumeUsageCommandHandler.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/RefreshVolumeUsageCommandHandler.java
index 3c14b2fb1614..1ab31ba1c413 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/RefreshVolumeUsageCommandHandler.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/RefreshVolumeUsageCommandHandler.java
@@ -18,6 +18,8 @@
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos;
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMCommandProto.Type;
+import org.apache.hadoop.metrics2.lib.MetricsRegistry;
+import org.apache.hadoop.metrics2.lib.MutableRate;
import org.apache.hadoop.ozone.container.common.statemachine.SCMConnectionManager;
import org.apache.hadoop.ozone.container.common.statemachine.StateContext;
import org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer;
@@ -27,7 +29,6 @@
import org.slf4j.LoggerFactory;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
/**
* Command handler to refresh usage info of all volumes.
@@ -38,9 +39,12 @@ public class RefreshVolumeUsageCommandHandler implements CommandHandler {
LoggerFactory.getLogger(RefreshVolumeUsageCommandHandler.class);
private final AtomicInteger invocationCount = new AtomicInteger(0);
- private final AtomicLong totalTime = new AtomicLong(0);
+ private final MutableRate opsLatencyMs;
public RefreshVolumeUsageCommandHandler() {
+ MetricsRegistry registry = new MetricsRegistry(
+ RefreshVolumeUsageCommandHandler.class.getSimpleName());
+ this.opsLatencyMs = registry.newRate(Type.refreshVolumeUsageInfo + "Ms");
}
@Override
@@ -50,7 +54,7 @@ public void handle(SCMCommand command, OzoneContainer container,
invocationCount.incrementAndGet();
final long startTime = Time.monotonicNow();
container.getVolumeSet().refreshAllVolumeUsage();
- totalTime.getAndAdd(Time.monotonicNow() - startTime);
+ this.opsLatencyMs.add(Time.monotonicNow() - startTime);
}
@Override
@@ -66,14 +70,12 @@ public int getInvocationCount() {
@Override
public long getAverageRunTime() {
- final int invocations = invocationCount.get();
- return invocations == 0 ?
- 0 : totalTime.get() / invocations;
+ return (long) this.opsLatencyMs.lastStat().mean();
}
@Override
public long getTotalRunTime() {
- return totalTime.get();
+ return (long) this.opsLatencyMs.lastStat().total();
}
@Override
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/ReplicateContainerCommandHandler.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/ReplicateContainerCommandHandler.java
index 21b26339e238..242a4eb74bed 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/ReplicateContainerCommandHandler.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/ReplicateContainerCommandHandler.java
@@ -43,29 +43,28 @@ public class ReplicateContainerCommandHandler implements CommandHandler {
static final Logger LOG =
LoggerFactory.getLogger(ReplicateContainerCommandHandler.class);
- private int invocationCount;
-
- private long totalTime;
-
- private ConfigurationSource conf;
-
private ReplicationSupervisor supervisor;
private ContainerReplicator downloadReplicator;
private ContainerReplicator pushReplicator;
+ private String metricsName;
+
public ReplicateContainerCommandHandler(
ConfigurationSource conf,
ReplicationSupervisor supervisor,
ContainerReplicator downloadReplicator,
ContainerReplicator pushReplicator) {
- this.conf = conf;
this.supervisor = supervisor;
this.downloadReplicator = downloadReplicator;
this.pushReplicator = pushReplicator;
}
+ public String getMetricsName() {
+ return this.metricsName;
+ }
+
@Override
public void handle(SCMCommand command, OzoneContainer container,
StateContext context, SCMConnectionManager connectionManager) {
@@ -86,12 +85,16 @@ public void handle(SCMCommand command, OzoneContainer container,
downloadReplicator : pushReplicator;
ReplicationTask task = new ReplicationTask(replicateCommand, replicator);
+ if (metricsName == null) {
+ metricsName = task.getMetricName();
+ }
supervisor.addTask(task);
}
@Override
public int getQueuedCount() {
- return supervisor.getInFlightReplications(ReplicationTask.class);
+ return this.metricsName == null ? 0 : (int) this.supervisor
+ .getReplicationQueuedCount(metricsName);
}
@Override
@@ -101,19 +104,19 @@ public SCMCommandProto.Type getCommandType() {
@Override
public int getInvocationCount() {
- return this.invocationCount;
+ return this.metricsName == null ? 0 : (int) this.supervisor
+ .getReplicationRequestCount(metricsName);
}
@Override
public long getAverageRunTime() {
- if (invocationCount > 0) {
- return totalTime / invocationCount;
- }
- return 0;
+ return this.metricsName == null ? 0 : (int) this.supervisor
+ .getReplicationRequestAvgTime(metricsName);
}
@Override
public long getTotalRunTime() {
- return totalTime;
+ return this.metricsName == null ? 0 : this.supervisor
+ .getReplicationRequestTotalTime(metricsName);
}
}
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/SetNodeOperationalStateCommandHandler.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/SetNodeOperationalStateCommandHandler.java
index 6f7f4414eeb0..335636247950 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/SetNodeOperationalStateCommandHandler.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/SetNodeOperationalStateCommandHandler.java
@@ -21,8 +21,10 @@
import org.apache.hadoop.hdds.conf.ConfigurationSource;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
-import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SetNodeOperationalStateCommandProto;
import org.apache.hadoop.hdds.utils.HddsServerUtil;
+import org.apache.hadoop.metrics2.lib.MetricsRegistry;
+import org.apache.hadoop.metrics2.lib.MutableRate;
import org.apache.hadoop.ozone.container.common.helpers.ContainerUtils;
import org.apache.hadoop.ozone.container.common.statemachine.SCMConnectionManager;
import org.apache.hadoop.ozone.container.common.statemachine.StateContext;
@@ -39,7 +41,6 @@
import java.io.File;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer;
@@ -54,7 +55,7 @@ public class SetNodeOperationalStateCommandHandler implements CommandHandler {
private final ConfigurationSource conf;
private final Consumer replicationSupervisor;
private final AtomicInteger invocationCount = new AtomicInteger(0);
- private final AtomicLong totalTime = new AtomicLong(0);
+ private final MutableRate opsLatencyMs;
/**
* Set Node State command handler.
@@ -65,6 +66,9 @@ public SetNodeOperationalStateCommandHandler(ConfigurationSource conf,
Consumer replicationSupervisor) {
this.conf = conf;
this.replicationSupervisor = replicationSupervisor;
+ MetricsRegistry registry = new MetricsRegistry(
+ SetNodeOperationalStateCommandHandler.class.getSimpleName());
+ this.opsLatencyMs = registry.newRate(Type.setNodeOperationalStateCommand + "Ms");
}
/**
@@ -80,9 +84,6 @@ public void handle(SCMCommand command, OzoneContainer container,
StateContext context, SCMConnectionManager connectionManager) {
long startTime = Time.monotonicNow();
invocationCount.incrementAndGet();
- StorageContainerDatanodeProtocolProtos.SetNodeOperationalStateCommandProto
- setNodeCmdProto = null;
-
if (command.getType() != Type.setNodeOperationalStateCommand) {
LOG.warn("Skipping handling command, expected command "
+ "type {} but found {}",
@@ -91,7 +92,7 @@ public void handle(SCMCommand command, OzoneContainer container,
}
SetNodeOperationalStateCommand setNodeCmd =
(SetNodeOperationalStateCommand) command;
- setNodeCmdProto = setNodeCmd.getProto();
+ SetNodeOperationalStateCommandProto setNodeCmdProto = setNodeCmd.getProto();
DatanodeDetails dni = context.getParent().getDatanodeDetails();
HddsProtos.NodeOperationalState state =
setNodeCmdProto.getNodeOperationalState();
@@ -106,7 +107,7 @@ public void handle(SCMCommand command, OzoneContainer container,
// handler interface.
}
replicationSupervisor.accept(state);
- totalTime.addAndGet(Time.monotonicNow() - startTime);
+ this.opsLatencyMs.add(Time.monotonicNow() - startTime);
}
// TODO - this duplicates code in HddsDatanodeService and InitDatanodeState
@@ -125,8 +126,7 @@ private void persistDatanodeDetails(DatanodeDetails dnDetails)
* @return Type
*/
@Override
- public StorageContainerDatanodeProtocolProtos.SCMCommandProto.Type
- getCommandType() {
+ public Type getCommandType() {
return Type.setNodeOperationalStateCommand;
}
@@ -147,14 +147,12 @@ public int getInvocationCount() {
*/
@Override
public long getAverageRunTime() {
- final int invocations = invocationCount.get();
- return invocations == 0 ?
- 0 : totalTime.get() / invocations;
+ return (long) this.opsLatencyMs.lastStat().mean();
}
@Override
public long getTotalRunTime() {
- return totalTime.get();
+ return (long) this.opsLatencyMs.lastStat().total();
}
@Override
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/HeartbeatEndpointTask.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/HeartbeatEndpointTask.java
index 44f0eae49ead..25db14a1012b 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/HeartbeatEndpointTask.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/HeartbeatEndpointTask.java
@@ -489,7 +489,7 @@ public Builder setEndpointStateMachine(EndpointStateMachine rpcEndPoint) {
/**
* Sets the LayoutVersionManager.
*
- * @param versionMgr - config
+ * @param lvm config
* @return Builder
*/
public Builder setLayoutVersionManager(HDDSLayoutVersionManager lvm) {
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/RegisterEndpointTask.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/RegisterEndpointTask.java
index 71f95cc4d329..969756b40f8f 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/RegisterEndpointTask.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/RegisterEndpointTask.java
@@ -244,7 +244,7 @@ public Builder setConfig(ConfigurationSource config) {
/**
* Sets the LayoutVersionManager.
*
- * @param versionMgr - config
+ * @param lvm config
* @return Builder.
*/
public Builder setLayoutVersionManager(HDDSLayoutVersionManager lvm) {
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/VersionEndpointTask.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/VersionEndpointTask.java
index e702b1e6e158..968c9b9a6e66 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/VersionEndpointTask.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/VersionEndpointTask.java
@@ -17,6 +17,7 @@
package org.apache.hadoop.ozone.container.common.states.endpoint;
import java.io.IOException;
+import java.net.BindException;
import java.util.concurrent.Callable;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
@@ -104,7 +105,7 @@ public EndpointStateMachine.EndPointStates call() throws Exception {
LOG.debug("Cannot execute GetVersion task as endpoint state machine " +
"is in {} state", rpcEndPoint.getState());
}
- } catch (DiskOutOfSpaceException ex) {
+ } catch (DiskOutOfSpaceException | BindException ex) {
rpcEndPoint.setState(EndpointStateMachine.EndPointStates.SHUTDOWN);
} catch (IOException ex) {
rpcEndPoint.logIfNeeded(ex);
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/XceiverServerGrpc.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/XceiverServerGrpc.java
index ad9c5c9d9ca0..42daaa94be39 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/XceiverServerGrpc.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/XceiverServerGrpc.java
@@ -19,6 +19,7 @@
package org.apache.hadoop.ozone.container.common.transport.server;
import java.io.IOException;
+import java.net.BindException;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
@@ -185,7 +186,16 @@ public HddsProtos.ReplicationType getServerType() {
@Override
public void start() throws IOException {
if (!isStarted) {
- server.start();
+ try {
+ server.start();
+ } catch (IOException e) {
+ LOG.error("Error while starting the server", e);
+ if (e.getMessage().contains("Failed to bind to address")) {
+ throw new BindException(e.getMessage());
+ } else {
+ throw e;
+ }
+ }
int realPort = server.getPort();
if (port == 0) {
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachine.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachine.java
index 9dc6af19353a..1048ec5092c7 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachine.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachine.java
@@ -41,8 +41,9 @@
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
-import java.util.stream.Collectors;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.hadoop.hdds.HddsUtils;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
@@ -69,19 +70,17 @@
import org.apache.hadoop.ozone.container.keyvalue.impl.KeyValueStreamDataChannel;
import org.apache.hadoop.ozone.container.ozoneimpl.ContainerController;
import org.apache.hadoop.util.Time;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import org.apache.ratis.proto.RaftProtos;
-import org.apache.ratis.proto.RaftProtos.StateMachineEntryProto;
import org.apache.ratis.proto.RaftProtos.LogEntryProto;
import org.apache.ratis.proto.RaftProtos.RaftPeerRole;
import org.apache.ratis.proto.RaftProtos.RoleInfoProto;
+import org.apache.ratis.proto.RaftProtos.StateMachineEntryProto;
import org.apache.ratis.proto.RaftProtos.StateMachineLogEntryProto;
import org.apache.ratis.protocol.Message;
import org.apache.ratis.protocol.RaftClientRequest;
import org.apache.ratis.protocol.RaftGroupId;
import org.apache.ratis.protocol.RaftGroupMemberId;
+import org.apache.ratis.protocol.RaftPeer;
import org.apache.ratis.protocol.RaftPeerId;
import org.apache.ratis.protocol.exceptions.StateMachineException;
import org.apache.ratis.server.RaftServer;
@@ -97,10 +96,10 @@
import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
import org.apache.ratis.thirdparty.com.google.protobuf.InvalidProtocolBufferException;
import org.apache.ratis.thirdparty.com.google.protobuf.TextFormat;
+import org.apache.ratis.util.JavaUtils;
import org.apache.ratis.util.LifeCycle;
import org.apache.ratis.util.TaskQueue;
import org.apache.ratis.util.function.CheckedSupplier;
-import org.apache.ratis.util.JavaUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -184,7 +183,6 @@ long getStartTime() {
private final SimpleStateMachineStorage storage =
new SimpleStateMachineStorage();
- private final RaftGroupId gid;
private final ContainerDispatcher dispatcher;
private final ContainerController containerController;
private final XceiverServerRatis ratisServer;
@@ -219,7 +217,6 @@ public ContainerStateMachine(HddsDatanodeService hddsDatanodeService, RaftGroupI
ConfigurationSource conf,
String threadNamePrefix) {
this.datanodeService = hddsDatanodeService;
- this.gid = gid;
this.dispatcher = dispatcher;
this.containerController = containerController;
this.ratisServer = ratisServer;
@@ -283,8 +280,9 @@ public void initialize(
throws IOException {
super.initialize(server, id, raftStorage);
storage.init(raftStorage);
- ratisServer.notifyGroupAdd(gid);
+ ratisServer.notifyGroupAdd(id);
+ LOG.info("{}: initialize {}", server.getId(), id);
loadSnapshot(storage.getLatestSnapshot());
}
@@ -293,7 +291,7 @@ private long loadSnapshot(SingleFileSnapshotInfo snapshot)
if (snapshot == null) {
TermIndex empty = TermIndex.valueOf(0, RaftLog.INVALID_LOG_INDEX);
LOG.info("{}: The snapshot info is null. Setting the last applied index " +
- "to:{}", gid, empty);
+ "to:{}", getGroupId(), empty);
setLastAppliedTermIndex(empty);
return empty.getIndex();
}
@@ -301,7 +299,7 @@ private long loadSnapshot(SingleFileSnapshotInfo snapshot)
final File snapshotFile = snapshot.getFile().getPath().toFile();
final TermIndex last =
SimpleStateMachineStorage.getTermIndexFromSnapshotFile(snapshotFile);
- LOG.info("{}: Setting the last applied index to {}", gid, last);
+ LOG.info("{}: Setting the last applied index to {}", getGroupId(), last);
setLastAppliedTermIndex(last);
// initialize the dispatcher with snapshot so that it build the missing
@@ -351,7 +349,7 @@ public long takeSnapshot() throws IOException {
long startTime = Time.monotonicNow();
if (!isStateMachineHealthy()) {
String msg =
- "Failed to take snapshot " + " for " + gid + " as the stateMachine"
+ "Failed to take snapshot " + " for " + getGroupId() + " as the stateMachine"
+ " is unhealthy. The last applied index is at " + ti;
StateMachineException sme = new StateMachineException(msg);
LOG.error(msg);
@@ -360,19 +358,19 @@ public long takeSnapshot() throws IOException {
if (ti != null && ti.getIndex() != RaftLog.INVALID_LOG_INDEX) {
final File snapshotFile =
storage.getSnapshotFile(ti.getTerm(), ti.getIndex());
- LOG.info("{}: Taking a snapshot at:{} file {}", gid, ti, snapshotFile);
+ LOG.info("{}: Taking a snapshot at:{} file {}", getGroupId(), ti, snapshotFile);
try (FileOutputStream fos = new FileOutputStream(snapshotFile)) {
persistContainerSet(fos);
fos.flush();
// make sure the snapshot file is synced
fos.getFD().sync();
} catch (IOException ioe) {
- LOG.error("{}: Failed to write snapshot at:{} file {}", gid, ti,
+ LOG.error("{}: Failed to write snapshot at:{} file {}", getGroupId(), ti,
snapshotFile);
throw ioe;
}
LOG.info("{}: Finished taking a snapshot at:{} file:{} took: {} ms",
- gid, ti, snapshotFile, (Time.monotonicNow() - startTime));
+ getGroupId(), ti, snapshotFile, (Time.monotonicNow() - startTime));
return ti.getIndex();
}
return -1;
@@ -386,7 +384,7 @@ public TransactionContext startTransaction(LogEntryProto entry, RaftPeerRole rol
final StateMachineLogEntryProto stateMachineLogEntry = entry.getStateMachineLogEntry();
final ContainerCommandRequestProto logProto;
try {
- logProto = getContainerCommandRequestProto(gid, stateMachineLogEntry.getLogData());
+ logProto = getContainerCommandRequestProto(getGroupId(), stateMachineLogEntry.getLogData());
} catch (InvalidProtocolBufferException e) {
trx.setException(e);
return trx;
@@ -413,7 +411,7 @@ public TransactionContext startTransaction(RaftClientRequest request)
long startTime = Time.monotonicNowNanos();
final ContainerCommandRequestProto proto =
message2ContainerCommandRequestProto(request.getMessage());
- Preconditions.checkArgument(request.getRaftGroupId().equals(gid));
+ Preconditions.checkArgument(request.getRaftGroupId().equals(getGroupId()));
final TransactionContext.Builder builder = TransactionContext.newBuilder()
.setClientRequest(request)
@@ -449,7 +447,7 @@ public TransactionContext startTransaction(RaftClientRequest request)
final WriteChunkRequestProto.Builder commitWriteChunkProto = WriteChunkRequestProto.newBuilder(write)
.clearData();
protoBuilder.setWriteChunk(commitWriteChunkProto)
- .setPipelineID(gid.getUuid().toString())
+ .setPipelineID(getGroupId().getUuid().toString())
.setTraceID(proto.getTraceID());
builder.setStateMachineData(write.getData());
@@ -491,20 +489,20 @@ private static ContainerCommandRequestProto getContainerCommandRequestProto(
private ContainerCommandRequestProto message2ContainerCommandRequestProto(
Message message) throws InvalidProtocolBufferException {
- return ContainerCommandRequestMessage.toProto(message.getContent(), gid);
+ return ContainerCommandRequestMessage.toProto(message.getContent(), getGroupId());
}
private ContainerCommandResponseProto dispatchCommand(
ContainerCommandRequestProto requestProto, DispatcherContext context) {
if (LOG.isTraceEnabled()) {
- LOG.trace("{}: dispatch {} containerID={} pipelineID={} traceID={}", gid,
+ LOG.trace("{}: dispatch {} containerID={} pipelineID={} traceID={}", getGroupId(),
requestProto.getCmdType(), requestProto.getContainerID(),
requestProto.getPipelineID(), requestProto.getTraceID());
}
ContainerCommandResponseProto response =
dispatcher.dispatch(requestProto, context);
if (LOG.isTraceEnabled()) {
- LOG.trace("{}: response {}", gid, response);
+ LOG.trace("{}: response {}", getGroupId(), response);
}
return response;
}
@@ -531,7 +529,7 @@ private CompletableFuture writeStateMachineData(
RaftServer server = ratisServer.getServer();
Preconditions.checkArgument(!write.getData().isEmpty());
try {
- if (server.getDivision(gid).getInfo().isLeader()) {
+ if (server.getDivision(getGroupId()).getInfo().isLeader()) {
stateMachineDataCache.put(entryIndex, write.getData());
}
} catch (InterruptedException ioe) {
@@ -559,7 +557,7 @@ private CompletableFuture writeStateMachineData(
return dispatchCommand(requestProto, context);
} catch (Exception e) {
LOG.error("{}: writeChunk writeStateMachineData failed: blockId" +
- "{} logIndex {} chunkName {}", gid, write.getBlockID(),
+ "{} logIndex {} chunkName {}", getGroupId(), write.getBlockID(),
entryIndex, write.getChunkData().getChunkName(), e);
metrics.incNumWriteDataFails();
// write chunks go in parallel. It's possible that one write chunk
@@ -573,7 +571,7 @@ private CompletableFuture writeStateMachineData(
writeChunkFutureMap.put(entryIndex, writeChunkFuture);
if (LOG.isDebugEnabled()) {
LOG.debug("{}: writeChunk writeStateMachineData : blockId" +
- "{} logIndex {} chunkName {}", gid, write.getBlockID(),
+ "{} logIndex {} chunkName {}", getGroupId(), write.getBlockID(),
entryIndex, write.getChunkData().getChunkName());
}
// Remove the future once it finishes execution from the
@@ -587,7 +585,7 @@ private CompletableFuture writeStateMachineData(
&& r.getResult() != ContainerProtos.Result.CHUNK_FILE_INCONSISTENCY) {
StorageContainerException sce =
new StorageContainerException(r.getMessage(), r.getResult());
- LOG.error(gid + ": writeChunk writeStateMachineData failed: blockId" +
+ LOG.error(getGroupId() + ": writeChunk writeStateMachineData failed: blockId" +
write.getBlockID() + " logIndex " + entryIndex + " chunkName " +
write.getChunkData().getChunkName() + " Error message: " +
r.getMessage() + " Container Result: " + r.getResult());
@@ -601,7 +599,7 @@ private CompletableFuture writeStateMachineData(
metrics.incNumBytesWrittenCount(
requestProto.getWriteChunk().getChunkData().getLen());
if (LOG.isDebugEnabled()) {
- LOG.debug(gid +
+ LOG.debug(getGroupId() +
": writeChunk writeStateMachineData completed: blockId" +
write.getBlockID() + " logIndex " + entryIndex + " chunkName " +
write.getChunkData().getChunkName());
@@ -622,7 +620,7 @@ private StateMachine.DataChannel getStreamDataChannel(
DispatcherContext context) throws StorageContainerException {
if (LOG.isDebugEnabled()) {
LOG.debug("{}: getStreamDataChannel {} containerID={} pipelineID={} " +
- "traceID={}", gid, requestProto.getCmdType(),
+ "traceID={}", getGroupId(), requestProto.getCmdType(),
requestProto.getContainerID(), requestProto.getPipelineID(),
requestProto.getTraceID());
}
@@ -705,9 +703,9 @@ private ExecutorService getChunkExecutor(WriteChunkRequestProto req) {
}
/**
- * {@link #writeStateMachineData(ContainerCommandRequestProto, long, long, long)}
+ * {@link #writeStateMachineData}
* calls are not synchronized with each other
- * and also with {@link #applyTransaction(TransactionContext)}.
+ * and also with {@code applyTransaction(TransactionContext)}.
*/
@Override
public CompletableFuture write(LogEntryProto entry, TransactionContext trx) {
@@ -781,7 +779,7 @@ private ByteString readStateMachineData(
new StorageContainerException(response.getMessage(),
response.getResult());
LOG.error("gid {} : ReadStateMachine failed. cmd {} logIndex {} msg : "
- + "{} Container Result: {}", gid, response.getCmdType(), index,
+ + "{} Container Result: {}", getGroupId(), response.getCmdType(), index,
response.getMessage(), response.getResult());
stateMachineHealthy.set(false);
throw sce;
@@ -817,11 +815,9 @@ private ByteString readStateMachineData(
*/
@Override
public CompletableFuture flush(long index) {
- List> futureList =
- writeChunkFutureMap.entrySet().stream().filter(x -> x.getKey() <= index)
- .map(Map.Entry::getValue).collect(Collectors.toList());
return CompletableFuture.allOf(
- futureList.toArray(new CompletableFuture[futureList.size()]));
+ writeChunkFutureMap.entrySet().stream().filter(x -> x.getKey() <= index)
+ .map(Map.Entry::getValue).toArray(CompletableFuture[]::new));
}
/**
@@ -858,7 +854,7 @@ public CompletableFuture read(LogEntryProto entry, TransactionContex
.map(TransactionContext::getStateMachineContext)
.orElse(null);
final ContainerCommandRequestProto requestProto = context != null ? context.getLogProto()
- : getContainerCommandRequestProto(gid, entry.getStateMachineLogEntry().getLogData());
+ : getContainerCommandRequestProto(getGroupId(), entry.getStateMachineLogEntry().getLogData());
if (requestProto.getCmdType() != Type.WriteChunk) {
throw new IllegalStateException("Cmd type:" + requestProto.getCmdType()
@@ -876,7 +872,7 @@ public CompletableFuture read(LogEntryProto entry, TransactionContex
return future;
} catch (Exception e) {
metrics.incNumReadStateMachineFails();
- LOG.error("{} unable to read stateMachineData:", gid, e);
+ LOG.error("{} unable to read stateMachineData:", getGroupId(), e);
return completeExceptionally(e);
}
}
@@ -922,7 +918,7 @@ public void notifyServerShutdown(RaftProtos.RoleInfoProto roleInfo, boolean allS
// from `HddsDatanodeService.stop()`, otherwise, it indicates this `close` originates from ratis.
if (allServer) {
if (datanodeService != null && !datanodeService.isStopped()) {
- LOG.info("{} is closed by ratis", gid);
+ LOG.info("{} is closed by ratis", getGroupId());
if (semaphore.tryAcquire()) {
// run with a different thread, so this raft group can be closed
Runnable runnable = () -> {
@@ -954,7 +950,7 @@ public void notifyServerShutdown(RaftProtos.RoleInfoProto roleInfo, boolean allS
CompletableFuture.runAsync(runnable);
}
} else {
- LOG.info("{} is closed by HddsDatanodeService", gid);
+ LOG.info("{} is closed by HddsDatanodeService", getGroupId());
}
}
}
@@ -985,7 +981,7 @@ private CompletableFuture applyTransaction(
private void removeStateMachineDataIfNeeded(long index) {
if (waitOnBothFollowers) {
try {
- RaftServer.Division division = ratisServer.getServer().getDivision(gid);
+ RaftServer.Division division = ratisServer.getServer().getDivision(getGroupId());
if (division.getInfo().isLeader()) {
long minIndex = Arrays.stream(division.getInfo()
.getFollowerNextIndices()).min().getAsLong();
@@ -1043,7 +1039,7 @@ public CompletableFuture applyTransaction(TransactionContext trx) {
CompletableFuture applyTransactionFuture =
new CompletableFuture<>();
final Consumer exceptionHandler = e -> {
- LOG.error(gid + ": failed to applyTransaction at logIndex " + index
+ LOG.error(getGroupId() + ": failed to applyTransaction at logIndex " + index
+ " for " + requestProto.getCmdType(), e);
stateMachineHealthy.compareAndSet(true, false);
metrics.incNumApplyTransactionsFails();
@@ -1071,7 +1067,7 @@ public CompletableFuture applyTransaction(TransactionContext trx) {
new StorageContainerException(r.getMessage(), r.getResult());
LOG.error(
"gid {} : ApplyTransaction failed. cmd {} logIndex {} msg : "
- + "{} Container Result: {}", gid, r.getCmdType(), index,
+ + "{} Container Result: {}", getGroupId(), r.getCmdType(), index,
r.getMessage(), r.getResult());
metrics.incNumApplyTransactionsFails();
// Since the applyTransaction now is completed exceptionally,
@@ -1080,12 +1076,12 @@ public CompletableFuture applyTransaction(TransactionContext trx) {
// shutdown.
applyTransactionFuture.completeExceptionally(sce);
stateMachineHealthy.compareAndSet(true, false);
- ratisServer.handleApplyTransactionFailure(gid, trx.getServerRole());
+ ratisServer.handleApplyTransactionFailure(getGroupId(), trx.getServerRole());
} else {
if (LOG.isDebugEnabled()) {
LOG.debug(
"gid {} : ApplyTransaction completed. cmd {} logIndex {} msg : "
- + "{} Container Result: {}", gid, r.getCmdType(), index,
+ + "{} Container Result: {}", getGroupId(), r.getCmdType(), index,
r.getMessage(), r.getResult());
}
if (cmdType == Type.WriteChunk || cmdType == Type.PutSmallFile) {
@@ -1162,26 +1158,26 @@ public void evictStateMachineCache() {
}
@Override
- public void notifyFollowerSlowness(RoleInfoProto roleInfoProto) {
- ratisServer.handleNodeSlowness(gid, roleInfoProto);
+ public void notifyFollowerSlowness(RoleInfoProto roleInfoProto, RaftPeer follower) {
+ ratisServer.handleFollowerSlowness(getGroupId(), roleInfoProto, follower);
}
@Override
public void notifyExtendedNoLeader(RoleInfoProto roleInfoProto) {
- ratisServer.handleNoLeader(gid, roleInfoProto);
+ ratisServer.handleNoLeader(getGroupId(), roleInfoProto);
}
@Override
public void notifyLogFailed(Throwable t, LogEntryProto failedEntry) {
- LOG.error("{}: {} {}", gid, TermIndex.valueOf(failedEntry),
+ LOG.error("{}: {} {}", getGroupId(), TermIndex.valueOf(failedEntry),
toStateMachineLogEntryString(failedEntry.getStateMachineLogEntry()), t);
- ratisServer.handleNodeLogFailure(gid, t);
+ ratisServer.handleNodeLogFailure(getGroupId(), t);
}
@Override
public CompletableFuture notifyInstallSnapshotFromLeader(
RoleInfoProto roleInfoProto, TermIndex firstTermIndexInLog) {
- ratisServer.handleInstallSnapshotFromLeader(gid, roleInfoProto,
+ ratisServer.handleInstallSnapshotFromLeader(getGroupId(), roleInfoProto,
firstTermIndexInLog);
final CompletableFuture future = new CompletableFuture<>();
future.complete(firstTermIndexInLog);
@@ -1190,7 +1186,7 @@ public CompletableFuture notifyInstallSnapshotFromLeader(
@Override
public void notifyGroupRemove() {
- ratisServer.notifyGroupRemove(gid);
+ ratisServer.notifyGroupRemove(getGroupId());
// Make best effort to quasi-close all the containers on group removal.
// Containers already in terminal state like CLOSED or UNHEALTHY will not
// be affected.
@@ -1198,7 +1194,7 @@ public void notifyGroupRemove() {
try {
containerController.markContainerForClose(cid);
containerController.quasiCloseContainer(cid,
- "Ratis group removed. Group id: " + gid);
+ "Ratis group removed. Group id: " + getGroupId());
} catch (IOException e) {
LOG.debug("Failed to quasi-close container {}", cid);
}
@@ -1220,7 +1216,7 @@ public void notifyLeaderChanged(RaftGroupMemberId groupMemberId,
@Override
public String toStateMachineLogEntryString(StateMachineLogEntryProto proto) {
- return smProtoToString(gid, containerController, proto);
+ return smProtoToString(getGroupId(), containerController, proto);
}
public static String smProtoToString(RaftGroupId gid,
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java
index 7899cdcc0e67..a4c143439852 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java
@@ -104,6 +104,7 @@
import org.apache.ratis.server.RaftServerRpc;
import org.apache.ratis.server.protocol.TermIndex;
import org.apache.ratis.server.storage.RaftStorage;
+import org.apache.ratis.util.Preconditions;
import org.apache.ratis.util.SizeInBytes;
import org.apache.ratis.util.TimeDuration;
import org.apache.ratis.util.TraditionalBinaryPrefix;
@@ -161,19 +162,18 @@ private static long nextCallId() {
private int clientPort;
private int dataStreamPort;
private final RaftServer server;
+ private final String name;
private final List chunkExecutors;
private final ContainerDispatcher dispatcher;
private final ContainerController containerController;
private final ClientId clientId = ClientId.randomId();
private final StateContext context;
- private final long nodeFailureTimeoutMs;
private boolean isStarted = false;
private final DatanodeDetails datanodeDetails;
private final ConfigurationSource conf;
// TODO: Remove the gids set when Ratis supports an api to query active
// pipelines
private final ConcurrentMap activePipelines = new ConcurrentHashMap<>();
- private final RaftPeerId raftPeerId;
// Timeout used while calling submitRequest directly.
private final long requestTimeout;
private final boolean shouldDeleteRatisLogDirectory;
@@ -197,14 +197,14 @@ private XceiverServerRatis(HddsDatanodeService hddsDatanodeService, DatanodeDeta
this.context = context;
this.dispatcher = dispatcher;
this.containerController = containerController;
- this.raftPeerId = RatisHelper.toRaftPeerId(dd);
String threadNamePrefix = datanodeDetails.threadNamePrefix();
chunkExecutors = createChunkExecutors(conf, threadNamePrefix);
- nodeFailureTimeoutMs = ratisServerConfig.getFollowerSlownessTimeout();
shouldDeleteRatisLogDirectory =
ratisServerConfig.shouldDeleteRatisLogDirectory();
RaftProperties serverProperties = newRaftProperties();
+ final RaftPeerId raftPeerId = RatisHelper.toRaftPeerId(dd);
+ this.name = getClass().getSimpleName() + "(" + raftPeerId + ")";
this.server =
RaftServer.newBuilder().setServerId(raftPeerId)
.setProperties(serverProperties)
@@ -474,7 +474,7 @@ private void setStateMachineDataConfigurations(RaftProperties properties) {
// NOTE : the default value for the retry count in ratis is -1,
// which means retry indefinitely.
- int syncTimeoutRetryDefault = (int) nodeFailureTimeoutMs /
+ final int syncTimeoutRetryDefault = (int) ratisServerConfig.getFollowerSlownessTimeout() /
dataSyncTimeout.toIntExact(TimeUnit.MILLISECONDS);
int numSyncRetries = conf.getInt(
OzoneConfigKeys.HDDS_CONTAINER_RATIS_STATEMACHINEDATA_SYNC_RETRIES,
@@ -558,7 +558,7 @@ private static Parameters createTlsParameters(SecurityConfig conf,
@Override
public void start() throws IOException {
if (!isStarted) {
- LOG.info("Starting {} {}", getClass().getSimpleName(), server.getId());
+ LOG.info("Starting {}", name);
for (ThreadPoolExecutor executor : chunkExecutors) {
executor.prestartAllCoreThreads();
}
@@ -581,11 +581,11 @@ public void start() throws IOException {
}
}
- private int getRealPort(InetSocketAddress address, Port.Name name) {
+ private int getRealPort(InetSocketAddress address, Port.Name portName) {
int realPort = address.getPort();
- datanodeDetails.setPort(DatanodeDetails.newPort(name, realPort));
- LOG.info("{} {} is started using port {} for {}",
- getClass().getSimpleName(), server.getId(), realPort, name);
+ final Port port = DatanodeDetails.newPort(portName, realPort);
+ datanodeDetails.setPort(port);
+ LOG.info("{} is started using port {}", name, port);
return realPort;
}
@@ -593,7 +593,7 @@ private int getRealPort(InetSocketAddress address, Port.Name name) {
public void stop() {
if (isStarted) {
try {
- LOG.info("Stopping {} {}", getClass().getSimpleName(), server.getId());
+ LOG.info("Closing {}", name);
// shutdown server before the executors as while shutting down,
// some of the tasks would be executed using the executors.
server.close();
@@ -602,7 +602,7 @@ public void stop() {
}
isStarted = false;
} catch (IOException e) {
- LOG.error("XceiverServerRatis Could not be stopped gracefully.", e);
+ LOG.error("Failed to close {}.", name, e);
}
}
}
@@ -706,45 +706,40 @@ private GroupInfoRequest createGroupInfoRequest(
nextCallId());
}
- private void handlePipelineFailure(RaftGroupId groupId,
- RoleInfoProto roleInfoProto) {
- String msg;
- UUID datanode = RatisHelper.toDatanodeId(roleInfoProto.getSelf());
- RaftPeerId id = RaftPeerId.valueOf(roleInfoProto.getSelf().getId());
+ private void handlePipelineFailure(RaftGroupId groupId, RoleInfoProto roleInfoProto, String reason) {
+ final RaftPeerId raftPeerId = RaftPeerId.valueOf(roleInfoProto.getSelf().getId());
+ Preconditions.assertEquals(getServer().getId(), raftPeerId, "raftPeerId");
+ final StringBuilder b = new StringBuilder()
+ .append(name).append(" with datanodeId ").append(RatisHelper.toDatanodeId(raftPeerId))
+ .append("handlePipelineFailure ").append(" for ").append(reason)
+ .append(": ").append(roleInfoProto.getRole())
+ .append(" elapsed time=").append(roleInfoProto.getRoleElapsedTimeMs()).append("ms");
+
switch (roleInfoProto.getRole()) {
case CANDIDATE:
- msg = datanode + " is in candidate state for " +
- roleInfoProto.getCandidateInfo().getLastLeaderElapsedTimeMs() + "ms";
+ final long lastLeaderElapsedTime = roleInfoProto.getCandidateInfo().getLastLeaderElapsedTimeMs();
+ b.append(", lastLeaderElapsedTime=").append(lastLeaderElapsedTime).append("ms");
break;
case FOLLOWER:
- msg = datanode + " closes pipeline when installSnapshot from leader " +
- "because leader snapshot doesn't contain any data to replay, " +
- "all the log entries prior to the snapshot might have been purged." +
- "So follower should not try to install snapshot from leader but" +
- "can close the pipeline here. It's in follower state for " +
- roleInfoProto.getRoleElapsedTimeMs() + "ms";
+ b.append(", outstandingOp=").append(roleInfoProto.getFollowerInfo().getOutstandingOp());
break;
case LEADER:
- StringBuilder sb = new StringBuilder();
- sb.append(datanode).append(" has not seen follower/s");
- for (RaftProtos.ServerRpcProto follower : roleInfoProto.getLeaderInfo()
- .getFollowerInfoList()) {
- if (follower.getLastRpcElapsedTimeMs() > nodeFailureTimeoutMs) {
- sb.append(" ").append(RatisHelper.toDatanodeId(follower.getId()))
- .append(" for ").append(follower.getLastRpcElapsedTimeMs())
- .append("ms");
- }
+ final long followerSlownessTimeoutMs = ratisServerConfig.getFollowerSlownessTimeout();
+ for (RaftProtos.ServerRpcProto follower : roleInfoProto.getLeaderInfo().getFollowerInfoList()) {
+ final long lastRpcElapsedTimeMs = follower.getLastRpcElapsedTimeMs();
+ final boolean slow = lastRpcElapsedTimeMs > followerSlownessTimeoutMs;
+ final RaftPeerId followerId = RaftPeerId.valueOf(follower.getId().getId());
+ b.append("\n Follower ").append(followerId)
+ .append(" with datanodeId ").append(RatisHelper.toDatanodeId(followerId))
+ .append(" is ").append(slow ? "slow" : " responding")
+ .append(" with lastRpcElapsedTime=").append(lastRpcElapsedTimeMs).append("ms");
}
- msg = sb.toString();
break;
default:
- LOG.error("unknown state: {}", roleInfoProto.getRole());
- throw new IllegalStateException("node" + id + " is in illegal role "
- + roleInfoProto.getRole());
+ throw new IllegalStateException("Unexpected role " + roleInfoProto.getRole());
}
- triggerPipelineClose(groupId, msg,
- ClosePipelineInfo.Reason.PIPELINE_FAILED);
+ triggerPipelineClose(groupId, b.toString(), ClosePipelineInfo.Reason.PIPELINE_FAILED);
}
private void triggerPipelineClose(RaftGroupId groupId, String detail,
@@ -869,12 +864,12 @@ public void removeGroup(HddsProtos.PipelineID pipelineId)
processReply(reply);
}
- void handleNodeSlowness(RaftGroupId groupId, RoleInfoProto roleInfoProto) {
- handlePipelineFailure(groupId, roleInfoProto);
+ void handleFollowerSlowness(RaftGroupId groupId, RoleInfoProto roleInfoProto, RaftPeer follower) {
+ handlePipelineFailure(groupId, roleInfoProto, "slow follower " + follower.getId());
}
void handleNoLeader(RaftGroupId groupId, RoleInfoProto roleInfoProto) {
- handlePipelineFailure(groupId, roleInfoProto);
+ handlePipelineFailure(groupId, roleInfoProto, "no leader");
}
void handleApplyTransactionFailure(RaftGroupId groupId,
@@ -901,10 +896,9 @@ void handleApplyTransactionFailure(RaftGroupId groupId,
void handleInstallSnapshotFromLeader(RaftGroupId groupId,
RoleInfoProto roleInfoProto,
TermIndex firstTermIndexInLog) {
- LOG.warn("Install snapshot notification received from Leader with " +
- "termIndex: {}, terminating pipeline: {}",
+ LOG.warn("handleInstallSnapshotFromLeader for firstTermIndexInLog={}, terminating pipeline: {}",
firstTermIndexInLog, groupId);
- handlePipelineFailure(groupId, roleInfoProto);
+ handlePipelineFailure(groupId, roleInfoProto, "install snapshot notification");
}
/**
@@ -950,7 +944,7 @@ void handleLeaderChangedNotification(RaftGroupMemberId groupMemberId,
LOG.info("Leader change notification received for group: {} with new " +
"leaderId: {}", groupMemberId.getGroupId(), raftPeerId1);
// Save the reported leader to be sent with the report to SCM
- boolean leaderForGroup = this.raftPeerId.equals(raftPeerId1);
+ final boolean leaderForGroup = server.getId().equals(raftPeerId1);
activePipelines.compute(groupMemberId.getGroupId(),
(key, value) -> value == null ? new ActivePipelineContext(leaderForGroup, false) :
new ActivePipelineContext(leaderForGroup, value.isPendingClose()));
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/HddsVolume.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/HddsVolume.java
index a74a23b7fbef..5fced0e39b39 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/HddsVolume.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/HddsVolume.java
@@ -206,7 +206,7 @@ public void shutdown() {
/**
* Delete all files under
- * /hdds//tmp/deleted-containers.
+ * volume/hdds/cluster-id/tmp/deleted-containers.
* This is the directory where containers are moved when they are deleted
* from the system, but before being removed from the filesystem. This
* makes the deletion atomic.
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/VolumeInfo.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/VolumeInfo.java
index af890269255d..3d1be9791ecc 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/VolumeInfo.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/VolumeInfo.java
@@ -46,16 +46,18 @@
* - fsCapacity: reported total capacity from local fs.
* - minVolumeFreeSpace (mvfs) : determines the free space for closing
containers.This is like adding a few reserved bytes to reserved space.
- Dn's will send close container action to SCM at this limit & it is
+ Dn's will send close container action to SCM at this limit, and it is
configurable.
*
- *
+ *
+ * {@code
* |----used----| (avail) |++mvfs++|++++reserved+++++++|
* |<- capacity ->|
* | fsAvail |-------other-----------|
* |<- fsCapacity ->|
- *
+ * }
+ *
* What we could directly get from local fs:
* fsCapacity, fsAvail, (fsUsed = fsCapacity - fsAvail)
* We could get from config:
@@ -78,11 +80,13 @@
* then we should use DedicatedDiskSpaceUsage for
* `hdds.datanode.du.factory.classname`,
* Then it is much simpler, since we don't care about other usage:
- *
+ * {@code
* |----used----| (avail)/fsAvail |
* |<- capacity/fsCapacity ->|
+ * }
*
* We have avail == fsAvail.
+ *
*/
public final class VolumeInfo {
@@ -153,11 +157,14 @@ public long getCapacity() {
}
/**
+ *
+ * {@code
* Calculate available space use method A.
* |----used----| (avail) |++++++++reserved++++++++|
* |<- capacity ->|
- *
* A) avail = capacity - used
+ * }
+ *
*/
public long getAvailable() {
return usage.getAvailable();
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/VolumeUsage.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/VolumeUsage.java
index 7e138b057168..34ba66c91bb2 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/VolumeUsage.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/VolumeUsage.java
@@ -19,6 +19,7 @@
package org.apache.hadoop.ozone.container.common.volume;
import com.google.common.annotations.VisibleForTesting;
+import org.apache.hadoop.hdds.conf.ConfigurationException;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
import org.apache.hadoop.hdds.conf.StorageSize;
import org.apache.hadoop.hdds.conf.StorageUnit;
@@ -77,11 +78,15 @@ public long getUsedSpace() {
}
/**
+ *
+ * {@code
* Calculate available space use method B.
* |----used----| (avail) |++++++++reserved++++++++|
* | fsAvail |-------other-------|
- * ->|~~~~|<-
+ * ->|~~~~|<-
* remainingReserved
+ * }
+ *
* B) avail = fsAvail - Max(reserved - other, 0);
*/
public SpaceUsageSource getCurrentUsage() {
@@ -216,9 +221,8 @@ private static long getReserved(ConfigurationSource conf, String rootDir,
for (String reserve : reserveList) {
String[] words = reserve.split(":");
if (words.length < 2) {
- LOG.error("Reserved space should be configured in a pair, but current value is {}",
- reserve);
- continue;
+ throw new ConfigurationException("hdds.datanode.dir.du.reserved - " +
+ "Reserved space should be configured in a pair, but current value is " + reserve);
}
try {
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ec/reconstruction/ECContainerOperationClient.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ec/reconstruction/ECContainerOperationClient.java
index 487e6d37b282..95b7d06167f5 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ec/reconstruction/ECContainerOperationClient.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ec/reconstruction/ECContainerOperationClient.java
@@ -18,11 +18,13 @@
package org.apache.hadoop.ozone.container.ec.reconstruction;
import com.google.common.collect.ImmutableList;
+import jakarta.annotation.Nonnull;
import org.apache.commons.collections.map.SingletonMap;
import org.apache.hadoop.hdds.client.ECReplicationConfig;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
+import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerDataProto.State;
import org.apache.hadoop.hdds.scm.XceiverClientManager;
import org.apache.hadoop.hdds.scm.XceiverClientSpi;
import org.apache.hadoop.hdds.scm.client.ClientTrustManager;
@@ -34,8 +36,6 @@
import org.apache.hadoop.ozone.container.common.helpers.BlockData;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.TokenIdentifier;
-import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerDataProto.State;
-import jakarta.annotation.Nonnull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,7 +44,6 @@
import java.util.List;
import java.util.Objects;
import java.util.Set;
-import java.util.stream.Collectors;
/**
* This class wraps necessary container-level rpc calls
@@ -93,14 +92,11 @@ public BlockData[] listBlock(long containerId, DatanodeDetails dn,
try {
return BlockData.getFromProtoBuf(i);
} catch (IOException e) {
- LOG.debug("Failed while converting to protobuf BlockData. Returning"
- + " null for listBlock from DN: " + dn,
- e);
+ LOG.debug("Failed while converting to protobuf BlockData. Returning null for listBlock from DN: {}", dn, e);
// TODO: revisit here.
return null;
}
- }).collect(Collectors.toList())
- .toArray(new BlockData[blockDataList.size()]);
+ }).toArray(BlockData[]::new);
} finally {
this.xceiverClientManager.releaseClient(xceiverClient, false);
}
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ec/reconstruction/ECReconstructionCoordinator.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ec/reconstruction/ECReconstructionCoordinator.java
index 8fadd19b67d3..4273ed2b7163 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ec/reconstruction/ECReconstructionCoordinator.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ec/reconstruction/ECReconstructionCoordinator.java
@@ -42,7 +42,6 @@
import org.apache.hadoop.hdds.utils.IOUtils;
import org.apache.hadoop.io.ByteBufferPool;
import org.apache.hadoop.io.ElasticByteBufferPool;
-import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.client.io.BlockInputStreamFactory;
import org.apache.hadoop.ozone.client.io.BlockInputStreamFactoryImpl;
import org.apache.hadoop.ozone.client.io.ECBlockInputStreamProxy;
@@ -370,7 +369,7 @@ private void logBlockGroupDetails(BlockLocationInfo blockLocationInfo,
.append(" block length: ")
.append(data.getSize())
.append(" block group length: ")
- .append(getBlockDataLength(data))
+ .append(data.getBlockGroupLength())
.append(" chunk list: \n");
int cnt = 0;
for (ContainerProtos.ChunkInfo chunkInfo : data.getChunks()) {
@@ -572,7 +571,7 @@ private long calcEffectiveBlockGroupLen(BlockData[] blockGroup,
continue;
}
- long putBlockLen = getBlockDataLength(blockGroup[i]);
+ long putBlockLen = blockGroup[i].getBlockGroupLength();
// Use safe length is the minimum of the lengths recorded across the
// stripe
blockGroupLen = Math.min(putBlockLen, blockGroupLen);
@@ -580,16 +579,6 @@ private long calcEffectiveBlockGroupLen(BlockData[] blockGroup,
return blockGroupLen == Long.MAX_VALUE ? 0 : blockGroupLen;
}
- private long getBlockDataLength(BlockData blockData) {
- String lenStr = blockData.getMetadata()
- .get(OzoneConsts.BLOCK_GROUP_LEN_KEY_IN_PUT_BLOCK);
- // If we don't have the length, then it indicates a problem with the stripe.
- // All replica should carry the length, so if it is not there, we return 0,
- // which will cause us to set the length of the block to zero and not
- // attempt to reconstruct it.
- return (lenStr == null) ? 0 : Long.parseLong(lenStr);
- }
-
public ECReconstructionMetrics getECReconstructionMetrics() {
return this.metrics;
}
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainer.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainer.java
index 98d81c15d0ad..ae3288a3e983 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainer.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainer.java
@@ -932,7 +932,6 @@ private ContainerReplicaProto.State getHddsState()
/**
* Returns container DB file.
- * @return
*/
public File getContainerDBFile() {
return KeyValueContainerLocationUtil.getContainerDBFile(containerData);
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainerData.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainerData.java
index 47d4f3f9e70a..4ea8552e780e 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainerData.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainerData.java
@@ -430,7 +430,6 @@ public KeyPrefixFilter getDeletingBlockKeyFilter() {
/**
* Schema v3 use a prefix as startKey,
* for other schemas just return null.
- * @return
*/
public String startKeyEmpty() {
if (hasSchema(SCHEMA_V3)) {
@@ -442,7 +441,6 @@ public String startKeyEmpty() {
/**
* Schema v3 use containerID as key prefix,
* for other schemas just return null.
- * @return
*/
public String containerPrefix() {
if (hasSchema(SCHEMA_V3)) {
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/helpers/BlockUtils.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/helpers/BlockUtils.java
index 7773b54f7942..945efbcf6ea9 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/helpers/BlockUtils.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/helpers/BlockUtils.java
@@ -99,7 +99,6 @@ public static DatanodeStore getUncachedDatanodeStore(
* opened by this thread, the other thread will get a RocksDB exception.
* @param containerData The container data
* @param conf Configuration
- * @return
* @throws IOException
*/
public static DatanodeStore getUncachedDatanodeStore(
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/helpers/KeyValueContainerUtil.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/helpers/KeyValueContainerUtil.java
index b7d5b5fa59eb..691ccaa630d1 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/helpers/KeyValueContainerUtil.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/helpers/KeyValueContainerUtil.java
@@ -439,13 +439,13 @@ public static boolean isSameSchemaVersion(String schema, String other) {
/**
* Moves container directory to a new location
- * under "/hdds//tmp/deleted-containers"
+ * under "volume/hdds/cluster-id/tmp/deleted-containers"
* and updates metadata and chunks path.
* Containers will be moved under it before getting deleted
* to avoid, in case of failure, having artifact leftovers
* on the default container path on the disk.
*
- * Delete operation for Schema < V3
+ * Delete operation for Schema < V3
* 1. Container is marked DELETED
* 2. Container is removed from memory container set
* 3. Container DB handler from cache is removed and closed
@@ -460,7 +460,6 @@ public static boolean isSameSchemaVersion(String schema, String other) {
* 5. Container is deleted from tmp directory.
*
* @param keyValueContainerData
- * @return true if renaming was successful
*/
public static void moveToDeletedContainerDir(
KeyValueContainerData keyValueContainerData,
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/ChunkManagerFactory.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/ChunkManagerFactory.java
index 288a2d3e3312..aa5d52f3ceeb 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/ChunkManagerFactory.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/ChunkManagerFactory.java
@@ -46,7 +46,6 @@ private ChunkManagerFactory() {
* @param conf Configuration
* @param manager This parameter will be used only for read data of
* FILE_PER_CHUNK layout file. Can be null for other cases.
- * @return
*/
public static ChunkManager createChunkManager(ConfigurationSource conf,
BlockManager manager, VolumeSet volSet) {
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/StreamDataChannelBase.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/StreamDataChannelBase.java
index 8df856d4b93e..601e7b2712c6 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/StreamDataChannelBase.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/StreamDataChannelBase.java
@@ -99,7 +99,9 @@ public void setLinked() {
linked.set(true);
}
- /** @return true iff {@link StateMachine.DataChannel} is already linked. */
+ /**
+ * @return true if {@link org.apache.ratis.statemachine.StateMachine.DataChannel} is already linked.
+ */
public boolean cleanUp() {
if (linked.get()) {
// already linked, nothing to do.
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/AbstractDatanodeStore.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/AbstractDatanodeStore.java
index 26719d7f035a..88aeb3c174dd 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/AbstractDatanodeStore.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/AbstractDatanodeStore.java
@@ -300,9 +300,9 @@ protected static void checkTableStatus(Table, ?> table, String name)
/**
* Block Iterator for KeyValue Container. This block iterator returns blocks
- * which match with the {@link MetadataKeyFilters.KeyPrefixFilter}. If no
+ * which match with the {@link org.apache.hadoop.hdds.utils.MetadataKeyFilters.KeyPrefixFilter}. If no
* filter is specified, then default filter used is
- * {@link MetadataKeyFilters#getUnprefixedKeyFilter()}
+ * {@link org.apache.hadoop.hdds.utils.MetadataKeyFilters#getUnprefixedKeyFilter()}
*/
@InterfaceAudience.Public
public static class KeyValueBlockIterator implements
@@ -405,9 +405,9 @@ public void close() throws IOException {
/**
* Block localId Iterator for KeyValue Container.
* This Block localId iterator returns localIds
- * which match with the {@link MetadataKeyFilters.KeyPrefixFilter}. If no
+ * which match with the {@link org.apache.hadoop.hdds.utils.MetadataKeyFilters.KeyPrefixFilter}. If no
* filter is specified, then default filter used is
- * {@link MetadataKeyFilters#getUnprefixedKeyFilter()}
+ * {@link org.apache.hadoop.hdds.utils.MetadataKeyFilters#getUnprefixedKeyFilter()}
*/
@InterfaceAudience.Public
public static class KeyValueBlockLocalIdIterator implements
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/DatanodeSchemaOneDBDefinition.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/DatanodeSchemaOneDBDefinition.java
index 4f54e85da2b1..bd1c0fb368af 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/DatanodeSchemaOneDBDefinition.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/DatanodeSchemaOneDBDefinition.java
@@ -51,27 +51,21 @@ public class DatanodeSchemaOneDBDefinition
BLOCK_DATA =
new DBColumnFamilyDefinition<>(
StringUtils.bytes2String(DEFAULT_COLUMN_FAMILY),
- String.class,
SchemaOneKeyCodec.get(),
- BlockData.class,
BlockData.getCodec());
public static final DBColumnFamilyDefinition
METADATA =
new DBColumnFamilyDefinition<>(
StringUtils.bytes2String(DEFAULT_COLUMN_FAMILY),
- String.class,
SchemaOneKeyCodec.get(),
- Long.class,
LongCodec.get());
public static final DBColumnFamilyDefinition
DELETED_BLOCKS =
new DBColumnFamilyDefinition<>(
StringUtils.bytes2String(DEFAULT_COLUMN_FAMILY),
- String.class,
SchemaOneKeyCodec.get(),
- ChunkInfoList.class,
SchemaOneChunkInfoListCodec.get());
private static final Map>>
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/DatanodeSchemaThreeDBDefinition.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/DatanodeSchemaThreeDBDefinition.java
index d47446d49b0f..10537ca6f2d3 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/DatanodeSchemaThreeDBDefinition.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/DatanodeSchemaThreeDBDefinition.java
@@ -59,45 +59,35 @@ public class DatanodeSchemaThreeDBDefinition
BLOCK_DATA =
new DBColumnFamilyDefinition<>(
"block_data",
- String.class,
FixedLengthStringCodec.get(),
- BlockData.class,
BlockData.getCodec());
public static final DBColumnFamilyDefinition
METADATA =
new DBColumnFamilyDefinition<>(
"metadata",
- String.class,
FixedLengthStringCodec.get(),
- Long.class,
LongCodec.get());
public static final DBColumnFamilyDefinition
DELETE_TRANSACTION =
new DBColumnFamilyDefinition<>(
"delete_txns",
- String.class,
FixedLengthStringCodec.get(),
- DeletedBlocksTransaction.class,
Proto2Codec.get(DeletedBlocksTransaction.getDefaultInstance()));
public static final DBColumnFamilyDefinition
FINALIZE_BLOCKS =
new DBColumnFamilyDefinition<>(
"finalize_blocks",
- String.class,
FixedLengthStringCodec.get(),
- Long.class,
LongCodec.get());
public static final DBColumnFamilyDefinition
LAST_CHUNK_INFO =
new DBColumnFamilyDefinition<>(
"last_chunk_info",
- String.class,
FixedLengthStringCodec.get(),
- BlockData.class,
BlockData.getCodec());
private static String separator = "";
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/DatanodeSchemaTwoDBDefinition.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/DatanodeSchemaTwoDBDefinition.java
index b9e7ec7bd5bf..bf6b1d0a29ca 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/DatanodeSchemaTwoDBDefinition.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/DatanodeSchemaTwoDBDefinition.java
@@ -18,7 +18,6 @@
package org.apache.hadoop.ozone.container.metadata;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
-import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos;
import org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition;
import org.apache.hadoop.hdds.utils.db.DBDefinition;
import org.apache.hadoop.hdds.utils.db.FixedLengthStringCodec;
@@ -44,45 +43,35 @@ public class DatanodeSchemaTwoDBDefinition
BLOCK_DATA =
new DBColumnFamilyDefinition<>(
"block_data",
- String.class,
StringCodec.get(),
- BlockData.class,
BlockData.getCodec());
public static final DBColumnFamilyDefinition
METADATA =
new DBColumnFamilyDefinition<>(
"metadata",
- String.class,
StringCodec.get(),
- Long.class,
LongCodec.get());
public static final DBColumnFamilyDefinition
DELETE_TRANSACTION =
new DBColumnFamilyDefinition<>(
"delete_txns",
- Long.class,
LongCodec.get(),
- StorageContainerDatanodeProtocolProtos.DeletedBlocksTransaction.class,
Proto2Codec.get(DeletedBlocksTransaction.getDefaultInstance()));
public static final DBColumnFamilyDefinition
FINALIZE_BLOCKS =
new DBColumnFamilyDefinition<>(
"finalize_blocks",
- String.class,
FixedLengthStringCodec.get(),
- Long.class,
LongCodec.get());
public static final DBColumnFamilyDefinition
LAST_CHUNK_INFO =
new DBColumnFamilyDefinition<>(
"last_chunk_info",
- String.class,
FixedLengthStringCodec.get(),
- BlockData.class,
BlockData.getCodec());
public DatanodeSchemaTwoDBDefinition(String dbPath,
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/SchemaOneChunkInfoListCodec.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/SchemaOneChunkInfoListCodec.java
index 4beb20754322..25a49eaabe4f 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/SchemaOneChunkInfoListCodec.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/SchemaOneChunkInfoListCodec.java
@@ -25,7 +25,8 @@
import java.io.IOException;
/**
- * Codec for parsing {@link ContainerProtos.ChunkInfoList} objects from data
+ * Codec for parsing {@link org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ChunkInfoList}
+ * objects from data
* that may have been written using schema version one. Before upgrading
* schema versions, deleted block IDs were stored with a duplicate copy of
* their ID as the value in the database. After upgrading the code, any
@@ -56,6 +57,11 @@ private SchemaOneChunkInfoListCodec() {
// singleton
}
+ @Override
+ public Class getTypeClass() {
+ return ChunkInfoList.class;
+ }
+
@Override
public byte[] toPersistedFormat(ChunkInfoList chunkList) {
return chunkList.getProtoBufMessage().toByteArray();
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/SchemaOneKeyCodec.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/SchemaOneKeyCodec.java
index 2f1660f4d2e2..add24874a312 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/SchemaOneKeyCodec.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/SchemaOneKeyCodec.java
@@ -48,6 +48,11 @@ private SchemaOneKeyCodec() {
// singleton
}
+ @Override
+ public Class getTypeClass() {
+ return String.class;
+ }
+
@Override
public byte[] toPersistedFormat(String stringObject) throws IOException {
try {
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/ContainerController.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/ContainerController.java
index 9ddf8084e3bb..567741a98d8b 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/ContainerController.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/ContainerController.java
@@ -163,7 +163,6 @@ public void closeContainer(final long containerId) throws IOException {
* Returns the Container given a container id.
*
* @param containerId ID of the container
- * @return Container
*/
public void addFinalizedBlock(final long containerId,
final long localId) {
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/OzoneContainer.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/OzoneContainer.java
index 508176c25274..d06276285051 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/OzoneContainer.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/OzoneContainer.java
@@ -490,10 +490,10 @@ public void start(String clusterId) throws IOException {
replicationServer.start();
datanodeDetails.setPort(Name.REPLICATION, replicationServer.getPort());
- writeChannel.start();
- readChannel.start();
hddsDispatcher.init();
hddsDispatcher.setClusterId(clusterId);
+ writeChannel.start();
+ readChannel.start();
blockDeletingService.start();
recoveringContainerScrubbingService.start();
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/ReplicationSupervisor.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/ReplicationSupervisor.java
index 92ff4b6d8d61..9513cac84efe 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/ReplicationSupervisor.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/ReplicationSupervisor.java
@@ -43,6 +43,8 @@
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ReplicationCommandPriority;
+import org.apache.hadoop.metrics2.lib.MetricsRegistry;
+import org.apache.hadoop.metrics2.lib.MutableRate;
import org.apache.hadoop.ozone.container.common.statemachine.DatanodeConfiguration;
import org.apache.hadoop.ozone.container.common.statemachine.StateContext;
import org.apache.hadoop.ozone.container.replication.ReplicationServer.ReplicationConfig;
@@ -50,6 +52,7 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import org.apache.hadoop.util.Time;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -77,6 +80,10 @@ public final class ReplicationSupervisor {
private final Map failureCounter = new ConcurrentHashMap<>();
private final Map timeoutCounter = new ConcurrentHashMap<>();
private final Map skippedCounter = new ConcurrentHashMap<>();
+ private final Map queuedCounter = new ConcurrentHashMap<>();
+
+ private final MetricsRegistry registry;
+ private final Map opsLatencyMs = new ConcurrentHashMap<>();
private static final Map METRICS_MAP;
@@ -218,6 +225,7 @@ private ReplicationSupervisor(StateContext context, ExecutorService executor,
nodeStateUpdated(dn.getPersistedOpState());
}
}
+ registry = new MetricsRegistry(ReplicationSupervisor.class.getSimpleName());
}
/**
@@ -240,6 +248,9 @@ public void addTask(AbstractReplicationTask task) {
failureCounter.put(task.getMetricName(), new AtomicLong(0));
timeoutCounter.put(task.getMetricName(), new AtomicLong(0));
skippedCounter.put(task.getMetricName(), new AtomicLong(0));
+ queuedCounter.put(task.getMetricName(), new AtomicLong(0));
+ opsLatencyMs.put(task.getMetricName(), registry.newRate(
+ task.getClass().getSimpleName() + "Ms"));
METRICS_MAP.put(task.getMetricName(), task.getMetricDescriptionSegment());
}
}
@@ -253,6 +264,7 @@ public void addTask(AbstractReplicationTask task) {
taskCounter.computeIfAbsent(task.getClass(),
k -> new AtomicInteger()).incrementAndGet();
}
+ queuedCounter.get(task.getMetricName()).incrementAndGet();
executor.execute(new TaskRunner(task));
}
}
@@ -353,6 +365,7 @@ public TaskRunner(AbstractReplicationTask task) {
@Override
public void run() {
+ final long startTime = Time.monotonicNow();
try {
requestCounter.get(task.getMetricName()).incrementAndGet();
@@ -401,6 +414,8 @@ public void run() {
LOG.warn("Failed {}", this, e);
failureCounter.get(task.getMetricName()).incrementAndGet();
} finally {
+ queuedCounter.get(task.getMetricName()).decrementAndGet();
+ opsLatencyMs.get(task.getMetricName()).add(Time.monotonicNow() - startTime);
inFlight.remove(task);
decrementTaskCounter(task);
}
@@ -511,4 +526,22 @@ public long getReplicationSkippedCount(String metricsName) {
return counter != null ? counter.get() : 0;
}
+ public long getReplicationQueuedCount() {
+ return getCount(queuedCounter);
+ }
+
+ public long getReplicationQueuedCount(String metricsName) {
+ AtomicLong counter = queuedCounter.get(metricsName);
+ return counter != null ? counter.get() : 0;
+ }
+
+ public long getReplicationRequestAvgTime(String metricsName) {
+ MutableRate rate = opsLatencyMs.get(metricsName);
+ return rate != null ? (long) rate.lastStat().mean() : 0;
+ }
+
+ public long getReplicationRequestTotalTime(String metricsName) {
+ MutableRate rate = opsLatencyMs.get(metricsName);
+ return rate != null ? (long) rate.lastStat().total() : 0;
+ }
}
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/ReplicationSupervisorMetrics.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/ReplicationSupervisorMetrics.java
index a1763976af99..cd1103a0c463 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/ReplicationSupervisorMetrics.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/ReplicationSupervisorMetrics.java
@@ -67,7 +67,7 @@ public void getMetrics(MetricsCollector collector, boolean all) {
supervisor.getTotalInFlightReplications())
.addGauge(Interns.info("numQueuedReplications",
"Number of replications in queue"),
- supervisor.getQueueSize())
+ supervisor.getReplicationQueuedCount())
.addGauge(Interns.info("numRequestedReplications",
"Number of requested replications"),
supervisor.getReplicationRequestCount())
@@ -107,7 +107,10 @@ public void getMetrics(MetricsCollector collector, boolean all) {
.addGauge(Interns.info("numSkipped" + metricsName,
"Number of " + descriptionSegment + " skipped as the container is "
+ "already present"),
- supervisor.getReplicationSkippedCount(metricsName));
+ supervisor.getReplicationSkippedCount(metricsName))
+ .addGauge(Interns.info("numQueued" + metricsName,
+ "Number of " + descriptionSegment + " in queue"),
+ supervisor.getReplicationQueuedCount(metricsName));
}
});
}
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/stream/StreamingSource.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/stream/StreamingSource.java
index 5fdfc931b99c..e49f3c3d6e5c 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/stream/StreamingSource.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/stream/StreamingSource.java
@@ -27,9 +27,9 @@ public interface StreamingSource {
/**
*
- * @param id: custom identifier
+ * @param id custom identifier
*
- * @return map of files which should be copied (logical name -> real path)
+ * @return map of files which should be copied (logical name -> real path)
*/
Map getFilesToStream(String id) throws InterruptedException;
diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/protocolPB/StorageContainerDatanodeProtocolClientSideTranslatorPB.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/protocolPB/StorageContainerDatanodeProtocolClientSideTranslatorPB.java
index eeb99b5a3db2..d6b44f2a6416 100644
--- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/protocolPB/StorageContainerDatanodeProtocolClientSideTranslatorPB.java
+++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/protocolPB/StorageContainerDatanodeProtocolClientSideTranslatorPB.java
@@ -122,7 +122,6 @@ private SCMDatanodeResponse submitRequest(Type type,
/**
* Returns SCM version.
*
- * @param unused - set to null and unused.
* @return Version info.
*/
@Override
diff --git a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestReconstructECContainersCommandHandler.java b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestReconstructECContainersCommandHandler.java
new file mode 100644
index 000000000000..7e6c76081803
--- /dev/null
+++ b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestReconstructECContainersCommandHandler.java
@@ -0,0 +1,139 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.container.common.statemachine.commandhandler;
+
+import com.google.protobuf.ByteString;
+import com.google.protobuf.Proto2Utils;
+import org.apache.hadoop.hdds.client.ECReplicationConfig;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.protocol.DatanodeDetails;
+import org.apache.hadoop.hdds.protocol.MockDatanodeDetails;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMCommandProto;
+import org.apache.hadoop.metrics2.impl.MetricsCollectorImpl;
+import org.apache.hadoop.ozone.container.common.helpers.CommandHandlerMetrics;
+import org.apache.hadoop.ozone.container.common.statemachine.SCMConnectionManager;
+import org.apache.hadoop.ozone.container.common.statemachine.StateContext;
+import org.apache.hadoop.ozone.container.ec.reconstruction.ECReconstructionCoordinator;
+import org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer;
+import org.apache.hadoop.ozone.container.replication.ReplicationSupervisor;
+import org.apache.hadoop.ozone.protocol.commands.ReconstructECContainersCommand;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.when;
+
+/**
+ * Test cases to verify {@link ReconstructECContainersCommandHandler}.
+ */
+public class TestReconstructECContainersCommandHandler {
+ private OzoneConfiguration conf;
+ private ReplicationSupervisor supervisor;
+ private ECReconstructionCoordinator coordinator;
+ private OzoneContainer ozoneContainer;
+ private StateContext stateContext;
+ private SCMConnectionManager connectionManager;
+
+ @BeforeEach
+ public void setUp() {
+ supervisor = mock(ReplicationSupervisor.class);
+ coordinator = mock(ECReconstructionCoordinator.class);
+ conf = new OzoneConfiguration();
+ ozoneContainer = mock(OzoneContainer.class);
+ connectionManager = mock(SCMConnectionManager.class);
+ stateContext = mock(StateContext.class);
+ }
+
+ @Test
+ public void testMetrics() {
+ ReconstructECContainersCommandHandler commandHandler =
+ new ReconstructECContainersCommandHandler(conf, supervisor, coordinator);
+ doNothing().when(supervisor).addTask(any());
+ Map handlerMap = new HashMap<>();
+ handlerMap.put(commandHandler.getCommandType(), commandHandler);
+ CommandHandlerMetrics metrics = CommandHandlerMetrics.create(handlerMap);
+ try {
+ byte[] missingIndexes = {1, 2};
+ ByteString missingContainerIndexes = Proto2Utils.unsafeByteString(missingIndexes);
+ ECReplicationConfig ecReplicationConfig = new ECReplicationConfig(3, 2);
+ List dnDetails = getDNDetails(5);
+ List sources =
+ dnDetails.stream().map(a -> new ReconstructECContainersCommand
+ .DatanodeDetailsAndReplicaIndex(a, dnDetails.indexOf(a)))
+ .collect(Collectors.toList());
+ List targets = getDNDetails(2);
+ ReconstructECContainersCommand reconstructECContainersCommand =
+ new ReconstructECContainersCommand(1L, sources, targets,
+ missingContainerIndexes, ecReplicationConfig);
+
+ commandHandler.handle(reconstructECContainersCommand, ozoneContainer,
+ stateContext, connectionManager);
+ String metricsName = "ECReconstructions";
+ assertEquals(commandHandler.getMetricsName(), metricsName);
+ when(supervisor.getReplicationRequestCount(metricsName)).thenReturn(1L);
+ assertEquals(commandHandler.getInvocationCount(), 1);
+
+ commandHandler.handle(new ReconstructECContainersCommand(2L, sources,
+ targets, missingContainerIndexes, ecReplicationConfig), ozoneContainer,
+ stateContext, connectionManager);
+ commandHandler.handle(new ReconstructECContainersCommand(3L, sources,
+ targets, missingContainerIndexes, ecReplicationConfig), ozoneContainer,
+ stateContext, connectionManager);
+ commandHandler.handle(new ReconstructECContainersCommand(4L, sources,
+ targets, missingContainerIndexes, ecReplicationConfig), ozoneContainer,
+ stateContext, connectionManager);
+ commandHandler.handle(new ReconstructECContainersCommand(5L, sources,
+ targets, missingContainerIndexes, ecReplicationConfig), ozoneContainer,
+ stateContext, connectionManager);
+ commandHandler.handle(new ReconstructECContainersCommand(6L, sources,
+ targets, missingContainerIndexes, ecReplicationConfig), ozoneContainer,
+ stateContext, connectionManager);
+
+ when(supervisor.getReplicationRequestCount(metricsName)).thenReturn(5L);
+ when(supervisor.getReplicationRequestTotalTime(metricsName)).thenReturn(10L);
+ when(supervisor.getReplicationRequestAvgTime(metricsName)).thenReturn(2L);
+ when(supervisor.getReplicationQueuedCount(metricsName)).thenReturn(1L);
+ assertEquals(commandHandler.getInvocationCount(), 5);
+ assertEquals(commandHandler.getQueuedCount(), 1);
+ assertEquals(commandHandler.getTotalRunTime(), 10);
+ assertEquals(commandHandler.getAverageRunTime(), 2);
+
+ MetricsCollectorImpl metricsCollector = new MetricsCollectorImpl();
+ metrics.getMetrics(metricsCollector, true);
+ assertEquals(1, metricsCollector.getRecords().size());
+ } finally {
+ metrics.unRegister();
+ }
+ }
+
+ private List getDNDetails(int numDns) {
+ List dns = new ArrayList<>();
+ for (int i = 0; i < numDns; i++) {
+ dns.add(MockDatanodeDetails.randomDatanodeDetails());
+ }
+ return dns;
+ }
+}
diff --git a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestReplicateContainerCommandHandler.java b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestReplicateContainerCommandHandler.java
new file mode 100644
index 000000000000..9de00877e5be
--- /dev/null
+++ b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestReplicateContainerCommandHandler.java
@@ -0,0 +1,118 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.container.common.statemachine.commandhandler;
+
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.protocol.DatanodeDetails;
+import org.apache.hadoop.hdds.protocol.MockDatanodeDetails;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMCommandProto;
+import org.apache.hadoop.metrics2.impl.MetricsCollectorImpl;
+import org.apache.hadoop.ozone.container.common.helpers.CommandHandlerMetrics;
+import org.apache.hadoop.ozone.container.common.statemachine.SCMConnectionManager;
+import org.apache.hadoop.ozone.container.common.statemachine.StateContext;
+import org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer;
+import org.apache.hadoop.ozone.container.replication.ContainerReplicator;
+import org.apache.hadoop.ozone.container.replication.ReplicationSupervisor;
+import org.apache.hadoop.ozone.protocol.commands.ReplicateContainerCommand;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.doNothing;
+
+/**
+ * Test cases to verify {@link ReplicateContainerCommandHandler}.
+ */
+public class TestReplicateContainerCommandHandler {
+ private OzoneConfiguration conf;
+ private ReplicationSupervisor supervisor;
+ private ContainerReplicator downloadReplicator;
+ private ContainerReplicator pushReplicator;
+ private OzoneContainer ozoneContainer;
+ private StateContext stateContext;
+ private SCMConnectionManager connectionManager;
+
+ @BeforeEach
+ public void setUp() {
+ conf = new OzoneConfiguration();
+ supervisor = mock(ReplicationSupervisor.class);
+ downloadReplicator = mock(ContainerReplicator.class);
+ pushReplicator = mock(ContainerReplicator.class);
+ ozoneContainer = mock(OzoneContainer.class);
+ connectionManager = mock(SCMConnectionManager.class);
+ stateContext = mock(StateContext.class);
+ }
+
+ @Test
+ public void testMetrics() {
+ ReplicateContainerCommandHandler commandHandler =
+ new ReplicateContainerCommandHandler(conf, supervisor,
+ downloadReplicator, pushReplicator);
+ Map handlerMap = new HashMap<>();
+ handlerMap.put(commandHandler.getCommandType(), commandHandler);
+ CommandHandlerMetrics metrics = CommandHandlerMetrics.create(handlerMap);
+ try {
+ doNothing().when(supervisor).addTask(any());
+ DatanodeDetails source = MockDatanodeDetails.randomDatanodeDetails();
+ DatanodeDetails target = MockDatanodeDetails.randomDatanodeDetails();
+ List sourceList = new ArrayList<>();
+ sourceList.add(source);
+
+ ReplicateContainerCommand command = ReplicateContainerCommand.fromSources(
+ 1, sourceList);
+ commandHandler.handle(command, ozoneContainer, stateContext, connectionManager);
+ String metricsName = "ContainerReplications";
+ assertEquals(commandHandler.getMetricsName(), metricsName);
+ when(supervisor.getReplicationRequestCount(metricsName)).thenReturn(1L);
+ assertEquals(commandHandler.getInvocationCount(), 1);
+
+ commandHandler.handle(ReplicateContainerCommand.fromSources(2, sourceList),
+ ozoneContainer, stateContext, connectionManager);
+ commandHandler.handle(ReplicateContainerCommand.fromSources(3, sourceList),
+ ozoneContainer, stateContext, connectionManager);
+ commandHandler.handle(ReplicateContainerCommand.toTarget(4, target),
+ ozoneContainer, stateContext, connectionManager);
+ commandHandler.handle(ReplicateContainerCommand.toTarget(5, target),
+ ozoneContainer, stateContext, connectionManager);
+ commandHandler.handle(ReplicateContainerCommand.fromSources(6, sourceList),
+ ozoneContainer, stateContext, connectionManager);
+
+ when(supervisor.getReplicationRequestCount(metricsName)).thenReturn(5L);
+ when(supervisor.getReplicationRequestTotalTime(metricsName)).thenReturn(10L);
+ when(supervisor.getReplicationRequestAvgTime(metricsName)).thenReturn(3L);
+ when(supervisor.getReplicationQueuedCount(metricsName)).thenReturn(1L);
+ assertEquals(commandHandler.getInvocationCount(), 5);
+ assertEquals(commandHandler.getQueuedCount(), 1);
+ assertEquals(commandHandler.getTotalRunTime(), 10);
+ assertEquals(commandHandler.getAverageRunTime(), 3);
+
+ MetricsCollectorImpl metricsCollector = new MetricsCollectorImpl();
+ metrics.getMetrics(metricsCollector, true);
+ assertEquals(1, metricsCollector.getRecords().size());
+ } finally {
+ metrics.unRegister();
+ }
+ }
+}
diff --git a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/volume/TestReservedVolumeSpace.java b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/volume/TestReservedVolumeSpace.java
index 5e2dd0c75c9b..5e0a31944f78 100644
--- a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/volume/TestReservedVolumeSpace.java
+++ b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/volume/TestReservedVolumeSpace.java
@@ -20,6 +20,7 @@
import org.apache.hadoop.conf.StorageUnit;
import org.apache.hadoop.hdds.HddsConfigKeys;
+import org.apache.hadoop.hdds.conf.ConfigurationException;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.fs.MockSpaceUsageCheckFactory;
import org.apache.hadoop.hdds.scm.ScmConfigKeys;
@@ -37,6 +38,7 @@
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.HDDS_DATANODE_DIR_DU_RESERVED_PERCENT;
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.HDDS_DATANODE_DIR_DU_RESERVED_PERCENT_DEFAULT;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
/**
@@ -166,6 +168,16 @@ public void testInvalidConfig() throws Exception {
assertEquals(getExpectedDefaultReserved(hddsVolume2), reservedFromVolume2);
}
+ @Test
+ public void testInvalidConfigThrowsException() {
+ OzoneConfiguration conf = new OzoneConfiguration();
+ conf.set(ScmConfigKeys.HDDS_DATANODE_DIR_DU_RESERVED, "15GB");
+
+ assertThrows(ConfigurationException.class,
+ () -> volumeBuilder.conf(conf).build(),
+ "Reserved space should be configured in a pair");
+ }
+
@Test
public void testPathsCanonicalized() throws Exception {
OzoneConfiguration conf = new OzoneConfiguration();
diff --git a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueContainer.java b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueContainer.java
index e1a3de30ddf3..584db675d930 100644
--- a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueContainer.java
+++ b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueContainer.java
@@ -689,7 +689,7 @@ public void testContainerRocksDB(ContainerTestVersionInfo versionInfo)
try (DBHandle db = BlockUtils.getDB(keyValueContainerData, CONF)) {
RDBStore store = (RDBStore) db.getStore().getStore();
- long defaultCacheSize = 64 * OzoneConsts.MB;
+ long defaultCacheSize = OzoneConsts.GB;
long cacheSize = Long.parseLong(store
.getProperty("rocksdb.block-cache-capacity"));
assertEquals(defaultCacheSize, cacheSize);
diff --git a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueHandlerWithUnhealthyContainer.java b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueHandlerWithUnhealthyContainer.java
index f0c8a2077eac..1db2d7ff53eb 100644
--- a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueHandlerWithUnhealthyContainer.java
+++ b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueHandlerWithUnhealthyContainer.java
@@ -35,12 +35,14 @@
import org.apache.hadoop.ozone.container.common.volume.MutableVolumeSet;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.UUID;
@@ -72,6 +74,9 @@ public class TestKeyValueHandlerWithUnhealthyContainer {
public static final Logger LOG = LoggerFactory.getLogger(
TestKeyValueHandlerWithUnhealthyContainer.class);
+ @TempDir
+ private File tempDir;
+
private IncrementalReportSender mockIcrSender;
@BeforeEach
@@ -220,6 +225,7 @@ public void testMarkContainerUnhealthyInFailedVolume() throws IOException {
KeyValueContainerData mockContainerData = mock(KeyValueContainerData.class);
HddsVolume mockVolume = mock(HddsVolume.class);
when(mockContainerData.getVolume()).thenReturn(mockVolume);
+ when(mockContainerData.getMetadataPath()).thenReturn(tempDir.getAbsolutePath());
KeyValueContainer container = new KeyValueContainer(
mockContainerData, new OzoneConfiguration());
diff --git a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/TestReplicationSupervisor.java b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/TestReplicationSupervisor.java
index ef37c226653a..315e0c0253b4 100644
--- a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/TestReplicationSupervisor.java
+++ b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/TestReplicationSupervisor.java
@@ -87,6 +87,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ReplicationCommandPriority.LOW;
import static org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ReplicationCommandPriority.NORMAL;
import static org.mockito.Mockito.any;
@@ -488,6 +489,15 @@ public void testMultipleReplication(ContainerLayoutVersion layout,
assertEquals(0, ecReconstructionSupervisor.getReplicationRequestCount(
task1.getMetricName()));
+ assertTrue(replicationSupervisor.getReplicationRequestTotalTime(
+ task1.getMetricName()) > 0);
+ assertTrue(ecReconstructionSupervisor.getReplicationRequestTotalTime(
+ task2.getMetricName()) > 0);
+ assertTrue(replicationSupervisor.getReplicationRequestAvgTime(
+ task1.getMetricName()) > 0);
+ assertTrue(ecReconstructionSupervisor.getReplicationRequestAvgTime(
+ task2.getMetricName()) > 0);
+
MetricsCollectorImpl replicationMetricsCollector = new MetricsCollectorImpl();
replicationMetrics.getMetrics(replicationMetricsCollector, true);
assertEquals(1, replicationMetricsCollector.getRecords().size());
diff --git a/hadoop-hdds/crypto-api/pom.xml b/hadoop-hdds/crypto-api/pom.xml
index db19cc4f3414..ca54b3de9f2d 100644
--- a/hadoop-hdds/crypto-api/pom.xml
+++ b/hadoop-hdds/crypto-api/pom.xml
@@ -19,11 +19,11 @@
org.apache.ozone
hdds
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
hdds-crypto-api
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Apache Ozone Distributed Data Store cryptographic functions
Apache Ozone HDDS Crypto
diff --git a/hadoop-hdds/crypto-default/pom.xml b/hadoop-hdds/crypto-default/pom.xml
index c586f91712b8..6024c3e2ddf2 100644
--- a/hadoop-hdds/crypto-default/pom.xml
+++ b/hadoop-hdds/crypto-default/pom.xml
@@ -19,11 +19,11 @@
org.apache.ozone
hdds
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
hdds-crypto-default
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Default implementation of Apache Ozone Distributed Data Store's cryptographic functions
Apache Ozone HDDS Crypto - Default
diff --git a/hadoop-hdds/dev-support/checkstyle/checkstyle.xml b/hadoop-hdds/dev-support/checkstyle/checkstyle.xml
index 3a69c793c26f..288085ef9481 100644
--- a/hadoop-hdds/dev-support/checkstyle/checkstyle.xml
+++ b/hadoop-hdds/dev-support/checkstyle/checkstyle.xml
@@ -88,6 +88,7 @@
+
diff --git a/hadoop-hdds/docs/content/concept/Datanodes.md b/hadoop-hdds/docs/content/concept/Datanodes.md
index 47c09a798fc4..cf246712f68f 100644
--- a/hadoop-hdds/docs/content/concept/Datanodes.md
+++ b/hadoop-hdds/docs/content/concept/Datanodes.md
@@ -76,3 +76,15 @@ blocks that get reported. That is a 40x reduction in the block reports.
This extra indirection helps tremendously with scaling Ozone. SCM has far
less block data to process and the namespace service (Ozone Manager) as a
different service are critical to scaling Ozone.
+
+
+## Notable configurations
+
+key | default | description
+----|---------|------------
+dfs.container.ratis.datanode.storage.dir | none | This directory is used for storing Ratis metadata like logs.
+ozone.scm.datanode.id.dir | none | The path that datanodes will use to store the datanode ID.
+hdds.datanode.dir | none | Determines where HDDS data will be stored on the local filesystem.
+hdds.datanode.dir.du.reserved | none | Reserved space in bytes per volume. Always leave this much space free for non dfs use.
+ozone.metadata.dirs | none | Directory to store persisted data (RocksDB).
+ozone.recon.address | 0.0.0.0:9891 | RPC address of the Recon. Use to connect Recon.
diff --git a/hadoop-hdds/docs/content/concept/Datanodes.zh.md b/hadoop-hdds/docs/content/concept/Datanodes.zh.md
index 8f129df7b9be..32071c9e51e4 100644
--- a/hadoop-hdds/docs/content/concept/Datanodes.zh.md
+++ b/hadoop-hdds/docs/content/concept/Datanodes.zh.md
@@ -49,3 +49,15 @@ Ozone 的存储容器是一个自包含的超级块,容器中包含一系列
SCM 如何获得容器的位置?这一点和现有的 HDFS 十分相似。数据节点会定期发送类似于块报告的容器报告,容器报告比块报告的内容简洁的多,比如,对于一个存储容量为 196 TB 的集群,Ozone 大概会拥有四万个容器,相比于 HDFS 的一百五十万个块,块报告数量缩减为四十分之一。
这种间接管理的方式大大地提高了 Ozone 的扩展性,因为 SCM 需要处理的块数据大大减少,且命名服务(OM)作为一个独特的服务主体对于扩展 Ozone 具有重要意义。
+
+
+## 需要关注的配置项
+
+配置项 |默认值 | 描述
+----|---------|------------
+dfs.container.ratis.datanode.storage.dir | none | 该目录用于存储 Ratis 元数据,如日志。
+ozone.scm.datanode.id.dir | none | 数据节点上用于存储数据节点 ID 的路径。
+hdds.datanode.dir | none | 此配置决定数据节点上的数据将存储在本地文件系统的哪个位置。
+hdds.datanode.dir.du.reserved | none | 每个卷保留的存储空间(以字节为单位)。始终为非DFS用途保留这么多空闲空间。
+ozone.metadata.dirs | none | 用于存储持久化数据(RocksDB)的目录。
+ozone.recon.address | 0.0.0.0:9891 | Recon的RPC地址。 使用 连接到Recon。
\ No newline at end of file
diff --git a/hadoop-hdds/docs/content/feature/Quota.md b/hadoop-hdds/docs/content/feature/Quota.md
index 90e413357b50..53c196307fa3 100644
--- a/hadoop-hdds/docs/content/feature/Quota.md
+++ b/hadoop-hdds/docs/content/feature/Quota.md
@@ -1,6 +1,6 @@
---
title: "Quota in Ozone"
-date: "2020-October-22"
+date: "2020-10-22"
weight: 4
summary: Quota in Ozone
icon: user
diff --git a/hadoop-hdds/docs/content/feature/Quota.zh.md b/hadoop-hdds/docs/content/feature/Quota.zh.md
index 16e5db26cde3..d690947ef06c 100644
--- a/hadoop-hdds/docs/content/feature/Quota.zh.md
+++ b/hadoop-hdds/docs/content/feature/Quota.zh.md
@@ -1,6 +1,6 @@
---
title: "Ozone 中的配额"
-date: "2020-October-22"
+date: "2020-10-22"
weight: 4
summary: Ozone中的配额
icon: user
diff --git a/hadoop-hdds/docs/content/security/GDPR.md b/hadoop-hdds/docs/content/security/GDPR.md
index 25b2f2c4416b..409a3ae7be0d 100644
--- a/hadoop-hdds/docs/content/security/GDPR.md
+++ b/hadoop-hdds/docs/content/security/GDPR.md
@@ -1,6 +1,6 @@
---
title: "GDPR in Ozone"
-date: "2019-September-17"
+date: "2019-09-17"
weight: 3
icon: user
menu:
diff --git a/hadoop-hdds/docs/content/security/GDPR.zh.md b/hadoop-hdds/docs/content/security/GDPR.zh.md
index a7db4030871b..8fd3514138f0 100644
--- a/hadoop-hdds/docs/content/security/GDPR.zh.md
+++ b/hadoop-hdds/docs/content/security/GDPR.zh.md
@@ -1,6 +1,6 @@
---
title: "Ozone 中的 GDPR"
-date: "2019-September-17"
+date: "2019-09-17"
weight: 3
summary: Ozone 中的 GDPR
menu:
diff --git a/hadoop-hdds/docs/content/security/SecureOzone.md b/hadoop-hdds/docs/content/security/SecureOzone.md
index 76fd74701095..bbeef79b6135 100644
--- a/hadoop-hdds/docs/content/security/SecureOzone.md
+++ b/hadoop-hdds/docs/content/security/SecureOzone.md
@@ -1,6 +1,6 @@
---
title: "Securing Ozone"
-date: "2019-April-03"
+date: "2019-04-03"
summary: Overview of Ozone security concepts and steps to secure Ozone Manager and SCM.
weight: 1
menu:
diff --git a/hadoop-hdds/docs/content/security/SecureOzone.zh.md b/hadoop-hdds/docs/content/security/SecureOzone.zh.md
index a7660233f4d0..e74b5d8dfab5 100644
--- a/hadoop-hdds/docs/content/security/SecureOzone.zh.md
+++ b/hadoop-hdds/docs/content/security/SecureOzone.zh.md
@@ -1,6 +1,6 @@
---
title: "安全化 Ozone"
-date: "2019-April-03"
+date: "2019-04-03"
summary: 简要介绍 Ozone 中的安全概念以及安全化 OM 和 SCM 的步骤。
weight: 1
menu:
diff --git a/hadoop-hdds/docs/content/security/SecuringDatanodes.md b/hadoop-hdds/docs/content/security/SecuringDatanodes.md
index 717e746cfb91..2254155e1f4e 100644
--- a/hadoop-hdds/docs/content/security/SecuringDatanodes.md
+++ b/hadoop-hdds/docs/content/security/SecuringDatanodes.md
@@ -1,6 +1,6 @@
---
title: "Securing Datanodes"
-date: "2019-April-03"
+date: "2019-04-03"
weight: 3
menu:
main:
diff --git a/hadoop-hdds/docs/content/security/SecuringDatanodes.zh.md b/hadoop-hdds/docs/content/security/SecuringDatanodes.zh.md
index 608be16e8a3b..8b37fd2f6ee2 100644
--- a/hadoop-hdds/docs/content/security/SecuringDatanodes.zh.md
+++ b/hadoop-hdds/docs/content/security/SecuringDatanodes.zh.md
@@ -1,6 +1,6 @@
---
title: "安全化 Datanode"
-date: "2019-April-03"
+date: "2019-04-03"
weight: 3
menu:
main:
diff --git a/hadoop-hdds/docs/content/security/SecuringOzoneHTTP.md b/hadoop-hdds/docs/content/security/SecuringOzoneHTTP.md
index 47c04eb94d93..a8601d7a5e1f 100644
--- a/hadoop-hdds/docs/content/security/SecuringOzoneHTTP.md
+++ b/hadoop-hdds/docs/content/security/SecuringOzoneHTTP.md
@@ -1,6 +1,6 @@
---
title: "Securing HTTP"
-date: "2020-June-17"
+date: "2020-06-17"
summary: Secure HTTP web-consoles for Ozone services
weight: 4
menu:
diff --git a/hadoop-hdds/docs/content/security/SecuringOzoneHTTP.zh.md b/hadoop-hdds/docs/content/security/SecuringOzoneHTTP.zh.md
index 07b3f6164f6f..5907a7caf9a2 100644
--- a/hadoop-hdds/docs/content/security/SecuringOzoneHTTP.zh.md
+++ b/hadoop-hdds/docs/content/security/SecuringOzoneHTTP.zh.md
@@ -1,6 +1,6 @@
---
title: "安全化 HTTP"
-date: "2020-June-17"
+date: "2020-06-17"
summary: 安全化 Ozone 服务的 HTTP 网络控制台
weight: 4
menu:
diff --git a/hadoop-hdds/docs/content/security/SecuringS3.md b/hadoop-hdds/docs/content/security/SecuringS3.md
index e6218b95e91e..04ef6921af65 100644
--- a/hadoop-hdds/docs/content/security/SecuringS3.md
+++ b/hadoop-hdds/docs/content/security/SecuringS3.md
@@ -1,6 +1,6 @@
---
title: "Securing S3"
-date: "2019-April-03"
+date: "2019-04-03"
summary: Ozone supports S3 protocol, and uses AWS Signature Version 4 protocol which allows a seamless S3 experience.
weight: 5
menu:
diff --git a/hadoop-hdds/docs/content/security/SecuringS3.zh.md b/hadoop-hdds/docs/content/security/SecuringS3.zh.md
index 218786fd366f..395b9303354b 100644
--- a/hadoop-hdds/docs/content/security/SecuringS3.zh.md
+++ b/hadoop-hdds/docs/content/security/SecuringS3.zh.md
@@ -1,6 +1,6 @@
---
title: "安全化 S3"
-date: "2019-April-03"
+date: "2019-04-03"
summary: Ozone 支持 S3 协议,并使用 AWS Signature Version 4 protocol which allows a seamless S3
experience.
weight: 5
diff --git a/hadoop-hdds/docs/content/security/SecuringTDE.md b/hadoop-hdds/docs/content/security/SecuringTDE.md
index 3b75bee1bfd5..0d04a28aec77 100644
--- a/hadoop-hdds/docs/content/security/SecuringTDE.md
+++ b/hadoop-hdds/docs/content/security/SecuringTDE.md
@@ -1,6 +1,6 @@
---
title: "Transparent Data Encryption"
-date: "2019-April-03"
+date: "2019-04-03"
summary: TDE allows data on the disks to be encrypted-at-rest and automatically decrypted during access.
weight: 2
menu:
diff --git a/hadoop-hdds/docs/content/security/SecuringTDE.zh.md b/hadoop-hdds/docs/content/security/SecuringTDE.zh.md
index ed42519e0b25..d7fa4941e446 100644
--- a/hadoop-hdds/docs/content/security/SecuringTDE.zh.md
+++ b/hadoop-hdds/docs/content/security/SecuringTDE.zh.md
@@ -1,6 +1,6 @@
---
title: "透明数据加密"
-date: "2019-April-03"
+date: "2019-04-03"
summary: 透明数据加密(Transparent Data Encryption,TDE)以密文形式在磁盘上保存数据,但可以在用户访问的时候自动进行解密。
weight: 2
menu:
diff --git a/hadoop-hdds/docs/content/security/SecurityAcls.md b/hadoop-hdds/docs/content/security/SecurityAcls.md
index 9976cbbc4fba..ee48999ed25d 100644
--- a/hadoop-hdds/docs/content/security/SecurityAcls.md
+++ b/hadoop-hdds/docs/content/security/SecurityAcls.md
@@ -1,6 +1,6 @@
---
title: "Ozone ACLs"
-date: "2019-April-03"
+date: "2019-04-03"
weight: 6
menu:
main:
diff --git a/hadoop-hdds/docs/content/security/SecurityAcls.zh.md b/hadoop-hdds/docs/content/security/SecurityAcls.zh.md
index 3d95fcf0877b..99751cd62da3 100644
--- a/hadoop-hdds/docs/content/security/SecurityAcls.zh.md
+++ b/hadoop-hdds/docs/content/security/SecurityAcls.zh.md
@@ -1,6 +1,6 @@
---
title: "Ozone 访问控制列表"
-date: "2019-April-03"
+date: "2019-04-03"
weight: 6
menu:
main:
diff --git a/hadoop-hdds/docs/content/security/SecurityWithRanger.md b/hadoop-hdds/docs/content/security/SecurityWithRanger.md
index bbbd8c19f32e..7dc1895ad3dc 100644
--- a/hadoop-hdds/docs/content/security/SecurityWithRanger.md
+++ b/hadoop-hdds/docs/content/security/SecurityWithRanger.md
@@ -1,6 +1,6 @@
---
title: "Apache Ranger"
-date: "2019-April-03"
+date: "2019-04-03"
weight: 7
menu:
main:
diff --git a/hadoop-hdds/docs/content/security/SecurityWithRanger.zh.md b/hadoop-hdds/docs/content/security/SecurityWithRanger.zh.md
index b7c7b8721bbe..8917c0b84bcf 100644
--- a/hadoop-hdds/docs/content/security/SecurityWithRanger.zh.md
+++ b/hadoop-hdds/docs/content/security/SecurityWithRanger.zh.md
@@ -1,6 +1,6 @@
---
title: "Apache Ranger"
-date: "2019-April-03"
+date: "2019-04-03"
weight: 7
menu:
main:
diff --git a/hadoop-hdds/docs/pom.xml b/hadoop-hdds/docs/pom.xml
index d14ae28c10d8..7f4ffbb8a709 100644
--- a/hadoop-hdds/docs/pom.xml
+++ b/hadoop-hdds/docs/pom.xml
@@ -20,10 +20,10 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
org.apache.ozone
hdds
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
hdds-docs
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Apache Ozone/HDDS Documentation
Apache Ozone/HDDS Documentation
jar
diff --git a/hadoop-hdds/erasurecode/pom.xml b/hadoop-hdds/erasurecode/pom.xml
index 201336d5ed3a..b540d1c68ea6 100644
--- a/hadoop-hdds/erasurecode/pom.xml
+++ b/hadoop-hdds/erasurecode/pom.xml
@@ -20,10 +20,10 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
org.apache.ozone
hdds
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
hdds-erasurecode
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Apache Ozone Distributed Data Store Earsurecode utils
Apache Ozone HDDS Erasurecode
diff --git a/hadoop-hdds/erasurecode/src/main/java/org/apache/ozone/erasurecode/CodecRegistry.java b/hadoop-hdds/erasurecode/src/main/java/org/apache/ozone/erasurecode/CodecRegistry.java
index 83650c132b05..2069a51be171 100644
--- a/hadoop-hdds/erasurecode/src/main/java/org/apache/ozone/erasurecode/CodecRegistry.java
+++ b/hadoop-hdds/erasurecode/src/main/java/org/apache/ozone/erasurecode/CodecRegistry.java
@@ -19,9 +19,9 @@
import com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.hdds.annotation.InterfaceAudience;
-import org.apache.ozone.erasurecode.rawcoder.RawErasureCoderFactory;
import org.apache.ozone.erasurecode.rawcoder.NativeRSRawErasureCoderFactory;
import org.apache.ozone.erasurecode.rawcoder.NativeXORRawErasureCoderFactory;
+import org.apache.ozone.erasurecode.rawcoder.RawErasureCoderFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,7 +31,6 @@
import java.util.Map;
import java.util.ServiceLoader;
import java.util.Set;
-import java.util.stream.Collectors;
/**
* This class registers all coder implementations.
@@ -108,8 +107,8 @@ void updateCoders(Iterable coderFactories) {
String codecName = entry.getKey();
List coders = entry.getValue();
coderNameMap.put(codecName, coders.stream().
- map(RawErasureCoderFactory::getCoderName).
- collect(Collectors.toList()).toArray(new String[0]));
+ map(RawErasureCoderFactory::getCoderName)
+ .toArray(String[]::new));
}
}
diff --git a/hadoop-hdds/framework/pom.xml b/hadoop-hdds/framework/pom.xml
index 70cce849aec1..37d41cde390a 100644
--- a/hadoop-hdds/framework/pom.xml
+++ b/hadoop-hdds/framework/pom.xml
@@ -20,10 +20,10 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
org.apache.ozone
hdds
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
hdds-server-framework
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Apache Ozone Distributed Data Store Server Framework
Apache Ozone HDDS Server Framework
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/protocol/SCMSecurityProtocol.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/protocol/SCMSecurityProtocol.java
index cbb4f3fc2ee7..0cb39482e98c 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/protocol/SCMSecurityProtocol.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/protocol/SCMSecurityProtocol.java
@@ -118,7 +118,6 @@ String getSCMCertificate(ScmNodeDetailsProto scmNodeDetails,
/**
* Get Root CA certificate.
- * @return
* @throws IOException
*/
String getRootCACertificate() throws IOException;
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/protocolPB/SCMSecurityProtocolClientSideTranslatorPB.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/protocolPB/SCMSecurityProtocolClientSideTranslatorPB.java
index a938d53c7c42..71918308f145 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/protocolPB/SCMSecurityProtocolClientSideTranslatorPB.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/protocolPB/SCMSecurityProtocolClientSideTranslatorPB.java
@@ -330,7 +330,6 @@ public SCMGetCertResponseProto getCACert() throws IOException {
* @param role - node type: OM/SCM/DN.
* @param startSerialId - start cert serial id.
* @param count - max number of certificates returned in a batch.
- * @return
* @throws IOException
*/
@Override
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/container/common/helpers/MoveDataNodePair.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/container/common/helpers/MoveDataNodePair.java
index 42e8f8202cbd..4690054a87db 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/container/common/helpers/MoveDataNodePair.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/container/common/helpers/MoveDataNodePair.java
@@ -36,6 +36,7 @@ public class MoveDataNodePair {
Proto2Codec.get(MoveDataNodePairProto.getDefaultInstance()),
MoveDataNodePair::getFromProtobuf,
pair -> pair.getProtobufMessage(ClientVersion.CURRENT_VERSION),
+ MoveDataNodePair.class,
DelegatedCodec.CopyType.SHALLOW);
public static Codec getCodec() {
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/protocolPB/ScmBlockLocationProtocolClientSideTranslatorPB.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/protocolPB/ScmBlockLocationProtocolClientSideTranslatorPB.java
index 1f114304ccaa..d9b198d4b14a 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/protocolPB/ScmBlockLocationProtocolClientSideTranslatorPB.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/protocolPB/ScmBlockLocationProtocolClientSideTranslatorPB.java
@@ -307,7 +307,7 @@ public boolean addSCM(AddSCMRequest request) throws IOException {
}
/**
* Sort the datanodes based on distance from client.
- * @return List>
+ * @return list of datanodes;
* @throws IOException
*/
@Override
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/protocolPB/StorageContainerLocationProtocolClientSideTranslatorPB.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/protocolPB/StorageContainerLocationProtocolClientSideTranslatorPB.java
index d5972cfe0760..d76ce3b72c96 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/protocolPB/StorageContainerLocationProtocolClientSideTranslatorPB.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/protocolPB/StorageContainerLocationProtocolClientSideTranslatorPB.java
@@ -108,6 +108,7 @@
import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ContainerBalancerStatusInfoRequestProto;
import org.apache.hadoop.hdds.scm.DatanodeAdminError;
import org.apache.hadoop.hdds.scm.ScmInfo;
+import org.apache.hadoop.hdds.scm.container.ContainerListResult;
import org.apache.hadoop.hdds.scm.container.ContainerID;
import org.apache.hadoop.hdds.scm.container.ContainerInfo;
import org.apache.hadoop.hdds.scm.container.ReplicationManagerReport;
@@ -128,6 +129,7 @@
import java.io.Closeable;
import java.io.IOException;
+import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -157,6 +159,12 @@ public final class StorageContainerLocationProtocolClientSideTranslatorPB
private final StorageContainerLocationProtocolPB rpcProxy;
private final SCMContainerLocationFailoverProxyProvider fpp;
+ /**
+ * This is used to check if 'leader' or 'follower' exists,
+ * in order to confirm whether we have enabled Ratis.
+ */
+ private final List scmRatisRolesToCheck = Arrays.asList("leader", "follower");
+
/**
* Creates a new StorageContainerLocationProtocolClientSideTranslatorPB.
*
@@ -382,19 +390,19 @@ public List getExistContainerWithPipelinesInBatch(
* {@inheritDoc}
*/
@Override
- public List listContainer(long startContainerID, int count)
+ public ContainerListResult listContainer(long startContainerID, int count)
throws IOException {
return listContainer(startContainerID, count, null, null, null);
}
@Override
- public List listContainer(long startContainerID, int count,
+ public ContainerListResult listContainer(long startContainerID, int count,
HddsProtos.LifeCycleState state) throws IOException {
return listContainer(startContainerID, count, state, null, null);
}
@Override
- public List listContainer(long startContainerID, int count,
+ public ContainerListResult listContainer(long startContainerID, int count,
HddsProtos.LifeCycleState state,
HddsProtos.ReplicationType replicationType,
ReplicationConfig replicationConfig)
@@ -436,12 +444,17 @@ public List listContainer(long startContainerID, int count,
.getContainersList()) {
containerList.add(ContainerInfo.fromProtobuf(containerInfoProto));
}
- return containerList;
+
+ if (response.hasContainerCount()) {
+ return new ContainerListResult(containerList, response.getContainerCount());
+ } else {
+ return new ContainerListResult(containerList, -1);
+ }
}
@Deprecated
@Override
- public List listContainer(long startContainerID, int count,
+ public ContainerListResult listContainer(long startContainerID, int count,
HddsProtos.LifeCycleState state, HddsProtos.ReplicationFactor factor)
throws IOException {
throw new UnsupportedOperationException("Should no longer be called from " +
@@ -760,8 +773,23 @@ public ScmInfo getScmInfo() throws IOException {
.setScmId(resp.getScmId())
.setRatisPeerRoles(resp.getPeerRolesList());
- return builder.build();
+ // By default, we assume that SCM Ratis is not enabled.
+ // If the response contains the `ScmRatisEnabled` field,
+ // we will set it directly; otherwise,
+ // we will determine if Ratis is enabled based on
+ // whether the `peerRolesList` contains the keywords 'leader' or 'follower'.
+ if (resp.hasScmRatisEnabled()) {
+ builder.setScmRatisEnabled(resp.getScmRatisEnabled());
+ } else {
+ List peerRolesList = resp.getPeerRolesList();
+ if (!peerRolesList.isEmpty()) {
+ boolean containsScmRoles = peerRolesList.stream().map(String::toLowerCase)
+ .anyMatch(scmRatisRolesToCheck::contains);
+ builder.setScmRatisEnabled(containsScmRoles);
+ }
+ }
+ return builder.build();
}
@Override
@@ -1187,7 +1215,7 @@ public void close() {
public List getListOfContainers(
long startContainerID, int count, HddsProtos.LifeCycleState state)
throws IOException {
- return listContainer(startContainerID, count, state);
+ return listContainer(startContainerID, count, state).getContainerInfoList();
}
@Override
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/token/TokenVerifier.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/token/TokenVerifier.java
index e7e029f70877..da651160d047 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/token/TokenVerifier.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/token/TokenVerifier.java
@@ -50,8 +50,7 @@ void verify(Token> token,
ContainerCommandRequestProtoOrBuilder cmd)
throws SCMSecurityException;
- /** Same as {@link #verify(Token,
- * ContainerCommandRequestProtoOrBuilder)}, but with encoded token. */
+ /** Same as {@link #verify}, but with encoded token. */
default void verify(ContainerCommandRequestProtoOrBuilder cmd,
String encodedToken) throws SCMSecurityException {
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/CertInfo.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/CertInfo.java
index b78604643e57..154f1c2d858f 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/CertInfo.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/CertInfo.java
@@ -39,7 +39,8 @@ public final class CertInfo implements Comparable, Serializable {
private static final Codec CODEC = new DelegatedCodec<>(
Proto2Codec.get(CertInfoProto.getDefaultInstance()),
CertInfo::fromProtobuf,
- CertInfo::getProtobuf);
+ CertInfo::getProtobuf,
+ CertInfo.class);
public static Codec getCodec() {
return CODEC;
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/DefaultApprover.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/DefaultApprover.java
index b2d62443b776..5a39d0f1dd0b 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/DefaultApprover.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/DefaultApprover.java
@@ -104,7 +104,7 @@ public DefaultApprover(PKIProfile pkiProfile, SecurityConfig config) {
* @param certSerialId - the new certificate id.
* @return Signed Certificate.
* @throws IOException - On Error
- * @throws OperatorCreationException - on Error.
+ * @throws CertificateException - on Error.
*/
@SuppressWarnings("ParameterNumber")
@Override
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/DefaultCAServer.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/DefaultCAServer.java
index a93bdb4e3d67..118aa826013d 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/DefaultCAServer.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/DefaultCAServer.java
@@ -195,8 +195,6 @@ public CertPath getCaCertPath()
*
* @param certSerialId - Certificate for this CA.
* @return X509Certificate
- * @throws CertificateException - usually thrown if this CA is not
- * initialized.
* @throws IOException - on Error.
*/
@Override
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/client/DefaultCertificateClient.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/client/DefaultCertificateClient.java
index b277a759cb8d..42292b9663f1 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/client/DefaultCertificateClient.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/client/DefaultCertificateClient.java
@@ -668,6 +668,8 @@ protected enum InitCase {
* certificate.
*
* Truth table:
+ *
+ * {@code
* +--------------+---------------+--------------+---------------------+
* | Private Key | Public Keys | Certificate | Result |
* +--------------+---------------+--------------+---------------------+
@@ -680,7 +682,8 @@ protected enum InitCase {
* | True (1) | True (1) | False (0) | GETCERT->SUCCESS |
* | True (1) | True (1) | True (1) | SUCCESS |
* +--------------+-----------------+--------------+----------------+
- *
+ * }
+ *
* Success in following cases:
* 1. If keypair as well certificate is available.
* 2. If private key and certificate is available and public key is
@@ -1083,7 +1086,7 @@ public Duration timeBeforeExpiryGracePeriod(X509Certificate certificate) {
* Renew keys and certificate. Save the keys are certificate to disk in new
* directories, swap the current key directory and certs directory with the
* new directories.
- * @param force, check certificate expiry time again if force is false.
+ * @param force check certificate expiry time again if force is false.
* @return String, new certificate ID
* */
public String renewAndStoreKeyAndCertificate(boolean force)
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ServiceRuntimeInfo.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ServiceRuntimeInfo.java
index bcd75f3f215d..3783613f3e34 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ServiceRuntimeInfo.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ServiceRuntimeInfo.java
@@ -47,13 +47,6 @@ public interface ServiceRuntimeInfo {
*/
String getSoftwareVersion();
- /**
- * Get the compilation information which contains date, user and branch.
- *
- * @return the compilation information, as a JSON string.
- */
- String getCompileInfo();
-
/**
* Gets the NN start time in milliseconds.
*
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ServiceRuntimeInfoImpl.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ServiceRuntimeInfoImpl.java
index 987f4aee0314..74ba3c5b629c 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ServiceRuntimeInfoImpl.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ServiceRuntimeInfoImpl.java
@@ -42,12 +42,6 @@ public String getSoftwareVersion() {
return versionInfo.getVersion();
}
- @Override
- public String getCompileInfo() {
- return versionInfo.getDate() + " by " + versionInfo.getUser() + " from "
- + versionInfo.getBranch();
- }
-
@Override
public long getStartedTimeInMillis() {
return startedTimeInMillis;
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/http/HttpServer2.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/http/HttpServer2.java
index f27f42e0b4c7..9d037fed6bc8 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/http/HttpServer2.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/http/HttpServer2.java
@@ -123,8 +123,8 @@
/**
* Create a Jetty embedded server to answer http requests. The primary goal is
* to serve up status information for the server. There are three contexts:
- * "/logs/" -> points to the log directory "/static/" -> points to common static
- * files (src/webapps/static) "/" -> the jsp server code from
+ * "/logs/" -> points to the log directory "/static/" -> points to common static
+ * files (src/webapps/static) "/" -> the jsp server code from
* (src/webapps/)
*
* This class is a fork of the old HttpServer. HttpServer exists for
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/http/ProfileServlet.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/http/ProfileServlet.java
index f4f188aaf395..bceec92c6c8f 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/http/ProfileServlet.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/http/ProfileServlet.java
@@ -41,11 +41,12 @@
import org.slf4j.LoggerFactory;
/**
+ *
* Servlet that runs async-profiler as web-endpoint.
- *
+ *
* Source: https://github.com/apache/hive/blob/master/common/src/java/org
* /apache/hive/http/ProfileServlet.java
- *
+ *
* Following options from async-profiler can be specified as query parameter.
* // -e event profiling event: cpu|alloc|lock|cache-misses etc.
* // -d duration run profiling for seconds
@@ -79,7 +80,7 @@
* curl "http://localhost:10002/prof"
* - To collect 1 minute CPU profile of current process and output in tree
* format (html)
- * curl "http://localhost:10002/prof?output=tree&duration=60"
+ * curl "http://localhost:10002/prof?output=tree&duration=60"
* - To collect 30 second heap allocation profile of current process (returns
* FlameGraph svg)
* curl "http://localhost:10002/prof?event=alloc"
@@ -111,6 +112,7 @@
* The default output format of the newest async profiler is HTML.
* If the user is using an older version such as 1.5, HTML is not supported.
* Please specify the corresponding output format.
+ *
*/
public class ProfileServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/DBCheckpointServlet.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/DBCheckpointServlet.java
index 2d718628e1eb..cb1fdd3375a8 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/DBCheckpointServlet.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/DBCheckpointServlet.java
@@ -41,22 +41,20 @@
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.util.Streams;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.hdds.server.OzoneAdmins;
import org.apache.hadoop.hdds.utils.db.DBCheckpoint;
import org.apache.hadoop.hdds.utils.db.DBStore;
-
-import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.ozone.lock.BootstrapStateHandler;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import static org.apache.hadoop.hdds.utils.HddsServerUtil.writeDBCheckpointToStream;
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_DB_CHECKPOINT_REQUEST_FLUSH;
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_DB_CHECKPOINT_REQUEST_TO_EXCLUDE_SST;
import static org.apache.hadoop.ozone.OzoneConsts.ROCKSDB_SST_SUFFIX;
-import org.apache.hadoop.ozone.lock.BootstrapStateHandler;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* Provides the current checkpoint Snapshot of the OM/SCM DB. (tar)
*/
@@ -287,7 +285,7 @@ private static String[] parseFormDataParameters(HttpServletRequest request) {
LOG.warn("Exception occured during form data parsing {}", e.getMessage());
}
- return sstParam.size() == 0 ? null : sstParam.toArray(new String[0]);
+ return sstParam.isEmpty() ? null : sstParam.toArray(new String[0]);
}
/**
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/HddsServerUtil.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/HddsServerUtil.java
index c45e772c2417..d80b6b3a272c 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/HddsServerUtil.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/HddsServerUtil.java
@@ -125,11 +125,11 @@ private HddsServerUtil() {
HddsServerUtil.class);
/**
- * Add protobuf-based protocol to the {@link RPC.Server}.
+ * Add protobuf-based protocol to the {@link org.apache.hadoop.ipc.RPC.Server}.
* @param conf configuration
* @param protocol Protocol interface
* @param service service that implements the protocol
- * @param server RPC server to which the protocol & implementation is added to
+ * @param server RPC server to which the protocol and implementation is added to
*/
public static void addPBProtocol(Configuration conf, Class> protocol,
BlockingService service, RPC.Server server) throws IOException {
@@ -742,9 +742,7 @@ public static String createStartupShutdownMessage(VersionInfo versionInfo,
" version = " + versionInfo.getVersion(),
" classpath = " + System.getProperty("java.class.path"),
" build = " + versionInfo.getUrl() + "/"
- + versionInfo.getRevision()
- + " ; compiled by '" + versionInfo.getUser()
- + "' on " + versionInfo.getDate(),
+ + versionInfo.getRevision(),
" java = " + System.getProperty("java.version"),
" conf = " + conf);
}
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/TransactionInfo.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/TransactionInfo.java
index 29531f315184..8387934261ce 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/TransactionInfo.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/TransactionInfo.java
@@ -45,6 +45,7 @@ public final class TransactionInfo implements Comparable {
StringCodec.get(),
TransactionInfo::valueOf,
TransactionInfo::toString,
+ TransactionInfo.class,
DelegatedCodec.CopyType.SHALLOW);
public static Codec getCodec() {
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/ByteArrayCodec.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/ByteArrayCodec.java
index f62d3ac19cf2..bb5eef70d25a 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/ByteArrayCodec.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/ByteArrayCodec.java
@@ -33,6 +33,11 @@ private ByteArrayCodec() {
// singleton
}
+ @Override
+ public Class getTypeClass() {
+ return byte[].class;
+ }
+
@Override
public byte[] toPersistedFormat(byte[] bytes) {
return bytes;
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/ByteStringCodec.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/ByteStringCodec.java
index 997bdf6cf2ee..20e373317b17 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/ByteStringCodec.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/ByteStringCodec.java
@@ -34,6 +34,11 @@ public static ByteStringCodec get() {
private ByteStringCodec() { }
+ @Override
+ public Class getTypeClass() {
+ return ByteString.class;
+ }
+
@Override
public boolean supportCodecBuffer() {
return true;
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/DBColumnFamilyDefinition.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/DBColumnFamilyDefinition.java
index 653182214b6c..a5268e6031c8 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/DBColumnFamilyDefinition.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/DBColumnFamilyDefinition.java
@@ -54,32 +54,21 @@ public class DBColumnFamilyDefinition {
private final String tableName;
- private final Class keyType;
-
private final Codec keyCodec;
- private final Class valueType;
-
private final Codec valueCodec;
- private ManagedColumnFamilyOptions cfOptions;
+ private volatile ManagedColumnFamilyOptions cfOptions;
- public DBColumnFamilyDefinition(
- String tableName,
- Class keyType,
- Codec keyCodec,
- Class valueType,
- Codec valueCodec) {
+ public DBColumnFamilyDefinition(String tableName, Codec keyCodec, Codec valueCodec) {
this.tableName = tableName;
- this.keyType = keyType;
this.keyCodec = keyCodec;
- this.valueType = valueType;
this.valueCodec = valueCodec;
this.cfOptions = null;
}
public Table getTable(DBStore db) throws IOException {
- return db.getTable(tableName, keyType, valueType);
+ return db.getTable(tableName, getKeyType(), getValueType());
}
public String getName() {
@@ -87,7 +76,7 @@ public String getName() {
}
public Class getKeyType() {
- return keyType;
+ return keyCodec.getTypeClass();
}
public Codec getKeyCodec() {
@@ -95,7 +84,7 @@ public Codec getKeyCodec() {
}
public Class getValueType() {
- return valueType;
+ return valueCodec.getTypeClass();
}
public Codec getValueCodec() {
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/DBDefinition.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/DBDefinition.java
index 968d62f0dd5a..461bd35f413c 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/DBDefinition.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/DBDefinition.java
@@ -20,6 +20,7 @@
import org.apache.hadoop.hdds.conf.ConfigurationSource;
import org.apache.hadoop.hdds.server.ServerUtils;
+import org.apache.ratis.util.MemoizedSupplier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -28,6 +29,9 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
/**
* Simple interface to provide information to create a DBStore..
@@ -55,6 +59,16 @@ default File getDBLocation(ConfigurationSource conf) {
getLocationConfigKey(), getName());
}
+ static List getColumnFamilyNames(Iterable> columnFamilies) {
+ return Collections.unmodifiableList(StreamSupport.stream(columnFamilies.spliterator(), false)
+ .map(DBColumnFamilyDefinition::getName)
+ .collect(Collectors.toList()));
+ }
+
+ default List getColumnFamilyNames() {
+ return getColumnFamilyNames(getColumnFamilies());
+ }
+
/**
* @return The column families present in the DB.
*/
@@ -109,9 +123,17 @@ interface WithMapInterface extends DBDefinition {
*/
abstract class WithMap implements WithMapInterface {
private final Map> map;
+ private final Supplier> columnFamilyNames;
protected WithMap(Map> map) {
this.map = map;
+ this.columnFamilyNames = MemoizedSupplier.valueOf(
+ () -> DBDefinition.getColumnFamilyNames(getColumnFamilies()));
+ }
+
+ @Override
+ public final List getColumnFamilyNames() {
+ return columnFamilyNames.get();
}
@Override
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/DBStore.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/DBStore.java
index 3e8ea30a6528..8623a3bdd7d7 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/DBStore.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/DBStore.java
@@ -184,7 +184,7 @@ void move(KEY sourceKey, KEY destKey, VALUE value,
/**
* Get List of Index to Table Names.
* (For decoding table from column family index)
- * @return Map of Index -> TableName
+ * @return Map of Index -> TableName
*/
Map getTableNames();
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RocksDatabase.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RocksDatabase.java
index c441ec929c76..c156b8e4d67a 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RocksDatabase.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RocksDatabase.java
@@ -841,7 +841,7 @@ private int getLastLevel() throws IOException {
/**
* Deletes sst files which do not correspond to prefix
* for given table.
- * @param prefixPairs, a map of TableName to prefixUsed.
+ * @param prefixPairs a map of TableName to prefixUsed.
*/
public void deleteFilesNotMatchingPrefix(Map prefixPairs)
throws IOException, RocksDBException {
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/Table.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/Table.java
index c818c07b1acc..c7055267052e 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/Table.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/Table.java
@@ -24,6 +24,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.hadoop.hdds.annotation.InterfaceStability;
@@ -169,7 +170,7 @@ default VALUE getReadCopy(KEY key) throws IOException {
/**
* Returns a prefixed iterator for this metadata store.
* @param prefix
- * @return
+ * @return MetaStoreIterator
*/
TableIterator> iterator(KEY prefix)
throws IOException;
@@ -245,7 +246,7 @@ default TableCacheMetrics createCacheMetrics() throws IOException {
/**
* Returns a certain range of key value pairs as a list based on a
- * startKey or count. Further a {@link MetadataKeyFilters.MetadataKeyFilter}
+ * startKey or count. Further a {@link org.apache.hadoop.hdds.utils.MetadataKeyFilters.MetadataKeyFilter}
* can be added to * filter keys if necessary.
* To prevent race conditions while listing
* entries, this implementation takes a snapshot and lists the entries from
@@ -261,7 +262,7 @@ default TableCacheMetrics createCacheMetrics() throws IOException {
* the value for count must be an integer greater than 0.
*
* This method allows to specify one or more
- * {@link MetadataKeyFilters.MetadataKeyFilter}
+ * {@link org.apache.hadoop.hdds.utils.MetadataKeyFilters.MetadataKeyFilter}
* to filter keys by certain condition. Once given, only the entries
* whose key passes all the filters will be included in the result.
*
@@ -269,7 +270,7 @@ default TableCacheMetrics createCacheMetrics() throws IOException {
* @param count max number of entries to return.
* @param prefix fixed key schema specific prefix
* @param filters customized one or more
- * {@link MetadataKeyFilters.MetadataKeyFilter}.
+ * {@link org.apache.hadoop.hdds.utils.MetadataKeyFilters.MetadataKeyFilter}.
* @return a list of entries found in the database or an empty list if the
* startKey is invalid.
* @throws IOException if there are I/O errors.
@@ -292,7 +293,7 @@ List extends KeyValue> getRangeKVs(KEY startKey,
* @param count max number of entries to return.
* @param prefix fixed key schema specific prefix
* @param filters customized one or more
- * {@link MetadataKeyFilters.MetadataKeyFilter}.
+ * {@link org.apache.hadoop.hdds.utils.MetadataKeyFilters.MetadataKeyFilter}.
* @return a list of entries found in the database.
* @throws IOException
* @throws IllegalArgumentException
@@ -307,7 +308,6 @@ List extends KeyValue> getSequentialRangeKVs(KEY startKey,
* as part of a batch operation.
* @param batch
* @param prefix
- * @return
*/
void deleteBatchWithPrefix(BatchOperation batch, KEY prefix)
throws IOException;
@@ -354,6 +354,24 @@ public V getValue() {
public String toString() {
return "(key=" + key + ", value=" + value + ")";
}
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof KeyValue)) {
+ return false;
+ }
+ KeyValue, ?> kv = (KeyValue, ?>) obj;
+ try {
+ return getKey().equals(kv.getKey()) && getValue().equals(kv.getValue());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getKey(), getValue());
+ }
};
}
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/audit/package-info.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/audit/package-info.java
index 0c1ec710d2c8..c428f2860eee 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/audit/package-info.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/audit/package-info.java
@@ -48,7 +48,7 @@
* This interface must be implemented by entities requiring audit logging.
* For example - OMVolumeArgs, OMBucketArgs.
* The implementing class must override toAuditMap() to return an
- * instance of Map where both Key and Value are String.
+ * instance of {@code Map} where both Key and Value are String.
*
* Key: must contain printable US ASCII characters
* May not contain a space, =, ], or "
diff --git a/hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestDBStoreBuilder.java b/hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestDBStoreBuilder.java
index aad3e9e12e64..7966afe50457 100644
--- a/hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestDBStoreBuilder.java
+++ b/hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestDBStoreBuilder.java
@@ -179,7 +179,7 @@ public void builderWithColumnFamilyOptions(@TempDir Path tempDir)
String sampleTableName = "sampleTable";
final DBColumnFamilyDefinition sampleTable =
new DBColumnFamilyDefinition<>(sampleTableName,
- String.class, StringCodec.get(), Long.class, LongCodec.get());
+ StringCodec.get(), LongCodec.get());
final DBDefinition sampleDB = new DBDefinition.WithMap(
DBColumnFamilyDefinition.newUnmodifiableMap(sampleTable)) {
{
@@ -250,8 +250,8 @@ public void testIfAutoCompactionDisabled(boolean disableAutoCompaction,
String sampleTableName = "sampleTable";
final DBColumnFamilyDefinition sampleTable =
- new DBColumnFamilyDefinition<>(sampleTableName, String.class,
- StringCodec.get(), Long.class, LongCodec.get());
+ new DBColumnFamilyDefinition<>(sampleTableName,
+ StringCodec.get(), LongCodec.get());
final DBDefinition sampleDB = new DBDefinition.WithMap(
DBColumnFamilyDefinition.newUnmodifiableMap(sampleTable)) {
@Override
diff --git a/hadoop-hdds/hadoop-dependency-client/pom.xml b/hadoop-hdds/hadoop-dependency-client/pom.xml
index 03b677e3818c..dbf4a9420c1d 100644
--- a/hadoop-hdds/hadoop-dependency-client/pom.xml
+++ b/hadoop-hdds/hadoop-dependency-client/pom.xml
@@ -20,10 +20,10 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
org.apache.ozone
hdds
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
hdds-hadoop-dependency-client
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Apache Ozone Distributed Data Store Hadoop client dependencies
Apache Ozone HDDS Hadoop Client dependencies
diff --git a/hadoop-hdds/hadoop-dependency-server/pom.xml b/hadoop-hdds/hadoop-dependency-server/pom.xml
index 69daeac4bd7f..c6f91c4ca173 100644
--- a/hadoop-hdds/hadoop-dependency-server/pom.xml
+++ b/hadoop-hdds/hadoop-dependency-server/pom.xml
@@ -20,10 +20,10 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
org.apache.ozone
hdds
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
hdds-hadoop-dependency-server
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Apache Ozone Distributed Data Store Hadoop server dependencies
Apache Ozone HDDS Hadoop Server dependencies
diff --git a/hadoop-hdds/hadoop-dependency-test/pom.xml b/hadoop-hdds/hadoop-dependency-test/pom.xml
index 80ec91cd6d94..f04e45a03404 100644
--- a/hadoop-hdds/hadoop-dependency-test/pom.xml
+++ b/hadoop-hdds/hadoop-dependency-test/pom.xml
@@ -20,10 +20,10 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
org.apache.ozone
hdds
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
hdds-hadoop-dependency-test
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Apache Ozone Distributed Data Store Hadoop test dependencies
Apache Ozone HDDS Hadoop Test dependencies
diff --git a/hadoop-hdds/interface-admin/pom.xml b/hadoop-hdds/interface-admin/pom.xml
index 9230b02b524c..422fb2048a34 100644
--- a/hadoop-hdds/interface-admin/pom.xml
+++ b/hadoop-hdds/interface-admin/pom.xml
@@ -20,10 +20,10 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
org.apache.ozone
hdds
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
hdds-interface-admin
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Apache Ozone Distributed Data Store Admin interface
Apache Ozone HDDS Admin Interface
diff --git a/hadoop-hdds/interface-admin/src/main/proto/ScmAdminProtocol.proto b/hadoop-hdds/interface-admin/src/main/proto/ScmAdminProtocol.proto
index 039914369b5f..ee2df89e81b7 100644
--- a/hadoop-hdds/interface-admin/src/main/proto/ScmAdminProtocol.proto
+++ b/hadoop-hdds/interface-admin/src/main/proto/ScmAdminProtocol.proto
@@ -296,6 +296,7 @@ message SCMListContainerRequestProto {
message SCMListContainerResponseProto {
repeated ContainerInfoProto containers = 1;
+ optional int64 containerCount = 2;
}
message SCMDeleteContainerRequestProto {
diff --git a/hadoop-hdds/interface-client/pom.xml b/hadoop-hdds/interface-client/pom.xml
index 98cfc53f5e86..3c8c7cfc2257 100644
--- a/hadoop-hdds/interface-client/pom.xml
+++ b/hadoop-hdds/interface-client/pom.xml
@@ -20,10 +20,10 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
org.apache.ozone
hdds
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
hdds-interface-client
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Apache Ozone Distributed Data Store Client interface
Apache Ozone HDDS Client Interface
diff --git a/hadoop-hdds/interface-client/src/main/proto/hdds.proto b/hadoop-hdds/interface-client/src/main/proto/hdds.proto
index 6cd4f6235ce7..1fc5884e24fa 100644
--- a/hadoop-hdds/interface-client/src/main/proto/hdds.proto
+++ b/hadoop-hdds/interface-client/src/main/proto/hdds.proto
@@ -61,7 +61,7 @@ message ExtendedDatanodeDetailsProto {
optional string version = 2;
optional int64 setupTime = 3;
optional string revision = 4;
- optional string buildDate = 5;
+ optional string buildDate = 5; // unused, reserved for compatibility
}
message MoveDataNodePairProto {
@@ -257,6 +257,7 @@ message GetScmInfoResponseProto {
required string clusterId = 1;
required string scmId = 2;
repeated string peerRoles = 3;
+ optional bool scmRatisEnabled = 4;
}
message AddScmRequestProto {
diff --git a/hadoop-hdds/interface-server/pom.xml b/hadoop-hdds/interface-server/pom.xml
index df65c1e2b2af..6a6f2a6b383a 100644
--- a/hadoop-hdds/interface-server/pom.xml
+++ b/hadoop-hdds/interface-server/pom.xml
@@ -20,10 +20,10 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
org.apache.ozone
hdds
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
hdds-interface-server
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Apache Ozone Distributed Data Store Server interface
Apache Ozone HDDS Server Interface
diff --git a/hadoop-hdds/managed-rocksdb/pom.xml b/hadoop-hdds/managed-rocksdb/pom.xml
index 125783222e54..40ad920647a0 100644
--- a/hadoop-hdds/managed-rocksdb/pom.xml
+++ b/hadoop-hdds/managed-rocksdb/pom.xml
@@ -19,10 +19,10 @@
org.apache.ozone
hdds
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
hdds-managed-rocksdb
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Apache Ozone Managed RocksDB library
Apache Ozone HDDS Managed RocksDB
jar
diff --git a/hadoop-hdds/managed-rocksdb/src/main/java/org/apache/hadoop/hdds/utils/db/managed/ManagedRocksObjectUtils.java b/hadoop-hdds/managed-rocksdb/src/main/java/org/apache/hadoop/hdds/utils/db/managed/ManagedRocksObjectUtils.java
index 148abee7fc0e..d58f70495fe8 100644
--- a/hadoop-hdds/managed-rocksdb/src/main/java/org/apache/hadoop/hdds/utils/db/managed/ManagedRocksObjectUtils.java
+++ b/hadoop-hdds/managed-rocksdb/src/main/java/org/apache/hadoop/hdds/utils/db/managed/ManagedRocksObjectUtils.java
@@ -55,12 +55,7 @@ static UncheckedAutoCloseable track(AutoCloseable object) {
static void reportLeak(Class> clazz, String stackTrace) {
ManagedRocksObjectMetrics.INSTANCE.increaseLeakObject();
- String warning = String.format("%s is not closed properly", clazz.getSimpleName());
- if (stackTrace != null && LOG.isDebugEnabled()) {
- String debugMessage = String.format("%nStackTrace for unclosed instance: %s", stackTrace);
- warning = warning.concat(debugMessage);
- }
- LOG.warn(warning);
+ HddsUtils.reportLeak(clazz, stackTrace, LOG);
}
private static @Nullable StackTraceElement[] getStackTrace() {
diff --git a/hadoop-hdds/pom.xml b/hadoop-hdds/pom.xml
index 87d761583014..2fb94d8c809a 100644
--- a/hadoop-hdds/pom.xml
+++ b/hadoop-hdds/pom.xml
@@ -20,11 +20,11 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
org.apache.ozone
ozone-main
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
hdds
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Apache Ozone Distributed Data Store Project
Apache Ozone HDDS
pom
diff --git a/hadoop-hdds/rocks-native/pom.xml b/hadoop-hdds/rocks-native/pom.xml
index 5fc9949514bd..35a03db730a4 100644
--- a/hadoop-hdds/rocks-native/pom.xml
+++ b/hadoop-hdds/rocks-native/pom.xml
@@ -18,7 +18,7 @@
hdds
org.apache.ozone
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
4.0.0
Apache Ozone HDDS RocksDB Tools
diff --git a/hadoop-hdds/rocks-native/src/main/java/org/apache/hadoop/hdds/utils/NativeLibraryLoader.java b/hadoop-hdds/rocks-native/src/main/java/org/apache/hadoop/hdds/utils/NativeLibraryLoader.java
index ce424c930e1c..d93933dee362 100644
--- a/hadoop-hdds/rocks-native/src/main/java/org/apache/hadoop/hdds/utils/NativeLibraryLoader.java
+++ b/hadoop-hdds/rocks-native/src/main/java/org/apache/hadoop/hdds/utils/NativeLibraryLoader.java
@@ -36,6 +36,8 @@
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
+import static org.apache.hadoop.hdds.utils.NativeConstants.ROCKS_TOOLS_NATIVE_LIBRARY_NAME;
+
/**
* Class to load Native Libraries.
*/
@@ -67,6 +69,10 @@ public static NativeLibraryLoader getInstance() {
return instance;
}
+ public static String getJniLibraryFileName() {
+ return appendLibOsSuffix("lib" + ROCKS_TOOLS_NATIVE_LIBRARY_NAME);
+ }
+
public static String getJniLibraryFileName(String libraryName) {
return appendLibOsSuffix("lib" + libraryName);
}
@@ -99,9 +105,12 @@ private static String appendLibOsSuffix(String libraryFileName) {
return libraryFileName + getLibOsSuffix();
}
+ public static boolean isLibraryLoaded() {
+ return isLibraryLoaded(ROCKS_TOOLS_NATIVE_LIBRARY_NAME);
+ }
+
public static boolean isLibraryLoaded(final String libraryName) {
- return getInstance().librariesLoaded
- .getOrDefault(libraryName, false);
+ return getInstance().librariesLoaded.getOrDefault(libraryName, false);
}
public synchronized boolean loadLibrary(final String libraryName, final List dependentFiles) {
diff --git a/hadoop-hdds/rocksdb-checkpoint-differ/pom.xml b/hadoop-hdds/rocksdb-checkpoint-differ/pom.xml
index 3e535c5f5f26..c4284a4e85d1 100644
--- a/hadoop-hdds/rocksdb-checkpoint-differ/pom.xml
+++ b/hadoop-hdds/rocksdb-checkpoint-differ/pom.xml
@@ -20,11 +20,11 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
org.apache.ozone
hdds
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
rocksdb-checkpoint-differ
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
RocksDB Checkpoint Differ
RocksDB Checkpoint Differ
jar
diff --git a/hadoop-hdds/rocksdb-checkpoint-differ/src/main/java/org/apache/ozone/compaction/log/CompactionLogEntry.java b/hadoop-hdds/rocksdb-checkpoint-differ/src/main/java/org/apache/ozone/compaction/log/CompactionLogEntry.java
index c27763b97880..04980821ba9e 100644
--- a/hadoop-hdds/rocksdb-checkpoint-differ/src/main/java/org/apache/ozone/compaction/log/CompactionLogEntry.java
+++ b/hadoop-hdds/rocksdb-checkpoint-differ/src/main/java/org/apache/ozone/compaction/log/CompactionLogEntry.java
@@ -38,7 +38,8 @@ public final class CompactionLogEntry implements
private static final Codec CODEC = new DelegatedCodec<>(
Proto2Codec.get(CompactionLogEntryProto.getDefaultInstance()),
CompactionLogEntry::getFromProtobuf,
- CompactionLogEntry::getProtobuf);
+ CompactionLogEntry::getProtobuf,
+ CompactionLogEntry.class);
public static Codec getCodec() {
return CODEC;
diff --git a/hadoop-hdds/server-scm/pom.xml b/hadoop-hdds/server-scm/pom.xml
index 32408e8904b2..26e35b072ffc 100644
--- a/hadoop-hdds/server-scm/pom.xml
+++ b/hadoop-hdds/server-scm/pom.xml
@@ -20,10 +20,10 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
org.apache.ozone
hdds
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
hdds-server-scm
- 1.5.0-SNAPSHOT
+ 2.0.0-SNAPSHOT
Apache Ozone Distributed Data Store Storage Container Manager Server
Apache Ozone HDDS SCM Server
jar
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/PlacementPolicy.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/PlacementPolicy.java
index a792e2cea6b7..05eb32722e73 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/PlacementPolicy.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/PlacementPolicy.java
@@ -73,7 +73,7 @@ ContainerPlacementStatus validateContainerPlacement(
* Given a set of replicas of a container which are
* neither over underreplicated nor overreplicated,
* return a set of replicas to copy to another node to fix misreplication.
- * @param replicas: Map of replicas with value signifying if
+ * @param replicas Map of replicas with value signifying if
* replica can be copied
*/
Set replicasToCopyToFixMisreplication(
@@ -82,8 +82,8 @@ Set replicasToCopyToFixMisreplication(
/**
* Given a set of replicas of a container which are overreplicated,
* return a set of replicas to delete to fix overreplication.
- * @param replicas: Set of existing replicas of the container
- * @param expectedCountPerUniqueReplica: Replication factor of each
+ * @param replicas Set of existing replicas of the container
+ * @param expectedCountPerUniqueReplica Replication factor of each
* unique replica
*/
Set replicasToRemoveToFixOverreplication(
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/SCMCommonPlacementPolicy.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/SCMCommonPlacementPolicy.java
index 471a94794122..2a1c6fce0c0f 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/SCMCommonPlacementPolicy.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/SCMCommonPlacementPolicy.java
@@ -525,7 +525,7 @@ public boolean isValidNode(DatanodeDetails datanodeDetails,
* Given a set of replicas of a container which are
* neither over underreplicated nor overreplicated,
* return a set of replicas to copy to another node to fix misreplication.
- * @param replicas: Map of replicas with value signifying if
+ * @param replicas Map of replicas with value signifying if
* replica can be copied
*/
@Override
@@ -582,7 +582,7 @@ protected Node getPlacementGroup(DatanodeDetails dn) {
* replication is computed.
* The algorithm starts with creating a replicaIdMap which contains the
* replicas grouped by replica Index. A placementGroup Map is created which
- * groups replicas based on their rack & the replicas within the rack
+ * groups replicas based on their rack and the replicas within the rack
* are further grouped based on the replica Index.
* A placement Group Count Map is created which keeps
* track of the count of replicas in each rack.
@@ -590,13 +590,13 @@ protected Node getPlacementGroup(DatanodeDetails dn) {
* order based on their current replication factor in a descending factor.
* For each replica Index the replica is removed from the rack which contains
* the most replicas, in order to achieve this the racks are put
- * into priority queue & are based on the number of replicas they have.
- * The replica is removed from the rack with maximum replicas & the replica
- * to be removed is also removed from the maps created above &
+ * into priority queue and are based on the number of replicas they have.
+ * The replica is removed from the rack with maximum replicas and the replica
+ * to be removed is also removed from the maps created above and
* the count for rack is reduced.
* The set of replicas computed are then returned by the function.
- * @param replicas: Set of existing replicas of the container
- * @param expectedCountPerUniqueReplica: Replication factor of each
+ * @param replicas Set of existing replicas of the container
+ * @param expectedCountPerUniqueReplica Replication factor of each
* * unique replica
* @return Set of replicas to be removed are computed.
*/
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DatanodeDeletedBlockTransactions.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DatanodeDeletedBlockTransactions.java
index e485fcc98d93..99fd9c7b431d 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DatanodeDeletedBlockTransactions.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DatanodeDeletedBlockTransactions.java
@@ -47,7 +47,8 @@ void addTransactionToDN(UUID dnID, DeletedBlocksTransaction tx) {
blocksDeleted += tx.getLocalIDCount();
if (SCMBlockDeletingService.LOG.isDebugEnabled()) {
SCMBlockDeletingService.LOG
- .debug("Transaction added: {} <- TX({})", dnID, tx.getTxID());
+ .debug("Transaction added: {} <- TX({}), DN {} <- blocksDeleted Add {}.",
+ dnID, tx.getTxID(), dnID, tx.getLocalIDCount());
}
}
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLog.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLog.java
index 45d53c0ef2cd..5ec68c78d74a 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLog.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLog.java
@@ -57,7 +57,7 @@ DatanodeDeletedBlockTransactions getTransactions(
* considered to be failed if it has been sent more than MAX_RETRY limit
* and its count is reset to -1.
*
- * @param count Maximum num of returned transactions, if < 0. return all.
+ * @param count Maximum num of returned transactions, if < 0. return all.
* @param startTxId The least transaction id to start with.
* @return a list of failed deleted block transactions.
* @throws IOException
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java
index 9d5377b9e3e6..987f293dd14c 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java
@@ -35,7 +35,6 @@
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.CommandStatus;
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerBlocksDeletionACKProto;
-import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerBlocksDeletionACKProto.DeleteBlockTransactionResult;
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.DeletedBlocksTransaction;
import org.apache.hadoop.hdds.scm.command.CommandStatusReportHandler.DeleteBlockStatus;
import org.apache.hadoop.hdds.scm.container.ContainerInfo;
@@ -200,20 +199,6 @@ private DeletedBlocksTransaction constructNewTransaction(
.build();
}
- private boolean isTransactionFailed(DeleteBlockTransactionResult result) {
- if (LOG.isDebugEnabled()) {
- LOG.debug(
- "Got block deletion ACK from datanode, TXIDs={}, " + "success={}",
- result.getTxID(), result.getSuccess());
- }
- if (!result.getSuccess()) {
- LOG.warn("Got failed ACK for TXID={}, prepare to resend the "
- + "TX in next interval", result.getTxID());
- return true;
- }
- return false;
- }
-
@Override
public int getNumOfValidTransactions() throws IOException {
lock.lock();
@@ -300,26 +285,46 @@ private void getTransaction(DeletedBlocksTransaction tx,
.setCount(transactionStatusManager.getOrDefaultRetryCount(
tx.getTxID(), 0))
.build();
+
for (ContainerReplica replica : replicas) {
DatanodeDetails details = replica.getDatanodeDetails();
- if (!dnList.contains(details)) {
- continue;
- }
if (!transactionStatusManager.isDuplication(
details, updatedTxn.getTxID(), commandStatus)) {
transactions.addTransactionToDN(details.getUuid(), updatedTxn);
+ metrics.incrProcessedTransaction();
}
}
}
private Boolean checkInadequateReplica(Set replicas,
- DeletedBlocksTransaction txn) throws ContainerNotFoundException {
+ DeletedBlocksTransaction txn,
+ Set dnList) throws ContainerNotFoundException {
ContainerInfo containerInfo = containerManager
.getContainer(ContainerID.valueOf(txn.getContainerID()));
ReplicationManager replicationManager =
scmContext.getScm().getReplicationManager();
ContainerHealthResult result = replicationManager
.getContainerReplicationHealth(containerInfo, replicas);
+
+ // We have made an improvement here, and we expect that all replicas
+ // of the Container being sent will be included in the dnList.
+ // This change benefits ACK confirmation and improves deletion speed.
+ // The principle behind it is that
+ // DN can receive the command to delete a certain Container at the same time and provide
+ // feedback to SCM at roughly the same time.
+ // This avoids the issue of deletion blocking,
+ // where some replicas of a Container are deleted while others do not receive the delete command.
+ long containerId = txn.getContainerID();
+ for (ContainerReplica replica : replicas) {
+ DatanodeDetails datanodeDetails = replica.getDatanodeDetails();
+ if (!dnList.contains(datanodeDetails)) {
+ DatanodeDetails dnDetail = replica.getDatanodeDetails();
+ LOG.debug("Skip Container = {}, because DN = {} is not in dnList.",
+ containerId, dnDetail.getUuid());
+ return true;
+ }
+ }
+
return result.getHealthState() != ContainerHealthResult.HealthState.HEALTHY;
}
@@ -345,6 +350,7 @@ public DatanodeDeletedBlockTransactions getTransactions(
.getCommandStatusByTxId(dnList.stream().
map(DatanodeDetails::getUuid).collect(Collectors.toSet()));
ArrayList txIDs = new ArrayList<>();
+ metrics.setNumBlockDeletionTransactionDataNodes(dnList.size());
// Here takes block replica count as the threshold to avoid the case
// that part of replicas committed the TXN and recorded in the
// SCMDeletedBlockTransactionStatusManager, while they are counted
@@ -358,23 +364,25 @@ public DatanodeDeletedBlockTransactions getTransactions(
// HDDS-7126. When container is under replicated, it is possible
// that container is deleted, but transactions are not deleted.
if (containerManager.getContainer(id).isDeleted()) {
- LOG.warn("Container: " + id + " was deleted for the " +
- "transaction: " + txn);
+ LOG.warn("Container: {} was deleted for the " +
+ "transaction: {}.", id, txn);
txIDs.add(txn.getTxID());
} else if (txn.getCount() > -1 && txn.getCount() <= maxRetry
&& !containerManager.getContainer(id).isOpen()) {
Set replicas = containerManager
.getContainerReplicas(
ContainerID.valueOf(txn.getContainerID()));
- if (checkInadequateReplica(replicas, txn)) {
+ if (checkInadequateReplica(replicas, txn, dnList)) {
+ metrics.incrSkippedTransaction();
continue;
}
getTransaction(
txn, transactions, dnList, replicas, commandStatus);
+ } else if (txn.getCount() >= maxRetry || containerManager.getContainer(id).isOpen()) {
+ metrics.incrSkippedTransaction();
}
} catch (ContainerNotFoundException ex) {
- LOG.warn("Container: " + id + " was not found for the transaction: "
- + txn);
+ LOG.warn("Container: {} was not found for the transaction: {}.", id, txn);
txIDs.add(txn.getTxID());
}
}
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/SCMBlockDeletingService.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/SCMBlockDeletingService.java
index 7271d9dcba68..e6fc45cb5eee 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/SCMBlockDeletingService.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/SCMBlockDeletingService.java
@@ -203,9 +203,10 @@ public EmptyTaskResult call() throws Exception {
}
}
LOG.info("Totally added {} blocks to be deleted for"
- + " {} datanodes, task elapsed time: {}ms",
+ + " {} datanodes / {} totalnodes, task elapsed time: {}ms",
transactions.getBlocksDeleted(),
transactions.getDatanodeTransactionMap().size(),
+ included.size(),
Time.monotonicNow() - startTime);
deletedBlockLog.incrementCount(new ArrayList<>(processedTxIDs));
} catch (NotLeaderException nle) {
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/ScmBlockDeletingServiceMetrics.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/ScmBlockDeletingServiceMetrics.java
index 2cadca1d92a4..6637bd183293 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/ScmBlockDeletingServiceMetrics.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/ScmBlockDeletingServiceMetrics.java
@@ -24,6 +24,7 @@
import org.apache.hadoop.metrics2.annotation.Metrics;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
import org.apache.hadoop.metrics2.lib.MutableCounterLong;
+import org.apache.hadoop.metrics2.lib.MutableGaugeLong;
/**
* Metrics related to Block Deleting Service running in SCM.
@@ -76,6 +77,15 @@ public final class ScmBlockDeletingServiceMetrics {
@Metric(about = "The number of created txs which are added into DB.")
private MutableCounterLong numBlockDeletionTransactionCreated;
+ @Metric(about = "The number of skipped transactions")
+ private MutableCounterLong numSkippedTransactions;
+
+ @Metric(about = "The number of processed transactions")
+ private MutableCounterLong numProcessedTransactions;
+
+ @Metric(about = "The number of dataNodes of delete transactions.")
+ private MutableGaugeLong numBlockDeletionTransactionDataNodes;
+
private ScmBlockDeletingServiceMetrics() {
}
@@ -130,6 +140,18 @@ public void incrBlockDeletionTransactionCreated(long count) {
this.numBlockDeletionTransactionCreated.incr(count);
}
+ public void incrSkippedTransaction() {
+ this.numSkippedTransactions.incr();
+ }
+
+ public void incrProcessedTransaction() {
+ this.numProcessedTransactions.incr();
+ }
+
+ public void setNumBlockDeletionTransactionDataNodes(long dataNodes) {
+ this.numBlockDeletionTransactionDataNodes.set(dataNodes);
+ }
+
public long getNumBlockDeletionCommandSent() {
return numBlockDeletionCommandSent.value();
}
@@ -162,6 +184,18 @@ public long getNumBlockDeletionTransactionCreated() {
return numBlockDeletionTransactionCreated.value();
}
+ public long getNumSkippedTransactions() {
+ return numSkippedTransactions.value();
+ }
+
+ public long getNumProcessedTransactions() {
+ return numProcessedTransactions.value();
+ }
+
+ public long getNumBlockDeletionTransactionDataNodes() {
+ return numBlockDeletionTransactionDataNodes.value();
+ }
+
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManager.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManager.java
index 3eba240533e3..6b6a888f4241 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManager.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManager.java
@@ -61,9 +61,9 @@ default List getContainers() {
* The max size of the searching range cannot exceed the
* value of count.
*
- * @param startID start containerID, >=0,
+ * @param startID start containerID, >=0,
* start searching at the head if 0.
- * @param count count must be >= 0
+ * @param count count must be >= 0
* Usually the count will be replace with a very big
* value instead of being unlimited in case the db is very big.
*
@@ -85,9 +85,9 @@ default List getContainers() {
* The max size of the searching range cannot exceed the
* value of count.
*
- * @param startID start containerID, >=0,
+ * @param startID start containerID, >=0,
* start searching at the head if 0.
- * @param count count must be >= 0
+ * @param count count must be >= 0
* Usually the count will be replace with a very big
* value instead of being unlimited in case the db is very big.
* @param state container state
@@ -164,7 +164,6 @@ void updateContainerReplica(ContainerID containerID, ContainerReplica replica)
*
* @param containerID Container ID
* @param replica ContainerReplica
- * @return True of dataNode is removed successfully else false.
*/
void removeContainerReplica(ContainerID containerID, ContainerReplica replica)
throws ContainerNotFoundException, ContainerReplicaNotFoundException;
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManagerImpl.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManagerImpl.java
index 00aee0f62c25..d61f9ee366bd 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManagerImpl.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManagerImpl.java
@@ -86,6 +86,8 @@ public class ContainerManagerImpl implements ContainerManager {
@SuppressWarnings("java:S2245") // no need for secure random
private final Random random = new Random();
+ private int maxCountOfContainerList;
+
/**
*
*/
@@ -115,6 +117,10 @@ public ContainerManagerImpl(
.getInt(ScmConfigKeys.OZONE_SCM_PIPELINE_OWNER_CONTAINER_COUNT,
ScmConfigKeys.OZONE_SCM_PIPELINE_OWNER_CONTAINER_COUNT_DEFAULT);
+ this.maxCountOfContainerList = conf
+ .getInt(ScmConfigKeys.OZONE_SCM_CONTAINER_LIST_MAX_COUNT,
+ ScmConfigKeys.OZONE_SCM_CONTAINER_LIST_MAX_COUNT_DEFAULT);
+
this.scmContainerManagerMetrics = SCMContainerManagerMetrics.create();
}
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancerTask.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancerTask.java
index 19a2f3c2e621..c3b76dc44975 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancerTask.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancerTask.java
@@ -691,7 +691,7 @@ private void checkIterationMoveResults() {
moveSelectionToFutureMap.values();
if (!futures.isEmpty()) {
CompletableFuture allFuturesResult = CompletableFuture.allOf(
- futures.toArray(new CompletableFuture[futures.size()]));
+ futures.toArray(new CompletableFuture[0]));
try {
allFuturesResult.get(config.getMoveTimeout().toMillis(),
TimeUnit.MILLISECONDS);
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/placement/algorithms/SCMContainerPlacementRackAware.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/placement/algorithms/SCMContainerPlacementRackAware.java
index 7fec06e7e069..1c2b5a3be395 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/placement/algorithms/SCMContainerPlacementRackAware.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/placement/algorithms/SCMContainerPlacementRackAware.java
@@ -346,8 +346,7 @@ protected List chooseDatanodesInternalLegacy(
return chooseNodes(null, chosenNodes, mutableFavoredNodes,
mutableUsedNodes, favorIndex, nodesRequired, mapSizeRequired);
} else {
- List mutableExcludedNodes = new ArrayList<>();
- mutableExcludedNodes.addAll(excludedNodes);
+ List mutableExcludedNodes = new ArrayList<>(excludedNodes);
// choose node to meet replication requirement
// case 1: one excluded node, choose one on the same rack as the excluded
// node, choose others on different racks.
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/placement/metrics/SCMNodeMetric.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/placement/metrics/SCMNodeMetric.java
index 094e535dcbd9..3d113b3d3012 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/placement/metrics/SCMNodeMetric.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/placement/metrics/SCMNodeMetric.java
@@ -42,8 +42,7 @@ public SCMNodeMetric(SCMNodeStat stat) {
* @param capacity in bytes
* @param used in bytes
* @param remaining in bytes
- * @param committed
- * @paaram committed in bytes
+ * @param committed in bytes
*/
@VisibleForTesting
public SCMNodeMetric(long capacity, long used, long remaining,
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ContainerHealthResult.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ContainerHealthResult.java
index 0abe8f6ea34d..fcfef7de6e6c 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ContainerHealthResult.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ContainerHealthResult.java
@@ -248,7 +248,6 @@ public void setOfflineIndexesOkAfterPending(boolean val) {
/**
* Returns true if a container has under-replication caused by offline
* indexes, but it is corrected by a pending add.
- * @return
*/
public boolean offlineIndexesOkAfterPending() {
return offlineIndexesOkAfterPending;
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ContainerReplicaPendingOps.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ContainerReplicaPendingOps.java
index d1890bdf8026..4eef0a8a744c 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ContainerReplicaPendingOps.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ContainerReplicaPendingOps.java
@@ -116,7 +116,7 @@ public List getPendingOps(ContainerID containerID) {
* Store a ContainerReplicaOp to add a replica for the given ContainerID.
* @param containerID ContainerID for which to add a replica
* @param target The target datanode
- * @param replicaIndex The replica index (zero for Ratis, > 0 for EC)
+ * @param replicaIndex The replica index (zero for Ratis, > 0 for EC)
* @param deadlineEpochMillis The time by which the replica should have been
* added and reported by the datanode, or it will
* be discarded.
@@ -130,7 +130,7 @@ public void scheduleAddReplica(ContainerID containerID,
* Store a ContainerReplicaOp to delete a replica for the given ContainerID.
* @param containerID ContainerID for which to delete a replica
* @param target The target datanode
- * @param replicaIndex The replica index (zero for Ratis, > 0 for EC)
+ * @param replicaIndex The replica index (zero for Ratis, > 0 for EC)
* @param deadlineEpochMillis The time by which the replica should have been
* deleted and reported by the datanode, or it will
* be discarded.
@@ -145,7 +145,7 @@ public void scheduleDeleteReplica(ContainerID containerID,
* been replicated successfully.
* @param containerID ContainerID for which to complete the replication
* @param target The target Datanode
- * @param replicaIndex The replica index (zero for Ratis, > 0 for EC)
+ * @param replicaIndex The replica index (zero for Ratis, > 0 for EC)
* @return True if a pending replica was found and removed, false otherwise.
*/
public boolean completeAddReplica(ContainerID containerID,
@@ -167,7 +167,7 @@ public boolean completeAddReplica(ContainerID containerID,
* been deleted successfully.
* @param containerID ContainerID for which to complete the deletion
* @param target The target Datanode
- * @param replicaIndex The replica index (zero for Ratis, > 0 for EC)
+ * @param replicaIndex The replica index (zero for Ratis, > 0 for EC)
* @return True if a pending replica was found and removed, false otherwise.
*/
public boolean completeDeleteReplica(ContainerID containerID,
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/RatisContainerReplicaCount.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/RatisContainerReplicaCount.java
index fe771fac6a4a..4e14798ccdcc 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/RatisContainerReplicaCount.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/RatisContainerReplicaCount.java
@@ -186,9 +186,9 @@ private void countReplicas() {
* For example, consider a CLOSED container with the following replicas:
* {CLOSED, CLOSING, OPEN, UNHEALTHY}
* In this case, healthy replica count equals 3. Calculation:
- * 1 CLOSED -> 1 matching replica.
- * 1 OPEN, 1 CLOSING -> 2 mismatched replicas.
- * 1 UNHEALTHY -> 1 unhealthy replica. Not counted as healthy.
+ * 1 CLOSED -> 1 matching replica.
+ * 1 OPEN, 1 CLOSING -> 2 mismatched replicas.
+ * 1 UNHEALTHY -> 1 unhealthy replica. Not counted as healthy.
* Total healthy replicas = 3 = 1 matching + 2 mismatched replicas
*/
public int getHealthyReplicaCount() {
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/health/HealthCheck.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/health/HealthCheck.java
index a95c0d39945b..f271b8a863c9 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/health/HealthCheck.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/health/HealthCheck.java
@@ -49,7 +49,6 @@ public interface HealthCheck {
* returns false. This allows handlers to be chained together, and each will
* be tried in turn until one succeeds.
* @param handler
- * @return
*/
HealthCheck addNext(HealthCheck handler);
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/states/ContainerAttribute.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/states/ContainerAttribute.java
index c6f15be5d2cf..1289a0a21ff7 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/states/ContainerAttribute.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/states/ContainerAttribute.java
@@ -37,10 +37,10 @@
*
* Currently we manage the following attributes for a container.
*
- * 1. StateMap - LifeCycleState -> Set of ContainerIDs
- * 2. TypeMap - ReplicationType -> Set of ContainerIDs
- * 3. OwnerMap - OwnerNames -> Set of ContainerIDs
- * 4. FactorMap - ReplicationFactor -> Set of ContainerIDs
+ * 1. StateMap - LifeCycleState -> Set of ContainerIDs
+ * 2. TypeMap - ReplicationType -> Set of ContainerIDs
+ * 3. OwnerMap - OwnerNames -> Set of ContainerIDs
+ * 4. FactorMap - ReplicationFactor -> Set of ContainerIDs
*
* This means that for a cluster size of 750 PB -- we will have around 150
* Million containers, if we assume 5GB average container size.
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/HASecurityUtils.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/HASecurityUtils.java
index f0d78b23079a..5eeb489f677e 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/HASecurityUtils.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/HASecurityUtils.java
@@ -58,7 +58,7 @@
/**
* Utilities for SCM HA security.
*/
-public final class HASecurityUtils {
+public final class HASecurityUtils {
private HASecurityUtils() {
}
@@ -150,7 +150,6 @@ public static CertificateServer initializeRootCertificateServer(
*
* @param conf
* @param certificateClient
- * @return
*/
public static GrpcTlsConfig createSCMRatisTLSConfig(SecurityConfig conf,
CertificateClient certificateClient) throws IOException {
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/InterSCMGrpcService.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/InterSCMGrpcService.java
index bd4b56cd8c13..ec95ab66bf18 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/InterSCMGrpcService.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/InterSCMGrpcService.java
@@ -18,8 +18,7 @@
package org.apache.hadoop.hdds.scm.ha;
import java.io.IOException;
-
-import com.google.common.base.Preconditions;
+import java.util.Objects;
import org.apache.hadoop.hdds.protocol.scm.proto.InterSCMProtocolProtos.CopyDBCheckpointRequestProto;
import org.apache.hadoop.hdds.protocol.scm.proto.InterSCMProtocolProtos.CopyDBCheckpointResponseProto;
@@ -52,12 +51,11 @@ public class InterSCMGrpcService extends
private final Table transactionInfoTable;
InterSCMGrpcService(final StorageContainerManager scm) throws IOException {
- Preconditions.checkNotNull(scm);
+ Objects.requireNonNull(scm, "scm");
this.scm = scm;
this.transactionInfoTable = HAUtils.getTransactionInfoTable(
- scm.getScmMetadataStore().getStore(), new SCMDBDefinition());
- provider =
- new SCMDBCheckpointProvider(scm.getScmMetadataStore().getStore());
+ scm.getScmMetadataStore().getStore(), SCMDBDefinition.get());
+ this.provider = new SCMDBCheckpointProvider(scm.getScmMetadataStore().getStore());
}
@Override
@@ -67,7 +65,7 @@ public void download(CopyDBCheckpointRequestProto request,
scm.getScmHAManager().asSCMHADBTransactionBuffer().flush();
TransactionInfo transactionInfo =
transactionInfoTable.get(TRANSACTION_INFO_KEY);
- Preconditions.checkNotNull(transactionInfo);
+ Objects.requireNonNull(transactionInfo, "transactionInfo");
SCMGrpcOutputStream outputStream =
new SCMGrpcOutputStream(responseObserver, scm.getClusterId(),
BUFFER_SIZE);
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHADBTransactionBufferImpl.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHADBTransactionBufferImpl.java
index f1ee76a198ec..cd0346d72f83 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHADBTransactionBufferImpl.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHADBTransactionBufferImpl.java
@@ -26,6 +26,8 @@
import org.apache.hadoop.hdds.utils.db.BatchOperation;
import org.apache.hadoop.hdds.utils.db.Table;
import org.apache.ratis.statemachine.SnapshotInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicLong;
@@ -41,6 +43,8 @@
* operation in DB.
*/
public class SCMHADBTransactionBufferImpl implements SCMHADBTransactionBuffer {
+
+ public static final Logger LOG = LoggerFactory.getLogger(SCMHADBTransactionBufferImpl.class);
private final StorageContainerManager scm;
private SCMMetadataStore metadataStore;
private BatchOperation currentBatchOperation;
@@ -107,6 +111,8 @@ public SnapshotInfo getLatestSnapshot() {
@Override
public void setLatestSnapshot(SnapshotInfo latestSnapshot) {
+ LOG.info("{}: Set latest Snapshot to {}",
+ scm.getScmHAManager().getRatisServer().getDivision().getId(), latestSnapshot);
this.latestSnapshot.set(latestSnapshot);
}
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAManager.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAManager.java
index 03f6ae293b2e..92a5140ff2a9 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAManager.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAManager.java
@@ -55,7 +55,6 @@ public interface SCMHAManager extends AutoCloseable {
/**
* Returns the DBTransactionBuffer as SCMHADBTransactionBuffer if its
* valid.
- * @return
*/
SCMHADBTransactionBuffer asSCMHADBTransactionBuffer();
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAManagerImpl.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAManagerImpl.java
index fc3c1548ba14..5d0ea444ef8a 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAManagerImpl.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAManagerImpl.java
@@ -72,6 +72,7 @@ public class SCMHAManagerImpl implements SCMHAManager {
private final SCMRatisServer ratisServer;
private final ConfigurationSource conf;
+ private final OzoneConfiguration ozoneConf;
private final SecurityConfig securityConfig;
private final DBTransactionBuffer transactionBuffer;
private final SCMSnapshotProvider scmSnapshotProvider;
@@ -89,6 +90,7 @@ public SCMHAManagerImpl(final ConfigurationSource conf,
final SecurityConfig securityConfig,
final StorageContainerManager scm) throws IOException {
this.conf = conf;
+ this.ozoneConf = OzoneConfiguration.of(conf);
this.securityConfig = securityConfig;
this.scm = scm;
this.exitManager = new ExitManager();
@@ -128,7 +130,7 @@ public void start() throws IOException {
// It will first try to add itself to existing ring
final SCMNodeDetails nodeDetails =
scm.getSCMHANodeDetails().getLocalNodeDetails();
- final boolean success = HAUtils.addSCM(OzoneConfiguration.of(conf),
+ final boolean success = HAUtils.addSCM(ozoneConf,
new AddSCMRequest.Builder().setClusterId(scm.getClusterId())
.setScmId(scm.getScmId())
.setRatisAddr(nodeDetails
@@ -221,17 +223,18 @@ public List getSecretKeysFromLeader(String leaderID)
}
}
+ private TransactionInfo getTransactionInfoFromCheckpoint(Path checkpointLocation) throws IOException {
+ return HAUtils.getTrxnInfoFromCheckpoint(
+ ozoneConf, checkpointLocation, SCMDBDefinition.get());
+ }
+
@Override
public TermIndex verifyCheckpointFromLeader(String leaderId,
DBCheckpoint checkpoint) {
try {
Path checkpointLocation = checkpoint.getCheckpointLocation();
- TransactionInfo checkpointTxnInfo = HAUtils
- .getTrxnInfoFromCheckpoint(OzoneConfiguration.of(conf),
- checkpointLocation, new SCMDBDefinition());
-
- LOG.info("Installing checkpoint with SCMTransactionInfo {}",
- checkpointTxnInfo);
+ final TransactionInfo checkpointTxnInfo = getTransactionInfoFromCheckpoint(checkpointLocation);
+ LOG.info("{}: Verify checkpoint {} from leader {}", scm.getScmId(), checkpointTxnInfo, leaderId);
TermIndex termIndex =
getRatisServer().getSCMStateMachine().getLastAppliedTermIndex();
@@ -281,12 +284,9 @@ public TermIndex installCheckpoint(DBCheckpoint dbCheckpoint)
throws Exception {
Path checkpointLocation = dbCheckpoint.getCheckpointLocation();
- TransactionInfo checkpointTrxnInfo = HAUtils
- .getTrxnInfoFromCheckpoint(OzoneConfiguration.of(conf),
- checkpointLocation, new SCMDBDefinition());
+ final TransactionInfo checkpointTrxnInfo = getTransactionInfoFromCheckpoint(checkpointLocation);
- LOG.info("Installing checkpoint with SCMTransactionInfo {}",
- checkpointTrxnInfo);
+ LOG.info("{}: Install checkpoint {}", scm.getScmId(), checkpointTrxnInfo);
return installCheckpoint(checkpointLocation, checkpointTrxnInfo);
}
@@ -457,7 +457,7 @@ public void startServices() throws IOException {
// TODO: Fix the metrics ??
final SCMMetadataStore metadataStore = scm.getScmMetadataStore();
- metadataStore.start(OzoneConfiguration.of(conf));
+ metadataStore.start(ozoneConf);
scm.getSequenceIdGen().reinitialize(metadataStore.getSequenceIdTable());
scm.getPipelineManager().reinitialize(metadataStore.getPipelineTable());
scm.getContainerManager().reinitialize(metadataStore.getContainerTable());
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMStateMachine.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMStateMachine.java
index 1128accd2ff4..5805fe67e493 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMStateMachine.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMStateMachine.java
@@ -137,6 +137,7 @@ public void initialize(RaftServer server, RaftGroupId id,
getLifeCycle().startAndTransition(() -> {
super.initialize(server, id, raftStorage);
storage.init(raftStorage);
+ LOG.info("{}: initialize {}", server.getId(), id);
});
}
@@ -149,6 +150,9 @@ public CompletableFuture applyTransaction(
final SCMRatisRequest request = SCMRatisRequest.decode(
Message.valueOf(trx.getStateMachineLogEntry().getLogData()));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("{}: applyTransaction {}", getId(), TermIndex.valueOf(trx.getLogEntry()));
+ }
try {
applyTransactionFuture.complete(process(request));
} catch (SCMException ex) {
@@ -389,6 +393,7 @@ public void notifyConfigurationChanged(long term, long index,
@Override
public void pause() {
final LifeCycle lc = getLifeCycle();
+ LOG.info("{}: Try to pause from current LifeCycle state {}", getId(), lc);
if (lc.getCurrentState() != LifeCycle.State.NEW) {
lc.transition(LifeCycle.State.PAUSING);
lc.transition(LifeCycle.State.PAUSED);
@@ -414,6 +419,8 @@ public void reinitialize() throws IOException {
throw new IOException(e);
}
+ LOG.info("{}: SCMStateMachine is reinitializing. newTermIndex = {}", getId(), termIndex);
+
// re-initialize the DBTransactionBuffer and update the lastAppliedIndex.
try {
transactionBuffer.init();
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/metadata/BigIntegerCodec.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/metadata/BigIntegerCodec.java
index 5a7e86e99cc2..ab7530967166 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/metadata/BigIntegerCodec.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/metadata/BigIntegerCodec.java
@@ -38,6 +38,11 @@ private BigIntegerCodec() {
// singleton
}
+ @Override
+ public Class getTypeClass() {
+ return BigInteger.class;
+ }
+
@Override
public byte[] toPersistedFormat(BigInteger object) throws IOException {
return object.toByteArray();
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/metadata/SCMDBDefinition.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/metadata/SCMDBDefinition.java
index 4a280d2103ad..ea86fa154af5 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/metadata/SCMDBDefinition.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/metadata/SCMDBDefinition.java
@@ -41,75 +41,53 @@
* Class defines the structure and types of the scm.db.
*/
public class SCMDBDefinition extends DBDefinition.WithMap {
- public SCMDBDefinition() {
- this(COLUMN_FAMILIES);
- }
-
- protected SCMDBDefinition(Map> map) {
- super(map);
- }
-
public static final DBColumnFamilyDefinition
DELETED_BLOCKS =
new DBColumnFamilyDefinition<>(
"deletedBlocks",
- Long.class,
LongCodec.get(),
- DeletedBlocksTransaction.class,
Proto2Codec.get(DeletedBlocksTransaction.getDefaultInstance()));
public static final DBColumnFamilyDefinition
VALID_CERTS =
new DBColumnFamilyDefinition<>(
"validCerts",
- BigInteger.class,
BigIntegerCodec.get(),
- X509Certificate.class,
X509CertificateCodec.get());
public static final DBColumnFamilyDefinition
VALID_SCM_CERTS =
new DBColumnFamilyDefinition<>(
"validSCMCerts",
- BigInteger.class,
BigIntegerCodec.get(),
- X509Certificate.class,
X509CertificateCodec.get());
public static final DBColumnFamilyDefinition
PIPELINES =
new DBColumnFamilyDefinition<>(
"pipelines",
- PipelineID.class,
PipelineID.getCodec(),
- Pipeline.class,
Pipeline.getCodec());
public static final DBColumnFamilyDefinition
CONTAINERS =
new DBColumnFamilyDefinition<>(
"containers",
- ContainerID.class,
ContainerID.getCodec(),
- ContainerInfo.class,
ContainerInfo.getCodec());
public static final DBColumnFamilyDefinition
TRANSACTIONINFO =
new DBColumnFamilyDefinition<>(
"scmTransactionInfos",
- String.class,
StringCodec.get(),
- TransactionInfo.class,
TransactionInfo.getCodec());
public static final DBColumnFamilyDefinition
SEQUENCE_ID =
new DBColumnFamilyDefinition<>(
"sequenceId",
- String.class,
StringCodec.get(),
- Long.class,
LongCodec.get());
public static final DBColumnFamilyDefinition