use of org.jumpmind.symmetric.service.INodeService in project symmetric-ds by JumpMind.
the class RestService method isRegistered.
private boolean isRegistered(ISymmetricEngine engine) {
boolean registered = true;
INodeService nodeService = engine.getNodeService();
org.jumpmind.symmetric.model.Node modelNode = nodeService.findIdentity();
if (modelNode == null) {
registered = false;
} else {
NodeSecurity nodeSecurity = nodeService.findNodeSecurity(modelNode.getNodeId());
if (nodeSecurity == null) {
registered = false;
}
}
return registered;
}
use of org.jumpmind.symmetric.service.INodeService in project symmetric-ds by JumpMind.
the class RestService method securityVerified.
protected boolean securityVerified(String nodeId, ISymmetricEngine engine, String securityToken) {
INodeService nodeService = engine.getNodeService();
boolean allowed = false;
org.jumpmind.symmetric.model.Node targetNode = nodeService.findNode(nodeId);
if (targetNode != null) {
NodeSecurity security = nodeService.findNodeSecurity(nodeId);
allowed = security.getNodePassword().equals(securityToken);
}
return allowed;
}
use of org.jumpmind.symmetric.service.INodeService in project symmetric-ds by JumpMind.
the class RestService method isRootNode.
private boolean isRootNode(ISymmetricEngine engine, org.jumpmind.symmetric.model.Node node) {
INodeService nodeService = engine.getNodeService();
org.jumpmind.symmetric.model.Node modelNode = nodeService.findIdentity();
if (modelNode.getCreatedAtNodeId() == null || modelNode.getCreatedAtNodeId().equalsIgnoreCase(modelNode.getExternalId())) {
return true;
} else {
return false;
}
}
use of org.jumpmind.symmetric.service.INodeService in project symmetric-ds by JumpMind.
the class SnapshotUtil method writeJobsStats.
protected static void writeJobsStats(ISymmetricEngine engine, File tmpDir) {
FileWriter writer = null;
try {
writer = new FileWriter(new File(tmpDir, "jobs.txt"));
IJobManager jobManager = engine.getJobManager();
IClusterService clusterService = engine.getClusterService();
INodeService nodeService = engine.getNodeService();
writer.write("Clustering is " + (clusterService.isClusteringEnabled() ? "" : "not ") + "enabled and there are " + nodeService.findNodeHosts(nodeService.findIdentityNodeId()).size() + " instances in the cluster\n\n");
writer.write(StringUtils.rightPad("Job Name", 30) + StringUtils.rightPad("Schedule", 20) + StringUtils.rightPad("Status", 10) + StringUtils.rightPad("Server Id", 30) + StringUtils.rightPad("Last Server Id", 30) + StringUtils.rightPad("Last Finish Time", 30) + StringUtils.rightPad("Last Run Period", 20) + StringUtils.rightPad("Avg. Run Period", 20) + "\n");
List<IJob> jobs = jobManager.getJobs();
Map<String, Lock> locks = clusterService.findLocks();
for (IJob job : jobs) {
Lock lock = locks.get(job.getClusterLockName());
String status = getJobStatus(job, lock);
String runningServerId = lock != null ? lock.getLockingServerId() : "";
String lastServerId = clusterService.getServerId();
if (lock != null) {
lastServerId = lock.getLastLockingServerId();
}
String schedule = StringUtils.isBlank(job.getCronExpression()) ? Long.toString(job.getTimeBetweenRunsInMs()) : job.getCronExpression();
String lastFinishTime = getLastFinishTime(job, lock);
writer.write(StringUtils.rightPad(job.getClusterLockName().replace("_", " "), 30) + StringUtils.rightPad(schedule, 20) + StringUtils.rightPad(status, 10) + StringUtils.rightPad(runningServerId == null ? "" : runningServerId, 30) + StringUtils.rightPad(lastServerId == null ? "" : lastServerId, 30) + StringUtils.rightPad(lastFinishTime == null ? "" : lastFinishTime, 30) + StringUtils.rightPad(job.getLastExecutionTimeInMs() + "", 20) + StringUtils.rightPad(job.getAverageExecutionTimeInMs() + "", 20) + "\n");
}
} catch (Exception e) {
log.warn("Failed to write jobs information", e);
} finally {
IOUtils.closeQuietly(writer);
}
}
use of org.jumpmind.symmetric.service.INodeService in project symmetric-ds by JumpMind.
the class FileSyncService method loadFilesFromPush.
public void loadFilesFromPush(String nodeId, InputStream in, OutputStream out) {
INodeService nodeService = engine.getNodeService();
Node local = nodeService.findIdentity();
Node sourceNode = nodeService.findNode(nodeId, true);
if (local != null && sourceNode != null) {
ProcessInfo processInfo = engine.getStatisticManager().newProcessInfo(new ProcessInfoKey(nodeId, local.getNodeId(), ProcessInfoKey.ProcessType.FILE_SYNC_PUSH_HANDLER));
try {
List<IncomingBatch> list = processZip(in, nodeId, processInfo);
NodeSecurity security = nodeService.findNodeSecurity(local.getNodeId(), true);
processInfo.setStatus(ProcessInfo.Status.ACKING);
engine.getTransportManager().writeAcknowledgement(out, sourceNode, list, local, security != null ? security.getNodePassword() : null);
processInfo.setStatus(ProcessInfo.Status.OK);
} catch (Throwable e) {
processInfo.setStatus(ProcessInfo.Status.ERROR);
if (e instanceof IOException) {
throw new IoException((IOException) e);
} else if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
throw new RuntimeException(e);
}
}
} else {
throw new SymmetricException("Could not load data because the node is not registered");
}
}
Aggregations