Skip to content

Commit

Permalink
Better error handling on failed registration. Don't load an error whe…
Browse files Browse the repository at this point in the history
…n a virutal batch can't be updated.
  • Loading branch information
chenson42 committed Aug 30, 2011
1 parent f4c59ac commit 3049667
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
Expand Up @@ -51,6 +51,7 @@
import org.jumpmind.symmetric.load.IDataLoaderContext;
import org.jumpmind.symmetric.load.IDataLoaderFilter;
import org.jumpmind.symmetric.load.IDataLoaderStatistics;
import org.jumpmind.symmetric.model.BatchInfo;
import org.jumpmind.symmetric.model.ChannelMap;
import org.jumpmind.symmetric.model.IncomingBatch;
import org.jumpmind.symmetric.model.IncomingBatch.Status;
Expand Down Expand Up @@ -150,14 +151,17 @@ public void loadDataFromPull(Node remote, RemoteNodeStatus status)
if (list.size() > 0) {
status.updateIncomingStatus(list);
local = nodeService.findIdentity();
localSecurity = nodeService.findNodeSecurity(local.getNodeId());
if (StringUtils.isNotBlank(transport.getRedirectionUrl())) {
// we were redirected for the pull, we need to redirect for the ack
String url = transport.getRedirectionUrl();
url = url.replace(HttpTransportManager.buildRegistrationUrl("", local), "");
remote.setSyncUrl(url);
if (local != null) {
localSecurity = nodeService.findNodeSecurity(local.getNodeId());
if (StringUtils.isNotBlank(transport.getRedirectionUrl())) {
// we were redirected for the pull, we need to redirect
// for the ack
String url = transport.getRedirectionUrl();
url = url.replace(HttpTransportManager.buildRegistrationUrl("", local), "");
remote.setSyncUrl(url);
}
sendAck(remote, local, localSecurity, list);
}
sendAck(remote, local, localSecurity, list);
}

} catch (RegistrationRequiredException e) {
Expand Down Expand Up @@ -260,7 +264,8 @@ protected List<IncomingBatch> loadDataAndReturnBatches(IIncomingTransport transp

for (IncomingBatch incomingBatch : batchesProcessed) {
// TODO I wonder if there is a way to avoid the second update?
if (incomingBatchService.updateIncomingBatch(incomingBatch) == 0) {
if (incomingBatch.getBatchId() != BatchInfo.VIRTUAL_BATCH_FOR_REGISTRATION &&
incomingBatchService.updateIncomingBatch(incomingBatch) == 0) {
log.error("LoaderFailedToUpdateBatch", incomingBatch.getBatchId());
}
}
Expand Down
Expand Up @@ -280,18 +280,23 @@ public void registerWithServer() {
maxNumberOfAttempts--;

if (!registered && (maxNumberOfAttempts < 0 || maxNumberOfAttempts > 0)) {
sleepBeforeRegistrationRetry();
registered = isRegisteredWithServer();
} else {
Node node = nodeService.findIdentity();
if (node != null) {
log.info("NodeRegistered", node.getNodeId());
} else if (!errorOccurred) {
log.error("NodeRegisteringFailedIdentityMissing");
registered = false;
} else {
log.error("NodeRegisteringFailedUnavailable");
registered = false;
}
}

if (!registered) {
sleepBeforeRegistrationRetry();
}
}

if (!registered) {
Expand Down

0 comments on commit 3049667

Please sign in to comment.