Skip to content
Permalink
Browse files

0003882: Registration stuck in "open" even though data still syncing

over push link
  • Loading branch information...
erilong committed Mar 1, 2019
1 parent 0fb1699 commit e3dcd008c731a17763a70859ca6786371edb4419
@@ -109,9 +109,12 @@ protected void fireOffline(Exception error, Node remoteNode, RemoteNodeStatus st
} else if (isSyncDisabled(error)) {
log.warn("Sync was not enabled for {} at {}", new Object[] {remoteNode, syncUrl});
status.setStatus(Status.SYNC_DISABLED);
} else if (isRegistrationRequired(error)) {
} else if (isRegistrationNotOpen(error)) {
log.warn("Registration was not open at {}", new Object[] {remoteNode, syncUrl});
status.setStatus(Status.REGISTRATION_REQUIRED);
} else if (isRegistrationRequired(error)) {
log.warn("Registration is needed before communicating with {}", new Object[] {remoteNode, syncUrl});
status.setStatus(Status.REGISTRATION_REQUIRED);
} else if (getHttpException(error) != null) {
HttpException http = getHttpException(error);
if (shouldLogTransportError(remoteNode.getNodeId())) {
@@ -222,16 +225,26 @@ protected boolean isRegistrationRequired(Exception ex) {
boolean registrationRequired = false;
if (ex != null) {
Throwable cause = getRootCause(ex);
registrationRequired = cause instanceof RegistrationRequiredException ||
cause instanceof RegistrationNotOpenException;
if (registrationRequired == false && (ex instanceof RegistrationRequiredException ||
cause instanceof RegistrationNotOpenException)) {
registrationRequired = cause instanceof RegistrationRequiredException;
if (registrationRequired == false && (ex instanceof RegistrationRequiredException)) {
registrationRequired = true;
}
}
return registrationRequired;
}


protected boolean isRegistrationNotOpen(Exception ex) {
boolean registrationNotOpen = false;
if (ex != null) {
Throwable cause = getRootCause(ex);
registrationNotOpen = cause instanceof RegistrationNotOpenException;
if (registrationNotOpen == false && (ex instanceof RegistrationNotOpenException)) {
registrationNotOpen = true;
}
}
return registrationNotOpen;
}

protected HttpException getHttpException(Exception ex) {
HttpException exception = null;
if (ex != null) {
@@ -128,9 +128,11 @@ synchronized public RemoteNodeStatuses pushData(boolean force) {
}
}
} else {
log.error(
"Could not find a node security row for '{}'. A node needs a matching security row in both the local and remote nodes if it is going to authenticate to push data",
Node doubleCheckidentity = nodeService.findIdentity(false);
if (doubleCheckidentity != null) {
log.error("Could not find a node security row for '{}'. A node needs a matching security row in both the local and remote nodes if it is going to authenticate to push data",
identity.getNodeId());
}
}
}
} else {
@@ -219,6 +221,11 @@ private void pushToNode(Node remote, RemoteNodeStatus status) {
} catch (Exception ex) {
processInfo.setStatus(ProcessStatus.ERROR);
fireOffline(ex, remote, status);
if (isRegistrationRequired(ex)) {
log.info("Removing identity because registration is required");
nodeService.deleteIdentity();
nodeService.findIdentity(false);
}
} finally {
try {
transport.close();
@@ -30,6 +30,7 @@
import javax.servlet.http.HttpServletResponse;

import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.model.NodeSecurity;
import org.jumpmind.symmetric.service.IDataLoaderService;
import org.jumpmind.symmetric.service.INodeService;
import org.jumpmind.symmetric.service.IParameterService;
@@ -65,26 +66,34 @@ public void handle(HttpServletRequest req, HttpServletResponse res) throws IOExc

String threadChannel = req.getHeader(WebConstants.CHANNEL_QUEUE);

push(nodeId, threadChannel, inputStream, outputStream);
int rc = push(nodeId, threadChannel, inputStream, outputStream);

if (rc != WebConstants.SC_OK) {
res.sendError(rc);
}

res.flushBuffer();
log.debug("Push completed for {}", nodeId);

}

protected void push(String sourceNodeId, InputStream inputStream, OutputStream outputStream) throws IOException {
push(sourceNodeId, null, inputStream, outputStream);
}

protected void push(String sourceNodeId, String channelId, InputStream inputStream, OutputStream outputStream) throws IOException {
protected int push(String sourceNodeId, String channelId, InputStream inputStream, OutputStream outputStream) throws IOException {
long ts = System.currentTimeMillis();
try {
Node sourceNode = nodeService.findNode(sourceNodeId, true);
NodeSecurity nodeSecurity = nodeService.findNodeSecurity(sourceNodeId, true);

if (nodeSecurity != null) {
String createdAtNodeId = nodeSecurity.getCreatedAtNodeId();
if (nodeSecurity.isRegistrationEnabled() && (createdAtNodeId == null || createdAtNodeId.equals(nodeService.findIdentityNodeId()))) {
return WebConstants.REGISTRATION_REQUIRED;
}
}
dataLoaderService.loadDataFromPush(sourceNode, channelId, inputStream, outputStream);
} finally {
statisticManager.incrementNodesPushed(1);
statisticManager.incrementTotalNodesPushedTime(System.currentTimeMillis() - ts);
}
return WebConstants.SC_OK;
}

protected InputStream createInputStream(HttpServletRequest req) throws IOException {

0 comments on commit e3dcd00

Please sign in to comment.
You can’t perform that action at this time.