ACCUMULO-4551 Update to thrift 0.10.0
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/ead6674e Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/ead6674e Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/ead6674e Branch: refs/heads/master Commit: ead6674ee395bc645daffd456c7205ebc09bed1d Parents: 8be77df Author: Christopher Tubbs <ctubb...@apache.org> Authored: Sat Feb 4 23:49:23 2017 -0500 Committer: Christopher Tubbs <ctubb...@apache.org> Committed: Thu Feb 9 14:27:47 2017 -0500 ---------------------------------------------------------------------- .../core/rpc/TServiceClientWrapper.java | 56 ++++++++++++++++++++ core/src/main/scripts/generate-thrift.sh | 17 +++--- core/src/main/thrift/client.thrift | 18 +++---- core/src/main/thrift/master.thrift | 2 +- pom.xml | 2 +- .../accumulo/server/rpc/RpcWrapperTest.java | 2 +- 6 files changed, 79 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/ead6674e/core/src/main/java/org/apache/accumulo/core/rpc/TServiceClientWrapper.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/rpc/TServiceClientWrapper.java b/core/src/main/java/org/apache/accumulo/core/rpc/TServiceClientWrapper.java new file mode 100644 index 0000000..9636fe5 --- /dev/null +++ b/core/src/main/java/org/apache/accumulo/core/rpc/TServiceClientWrapper.java @@ -0,0 +1,56 @@ +/* + * 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.accumulo.core.rpc; + +import org.apache.thrift.TApplicationException; +import org.apache.thrift.TBase; +import org.apache.thrift.TException; +import org.apache.thrift.TServiceClient; +import org.apache.thrift.protocol.TMessage; +import org.apache.thrift.protocol.TMessageType; +import org.apache.thrift.protocol.TProtocol; + +// Wrapper for THRIFT-4062 workaround; shouldn't be needed in newer versions +// Also update generate-thrift.sh to stop using this +public abstract class TServiceClientWrapper extends TServiceClient { + + public TServiceClientWrapper(TProtocol iprot, TProtocol oprot) { + super(iprot, oprot); + } + + public TServiceClientWrapper(TProtocol prot) { + super(prot); + } + + @Override + protected void receiveBase(TBase<?,?> result, String methodName) throws TException { + TMessage msg = iprot_.readMessageBegin(); + if (msg.type == TMessageType.EXCEPTION) { + TApplicationException x = new TApplicationException(); + x.read(iprot_); + iprot_.readMessageEnd(); + throw x; + } + if (msg.seqid != seqid_) { + throw new TApplicationException(TApplicationException.BAD_SEQUENCE_ID, String.format("%s failed: out of sequence response: expected %d but got %d", + methodName, seqid_, msg.seqid)); + } + result.read(iprot_); + iprot_.readMessageEnd(); + } + +} http://git-wip-us.apache.org/repos/asf/accumulo/blob/ead6674e/core/src/main/scripts/generate-thrift.sh ---------------------------------------------------------------------- diff --git a/core/src/main/scripts/generate-thrift.sh b/core/src/main/scripts/generate-thrift.sh index 691ea79..d189323 100755 --- a/core/src/main/scripts/generate-thrift.sh +++ b/core/src/main/scripts/generate-thrift.sh @@ -26,7 +26,7 @@ # INCLUDED_MODULES should be an array that includes other Maven modules with src/main/thrift directories # Use INCLUDED_MODULES=(-) in calling scripts that require no other modules # ======================================================================================================================== -[[ -z $REQUIRED_THRIFT_VERSION ]] && REQUIRED_THRIFT_VERSION='0.9.3' +[[ -z $REQUIRED_THRIFT_VERSION ]] && REQUIRED_THRIFT_VERSION='0.10.0' [[ -z $INCLUDED_MODULES ]] && INCLUDED_MODULES=(../server/tracer) [[ -z $BASE_OUTPUT_PACKAGE ]] && BASE_OUTPUT_PACKAGE='org.apache.accumulo.core' [[ -z $PACKAGES_TO_GENERATE ]] && PACKAGES_TO_GENERATE=(gc master tabletserver security client.impl data replication trace) @@ -71,11 +71,16 @@ for f in src/main/thrift/*.thrift; do thrift ${THRIFT_ARGS} --gen cpp "$f" || fail unable to generate cpp thrift classes done -# For all generated thrift code, suppress all warnings and add the LICENSE header -cs='@SuppressWarnings({"unchecked", "serial", "rawtypes", "unused"})' -es='@SuppressWarnings({"unused"})' -find $BUILD_DIR/gen-java -name '*.java' -print0 | xargs -0 sed -i.orig -e 's/"unchecked"/"unchecked", "unused"/' -find $BUILD_DIR/gen-java -name '*.java' -print0 | xargs -0 sed -i.orig -e 's/\(public enum [A-Z]\)/'"$es"' \1/' +# For all generated thrift code, get rid of all warnings and add the LICENSE header + +# workaround for THRIFT-4062; should be fixed in newer thrift versions +find $BUILD_DIR/gen-java -name '*.java' -exec sed -i -e 's/\(org[.]apache[.]\)thrift\([.]TServiceClient\) /\1accumulo.core.rpc\2Wrapper /' {} + +# upstream stopped doing import statements for classes, but overlooked enums; delete unused imports +find $BUILD_DIR/gen-java -name '*.java' -exec grep -Zl '^public enum ' {} + | xargs -0 sed -i -e '/^import .*$/d' +# add dummy method to suppress "unnecessary suppress warnings" for classes which don't have any unused variables +# this only affects classes, enums aren't affected +find $BUILD_DIR/gen-java -name '*.java' -exec grep -Zl '^public class ' {} + | xargs -0 sed -i -e 's/^[}]$/ private static void unusedMethod() {}\ +}/' for lang in "${LANGUAGES_TO_GENERATE[@]}"; do case $lang in http://git-wip-us.apache.org/repos/asf/accumulo/blob/ead6674e/core/src/main/thrift/client.thrift ---------------------------------------------------------------------- diff --git a/core/src/main/thrift/client.thrift b/core/src/main/thrift/client.thrift index 722faaf..4ab3e48 100644 --- a/core/src/main/thrift/client.thrift +++ b/core/src/main/thrift/client.thrift @@ -133,15 +133,15 @@ service ClientService { list<binary> getUserAuthorizations(3:trace.TInfo tinfo, 4:security.TCredentials credentials, 2:string principal) throws (1:ThriftSecurityException sec) // permissions-related methods - bool hasSystemPermission(4:trace.TInfo tinfo, 5:security.TCredentials credentials, 2:string principal, 3:byte sysPerm) throws (1:ThriftSecurityException sec) - bool hasTablePermission(5:trace.TInfo tinfo, 6:security.TCredentials credentials, 2:string principal, 3:string tableName, 4:byte tblPerm) throws (1:ThriftSecurityException sec, 2:ThriftTableOperationException tope) - bool hasNamespacePermission(1:trace.TInfo tinfo, 2:security.TCredentials credentials, 3:string principal, 4:string ns, 5:byte tblNspcPerm) throws (1:ThriftSecurityException sec, 2:ThriftTableOperationException tope) - void grantSystemPermission(4:trace.TInfo tinfo, 5:security.TCredentials credentials, 2:string principal, 3:byte permission) throws (1:ThriftSecurityException sec) - void revokeSystemPermission(4:trace.TInfo tinfo, 5:security.TCredentials credentials, 2:string principal, 3:byte permission) throws (1:ThriftSecurityException sec) - void grantTablePermission(5:trace.TInfo tinfo, 6:security.TCredentials credentials, 2:string principal, 3:string tableName, 4:byte permission) throws (1:ThriftSecurityException sec, 2:ThriftTableOperationException tope) - void revokeTablePermission(5:trace.TInfo tinfo, 6:security.TCredentials credentials, 2:string principal, 3:string tableName, 4:byte permission) throws (1:ThriftSecurityException sec, 2:ThriftTableOperationException tope) - void grantNamespacePermission(1:trace.TInfo tinfo, 2:security.TCredentials credentials, 3:string principal, 4:string ns, 5:byte permission) throws (1:ThriftSecurityException sec, 2:ThriftTableOperationException tope) - void revokeNamespacePermission(1:trace.TInfo tinfo, 2:security.TCredentials credentials, 3:string principal, 4:string ns, 5:byte permission) throws (1:ThriftSecurityException sec, 2:ThriftTableOperationException tope) + bool hasSystemPermission(4:trace.TInfo tinfo, 5:security.TCredentials credentials, 2:string principal, 3:i8 sysPerm) throws (1:ThriftSecurityException sec) + bool hasTablePermission(5:trace.TInfo tinfo, 6:security.TCredentials credentials, 2:string principal, 3:string tableName, 4:i8 tblPerm) throws (1:ThriftSecurityException sec, 2:ThriftTableOperationException tope) + bool hasNamespacePermission(1:trace.TInfo tinfo, 2:security.TCredentials credentials, 3:string principal, 4:string ns, 5:i8 tblNspcPerm) throws (1:ThriftSecurityException sec, 2:ThriftTableOperationException tope) + void grantSystemPermission(4:trace.TInfo tinfo, 5:security.TCredentials credentials, 2:string principal, 3:i8 permission) throws (1:ThriftSecurityException sec) + void revokeSystemPermission(4:trace.TInfo tinfo, 5:security.TCredentials credentials, 2:string principal, 3:i8 permission) throws (1:ThriftSecurityException sec) + void grantTablePermission(5:trace.TInfo tinfo, 6:security.TCredentials credentials, 2:string principal, 3:string tableName, 4:i8 permission) throws (1:ThriftSecurityException sec, 2:ThriftTableOperationException tope) + void revokeTablePermission(5:trace.TInfo tinfo, 6:security.TCredentials credentials, 2:string principal, 3:string tableName, 4:i8 permission) throws (1:ThriftSecurityException sec, 2:ThriftTableOperationException tope) + void grantNamespacePermission(1:trace.TInfo tinfo, 2:security.TCredentials credentials, 3:string principal, 4:string ns, 5:i8 permission) throws (1:ThriftSecurityException sec, 2:ThriftTableOperationException tope) + void revokeNamespacePermission(1:trace.TInfo tinfo, 2:security.TCredentials credentials, 3:string principal, 4:string ns, 5:i8 permission) throws (1:ThriftSecurityException sec, 2:ThriftTableOperationException tope) // configuration methods map<string, string> getConfiguration(2:trace.TInfo tinfo, 3:security.TCredentials credentials, 1:ConfigurationType type); http://git-wip-us.apache.org/repos/asf/accumulo/blob/ead6674e/core/src/main/thrift/master.thrift ---------------------------------------------------------------------- diff --git a/core/src/main/thrift/master.thrift b/core/src/main/thrift/master.thrift index 58829ec..fbacc66 100644 --- a/core/src/main/thrift/master.thrift +++ b/core/src/main/thrift/master.thrift @@ -112,7 +112,7 @@ struct DeadServer { struct MasterMonitorInfo { 1:map<string, TableInfo> tableMap 2:list<TabletServerStatus> tServerInfo - 3:map<string, byte> badTServers + 3:map<string, i8> badTServers 6:MasterState state 8:MasterGoalState goalState 7:i32 unassignedTablets http://git-wip-us.apache.org/repos/asf/accumulo/blob/ead6674e/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index f813c51..8aacdb2 100644 --- a/pom.xml +++ b/pom.xml @@ -152,7 +152,7 @@ <surefire.failIfNoSpecifiedTests>false</surefire.failIfNoSpecifiedTests> <surefire.groups /> <!-- Thrift version --> - <thrift.version>0.9.3</thrift.version> + <thrift.version>0.10.0</thrift.version> <!-- ZooKeeper version --> <zookeeper.version>3.4.6</zookeeper.version> </properties> http://git-wip-us.apache.org/repos/asf/accumulo/blob/ead6674e/server/base/src/test/java/org/apache/accumulo/server/rpc/RpcWrapperTest.java ---------------------------------------------------------------------- diff --git a/server/base/src/test/java/org/apache/accumulo/server/rpc/RpcWrapperTest.java b/server/base/src/test/java/org/apache/accumulo/server/rpc/RpcWrapperTest.java index d32178e..894acce 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/rpc/RpcWrapperTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/rpc/RpcWrapperTest.java @@ -288,7 +288,7 @@ public class RpcWrapperTest { } @Override - public TBase<foo_args,fake_fields> deepCopy() { + public foo_args deepCopy() { throw new UnsupportedOperationException(); }