From bad478a245aa04322bf7601ffa0f7fb20fa76b00 Mon Sep 17 00:00:00 2001 From: Tsz-Wo Nicholas Sze Date: Tue, 23 Apr 2024 16:03:39 -0700 Subject: [PATCH 1/6] HDDS-10745. Do not use BitSet for OzoneAcl.aclBitSet. --- .../org/apache/hadoop/ozone/OzoneAcl.java | 133 +++++++++++------- .../ozone/security/acl/IAccessAuthorizer.java | 17 ++- .../ozone/recon/api/types/AclMetadata.java | 4 +- 3 files changed, 100 insertions(+), 54 deletions(-) diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java index 8ab39a9ff99b..7cecfb972bf7 100644 --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java +++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java @@ -27,14 +27,16 @@ import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OzoneAclInfo.OzoneAclType; import org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLIdentityType; import org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType; +import org.apache.ratis.util.MemoizedSupplier; import java.util.ArrayList; -import java.util.BitSet; +import java.util.Collections; import java.util.EnumSet; import java.util.List; import java.util.Objects; -import java.util.function.Consumer; -import java.util.stream.Collectors; +import java.util.function.Function; +import java.util.function.IntFunction; +import java.util.function.Supplier; import static org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.ALL; import static org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.NONE; @@ -55,48 +57,60 @@ public class OzoneAcl { private final ACLIdentityType type; private final String name; @JsonIgnore - private final BitSet aclBitSet; + private final int aclBits; private final AclScope aclScope; - private static final List EMPTY_LIST = new ArrayList<>(0); + + private final Supplier toStringMethod; + private final Supplier hashCodeMethod; public OzoneAcl(ACLIdentityType type, String name, AclScope scope, ACLType... acls) { - this(type, name, scope, bitSetOf(acls)); + this(type, name, scope, toInt(acls)); } public OzoneAcl(ACLIdentityType type, String name, AclScope scope, EnumSet acls) { - this(type, name, scope, bitSetOf(acls.toArray(new ACLType[0]))); + this(type, name, scope, toInt(acls)); } - private OzoneAcl(ACLIdentityType type, String name, AclScope scope, BitSet acls) { + private OzoneAcl(ACLIdentityType type, String name, AclScope scope, int acls) { this.name = validateNameAndType(type, name); this.type = type; this.aclScope = scope; - this.aclBitSet = acls; + this.aclBits = acls; + + this.toStringMethod = MemoizedSupplier.valueOf(() -> getType() + ":" + getName() + ":" + + ACLType.getACLString(getAclByteArray()) + "[" + getAclScope() + "]"); + this.hashCodeMethod = MemoizedSupplier.valueOf(() -> Objects.hash(getName(), + ACLType.getACLBitSet(getAclByteArray()), getType().toString(), getAclScope())); } - private static BitSet bitSetOf(ACLType... acls) { - BitSet bits = new BitSet(); - if (acls != null && acls.length > 0) { - for (ACLType acl : acls) { - bits.set(acl.ordinal()); - } - } - return bits; + private static int toInt(int ordinal) { + return 1 << ordinal; } - private static BitSet validateAndCopy(BitSet acls) { - Objects.requireNonNull(acls); + private static int toInt(ACLType acl) { + return toInt(acl.ordinal()); + } - if (acls.cardinality() > ACLType.getNoOfAcls()) { - throw new IllegalArgumentException("Acl bitset passed has unexpected " + - "size. bitset size:" + acls.cardinality() + ", bitset:" + acls); + private static int toInt(ACLType[] acls) { + if (acls == null) { + return 0; } - - return copyBitSet(acls); + int value = 0; + for (ACLType acl : acls) { + value |= toInt(acl); + } + return value; } - private static BitSet copyBitSet(BitSet acls) { - return (BitSet) acls.clone(); + private static int toInt(Iterable acls) { + if (acls == null) { + return 0; + } + int value = 0; + for (ACLType acl : acls) { + value |= toInt(acl); + } + return value; } private static String validateNameAndType(ACLIdentityType type, String name) { @@ -122,7 +136,7 @@ private static String validateNameAndType(ACLIdentityType type, String name) { public OzoneAcl withScope(final AclScope scope) { return scope == aclScope ? this - : new OzoneAcl(type, name, scope, copyBitSet(aclBitSet)); + : new OzoneAcl(type, name, scope, aclBits); } /** @@ -202,9 +216,16 @@ public static OzoneAclInfo toProtobuf(OzoneAcl acl) { } public static OzoneAcl fromProtobuf(OzoneAclInfo protoAcl) { - BitSet aclRights = BitSet.valueOf(protoAcl.getRights().toByteArray()); + final byte[] bytes = protoAcl.getRights().toByteArray(); + if (bytes.length > 4) { + throw new AssertionError("Expected at most 4 bytes but got " + bytes.length); + } + int aclRights = 0; + for(int i = 0; i < bytes.length; i++) { + aclRights |= (bytes[i] & 0xff) << (i * 8); + } return new OzoneAcl(ACLIdentityType.valueOf(protoAcl.getType().name()), protoAcl.getName(), - AclScope.valueOf(protoAcl.getAclScope().name()), validateAndCopy(aclRights)); + AclScope.valueOf(protoAcl.getAclScope().name()), aclRights); } public AclScope getAclScope() { @@ -213,8 +234,7 @@ public AclScope getAclScope() { @Override public String toString() { - return type + ":" + name + ":" + ACLType.getACLString(aclBitSet) - + "[" + aclScope + "]"; + return toStringMethod.get(); } /** @@ -228,8 +248,7 @@ public String toString() { */ @Override public int hashCode() { - return Objects.hash(this.getName(), aclBitSet, - this.getType().toString(), this.getAclScope()); + return hashCodeMethod.get(); } /** @@ -243,12 +262,12 @@ public String getName() { @JsonIgnore public boolean isEmpty() { - return aclBitSet.isEmpty(); + return aclBits == 0; } @VisibleForTesting public boolean isSet(ACLType acl) { - return aclBitSet.get(acl.ordinal()); + return (aclBits & toInt(acl)) != 0; } public boolean checkAccess(ACLType acl) { @@ -256,36 +275,50 @@ public boolean checkAccess(ACLType acl) { } public OzoneAcl add(OzoneAcl other) { - return apply(bits -> bits.or(other.aclBitSet)); + return apply(bits -> bits | other.aclBits); } public OzoneAcl remove(OzoneAcl other) { - return apply(bits -> bits.andNot(other.aclBitSet)); + return apply(bits -> bits & ~other.aclBits); } - /** @return copy of this {@code OzoneAcl} after applying the given {@code op}, - * or this instance if {@code op} makes no difference */ - private OzoneAcl apply(Consumer op) { - final BitSet cloneBits = copyBitSet(aclBitSet); - op.accept(cloneBits); - return cloneBits.equals(aclBitSet) + private OzoneAcl apply(IntFunction op) { + int applied = op.apply(aclBits); + return applied == aclBits ? this - : new OzoneAcl(type, name, aclScope, cloneBits); + : new OzoneAcl(type, name, aclScope, applied); } @JsonIgnore public byte[] getAclByteArray() { - return aclBitSet.toByteArray(); + // only first 9 bits are used currently + final byte first = (byte) aclBits; + final byte second = (byte) (aclBits >>> 8); + return second != 0? new byte[]{first, second} : new byte[]{first}; + } + + public List getAclStringList() { + return getAclList(aclBits, ACLType::name); } public List getAclList() { - if (aclBitSet != null) { - return aclBitSet.stream().mapToObj(a -> - ACLType.values()[a]).collect(Collectors.toList()); + return getAclList(aclBits, Function.identity()); + } + + private static List getAclList(int aclBits, Function converter) { + if (aclBits == 0) { + return Collections.emptyList(); + } + final List toReturn = new ArrayList<>(Integer.bitCount(aclBits)); + for(int i = 0; i < ACLType.values().length; i++) { + if ((toInt(i) & aclBits) != 0) { + toReturn.add(converter.apply(ACLType.values()[i])); + } } - return EMPTY_LIST; + return Collections.unmodifiableList(toReturn); } + /** * Returns Type. * @@ -314,7 +347,7 @@ public boolean equals(Object obj) { OzoneAcl otherAcl = (OzoneAcl) obj; return otherAcl.getName().equals(this.getName()) && otherAcl.getType().equals(this.getType()) && - Objects.equals(aclBitSet, otherAcl.aclBitSet) && + this.aclBits == otherAcl.aclBits && otherAcl.getAclScope().equals(this.getAclScope()); } diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/acl/IAccessAuthorizer.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/acl/IAccessAuthorizer.java index 060372f118d2..73786cf75004 100644 --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/acl/IAccessAuthorizer.java +++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/acl/IAccessAuthorizer.java @@ -1,4 +1,4 @@ -/** +/* * 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 @@ -63,6 +63,13 @@ enum ACLType { ALL, NONE; private static int length = ACLType.values().length; + static { + if (length > 16) { + // must update getAclBytes(..) and other code + throw new AssertionError("BUG: Length = " + length + + " > 16, check the commit of this change and update the code."); + } + } private static ACLType[] vals = ACLType.values(); public static int getNoOfAcls() { @@ -114,6 +121,14 @@ public static ACLType getACLRight(String type) { } + public static BitSet getACLBitSet(byte[] acls) { + return BitSet.valueOf(acls); + } + + public static String getACLString(byte[] acls) { + return getACLString(BitSet.valueOf(acls)); + } + /** * Returns String representation of ACL rights. * diff --git a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/AclMetadata.java b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/AclMetadata.java index d8a0cf5334e2..fae47b3b368c 100644 --- a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/AclMetadata.java +++ b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/AclMetadata.java @@ -130,9 +130,7 @@ public static AclMetadata fromOzoneAcl(OzoneAcl ozoneAcl) { return builder.withType(ozoneAcl.getType().toString().toUpperCase()) .withName(ozoneAcl.getName()) .withScope(ozoneAcl.getAclScope().toString().toUpperCase()) - .withAclList(ozoneAcl.getAclList().stream().map(Enum::toString) - .map(String::toUpperCase) - .collect(Collectors.toList())) + .withAclList(ozoneAcl.getAclStringList()) .build(); } } From 9b2b47276c71828b7119f1c45c98f443a171cdf9 Mon Sep 17 00:00:00 2001 From: Tsz-Wo Nicholas Sze Date: Tue, 23 Apr 2024 16:27:43 -0700 Subject: [PATCH 2/6] Fix checkstyle. --- .../src/main/java/org/apache/hadoop/ozone/OzoneAcl.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java index 7cecfb972bf7..56a2f1836597 100644 --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java +++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java @@ -221,7 +221,7 @@ public static OzoneAcl fromProtobuf(OzoneAclInfo protoAcl) { throw new AssertionError("Expected at most 4 bytes but got " + bytes.length); } int aclRights = 0; - for(int i = 0; i < bytes.length; i++) { + for (int i = 0; i < bytes.length; i++) { aclRights |= (bytes[i] & 0xff) << (i * 8); } return new OzoneAcl(ACLIdentityType.valueOf(protoAcl.getType().name()), protoAcl.getName(), @@ -294,7 +294,7 @@ public byte[] getAclByteArray() { // only first 9 bits are used currently final byte first = (byte) aclBits; final byte second = (byte) (aclBits >>> 8); - return second != 0? new byte[]{first, second} : new byte[]{first}; + return second != 0 ? new byte[]{first, second} : new byte[]{first}; } public List getAclStringList() { @@ -310,7 +310,7 @@ private static List getAclList(int aclBits, Function converte return Collections.emptyList(); } final List toReturn = new ArrayList<>(Integer.bitCount(aclBits)); - for(int i = 0; i < ACLType.values().length; i++) { + for (int i = 0; i < ACLType.values().length; i++) { if ((toInt(i) & aclBits) != 0) { toReturn.add(converter.apply(ACLType.values()[i])); } @@ -318,7 +318,6 @@ private static List getAclList(int aclBits, Function converte return Collections.unmodifiableList(toReturn); } - /** * Returns Type. * From 9c9365a2d505f60225998b680acd140fee13df0d Mon Sep 17 00:00:00 2001 From: Tsz-Wo Nicholas Sze Date: Wed, 24 Apr 2024 12:55:56 -0700 Subject: [PATCH 3/6] Address review comments. --- .../java/com/google/protobuf/Proto2Utils.java | 32 +++++++++++++++++++ .../org/apache/hadoop/ozone/OzoneAcl.java | 19 +++++++---- .../ozone/security/acl/IAccessAuthorizer.java | 8 ----- .../ozone/om/helpers/TestOzoneAclUtil.java | 4 +-- .../ozone/om/helpers/OzoneAclStorage.java | 4 +-- .../ozone/om/helpers/TestOmPrefixInfo.java | 2 +- 6 files changed, 47 insertions(+), 22 deletions(-) create mode 100644 hadoop-ozone/common/src/main/java/com/google/protobuf/Proto2Utils.java diff --git a/hadoop-ozone/common/src/main/java/com/google/protobuf/Proto2Utils.java b/hadoop-ozone/common/src/main/java/com/google/protobuf/Proto2Utils.java new file mode 100644 index 000000000000..093a04720d5b --- /dev/null +++ b/hadoop-ozone/common/src/main/java/com/google/protobuf/Proto2Utils.java @@ -0,0 +1,32 @@ +/* + * 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 com.google.protobuf; + +/** Utilities for protobuf v2. */ +public final class Proto2Utils { + /** + * Similar to {@link ByteString#copyFrom(byte[])} except that this method does not copy. + * This method is safe only if the content of the array remains unchanged. + * Otherwise, it violates the immutability of {@link ByteString}. + */ + public static ByteString unsafeByteString(byte[] array) { + return new LiteralByteString(array); + } + + private Proto2Utils() {} +} diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java index 56a2f1836597..26fa473428e3 100644 --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java +++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java @@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.google.common.annotations.VisibleForTesting; import com.google.protobuf.ByteString; +import com.google.protobuf.Proto2Utils; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OzoneAclInfo; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OzoneAclInfo.OzoneAclScope; import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OzoneAclInfo.OzoneAclType; @@ -30,6 +31,7 @@ import org.apache.ratis.util.MemoizedSupplier; import java.util.ArrayList; +import java.util.BitSet; import java.util.Collections; import java.util.EnumSet; import java.util.List; @@ -78,13 +80,14 @@ private OzoneAcl(ACLIdentityType type, String name, AclScope scope, int acls) { this.aclBits = acls; this.toStringMethod = MemoizedSupplier.valueOf(() -> getType() + ":" + getName() + ":" - + ACLType.getACLString(getAclByteArray()) + "[" + getAclScope() + "]"); + + ACLType.getACLString(BitSet.valueOf(getAclByteString().asReadOnlyByteBuffer())) + "[" + getAclScope() + "]"); this.hashCodeMethod = MemoizedSupplier.valueOf(() -> Objects.hash(getName(), - ACLType.getACLBitSet(getAclByteArray()), getType().toString(), getAclScope())); + BitSet.valueOf(getAclByteString().asReadOnlyByteBuffer()), getType().toString(), getAclScope())); } - private static int toInt(int ordinal) { - return 1 << ordinal; + + private static int toInt(int aclTypeOrdinal) { + return 1 << aclTypeOrdinal; } private static int toInt(ACLType acl) { @@ -211,7 +214,7 @@ public static OzoneAclInfo toProtobuf(OzoneAcl acl) { .setName(acl.getName()) .setType(OzoneAclType.valueOf(acl.getType().name())) .setAclScope(OzoneAclScope.valueOf(acl.getAclScope().name())) - .setRights(ByteString.copyFrom(acl.getAclByteArray())); + .setRights(acl.getAclByteString()); return builder.build(); } @@ -290,13 +293,15 @@ private OzoneAcl apply(IntFunction op) { } @JsonIgnore - public byte[] getAclByteArray() { + public ByteString getAclByteString() { // only first 9 bits are used currently final byte first = (byte) aclBits; final byte second = (byte) (aclBits >>> 8); - return second != 0 ? new byte[]{first, second} : new byte[]{first}; + final byte[] bytes = second != 0 ? new byte[]{first, second} : new byte[]{first}; + return Proto2Utils.unsafeByteString(bytes); } + @JsonIgnore public List getAclStringList() { return getAclList(aclBits, ACLType::name); } diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/acl/IAccessAuthorizer.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/acl/IAccessAuthorizer.java index 73786cf75004..92b59f782b1c 100644 --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/acl/IAccessAuthorizer.java +++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/acl/IAccessAuthorizer.java @@ -121,14 +121,6 @@ public static ACLType getACLRight(String type) { } - public static BitSet getACLBitSet(byte[] acls) { - return BitSet.valueOf(acls); - } - - public static String getACLString(byte[] acls) { - return getACLString(BitSet.valueOf(acls)); - } - /** * Returns String representation of ACL rights. * diff --git a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOzoneAclUtil.java b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOzoneAclUtil.java index 5781a68b58df..35a8a95d8d02 100644 --- a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOzoneAclUtil.java +++ b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOzoneAclUtil.java @@ -34,7 +34,6 @@ import static org.apache.hadoop.ozone.OzoneAcl.AclScope.DEFAULT; import static org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLIdentityType.GROUP; import static org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLIdentityType.USER; -import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; @@ -232,7 +231,6 @@ public void testAddDefaultAcl() { assertEquals(2, ozoneAcls.size()); assertNotEquals(ozoneAcls.get(0).getAclScope(), ozoneAcls.get(1).getAclScope()); - assertArrayEquals(ozoneAcls.get(0).getAclByteArray(), - ozoneAcls.get(1).getAclByteArray()); + assertEquals(ozoneAcls.get(0).getAclByteString(), ozoneAcls.get(1).getAclByteString()); } } 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 index cb9bdc2b4be4..097b5da2fc09 100644 --- 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 @@ -17,8 +17,6 @@ */ package org.apache.hadoop.ozone.om.helpers; -import com.google.protobuf.ByteString; - import java.util.BitSet; import java.util.EnumSet; import java.util.List; @@ -55,7 +53,7 @@ public static OzoneAclInfo toProtobuf(OzoneAcl acl) { .setName(acl.getName()) .setType(OzoneAclType.valueOf(acl.getType().name())) .setAclScope(OzoneAclScope.valueOf(acl.getAclScope().name())) - .setRights(ByteString.copyFrom(acl.getAclByteArray())); + .setRights(acl.getAclByteString()); return builder.build(); } diff --git a/hadoop-ozone/interface-storage/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 index 07eed9a53997..3a57fa050d02 100644 --- a/hadoop-ozone/interface-storage/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 @@ -40,7 +40,7 @@ public class TestOmPrefixInfo { private static OzoneManagerStorageProtos.OzoneAclInfo buildTestOzoneAclInfo( String aclString) { OzoneAcl oacl = OzoneAcl.parseAcl(aclString); - ByteString rights = ByteString.copyFrom(oacl.getAclByteArray()); + final ByteString rights = oacl.getAclByteString(); return OzoneManagerStorageProtos.OzoneAclInfo.newBuilder() .setType(OzoneManagerStorageProtos.OzoneAclInfo.OzoneAclType.USER) .setName(oacl.getName()) From ef21556c6f05003237aa754445b260a670c1573e Mon Sep 17 00:00:00 2001 From: Tsz-Wo Nicholas Sze Date: Wed, 24 Apr 2024 13:05:36 -0700 Subject: [PATCH 4/6] Fix checkstyle. --- .../java/com/google/protobuf/Proto2Utils.java | 4 ++-- .../com/google/protobuf/package-info.java | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 hadoop-ozone/common/src/main/java/com/google/protobuf/package-info.java diff --git a/hadoop-ozone/common/src/main/java/com/google/protobuf/Proto2Utils.java b/hadoop-ozone/common/src/main/java/com/google/protobuf/Proto2Utils.java index 093a04720d5b..a06114c920ed 100644 --- a/hadoop-ozone/common/src/main/java/com/google/protobuf/Proto2Utils.java +++ b/hadoop-ozone/common/src/main/java/com/google/protobuf/Proto2Utils.java @@ -28,5 +28,5 @@ public static ByteString unsafeByteString(byte[] array) { return new LiteralByteString(array); } - private Proto2Utils() {} -} + private Proto2Utils() { } + diff --git a/hadoop-ozone/common/src/main/java/com/google/protobuf/package-info.java b/hadoop-ozone/common/src/main/java/com/google/protobuf/package-info.java new file mode 100644 index 000000000000..0cabebdb6965 --- /dev/null +++ b/hadoop-ozone/common/src/main/java/com/google/protobuf/package-info.java @@ -0,0 +1,22 @@ +/* + * 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. + */ + +/** + * Classes using the protobuf internal APIs. + */ +package com.google.protobuf; From 37cba819d7e5160919725ac0176d565134521d7b Mon Sep 17 00:00:00 2001 From: Tsz-Wo Nicholas Sze Date: Thu, 25 Apr 2024 08:19:26 -0700 Subject: [PATCH 5/6] Fix compilation. --- .../common/src/main/java/com/google/protobuf/Proto2Utils.java | 2 +- .../common/src/main/java/com/google/protobuf/package-info.java | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename {hadoop-ozone => hadoop-hdds}/common/src/main/java/com/google/protobuf/Proto2Utils.java (99%) rename {hadoop-ozone => hadoop-hdds}/common/src/main/java/com/google/protobuf/package-info.java (100%) diff --git a/hadoop-ozone/common/src/main/java/com/google/protobuf/Proto2Utils.java b/hadoop-hdds/common/src/main/java/com/google/protobuf/Proto2Utils.java similarity index 99% rename from hadoop-ozone/common/src/main/java/com/google/protobuf/Proto2Utils.java rename to hadoop-hdds/common/src/main/java/com/google/protobuf/Proto2Utils.java index a06114c920ed..945f50bf4bd0 100644 --- a/hadoop-ozone/common/src/main/java/com/google/protobuf/Proto2Utils.java +++ b/hadoop-hdds/common/src/main/java/com/google/protobuf/Proto2Utils.java @@ -29,4 +29,4 @@ public static ByteString unsafeByteString(byte[] array) { } private Proto2Utils() { } - +} diff --git a/hadoop-ozone/common/src/main/java/com/google/protobuf/package-info.java b/hadoop-hdds/common/src/main/java/com/google/protobuf/package-info.java similarity index 100% rename from hadoop-ozone/common/src/main/java/com/google/protobuf/package-info.java rename to hadoop-hdds/common/src/main/java/com/google/protobuf/package-info.java From 4e561e4e74913a28a515da94a5e30781b0fb1ef7 Mon Sep 17 00:00:00 2001 From: Tsz-Wo Nicholas Sze Date: Thu, 25 Apr 2024 10:21:08 -0700 Subject: [PATCH 6/6] Add @JsonIgnore --- .../common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java index 74f414bd3c55..26693d19c64a 100644 --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java +++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java @@ -64,7 +64,9 @@ public class OzoneAcl { private final int aclBits; private final AclScope aclScope; + @JsonIgnore private final Supplier toStringMethod; + @JsonIgnore private final Supplier hashCodeMethod; public OzoneAcl(ACLIdentityType type, String name, AclScope scope, ACLType... acls) {