Skip to content
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

rh客户端 发生 RemotingException 时,重试 #1135

Merged
merged 4 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alipay.remoting.exception.RemotingException;
import com.alipay.sofa.jraft.Status;
import com.alipay.sofa.jraft.rhea.client.failover.FailoverClosure;
import com.alipay.sofa.jraft.rhea.client.failover.RetryRunner;
Expand Down Expand Up @@ -91,7 +92,12 @@ public void success(final T result) {

@Override
public void failure(final Throwable cause) {
this.future.completeExceptionally(cause);
if (cause instanceof RemotingException) {
fengjiachun marked this conversation as resolved.
Show resolved Hide resolved
fengjiachun marked this conversation as resolved.
Show resolved Hide resolved
setError(Errors.RPC_ERROR);
run(new Status(-1, "RPC failed occur exception %s", cause.getMessage()));
} else {
this.future.completeExceptionally(cause);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
* Do not add exceptions that occur only on the client or only on the server here.
*/
public enum Errors {
UNKNOWN_SERVER_ERROR(-1, "The server experienced an unexpected error when processing the request",
RPC_ERROR(-2, "Server unavailable (RPC connection disconnected).",
UnknownServerException::new),

UNKNOWN_SERVER_ERROR(-1, "The server experienced an unexpected error when processing the request.",
UnknownServerException::new),

NONE(0, null, message -> null),
Expand Down Expand Up @@ -64,13 +67,13 @@ public enum Errors {

INVALID_REGION_EPOCH(9, "Invalid region epoch (membership or version changed).", InvalidRegionEpochException::new),

INVALID_STORE_STATS(10, "Placement driver: invalid store stats", InvalidStoreStatsException::new),
INVALID_STORE_STATS(10, "Placement driver: invalid store stats.", InvalidStoreStatsException::new),

INVALID_REGION_STATS(11, "Placement driver: invalid region stats", InvalidStoreStatsException::new),
INVALID_REGION_STATS(11, "Placement driver: invalid region stats.", InvalidStoreStatsException::new),

STORE_HEARTBEAT_OUT_OF_DATE(12, "The store heartbeat info is out of date", StoreHeartbeatOutOfDateException::new),
STORE_HEARTBEAT_OUT_OF_DATE(12, "The store heartbeat info is out of date.", StoreHeartbeatOutOfDateException::new),

REGION_HEARTBEAT_OUT_OF_DATE(13, "The region heartbeat info is out of date", RegionHeartbeatOutOfDateException::new),
REGION_HEARTBEAT_OUT_OF_DATE(13, "The region heartbeat info is out of date.", RegionHeartbeatOutOfDateException::new),

CALL_SELF_ENDPOINT_ERROR(14, "The usual reason is that the rpc call selected the self endpoint.",
CallSelfEndpointException::new),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static boolean isInvalidPeer(final Errors error) {
return error == Errors.CALL_SELF_ENDPOINT_ERROR //
|| error == Errors.NOT_LEADER //
|| error == Errors.NO_REGION_FOUND //
|| error == Errors.RPC_ERROR
|| error == Errors.LEADER_NOT_AVAILABLE;
}

Expand Down
Loading