diff --git a/hadoop-ozone/interface-storage/pom.xml b/hadoop-ozone/interface-storage/pom.xml
index 43ba408dcba6..9f000bf8a7a1 100644
--- a/hadoop-ozone/interface-storage/pom.xml
+++ b/hadoop-ozone/interface-storage/pom.xml
@@ -34,6 +34,11 @@
hadoop-ozone-common
+
+ com.google.protobuf
+ protobuf-java
+
+
org.apache.hadoop
hadoop-ozone-interface-client
@@ -63,4 +68,29 @@
+
+
+
+ org.xolstice.maven.plugins
+ protobuf-maven-plugin
+ ${protobuf-maven-plugin.version}
+ true
+
+
+ compile-protoc
+
+ compile
+ test-compile
+
+
+ ${basedir}/src/main/proto/
+
+ com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/codec/OmPrefixInfoCodec.java b/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/codec/OmPrefixInfoCodec.java
index 44a07418a78f..919d97296f5b 100644
--- a/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/codec/OmPrefixInfoCodec.java
+++ b/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/codec/OmPrefixInfoCodec.java
@@ -20,7 +20,7 @@
import com.google.common.base.Preconditions;
import com.google.protobuf.InvalidProtocolBufferException;
import org.apache.hadoop.ozone.om.helpers.OmPrefixInfo;
-import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PrefixInfo;
+import org.apache.hadoop.ozone.storage.proto.OzoneManagerStorageProtos.PersistedPrefixInfo;
import org.apache.hadoop.hdds.utils.db.Codec;
@@ -44,7 +44,8 @@ public OmPrefixInfo fromPersistedFormat(byte[] rawData) throws IOException {
.checkNotNull(rawData,
"Null byte array can't converted to real object.");
try {
- return OmPrefixInfo.getFromProtobuf(PrefixInfo.parseFrom(rawData));
+ return OmPrefixInfo.getFromProtobuf(
+ PersistedPrefixInfo.parseFrom(rawData));
} catch (InvalidProtocolBufferException e) {
throw new IllegalArgumentException(
"Can't encode the the raw data from the byte array", e);
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmPrefixInfo.java b/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/helpers/OmPrefixInfo.java
similarity index 92%
rename from hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmPrefixInfo.java
rename to hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/helpers/OmPrefixInfo.java
index 80ca54d5404f..a1ad55a7b656 100644
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmPrefixInfo.java
+++ b/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/helpers/OmPrefixInfo.java
@@ -20,7 +20,7 @@
import com.google.common.base.Preconditions;
import org.apache.hadoop.ozone.OzoneAcl;
-import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PrefixInfo;
+import org.apache.hadoop.ozone.storage.proto.OzoneManagerStorageProtos.PersistedPrefixInfo;
import java.util.BitSet;
import java.util.HashMap;
@@ -150,11 +150,12 @@ public OmPrefixInfo build() {
/**
* Creates PrefixInfo protobuf from OmPrefixInfo.
*/
- public PrefixInfo getProtobuf() {
- PrefixInfo.Builder pib = PrefixInfo.newBuilder().setName(name)
+ public PersistedPrefixInfo getProtobuf() {
+ PersistedPrefixInfo.Builder pib =
+ PersistedPrefixInfo.newBuilder().setName(name)
.addAllMetadata(KeyValueUtil.toProtobuf(metadata));
if (acls != null) {
- pib.addAllAcls(OzoneAclUtil.toProtobuf(acls));
+ pib.addAllAcls(OzoneAclStorageUtil.toProtobuf(acls));
}
return pib.build();
}
@@ -164,7 +165,7 @@ public PrefixInfo getProtobuf() {
* @param prefixInfo
* @return instance of OmPrefixInfo
*/
- public static OmPrefixInfo getFromProtobuf(PrefixInfo prefixInfo) {
+ public static OmPrefixInfo getFromProtobuf(PersistedPrefixInfo prefixInfo) {
OmPrefixInfo.Builder opib = OmPrefixInfo.newBuilder()
.setName(prefixInfo.getName());
if (prefixInfo.getMetadataList() != null) {
@@ -172,7 +173,7 @@ public static OmPrefixInfo getFromProtobuf(PrefixInfo prefixInfo) {
.getFromProtobuf(prefixInfo.getMetadataList()));
}
if (prefixInfo.getAclsList() != null) {
- opib.setAcls(OzoneAclUtil.fromProtobuf(prefixInfo.getAclsList()));
+ opib.setAcls(OzoneAclStorageUtil.fromProtobuf(prefixInfo.getAclsList()));
}
return opib.build();
}
diff --git a/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/helpers/OzoneAclStorage.java b/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/helpers/OzoneAclStorage.java
new file mode 100644
index 000000000000..abc6359efcaf
--- /dev/null
+++ b/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/helpers/OzoneAclStorage.java
@@ -0,0 +1,63 @@
+/**
+ * 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.om.helpers;
+
+import com.google.protobuf.ByteString;
+import java.util.BitSet;
+import org.apache.hadoop.ozone.OzoneAcl;
+import org.apache.hadoop.ozone.OzoneAcl.AclScope;
+import org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLIdentityType;
+import org.apache.hadoop.ozone.storage.proto.OzoneManagerStorageProtos.OzoneAclInfo;
+import org.apache.hadoop.ozone.storage.proto.OzoneManagerStorageProtos.OzoneAclInfo.OzoneAclScope;
+import org.apache.hadoop.ozone.storage.proto.OzoneManagerStorageProtos.OzoneAclInfo.OzoneAclType;
+
+/**
+ * OzoneAclStorage classes define bucket ACLs used in OZONE.
+ * This class is used by storage proto only.
+ *
+ * ACLs in Ozone follow this pattern.
+ *
+ * - user:name:rw
+ *
- group:name:rw
+ *
- world::rw
+ *
+ */
+final class OzoneAclStorage {
+ /**
+ * Private constructor.
+ */
+ private OzoneAclStorage() {
+ }
+
+ public static OzoneAclInfo toProtobuf(OzoneAcl acl) {
+ OzoneAclInfo.Builder builder = OzoneAclInfo.newBuilder()
+ .setName(acl.getName())
+ .setType(OzoneAclType.valueOf(acl.getType().name()))
+ .setAclScope(OzoneAclScope.valueOf(acl.getAclScope().name()))
+ .setRights(ByteString.copyFrom(acl.getAclBitSet().toByteArray()));
+ return builder.build();
+ }
+
+ public static OzoneAcl fromProtobuf(OzoneAclInfo protoAcl) {
+ BitSet aclRights = BitSet.valueOf(protoAcl.getRights().toByteArray());
+ return new OzoneAcl(ACLIdentityType.valueOf(protoAcl.getType().name()),
+ protoAcl.getName(), aclRights,
+ AclScope.valueOf(protoAcl.getAclScope().name()));
+ }
+
+}
diff --git a/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/helpers/OzoneAclStorageUtil.java b/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/helpers/OzoneAclStorageUtil.java
new file mode 100644
index 000000000000..06c6e82d7179
--- /dev/null
+++ b/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/helpers/OzoneAclStorageUtil.java
@@ -0,0 +1,62 @@
+/**
+ * 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.om.helpers;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.hadoop.ozone.OzoneAcl;
+import org.apache.hadoop.ozone.storage.proto.OzoneManagerStorageProtos.OzoneAclInfo;
+
+/**
+ * Helper class for ozone acls operations.
+ * This class is used by storage proto only.
+ */
+final class OzoneAclStorageUtil {
+ /**
+ * Private constructor.
+ */
+ private OzoneAclStorageUtil() {
+ }
+
+ /**
+ * Convert a list of OzoneAcl(java) to list of OzoneAclInfo(protoc).
+ * @param protoAcls
+ * @return list of OzoneAclInfo.
+ */
+ public static List toProtobuf(List protoAcls) {
+ List ozoneAclInfos = new ArrayList<>();
+ for (OzoneAcl acl : protoAcls) {
+ ozoneAclInfos.add(OzoneAclStorage.toProtobuf(acl));
+ }
+ return ozoneAclInfos;
+ }
+
+ /**
+ * Convert a list of OzoneAclInfo(protoc) to list of OzoneAcl(java).
+ * @param protoAcls
+ * @return list of OzoneAcl.
+ */
+ public static List fromProtobuf(List protoAcls) {
+ List ozoneAcls = new ArrayList<>();
+ for (OzoneAclInfo aclInfo : protoAcls) {
+ ozoneAcls.add(OzoneAclStorage.fromProtobuf(aclInfo));
+ }
+ return ozoneAcls;
+ }
+
+}
diff --git a/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/helpers/package-info.java b/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/helpers/package-info.java
new file mode 100644
index 000000000000..4101cf376884
--- /dev/null
+++ b/hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/helpers/package-info.java
@@ -0,0 +1,24 @@
+/**
+ * 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.
+ *
+ * Utility classes to encode/decode DTO objects to/from byte array.
+ */
+
+/**
+ * Helpers for OM storage proto layer.
+ */
+package org.apache.hadoop.ozone.om.helpers;
\ No newline at end of file
diff --git a/hadoop-ozone/interface-storage/src/main/proto/OmStorageProtocol.proto b/hadoop-ozone/interface-storage/src/main/proto/OmStorageProtocol.proto
new file mode 100644
index 000000000000..74b0109fc05f
--- /dev/null
+++ b/hadoop-ozone/interface-storage/src/main/proto/OmStorageProtocol.proto
@@ -0,0 +1,60 @@
+/**
+ * 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.
+ */
+
+/**
+ * These .proto interfaces are private and unstable.
+ * Please see http://wiki.apache.org/hadoop/Compatibility
+ * for what changes are allowed for a *unstable* .proto interface.
+ */
+
+syntax = "proto2";
+option java_package = "org.apache.hadoop.ozone.storage.proto";
+option java_outer_classname = "OzoneManagerStorageProtos";
+option java_generic_services = true;
+option java_generate_equals_and_hash = true;
+package hadoop.ozone;
+
+import "hdds.proto";
+
+message OzoneAclInfo {
+ enum OzoneAclType {
+ USER = 1;
+ GROUP = 2;
+ WORLD = 3;
+ ANONYMOUS = 4;
+ CLIENT_IP = 5;
+ }
+
+ enum OzoneAclScope {
+ ACCESS = 0;
+ DEFAULT = 1;
+ }
+
+ required OzoneAclType type = 1;
+ required string name = 2;
+ required bytes rights = 3;
+ required OzoneAclScope aclScope = 4 [default = ACCESS];
+}
+
+message PersistedPrefixInfo {
+ required string name = 1;
+ repeated OzoneAclInfo acls = 2;
+ repeated hadoop.hdds.KeyValue metadata = 3;
+ optional uint64 objectID = 4;
+ optional uint64 updateID = 5;
+}
\ No newline at end of file
diff --git a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmPrefixInfo.java b/hadoop-ozone/interface-storage/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmPrefixInfo.java
similarity index 100%
rename from hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmPrefixInfo.java
rename to hadoop-ozone/interface-storage/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmPrefixInfo.java
diff --git a/hadoop-ozone/interface-storage/src/test/java/org/apache/hadoop/ozone/om/helpers/package-info.java b/hadoop-ozone/interface-storage/src/test/java/org/apache/hadoop/ozone/om/helpers/package-info.java
new file mode 100644
index 000000000000..bda29d2bcc8f
--- /dev/null
+++ b/hadoop-ozone/interface-storage/src/test/java/org/apache/hadoop/ozone/om/helpers/package-info.java
@@ -0,0 +1,24 @@
+/**
+ * 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.
+ *
+ * Utility classes to encode/decode DTO objects to/from byte array.
+ */
+
+/**
+ * Unit tests for helpers in OM.
+ */
+package org.apache.hadoop.ozone.om.helpers;
\ No newline at end of file