use of org.jumpmind.symmetric.model.ProcessInfo in project symmetric-ds by JumpMind.
the class DataLoaderService method loadDataFromConfig.
public void loadDataFromConfig(Node remote, RemoteNodeStatus status, boolean force) throws IOException {
if (engine.getParameterService().isRegistrationServer()) {
return;
}
Node local = nodeService.findIdentity();
try {
NodeSecurity localSecurity = nodeService.findNodeSecurity(local.getNodeId(), true);
String configVersion = force ? "" : local.getConfigVersion();
IIncomingTransport transport = engine.getTransportManager().getConfigTransport(remote, local, localSecurity.getNodePassword(), Version.version(), configVersion, remote.getSyncUrl());
ProcessInfo processInfo = statisticManager.newProcessInfo(new ProcessInfoKey(remote.getNodeId(), Constants.CHANNEL_CONFIG, local.getNodeId(), ProcessType.PULL_CONFIG_JOB));
try {
log.info("Requesting current configuration {symmetricVersion={}, configVersion={}}", Version.version(), local.getConfigVersion());
List<IncomingBatch> list = loadDataFromTransport(processInfo, remote, transport, null);
if (containsError(list)) {
processInfo.setStatus(ProcessInfo.Status.ERROR);
} else {
if (list.size() > 0) {
status.updateIncomingStatus(list);
local.setConfigVersion(Version.version());
nodeService.save(local);
}
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) {
log.warn("Failed to pull configuration from node '{}'. It probably is missing a node security record for '{}'.", remote.getNodeId(), local.getNodeId());
} catch (MalformedURLException e) {
log.error("Could not connect to the {} node's transport because of a bad URL: '{}' {}", remote.getNodeId(), remote.getSyncUrl(), e);
throw e;
}
}
use of org.jumpmind.symmetric.model.ProcessInfo in project symmetric-ds by JumpMind.
the class DataExtractorService method extractOnlyOutgoingBatch.
/**
* This method will extract an outgoing batch, but will not update the outgoing batch status
*/
public boolean extractOnlyOutgoingBatch(String nodeId, long batchId, Writer writer) {
boolean extracted = false;
Node targetNode = null;
if (Constants.UNROUTED_NODE_ID.equals(nodeId)) {
targetNode = new Node(nodeId, parameterService.getNodeGroupId());
} else {
targetNode = nodeService.findNode(nodeId);
}
if (targetNode != null) {
OutgoingBatch batch = outgoingBatchService.findOutgoingBatch(batchId, nodeId);
if (batch != null) {
IDataWriter dataWriter = new ProtocolDataWriter(nodeService.findIdentityNodeId(), writer, targetNode.requires13Compatiblity());
List<OutgoingBatch> batches = new ArrayList<OutgoingBatch>(1);
batches.add(batch);
batches = extract(new ProcessInfo(), targetNode, batches, dataWriter, null, ExtractMode.EXTRACT_ONLY);
extracted = batches.size() > 0;
}
}
return extracted;
}
use of org.jumpmind.symmetric.model.ProcessInfo in project symmetric-ds by JumpMind.
the class FileSyncService method trackChanges.
public void trackChanges(boolean force) {
if (force || engine.getClusterService().lock(ClusterConstants.FILE_SYNC_TRACKER)) {
try {
log.debug("Attempting to get exclusive lock for file sync track changes");
if (engine.getClusterService().lock(ClusterConstants.FILE_SYNC_SHARED, ClusterConstants.TYPE_EXCLUSIVE, getParameterService().getLong(ParameterConstants.FILE_SYNC_LOCK_WAIT_MS))) {
try {
log.debug("Tracking changes for file sync");
Node local = engine.getNodeService().findIdentity();
ProcessInfo processInfo = engine.getStatisticManager().newProcessInfo(new ProcessInfoKey(local.getNodeId(), null, ProcessInfoKey.ProcessType.FILE_SYNC_TRACKER));
boolean useCrc = engine.getParameterService().is(ParameterConstants.FILE_SYNC_USE_CRC);
if (engine.getParameterService().is(ParameterConstants.FILE_SYNC_FAST_SCAN)) {
trackChangesFastScan(processInfo, useCrc);
} else {
trackChanges(processInfo, useCrc);
}
if (engine.getParameterService().is(ParameterConstants.FILE_SYNC_PREVENT_PING_BACK)) {
deleteFromFileIncoming();
}
processInfo.setStatus(ProcessInfo.Status.OK);
} finally {
log.debug("Done tracking changes for file sync");
engine.getClusterService().unlock(ClusterConstants.FILE_SYNC_SHARED, ClusterConstants.TYPE_EXCLUSIVE);
}
} else {
log.warn("Did not run the track file sync changes process because it was shared locked");
}
} finally {
if (!force) {
engine.getClusterService().unlock(ClusterConstants.FILE_SYNC_TRACKER);
}
}
} else {
log.debug("Did not run the track file sync changes process because it was cluster locked");
}
}
use of org.jumpmind.symmetric.model.ProcessInfo in project symmetric-ds by JumpMind.
the class PushService method pushToNode.
private void pushToNode(Node remote, RemoteNodeStatus status) {
Node identity = nodeService.findIdentity();
NodeSecurity identitySecurity = nodeService.findNodeSecurity(identity.getNodeId(), true);
IOutgoingWithResponseTransport transport = null;
ProcessInfo processInfo = statisticManager.newProcessInfo(new ProcessInfoKey(identity.getNodeId(), status.getChannelId(), remote.getNodeId(), ProcessType.PUSH_JOB));
Map<String, String> requestProperties = new HashMap<String, String>();
requestProperties.put(WebConstants.THREAD_CHANNEL, status.getChannelId());
try {
transport = transportManager.getPushTransport(remote, identity, identitySecurity.getNodePassword(), requestProperties, parameterService.getRegistrationUrl());
List<OutgoingBatch> extractedBatches = dataExtractorService.extract(processInfo, remote, status.getChannelId(), transport);
if (extractedBatches.size() > 0) {
log.info("Push data sent to {}", remote);
List<BatchAck> batchAcks = readAcks(extractedBatches, transport, transportManager, acknowledgeService);
status.updateOutgoingStatus(extractedBatches, batchAcks);
}
if (processInfo.getStatus() != Status.ERROR) {
processInfo.setStatus(Status.OK);
}
fireOnline(remote, status);
} catch (Exception ex) {
processInfo.setStatus(Status.ERROR);
fireOffline(ex, remote, status);
} finally {
try {
transport.close();
} catch (Exception e) {
}
}
}
use of org.jumpmind.symmetric.model.ProcessInfo in project symmetric-ds by JumpMind.
the class RouterService method routeDataForEachChannel.
/**
* We route data channel by channel for two reasons. One is that if/when we
* decide to multi-thread the routing it is a simple matter of inserting a
* thread pool here and waiting for all channels to be processed. The other
* reason is to reduce the number of connections we are required to have.
*/
protected int routeDataForEachChannel() {
int dataCount = 0;
Node sourceNode = engine.getNodeService().findIdentity();
ProcessInfo processInfo = engine.getStatisticManager().newProcessInfo(new ProcessInfoKey(sourceNode.getNodeId(), null, ProcessType.ROUTER_JOB));
processInfo.setStatus(ProcessInfo.Status.PROCESSING);
try {
final List<NodeChannel> channels = engine.getConfigurationService().getNodeChannels(false);
Set<String> readyChannels = null;
if (parameterService.is(ParameterConstants.ROUTING_QUERY_CHANNELS_FIRST)) {
readyChannels = getReadyChannels();
}
for (NodeChannel nodeChannel : channels) {
if (nodeChannel.isEnabled() && (readyChannels == null || readyChannels.contains(nodeChannel.getChannelId()))) {
processInfo.setCurrentChannelId(nodeChannel.getChannelId());
dataCount += routeDataForChannel(processInfo, nodeChannel, sourceNode);
} else {
gapDetector.setIsAllDataRead(false);
if (log.isDebugEnabled()) {
log.debug("Not routing the {} channel. It is either disabled or suspended.", nodeChannel.getChannelId());
}
}
}
processInfo.setStatus(ProcessInfo.Status.OK);
} catch (RuntimeException ex) {
processInfo.setStatus(ProcessInfo.Status.ERROR);
firstTimeCheckForAbandonedBatches = true;
throw ex;
}
return dataCount;
}
Aggregations