You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/02/03 22:33:05 UTC

[GitHub] [ozone] hanishakoneru commented on a change in pull request #1766: HDDS-4563. Support TDE for MPU Keys on Encrypted Buckets

hanishakoneru commented on a change in pull request #1766:
URL: https://github.com/apache/ozone/pull/1766#discussion_r569798937



##########
File path: hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/MultipartCryptoKeyInputStream.java
##########
@@ -0,0 +1,373 @@
+/**
+ * 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.client.io;
+
+import com.google.common.base.Preconditions;
+import org.apache.hadoop.crypto.CryptoInputStream;
+import org.apache.hadoop.fs.CanUnbuffer;
+import org.apache.hadoop.fs.FSExceptionMessages;
+import org.apache.hadoop.fs.Seekable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+public class MultipartCryptoKeyInputStream extends OzoneInputStream
+    implements Seekable, CanUnbuffer {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(MultipartCryptoKeyInputStream.class);
+
+  private static final int EOF = -1;
+
+  private String key;
+  private long length = 0L;
+  private boolean closed = false;
+
+  // List of OzoneCryptoInputStream, one for each part of the key
+  private List<OzoneCryptoInputStream> partStreams;
+
+  // partOffsets[i] stores the index of the first data byte in
+  // partStream w.r.t the whole key data.
+  // For example, let’s say the part size is 200 bytes and part[0] stores
+  // data from indices 0 - 199, part[1] from indices 200 - 399 and so on.
+  // Then, partOffsets[0] = 0 (the offset of the first byte of data in
+  // part[0]), partOffsets[1] = 200 and so on.
+  private long[] partOffsets;
+
+  // Index of the partStream corresponding to the current position of the
+  // MultipartCryptoKeyInputStream i.e. offset of the data to be read next
+  private int partIndex = 0;
+
+  // Tracks the partIndex corresponding to the last seeked position so that it
+  // can be reset if a new position is seeked.
+  private int partIndexOfPrevPos = 0;

Review comment:
       Done.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org