accumulo icon indicating copy to clipboard operation
accumulo copied to clipboard

Further Thrift service optimization

Open dlmarion opened this issue 3 years ago • 5 comments

As noted in comments in #2620, it may be possible to:

  1. Modify ThriftProcessorTypes and/or ThriftClientTypes to be enum types
  2. It may be possible to have an enum of service names (or use the name from the enum in 1 above) rather than using the Thrift IDL service name in the TMultiplexedProcessor.registerProcessor call.

dlmarion avatar Apr 19 '22 18:04 dlmarion

It looks like TMultiplexedProcessor and TMultiplexedProtocol require a String for the serviceName so I'm not sure that an enum would work in its place.

Is the goal to reduce the size of serviceName? If so, could it be as simple as replacing the serviceName String with something shorter where the types are created in ThriftClientTypes?

DomGarguilo avatar May 02 '22 19:05 DomGarguilo

So these are two different things. (1) was to modify ThriftClientTypes to be an enum object as a whole. This may be OBE at this point based on the current definition (I can't remember). (2) was to create a different enum to use in ThriftClientTypes and ThriftProcessorTypes to reduce the size of the service name as the String is sent over the wire and the values in the client and server have to match.

Edit: Looking again at ThriftClientTypes, it's not as complicated as I remember. It should be relatively straight forward to make it an enum type.

dlmarion avatar May 02 '22 19:05 dlmarion

Modify ThriftProcessorTypes and/or ThriftClientTypes to be enum types

I'm not sure that this is possible as Java enum types cannot use generics, which directly impacts the users of this class to know exactly which type of Thrift client is being returned.

dlmarion avatar May 03 '22 17:05 dlmarion

Reading the related comments in #2620 it was also suggested that the serviceNames could be shorter Strings instead enums. It looks like we could potentially do something like this by defining constants in ThriftClientTypes and using those constants in place of the serviceNames to reduce the size of the String sent over the wire:

  final static String CLIENT_SERVICE = "cl";
  final static String COMPACTOR_SERVICE = "cm";

  ...

  public static final ThriftClientType<ClientService.Client,ClientService.Client.Factory> CLIENT =
      new ThriftClientType<>(CLIENT_SERVICE, new ClientService.Client.Factory());

  public static final ThriftClientType<CompactorService.Client,
      CompactorService.Client.Factory> COMPACTOR =
          new ThriftClientType<>(COMPACTOR_SERVICE, new CompactorService.Client.Factory());

DomGarguilo avatar May 03 '22 17:05 DomGarguilo

That was the idea behind the enum. It would end up being a shorter value than the Thrift service name.

dlmarion avatar May 04 '22 10:05 dlmarion