Search in sources :

Example 71 with Node

use of org.jumpmind.symmetric.model.Node in project symmetric-ds by JumpMind.

the class AbstractSymmetricEngine method autoConfigRegistrationServer.

protected void autoConfigRegistrationServer() {
    Node node = nodeService.findIdentity();
    if (node == null) {
        buildTablesFromDdlUtilXmlIfProvided();
        loadFromScriptIfProvided();
        parameterService.rereadParameters();
    }
    node = nodeService.findIdentity();
    if (node == null && parameterService.isRegistrationServer() && parameterService.is(ParameterConstants.AUTO_INSERT_REG_SVR_IF_NOT_FOUND, false)) {
        log.info("Inserting rows for node, security, identity and group for registration server");
        String nodeId = parameterService.getExternalId();
        node = new Node(parameterService, symmetricDialect);
        node.setNodeId(node.getExternalId());
        nodeService.save(node);
        nodeService.insertNodeIdentity(nodeId);
        node = nodeService.findIdentity();
        nodeService.insertNodeGroup(node.getNodeGroupId(), null);
        NodeSecurity nodeSecurity = nodeService.findOrCreateNodeSecurity(nodeId);
        nodeSecurity.setInitialLoadTime(new Date());
        nodeSecurity.setRegistrationTime(new Date());
        nodeSecurity.setInitialLoadEnabled(false);
        nodeSecurity.setRegistrationEnabled(false);
        nodeService.updateNodeSecurity(nodeSecurity);
    }
}
Also used : NodeSecurity(org.jumpmind.symmetric.model.NodeSecurity) Node(org.jumpmind.symmetric.model.Node) Date(java.util.Date)

Example 72 with Node

use of org.jumpmind.symmetric.model.Node in project symmetric-ds by JumpMind.

the class FileSyncZipDataWriter method write.

public void write(CsvData data) {
    DataEventType eventType = data.getDataEventType();
    if (eventType == DataEventType.INSERT || eventType == DataEventType.UPDATE) {
        Map<String, String> columnData = data.toColumnNameValuePairs(snapshotTable.getColumnNames(), CsvData.ROW_DATA);
        Map<String, String> oldColumnData = data.toColumnNameValuePairs(snapshotTable.getColumnNames(), CsvData.OLD_DATA);
        FileSnapshot snapshot = new FileSnapshot();
        snapshot.setTriggerId(columnData.get("TRIGGER_ID"));
        snapshot.setRouterId(columnData.get("ROUTER_ID"));
        snapshot.setFileModifiedTime(Long.parseLong(columnData.get("FILE_MODIFIED_TIME")));
        snapshot.setCrc32Checksum(Long.parseLong(columnData.get("CRC32_CHECKSUM")));
        String oldChecksum = oldColumnData.get("CRC32_CHECKSUM");
        if (StringUtils.isNotBlank(oldChecksum)) {
            snapshot.setOldCrc32Checksum(Long.parseLong(oldChecksum));
        }
        snapshot.setFileSize(Long.parseLong(columnData.get("FILE_SIZE")));
        snapshot.setLastUpdateBy(columnData.get("LAST_UPDATE_BY"));
        snapshot.setFileName(columnData.get("FILE_NAME"));
        snapshot.setRelativeDir(columnData.get("RELATIVE_DIR"));
        snapshot.setLastEventType(LastEventType.fromCode(columnData.get("LAST_EVENT_TYPE")));
        snapshotEvents.add(snapshot);
    } else if (eventType == DataEventType.RELOAD) {
        String targetNodeId = context.getBatch().getTargetNodeId();
        Node targetNode = nodeService.findNode(targetNodeId);
        List<FileTriggerRouter> fileTriggerRouters = fileSyncService.getFileTriggerRoutersForCurrentNode();
        for (FileTriggerRouter fileTriggerRouter : fileTriggerRouters) {
            if (fileTriggerRouter.isEnabled() && fileTriggerRouter.isInitialLoadEnabled() && fileTriggerRouter.getRouter().getNodeGroupLink().getTargetNodeGroupId().equals(targetNode.getNodeGroupId())) {
                DirectorySnapshot directorySnapshot = fileSyncService.getDirectorySnapshot(fileTriggerRouter);
                snapshotEvents.addAll(directorySnapshot);
            }
        }
    }
}
Also used : FileSnapshot(org.jumpmind.symmetric.model.FileSnapshot) FileTriggerRouter(org.jumpmind.symmetric.model.FileTriggerRouter) Node(org.jumpmind.symmetric.model.Node) DataEventType(org.jumpmind.symmetric.io.data.DataEventType) ArrayList(java.util.ArrayList) List(java.util.List)

Example 73 with Node

use of org.jumpmind.symmetric.model.Node in project symmetric-ds by JumpMind.

the class PushHeartbeatListener method heartbeat.

public void heartbeat(Node me) {
    IParameterService parameterService = engine.getParameterService();
    if (parameterService.is(ParameterConstants.HEARTBEAT_ENABLED)) {
        ISymmetricDialect symmetricDialect = engine.getSymmetricDialect();
        boolean updateWithBatchStatus = parameterService.is(ParameterConstants.HEARTBEAT_UPDATE_NODE_WITH_BATCH_STATUS, false);
        int outgoingErrorCount = -1;
        int outgoingUnsentCount = -1;
        if (updateWithBatchStatus) {
            outgoingUnsentCount = engine.getOutgoingBatchService().countOutgoingBatchesUnsent();
            outgoingErrorCount = engine.getOutgoingBatchService().countOutgoingBatchesInError();
        }
        if (!parameterService.getExternalId().equals(me.getExternalId()) || !parameterService.getNodeGroupId().equals(me.getNodeGroupId()) || (parameterService.getSyncUrl() != null && !parameterService.getSyncUrl().equals(me.getSyncUrl())) || !parameterService.getString(ParameterConstants.SCHEMA_VERSION, "").equals(me.getSchemaVersion()) || (engine.getDeploymentType() != null && !engine.getDeploymentType().equals(me.getDeploymentType())) || !Version.version().equals(me.getSymmetricVersion()) || !symmetricDialect.getName().equals(me.getDatabaseType()) || !symmetricDialect.getVersion().equals(me.getDatabaseVersion()) || me.getBatchInErrorCount() != outgoingErrorCount || me.getBatchToSendCount() != outgoingUnsentCount) {
            log.info("Some attribute(s) of node changed.  Recording changes");
            me.setDeploymentType(engine.getDeploymentType());
            me.setSymmetricVersion(Version.version());
            me.setDatabaseType(symmetricDialect.getName());
            me.setDatabaseVersion(symmetricDialect.getVersion());
            me.setBatchInErrorCount(outgoingErrorCount);
            me.setBatchToSendCount(outgoingUnsentCount);
            me.setSchemaVersion(parameterService.getString(ParameterConstants.SCHEMA_VERSION));
            if (parameterService.is(ParameterConstants.AUTO_UPDATE_NODE_VALUES)) {
                log.info("Updating my node configuration info according to the symmetric properties");
                me.setExternalId(parameterService.getExternalId());
                me.setNodeGroupId(parameterService.getNodeGroupId());
                if (!StringUtils.isBlank(parameterService.getSyncUrl())) {
                    me.setSyncUrl(parameterService.getSyncUrl());
                }
            }
            engine.getNodeService().save(me);
        }
        log.debug("Updating my node info");
        engine.getOutgoingBatchService().markAllChannelAsSent(Constants.CHANNEL_HEARTBEAT, getTableName());
        engine.getNodeService().updateNodeHostForCurrentNode();
        log.debug("Done updating my node info");
        if (!engine.getNodeService().isRegistrationServer()) {
            if (!symmetricDialect.getPlatform().getDatabaseInfo().isTriggersSupported()) {
                engine.getDataService().insertHeartbeatEvent(me, false);
                Set<Node> children = engine.getNodeService().findNodesThatOriginatedFromNodeId(me.getNodeId());
                for (Node node : children) {
                    engine.getDataService().insertHeartbeatEvent(node, false);
                }
            }
        }
    }
}
Also used : ISymmetricDialect(org.jumpmind.symmetric.db.ISymmetricDialect) Node(org.jumpmind.symmetric.model.Node) IParameterService(org.jumpmind.symmetric.service.IParameterService) IBuiltInExtensionPoint(org.jumpmind.extension.IBuiltInExtensionPoint)

Example 74 with Node

use of org.jumpmind.symmetric.model.Node in project symmetric-ds by JumpMind.

the class ConfigurationChangedDatabaseWriterFilter method recordNodeFlushNeeded.

private void recordNodeFlushNeeded(DataContext context, Table table, CsvData data) {
    if (matchesTable(table, TableConstants.SYM_NODE) && context.getBatch().getBatchId() != Constants.VIRTUAL_BATCH_FOR_REGISTRATION) {
        Map<String, String> newData = data.toColumnNameValuePairs(table.getColumnNames(), CsvData.ROW_DATA);
        String nodeId = newData.get("NODE_ID");
        Node node = engine.getNodeService().findNodeInCacheOnly(nodeId);
        if (node == null || data.getDataEventType() == DataEventType.INSERT || !node.isSyncEnabled()) {
            context.put(CTX_KEY_FLUSH_NODE_NEEDED, true);
        }
    }
}
Also used : Node(org.jumpmind.symmetric.model.Node)

Example 75 with Node

use of org.jumpmind.symmetric.model.Node in project symmetric-ds by JumpMind.

the class NotificationTypeLog method notify.

public void notify(Notification notification, List<MonitorEvent> monitorEvents) {
    Map<String, Node> nodes = engine.getNodeService().findAllNodesAsMap();
    for (MonitorEvent monitorEvent : monitorEvents) {
        Node node = nodes.get(monitorEvent.getNodeId());
        String nodeString = node != null ? node.toString() : monitorEvent.getNodeId();
        String message = "Monitor " + monitorEvent.getType() + " on " + nodeString + " reached threshold of " + monitorEvent.getThreshold() + " with a value of " + monitorEvent.getValue();
        if (monitorEvent.getSeverityLevel() >= Monitor.SEVERE) {
            log.error(message);
        } else if (monitorEvent.getSeverityLevel() >= Monitor.WARNING) {
            log.warn(message);
        } else {
            log.info(message);
        }
    }
}
Also used : MonitorEvent(org.jumpmind.symmetric.model.MonitorEvent) Node(org.jumpmind.symmetric.model.Node)

Aggregations

Node (org.jumpmind.symmetric.model.Node)129 HashSet (java.util.HashSet)18 ProcessInfo (org.jumpmind.symmetric.model.ProcessInfo)18 Test (org.junit.Test)18 TriggerHistory (org.jumpmind.symmetric.model.TriggerHistory)17 ArrayList (java.util.ArrayList)14 NetworkedNode (org.jumpmind.symmetric.model.NetworkedNode)14 NodeChannel (org.jumpmind.symmetric.model.NodeChannel)14 NodeSecurity (org.jumpmind.symmetric.model.NodeSecurity)13 ProcessInfoKey (org.jumpmind.symmetric.model.ProcessInfoKey)13 Table (org.jumpmind.db.model.Table)12 Data (org.jumpmind.symmetric.model.Data)12 Router (org.jumpmind.symmetric.model.Router)12 Date (java.util.Date)11 NodeGroupLink (org.jumpmind.symmetric.model.NodeGroupLink)11 IOException (java.io.IOException)10 DataMetaData (org.jumpmind.symmetric.model.DataMetaData)10 HashMap (java.util.HashMap)9 OutgoingBatch (org.jumpmind.symmetric.model.OutgoingBatch)9 ISqlTransaction (org.jumpmind.db.sql.ISqlTransaction)8