I was wondering along similar lines while trying to come up with an
API for the Responder side.
On the Requestor side, a plugin could be registered with callbacks
that are invoked before the request is send, and right after the
response is received. For the Responder, callbacks associated with a
registered plugin would be called after the request is received (but
before the logic of the rpc is executed), and then before the response
is sent back. Default implementations would just do a nop, and by
default an empty map would be sent.
For now, though, it might be best for me to first write a patch to the
spec (with the metadata coming before the name and parameters), and a
patch to the implementation. Time permitting before Wednesday, I can
then write a patch to support the public api for registering the plugin.
Sound good?
Thanks,
George
On Jun 30, 2009, at 12:04 PM, Doug Cutting wrote:
I wonder if, rather than using ThreadLocals, what might be better is
to have Requestor and Responder support plugins that can manipulate
the call and response metadata. Default plugins could be statically
configured, and per-proxy plugins could be passed to
ReflectRequestor#getClient().
Doug
Doug Cutting wrote:
George Porter wrote:
If (as I expect) it is possible for a thread to have multiple
Requestors open (but Requestors could not be shared to more than
one thread), then the ThreadLocal could be a Map<Requestor,
metadata>. This way you could set per-call metadata on a per-
requestor basis even if multiple requestors are open. We could
provide some static methods as you mentioned to facilitate this.
Perhaps the ThreadLocal need not be static, but rather per-
Requestor. The setters and getters would be implicitly per-thread
and explicitly per-requestor. Could that work?
So that I understand, in this case the call format for the request
would then become:
- the message name, an avro string, followed by the message
parameters
- the per-call metadata, which is a map. By default the map is
null
My intuition would be to transmit the metadata before the message
name and parameters. Also, a map would always be transmitted, but
it would be empty by default. The analogy is with HTTP headers,
which are transmitted before request and response payloads. It
should be easy to implement an HTTP-based Transceiver.
and the call response would become
- a one byte error flag boolean (with either a message response
or error)
- the per-call metadata, which is a map. By default the map is
null
Again, I would transmit metadata before the response data and
always transmit a map, empty by default.
Before you had mentioned that the metadata could be sent in
Transceiver.transceive. But couldn't it also be sent in
Requestor.request() (approximately at the writeRequset() call)?
Yes, if it is part of the Avro spec, it would be sent by Requestor
and Responder. If added by an application, it could be in
Transceiver#transceive().
What do people think of proceeding with Doug's recommendation of
using ThreadLocals, and including the map in the call request and
response?
+1 from me.
Doug
[[email protected]][+1.858.320.9932]
[Principal Investigator][Project BigData][Sun Labs]
[twitter.com/SunLabsBigData][blogs.sun.com/george]