accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshelser <...@git.apache.org>
Subject [GitHub] accumulo pull request: ACCUMULO-4065 Work around TExceptions being...
Date Tue, 01 Dec 2015 18:08:19 GMT
Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/56#discussion_r46314596
  
    --- Diff: server/base/src/main/java/org/apache/accumulo/server/util/RpcWrapper.java ---
    @@ -36,20 +42,51 @@
      * @since 1.6.1
      */
     public class RpcWrapper {
    +  private static final Logger log = LoggerFactory.getLogger(RpcWrapper.class);
    +
    +  public static <T> T service(final T instance, @SuppressWarnings("rawtypes") final
Map<String,ProcessFunction<T,? extends TBase>> processorView) {
    +    // Get a handle on the isOnewayMethod and make it accessible
    +    final Method isOnewayMethod;
    +    try {
    +      isOnewayMethod = ProcessFunction.class.getDeclaredMethod("isOneway");
    +    } catch (NoSuchMethodException e) {
    +      throw new RuntimeException("Could not access isOneway method", e);
    +    } catch (SecurityException e) {
    +      throw new RuntimeException("Could not access isOneway method", e);
    +    }
    +    isOnewayMethod.setAccessible(true);
    +
    +    final Set<String> onewayMethods = new HashSet<String>();
    +    for (@SuppressWarnings("rawtypes") Entry<String,ProcessFunction<T,? extends
TBase>> entry : processorView.entrySet()) {
    +      try {
    +        if ((Boolean) isOnewayMethod.invoke(entry.getValue())) {
    +          onewayMethods.add(entry.getKey());
    +        }
    +      } catch (Exception e) {
    +        throw new RuntimeException(e);
    +      }
    +    }
    +    log.debug("Found oneway Thrift methods: " + onewayMethods);
     
    -  public static <T> T service(final T instance) {
         InvocationHandler handler = new RpcServerInvocationHandler<T>(instance) {
           private final Logger log = LoggerFactory.getLogger(instance.getClass());
     
           @Override
           public Object invoke(Object obj, Method method, Object[] args) throws Throwable
{
    +        // e.g. ThriftClientHandler.flush(TInfo, TCredentials, ...)
             try {
               return super.invoke(obj, method, args);
             } catch (RuntimeException e) {
    +          if (onewayMethods.contains(method.getName())) {
    --- End diff --
    
    > I believe that Thrift disallows multiple methods with the same name in one service
    
    Yes, this is the case. Each Thrift service (e.g. master, client, tabletserver) will have
its own instance of RpcWrapper underneath the `Processor`. Thus, the methods contained are
unique to a service definition whose method names are guaranteed to be unique.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message