use of org.jumpmind.symmetric.service.INodeService in project symmetric-ds by JumpMind.
the class ConfigurationChangedDatabaseWriterFilter method batchCommitted.
@Override
public void batchCommitted(DataContext context) {
IParameterService parameterService = engine.getParameterService();
INodeService nodeService = engine.getNodeService();
if (context.getBatch().getBatchId() == Constants.VIRTUAL_BATCH_FOR_REGISTRATION) {
// mark registration as complete
String nodeId = nodeService.findIdentityNodeId();
if (nodeId != null) {
NodeSecurity security = nodeService.findNodeSecurity(nodeId);
if (security != null && (security.isRegistrationEnabled() || security.getRegistrationTime() == null)) {
engine.getRegistrationService().markNodeAsRegistered(nodeId);
}
}
}
if (context.get(CTX_KEY_FLUSH_GROUPLETS_NEEDED) != null) {
log.info("Grouplets flushed because new grouplet config came through the data loader");
engine.getGroupletService().clearCache();
context.remove(CTX_KEY_FLUSH_GROUPLETS_NEEDED);
}
if (context.get(CTX_KEY_FLUSH_LOADFILTERS_NEEDED) != null) {
log.info("Load filters flushed because new filter config came through the data loader");
engine.getLoadFilterService().clearCache();
context.remove(CTX_KEY_FLUSH_LOADFILTERS_NEEDED);
}
if (context.get(CTX_KEY_FLUSH_CHANNELS_NEEDED) != null) {
log.info("Channels flushed because new channels came through the data loader");
engine.getConfigurationService().clearCache();
context.remove(CTX_KEY_FLUSH_CHANNELS_NEEDED);
}
if (context.get(CTX_KEY_FLUSH_CONFLICTS_NEEDED) != null) {
log.info("About to refresh the cache of conflict settings because new configuration came through the data loader");
engine.getDataLoaderService().clearCache();
context.remove(CTX_KEY_FLUSH_CONFLICTS_NEEDED);
}
if (context.get(CTX_KEY_FLUSH_PARAMETERS_NEEDED) != null) {
log.info("About to refresh the cache of parameters because new configuration came through the data loader");
parameterService.rereadParameters();
context.remove(CTX_KEY_FLUSH_PARAMETERS_NEEDED);
}
if (context.get(CTX_KEY_FLUSH_NODE_SECURITY_NEEDED) != null) {
log.info("About to refresh the cache of node security because new configuration came through the data loader");
nodeService.flushNodeAuthorizedCache();
context.remove(CTX_KEY_FLUSH_NODE_SECURITY_NEEDED);
}
if (context.get(CTX_KEY_FLUSH_NODE_NEEDED) != null) {
log.info("About to refresh the cache of nodes because new configuration came through the data loader");
nodeService.flushNodeCache();
nodeService.flushNodeGroupCache();
context.remove(CTX_KEY_FLUSH_NODE_NEEDED);
}
}
use of org.jumpmind.symmetric.service.INodeService in project symmetric-ds by JumpMind.
the class RestService method sendSchemaImpl.
private SendSchemaResponse sendSchemaImpl(ISymmetricEngine engine, SendSchemaRequest request) {
IConfigurationService configurationService = engine.getConfigurationService();
INodeService nodeService = engine.getNodeService();
ITriggerRouterService triggerRouterService = engine.getTriggerRouterService();
IDataService dataService = engine.getDataService();
SendSchemaResponse response = new SendSchemaResponse();
org.jumpmind.symmetric.model.Node identity = nodeService.findIdentity();
if (identity != null) {
List<org.jumpmind.symmetric.model.Node> nodesToSendTo = new ArrayList<org.jumpmind.symmetric.model.Node>();
List<String> nodeIds = request.getNodeIdsToSendTo();
if (nodeIds == null || nodeIds.size() == 0) {
nodeIds = new ArrayList<String>();
String nodeGroupIdToSendTo = request.getNodeGroupIdToSendTo();
if (isNotBlank(nodeGroupIdToSendTo)) {
NodeGroupLink link = configurationService.getNodeGroupLinkFor(identity.getNodeGroupId(), nodeGroupIdToSendTo, false);
if (link != null) {
Collection<org.jumpmind.symmetric.model.Node> nodes = nodeService.findEnabledNodesFromNodeGroup(nodeGroupIdToSendTo);
nodesToSendTo.addAll(nodes);
} else {
log.warn("Could not send schema to all nodes in the '" + nodeGroupIdToSendTo + "' node group. No node group link exists");
}
} else {
log.warn("Could not send schema to nodes. There are none that were provided and the nodeGroupIdToSendTo was also not provided");
}
} else {
for (String nodeIdToValidate : nodeIds) {
org.jumpmind.symmetric.model.Node node = nodeService.findNode(nodeIdToValidate);
if (node != null) {
NodeGroupLink link = configurationService.getNodeGroupLinkFor(identity.getNodeGroupId(), node.getNodeGroupId(), false);
if (link != null) {
nodesToSendTo.add(node);
} else {
log.warn("Could not send schema to node '" + nodeIdToValidate + "'. No node group link exists");
}
} else {
log.warn("Could not send schema to node '" + nodeIdToValidate + "'. It was not present in the database");
}
}
}
Map<String, List<TableName>> results = response.getNodeIdsSentTo();
List<String> nodeIdsToSendTo = toNodeIds(nodesToSendTo);
for (String nodeId : nodeIdsToSendTo) {
results.put(nodeId, new ArrayList<TableName>());
}
if (nodesToSendTo.size() > 0) {
List<TableName> tablesToSend = request.getTablesToSend();
List<TriggerRouter> triggerRouters = triggerRouterService.getTriggerRouters(false);
for (TriggerRouter triggerRouter : triggerRouters) {
Trigger trigger = triggerRouter.getTrigger();
NodeGroupLink link = triggerRouter.getRouter().getNodeGroupLink();
if (link.getSourceNodeGroupId().equals(identity.getNodeGroupId())) {
for (org.jumpmind.symmetric.model.Node node : nodesToSendTo) {
if (link.getTargetNodeGroupId().equals(node.getNodeGroupId())) {
if (tablesToSend == null || tablesToSend.size() == 0 || contains(trigger, tablesToSend)) {
dataService.sendSchema(node.getNodeId(), trigger.getSourceCatalogName(), trigger.getSourceSchemaName(), trigger.getSourceTableName(), false);
results.get(node.getNodeId()).add(new TableName(trigger.getSourceCatalogName(), trigger.getSourceSchemaName(), trigger.getSourceTableName()));
}
}
}
}
}
}
}
return response;
}
use of org.jumpmind.symmetric.service.INodeService in project symmetric-ds by JumpMind.
the class RestService method heartbeatImpl.
private void heartbeatImpl(ISymmetricEngine engine, Heartbeat heartbeat) {
INodeService nodeService = engine.getNodeService();
NodeHost nodeHost = new NodeHost();
if (heartbeat.getAvailableProcessors() != null) {
nodeHost.setAvailableProcessors(heartbeat.getAvailableProcessors());
}
if (heartbeat.getCreateTime() != null) {
nodeHost.setCreateTime(heartbeat.getCreateTime());
}
if (heartbeat.getFreeMemoryBytes() != null) {
nodeHost.setFreeMemoryBytes(heartbeat.getFreeMemoryBytes());
}
if (heartbeat.getHeartbeatTime() != null) {
nodeHost.setHeartbeatTime(heartbeat.getHeartbeatTime());
}
if (heartbeat.getHostName() != null) {
nodeHost.setHostName(heartbeat.getHostName());
}
if (heartbeat.getIpAddress() != null) {
nodeHost.setIpAddress(heartbeat.getIpAddress());
}
if (heartbeat.getJavaVendor() != null) {
nodeHost.setJavaVendor(heartbeat.getJavaVendor());
}
if (heartbeat.getJdbcVersion() != null) {
nodeHost.setJdbcVersion(heartbeat.getJdbcVersion());
}
if (heartbeat.getJavaVersion() != null) {
nodeHost.setJavaVersion(heartbeat.getJavaVersion());
}
if (heartbeat.getLastRestartTime() != null) {
nodeHost.setLastRestartTime(heartbeat.getLastRestartTime());
}
if (heartbeat.getMaxMemoryBytes() != null) {
nodeHost.setMaxMemoryBytes(heartbeat.getMaxMemoryBytes());
}
if (heartbeat.getNodeId() != null) {
nodeHost.setNodeId(heartbeat.getNodeId());
}
if (heartbeat.getOsArchitecture() != null) {
nodeHost.setOsArch(heartbeat.getOsArchitecture());
}
if (heartbeat.getOsName() != null) {
nodeHost.setOsName(heartbeat.getOsName());
}
if (heartbeat.getOsUser() != null) {
nodeHost.setOsUser(heartbeat.getOsUser());
}
if (heartbeat.getOsVersion() != null) {
nodeHost.setOsVersion(heartbeat.getOsVersion());
}
if (heartbeat.getSymmetricVersion() != null) {
nodeHost.setSymmetricVersion(heartbeat.getSymmetricVersion());
}
if (heartbeat.getTimezoneOffset() != null) {
nodeHost.setTimezoneOffset(heartbeat.getTimezoneOffset());
}
if (heartbeat.getTotalMemoryBytes() != null) {
nodeHost.setTotalMemoryBytes(heartbeat.getTotalMemoryBytes());
}
nodeService.updateNodeHost(nodeHost);
}
use of org.jumpmind.symmetric.service.INodeService in project symmetric-ds by JumpMind.
the class RestService method postRequestInitialLoad.
/**
* Requests an initial load from the server for the node id provided. The
* initial load requst directs the server to queue up initial load data for
* the client node. Data is obtained for the initial load by the client
* calling the pull method.
*
* @param nodeID
*/
@ApiOperation(value = "Request an initial load for the specified node for the specified engine")
@RequestMapping(value = "/engine/{engine}/requestinitialload", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
@ResponseBody
public final void postRequestInitialLoad(@PathVariable("engine") String engineName, @RequestParam(value = "nodeId") String nodeId) {
ISymmetricEngine engine = getSymmetricEngine(engineName);
INodeService nodeService = engine.getNodeService();
nodeService.setInitialLoadEnabled(nodeId, true, false, -1, "restapi");
}
use of org.jumpmind.symmetric.service.INodeService in project symmetric-ds by JumpMind.
the class RouterService method findNodesThatAreReadyForInitialLoad.
public List<NodeSecurity> findNodesThatAreReadyForInitialLoad() {
INodeService nodeService = engine.getNodeService();
IConfigurationService configurationService = engine.getConfigurationService();
String me = nodeService.findIdentityNodeId();
List<NodeSecurity> toReturn = new ArrayList<NodeSecurity>();
List<NodeSecurity> securities = nodeService.findNodeSecurityWithLoadEnabled();
for (NodeSecurity nodeSecurity : securities) {
if (((!nodeSecurity.getNodeId().equals(me) && nodeSecurity.isInitialLoadEnabled()) || (!nodeSecurity.getNodeId().equals(me) && configurationService.isMasterToMaster()) || (nodeSecurity.getNodeId().equals(me) && nodeSecurity.isRevInitialLoadEnabled()))) {
toReturn.add(nodeSecurity);
}
}
return toReturn;
}
Aggregations