-
Notifications
You must be signed in to change notification settings - Fork 445
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
Implement getCompactionJob async RPC using Jetty and REST #5018
base: main
Are you sure you want to change the base?
Conversation
This change switches getCompactionJob() rpc call to be an async REST call using Jetty and Jersey so that we can use long polling and not block while waiting for jobs on the queue. Jetty is configured to use Jackson and a custom serializer/deserializer to handle Thrift objects being serialized to json. Authentication has been set up to work with username/password, SSL, and also Kerberos. Right now for the prototype the authentication is not quite complete and a couple shortcuts were taken to get it working with the IT set up so some more work needs to be done before it is finished.
// to prevent creating a new deserializer for every object? | ||
private static <T extends TBase<?,?>> void deserialize(T obj, String json) throws IOException { | ||
try { | ||
final TDeserializer deserializer = new TDeserializer(new TJSONProtocol.Factory()); |
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.
The Factory is thread-safe, right? I can imagine that the Deserializer is not. You could put the TDeserializer and TSerializers in a ThreadLocal. It looks like they reset their internals for reuse.
String advertiseHost = getHostname(); | ||
if (advertiseHost.equals("0.0.0.0")) { | ||
try { | ||
advertiseHost = InetAddress.getLocalHost().getHostName(); | ||
} catch (UnknownHostException e) { | ||
log.error("Unable to get hostname", e); | ||
} | ||
} | ||
HostAndPort restHostAndPort = HostAndPort.fromParts(advertiseHost, restPort); |
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.
I think you can use the value of sa.address
from the code above this. In the code above the Thrift server was started on an interface, I assume we want to use the same one, just a different port.
This change switches getCompactionJob() rpc call to be an async REST call using Jetty and Jersey so that we can use long polling and not block while waiting for jobs on the queue. This is meant to demonstrate another alternative for async RPC as described in #5000
Jetty is configured to use Jackson and a custom serializer/deserializer to handle Thrift objects being serialized to json.
Authentication has been set up to work with username/password, SSL, and also Kerberos. Right now for the prototype the authentication is working but a couple shortcuts were taken to get it working with the IT set up so some more work needs to be done before it could work outside ITs if we wanted to use it.
Some notes about the prototype: