|
This looks good to me. +1
For comparison, the proxy approach might look something like: XxxProtocol proxy = new RetryProxy(XxxProtocol.class, Try.FOREVER); The weakness of this approach would be (a) the client would need to know how to build an appropriate proxy for the protocol, and (b) specifying different reliability contracts for different methods would be awkward. By contrast, your annotation-based approach keeps the reliability requirements with the protocol and per-method. Note: VersionedProtocol.getProtocolVersion() should retry at least a few times.
Any news on this one?
Whenever the jobtracker is busy and it makes our JobClient.submitJob calls fail. Created a draft patch to solve this issue more or less as suggested by Owen.
I left out the Try option (try once, no exception) since it's not possible to return null if the proxied method has a primitive return value. This patch just contains the annotations and retry bits, I'm going to leave it up to someone with more intimate knowledge of hadoop to decide what retry policy goes where. Suggestions and corrections welcome. Example usage: @RpcReliability(RetryPolicy.TRY_NOTIFY) @RpcReliability(value=RetryPolicy.TIMED, timedDelaySecs=5, timedTrySecs=30) @RpcReliability(value=RetryPolicy.TIMED, timedDelaySecs=5, timedTrySecs=30, I created a generic mechanism for this as a part of
Looks much better!
Hope to see that in a future version. Thanks Johan. It would be good to add the annotations handling from your patch to the mechanism in
Also, I've put the retry classes in a new package org.apache.hadoop.io.retry. Do people feel this is OK? It doesn't feel quite right as it's not exclusively for IO retries. This is mostly included in
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public interface FooBar extends VersionedProtocol {
@RpcReliability(@Try) /* single try, no exception for failure */
void progress();
@RpcReliability(@TryNotify) /* single try, exception for failure */
void setStatus(String msg);
@RpcReliability(@Forever) /* keep trying forever */
void done();
@RpcReliability(@Timed(30,5)) /* try for 30 seconds waiting 5 seconds between attempts and then throw */
void doWork();
/* Set a default policy with some explicit handlers for specific exceptions.
Matches with remote exceptions will also be handled. */
@RpcReliability(value=@Timed(30,5),
handlers={@ErrorHandler(err=SocketTimeOutException.class, response=@Forever), @ErrorHandler(err=NullPointerException, reponse=@TryNotify)})
void complexWork();
}
Thoughts?