mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-29 04:57:48 +01:00
use OutdatedUpdateException in Synchandler
This commit is contained in:
@@ -20,6 +20,9 @@ import java.util.UUID;
|
|||||||
|
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
public class SyncHandler {
|
public class SyncHandler {
|
||||||
|
private static class OutdatedUpdateException extends RuntimeException {
|
||||||
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
JObjectManager jObjectManager;
|
JObjectManager jObjectManager;
|
||||||
|
|
||||||
@@ -77,7 +80,7 @@ public class SyncHandler {
|
|||||||
if (md.getRemoteCopies().getOrDefault(from, 0L) > receivedTotalVer) {
|
if (md.getRemoteCopies().getOrDefault(from, 0L) > receivedTotalVer) {
|
||||||
Log.error("Received older index update than was known for host: "
|
Log.error("Received older index update than was known for host: "
|
||||||
+ from + " " + header.getName());
|
+ from + " " + header.getName());
|
||||||
throw new StatusRuntimeException(Status.INVALID_ARGUMENT.withDescription("Outdated!"));
|
throw new OutdatedUpdateException();
|
||||||
}
|
}
|
||||||
|
|
||||||
String rcv = "";
|
String rcv = "";
|
||||||
@@ -102,7 +105,7 @@ public class SyncHandler {
|
|||||||
if (md.getOurVersion() > receivedTotalVer) {
|
if (md.getOurVersion() > receivedTotalVer) {
|
||||||
Log.info("Received older index update than known: "
|
Log.info("Received older index update than known: "
|
||||||
+ from + " " + header.getName());
|
+ from + " " + header.getName());
|
||||||
throw new StatusRuntimeException(Status.INVALID_ARGUMENT.withDescription("Outdated!"));
|
throw new OutdatedUpdateException();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Objects.equals(md.getOurVersion(), receivedTotalVer)) {
|
if (Objects.equals(md.getOurVersion(), receivedTotalVer)) {
|
||||||
@@ -147,13 +150,9 @@ public class SyncHandler {
|
|||||||
for (var u : request.getHeaderList()) {
|
for (var u : request.getHeaderList()) {
|
||||||
try {
|
try {
|
||||||
handleOneUpdate(UUID.fromString(request.getSelfUuid()), u);
|
handleOneUpdate(UUID.fromString(request.getSelfUuid()), u);
|
||||||
|
} catch (OutdatedUpdateException ignored) {
|
||||||
|
Log.info("Outdated update of " + u.getName() + " from " + request.getSelfUuid());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (ex instanceof StatusRuntimeException sr) {
|
|
||||||
if (sr.getStatus().equals(Status.INVALID_ARGUMENT)) {
|
|
||||||
Log.info("Not reporting error when updating index of " + u.getName() + " from " + request.getSelfUuid() + ": " + sr.getMessage());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Log.info("Error when handling update from " + request.getSelfUuid() + " of " + u.getName(), ex);
|
Log.info("Error when handling update from " + request.getSelfUuid() + " of " + u.getName(), ex);
|
||||||
builder.addErrors(IndexUpdateError.newBuilder().setObjectName(u.getName()).setError(ex.toString() + Arrays.toString(ex.getStackTrace())).build());
|
builder.addErrors(IndexUpdateError.newBuilder().setObjectName(u.getName()).setError(ex.toString() + Arrays.toString(ex.getStackTrace())).build());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user