errose28 commented on code in PR #6945:
URL: https://github.com/apache/ozone/pull/6945#discussion_r1690470934
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/protocolPB/ContainerCommandResponseBuilders.java:
##########
@@ -335,6 +335,17 @@ public static ContainerCommandResponseProto
getEchoResponse(
.build();
}
+ public static ContainerCommandResponseProto
getGetContainerMerkleTreeResponse(
+ ContainerCommandRequestProto request, ByteString checksumByteString) {
Review Comment:
Lets rename `checksumByteString` to `checksumTree` or something like that.
The current name seems to imply its a standalone checksum.
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/checksum/ContainerChecksumTreeManager.java:
##########
@@ -157,6 +159,28 @@ private void write(KeyValueContainerData data,
ContainerProtos.ContainerChecksum
}
}
+ public ByteString readChecksumFileAsBytes(KeyValueContainerData data) {
+ long containerID = data.getContainerID();
+ Lock readLock = getReadLock(containerID);
+ readLock.lock();
+ try {
+ File checksumFile = getContainerChecksumFile(data);
+
+ try (FileInputStream inStream = new FileInputStream(checksumFile)) {
+ return ByteString.readFrom(inStream);
+ } catch (FileNotFoundException ex) {
+ LOG.info("No checksum file currently exists for container {} at the
path {}. Returning an empty instance.",
Review Comment:
For now this should also return an error. Let's add a TODO to handle this
the same as HDDS-10379 (build the tree on the spot from the DB) when that is
implemented. Whether that is handled in this layer or the layer above based on
an exception is TBD.
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/checksum/ContainerChecksumTreeManager.java:
##########
@@ -157,6 +159,28 @@ private void write(KeyValueContainerData data,
ContainerProtos.ContainerChecksum
}
}
+ public ByteString readChecksumFileAsBytes(KeyValueContainerData data) {
Review Comment:
```suggestion
public ByteString getContainerChecksumInfo(KeyValueContainerData data) {
```
This name reflects this a `ByteString` representation of the
`ContainerChecksumInfo` proto.
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java:
##########
@@ -1165,7 +1206,16 @@ public void deleteContainer(Container container, boolean
force)
@Override
public void reconcileContainer(Container<?> container, List<DatanodeDetails>
peers) throws IOException {
- // TODO Just a deterministic placeholder hash for testing until actual
implementation is finished.
Review Comment:
Let's leave this TODO in place to indicate this is not the final
implementation.
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/TokenHelper.java:
##########
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.hadoop.ozone.container.ec.reconstruction;
+package org.apache.hadoop.ozone.container;
Review Comment:
We can probably use either
`org.apache.hadoop.ozone.container.common.helpers` or
`org.apache.hadoop.hdds.security.token` as more specific packages.
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/checksum/ContainerChecksumTreeManager.java:
##########
@@ -157,6 +159,28 @@ private void write(KeyValueContainerData data,
ContainerProtos.ContainerChecksum
}
}
+ public ByteString readChecksumFileAsBytes(KeyValueContainerData data) {
+ long containerID = data.getContainerID();
+ Lock readLock = getReadLock(containerID);
+ readLock.lock();
+ try {
+ File checksumFile = getContainerChecksumFile(data);
+
+ try (FileInputStream inStream = new FileInputStream(checksumFile)) {
+ return ByteString.readFrom(inStream);
+ } catch (FileNotFoundException ex) {
+ LOG.info("No checksum file currently exists for container {} at the
path {}. Returning an empty instance.",
+ containerID, checksumFile, ex);
+ } catch (IOException ex) {
+ LOG.info("Error occured when reading checksum file for container {} at
the path {}. " +
Review Comment:
This exception should be propagated to the caller, and eventually back to
the client invoking the API.
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/checksum/DNContainerOperationClient.java:
##########
@@ -0,0 +1,119 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.checksum;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.hadoop.hdds.client.StandaloneReplicationConfig;
+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.proto.HddsProtos;
+import org.apache.hadoop.hdds.scm.XceiverClientManager;
+import org.apache.hadoop.hdds.scm.XceiverClientSpi;
+import org.apache.hadoop.hdds.scm.client.ClientTrustManager;
+import org.apache.hadoop.hdds.scm.container.ContainerID;
+import org.apache.hadoop.hdds.scm.pipeline.Pipeline;
+import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
+import org.apache.hadoop.hdds.scm.storage.ContainerProtocolCalls;
+import org.apache.hadoop.hdds.security.SecurityConfig;
+import org.apache.hadoop.hdds.security.symmetric.SecretKeySignerClient;
+import
org.apache.hadoop.hdds.security.x509.certificate.client.CACertificateProvider;
+import
org.apache.hadoop.hdds.security.x509.certificate.client.CertificateClient;
+import org.apache.hadoop.hdds.utils.HAUtils;
+import org.apache.hadoop.ozone.OzoneSecurityUtil;
+import jakarta.annotation.Nonnull;
+import org.apache.hadoop.ozone.container.TokenHelper;
+import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+import static org.apache.hadoop.ozone.container.TokenHelper.encode;
+
+/**
+ * This class wraps necessary container-level rpc calls for container
reconcilitaion.
+ * - GetContainerMerkleTree
+ */
+public class DNContainerOperationClient implements AutoCloseable {
+
+ private static final Logger LOG =
+ LoggerFactory.getLogger(DNContainerOperationClient.class);
+ private final TokenHelper tokenHelper;
+ private final XceiverClientManager xceiverClientManager;
+
+ public DNContainerOperationClient(ConfigurationSource conf,
+ CertificateClient certificateClient,
+ SecretKeySignerClient secretKeyClient)
throws IOException {
+ this.tokenHelper = new TokenHelper(new SecurityConfig(conf),
secretKeyClient);
+ this.xceiverClientManager = createClientManager(conf, certificateClient);
+ }
+
+ @Nonnull
+ private static XceiverClientManager createClientManager(
+ ConfigurationSource conf, CertificateClient certificateClient)
+ throws IOException {
+ ClientTrustManager trustManager = null;
+ if (OzoneSecurityUtil.isSecurityEnabled(conf)) {
+ CACertificateProvider localCaCerts =
+ () -> HAUtils.buildCAX509List(certificateClient, conf);
+ CACertificateProvider remoteCacerts =
+ () -> HAUtils.buildCAX509List(null, conf);
+ trustManager = new ClientTrustManager(remoteCacerts, localCaCerts);
+ }
+ return new XceiverClientManager(conf,
+ new XceiverClientManager.XceiverClientManagerConfigBuilder()
+ .setMaxCacheSize(100).setStaleThresholdMs(10 * 1000).build(),
Review Comment:
Let's add config keys for these.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]