-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-4242. Copy PrefixInfo proto to new project hadoop-ozone/interface-storage #1444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...e/interface-storage/src/main/java/org/apache/hadoop/ozone/om/helpers/OzoneAclStorage.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| * <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.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. | ||
| * <ul> | ||
| * <li>user:name:rw | ||
| * <li>group:name:rw | ||
| * <li>world::rw | ||
| * </ul> | ||
| */ | ||
| 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())); | ||
| } | ||
|
|
||
| } | ||
62 changes: 62 additions & 0 deletions
62
...terface-storage/src/main/java/org/apache/hadoop/ozone/om/helpers/OzoneAclStorageUtil.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| * <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.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<OzoneAclInfo> toProtobuf(List<OzoneAcl> protoAcls) { | ||
| List<OzoneAclInfo> 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<OzoneAcl> fromProtobuf(List<OzoneAclInfo> protoAcls) { | ||
| List<OzoneAcl> ozoneAcls = new ArrayList<>(); | ||
| for (OzoneAclInfo aclInfo : protoAcls) { | ||
| ozoneAcls.add(OzoneAclStorage.fromProtobuf(aclInfo)); | ||
| } | ||
| return ozoneAcls; | ||
| } | ||
|
|
||
| } |
24 changes: 24 additions & 0 deletions
24
...zone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/helpers/package-info.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| * <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. | ||
| * <p> | ||
| * Utility classes to encode/decode DTO objects to/from byte array. | ||
| */ | ||
|
|
||
| /** | ||
| * Helpers for OM storage proto layer. | ||
| */ | ||
| package org.apache.hadoop.ozone.om.helpers; |
60 changes: 60 additions & 0 deletions
60
hadoop-ozone/interface-storage/src/main/proto/OmStorageProtocol.proto
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| } |
File renamed without changes.
24 changes: 24 additions & 0 deletions
24
...zone/interface-storage/src/test/java/org/apache/hadoop/ozone/om/helpers/package-info.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| * <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. | ||
| * <p> | ||
| * Utility classes to encode/decode DTO objects to/from byte array. | ||
| */ | ||
|
|
||
| /** | ||
| * Unit tests for helpers in OM. | ||
| */ | ||
| package org.apache.hadoop.ozone.om.helpers; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have to duplicate this class because the original one was used by different places. That's why I make this class
package-privateto make it only useable by codec classes.