use of org.jumpmind.symmetric.model.ChannelMap in project symmetric-ds by JumpMind.
the class NodeConcurrencyInterceptor method buildSuspendIgnoreResponseHeaders.
protected void buildSuspendIgnoreResponseHeaders(final String nodeId, final ServletResponse resp) {
HttpServletResponse httpResponse = (HttpServletResponse) resp;
ChannelMap suspendIgnoreChannels = configurationService.getSuspendIgnoreChannelLists(nodeId);
httpResponse.setHeader(WebConstants.SUSPENDED_CHANNELS, suspendIgnoreChannels.getSuspendChannelsAsString());
httpResponse.setHeader(WebConstants.IGNORED_CHANNELS, suspendIgnoreChannels.getIgnoreChannelsAsString());
}
use of org.jumpmind.symmetric.model.ChannelMap in project symmetric-ds by JumpMind.
the class PullUriHandler method pull.
public void pull(String nodeId, String remoteHost, String remoteAddress, OutputStream outputStream, String encoding, ChannelMap map) throws IOException {
NodeSecurity nodeSecurity = nodeService.findNodeSecurity(nodeId);
long ts = System.currentTimeMillis();
try {
ChannelMap remoteSuspendIgnoreChannelsList = configurationService.getSuspendIgnoreChannelLists(nodeId);
map.addSuspendChannels(remoteSuspendIgnoreChannelsList.getSuspendChannels());
map.addIgnoreChannels(remoteSuspendIgnoreChannelsList.getIgnoreChannels());
if (nodeSecurity != null) {
String createdAtNodeId = nodeSecurity.getCreatedAtNodeId();
if (nodeSecurity.isRegistrationEnabled() && (createdAtNodeId == null || createdAtNodeId.equals(nodeService.findIdentityNodeId()))) {
registrationService.registerNode(nodeService.findNode(nodeId), remoteHost, remoteAddress, outputStream, false);
} else {
IOutgoingTransport outgoingTransport = createOutgoingTransport(outputStream, encoding, map);
ProcessInfo processInfo = statisticManager.newProcessInfo(new ProcessInfoKey(nodeService.findIdentityNodeId(), nodeId, ProcessType.PULL_HANDLER));
try {
Node targetNode = nodeService.findNode(nodeId);
List<OutgoingBatch> batchList = dataExtractorService.extract(processInfo, targetNode, outgoingTransport);
logDataReceivedFromPush(targetNode, batchList);
if (processInfo.getStatus() != Status.ERROR) {
processInfo.setStatus(Status.OK);
}
} finally {
if (processInfo.getStatus() != Status.OK) {
processInfo.setStatus(Status.ERROR);
}
}
outgoingTransport.close();
}
} else {
log.warn("Node {} does not exist", nodeId);
}
} finally {
statisticManager.incrementNodesPulled(1);
statisticManager.incrementTotalNodesPulledTime(System.currentTimeMillis() - ts);
}
}
use of org.jumpmind.symmetric.model.ChannelMap in project symmetric-ds by JumpMind.
the class DataLoaderService method loadDataFromPull.
public void loadDataFromPull(Node remote, RemoteNodeStatus status) throws IOException {
Node local = nodeService.findIdentity();
if (local == null) {
local = new Node(this.parameterService, symmetricDialect);
}
try {
NodeSecurity localSecurity = nodeService.findNodeSecurity(local.getNodeId());
IIncomingTransport transport = null;
if (remote != null && localSecurity != null) {
Map<String, String> requestProperties = new HashMap<String, String>();
ChannelMap suspendIgnoreChannels = configurationService.getSuspendIgnoreChannelLists();
requestProperties.put(WebConstants.SUSPENDED_CHANNELS, suspendIgnoreChannels.getSuspendChannelsAsString());
requestProperties.put(WebConstants.IGNORED_CHANNELS, suspendIgnoreChannels.getIgnoreChannelsAsString());
transport = transportManager.getPullTransport(remote, local, localSecurity.getNodePassword(), requestProperties, parameterService.getRegistrationUrl());
} else {
transport = transportManager.getRegisterTransport(local, parameterService.getRegistrationUrl());
log.info("Using registration URL of {}", transport.getUrl());
remote = new Node();
remote.setSyncUrl(parameterService.getRegistrationUrl());
}
ProcessInfo processInfo = statisticManager.newProcessInfo(new ProcessInfoKey(remote.getNodeId(), local.getNodeId(), ProcessType.PULL_JOB));
try {
List<IncomingBatch> list = loadDataFromTransport(processInfo, remote, transport);
if (list.size() > 0) {
processInfo.setStatus(ProcessInfo.Status.ACKING);
status.updateIncomingStatus(list);
local = nodeService.findIdentity();
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, transportManager);
}
}
if (containsError(list)) {
processInfo.setStatus(ProcessInfo.Status.ERROR);
} else {
processInfo.setStatus(ProcessInfo.Status.OK);
}
} catch (RuntimeException e) {
processInfo.setStatus(ProcessInfo.Status.ERROR);
throw e;
} catch (IOException e) {
processInfo.setStatus(ProcessInfo.Status.ERROR);
throw e;
}
} catch (RegistrationRequiredException e) {
if (StringUtils.isBlank(remote.getSyncUrl()) || remote.getSyncUrl().equals(parameterService.getRegistrationUrl())) {
log.warn("Node information missing on the server. Attempting to re-register");
loadDataFromPull(null, status);
nodeService.findIdentity(false);
} else {
log.warn("Failed to pull data from node '{}'. It probably is missing a node security record for '{}'.", remote.getNodeId(), local.getNodeId());
}
} catch (MalformedURLException e) {
if (remote != null) {
log.error("Could not connect to the {} node's transport because of a bad URL: {}", remote.getNodeId(), remote.getSyncUrl());
} else {
log.error("", e);
}
throw e;
}
}
Aggregations