public void refresh() { this.hostName = AppUtils.getHostName(); setIpAddress(AppUtils.getIpAddress()); this.osUser = System.getProperty("user.name"); this.osName = System.getProperty("os.name"); this.osArch = System.getProperty("os.arch"); this.osVersion = System.getProperty("os.version"); this.availableProcessors = Runtime.getRuntime().availableProcessors(); this.freeMemoryBytes = Runtime.getRuntime().freeMemory(); this.totalMemoryBytes = Runtime.getRuntime().totalMemory(); this.maxMemoryBytes = Runtime.getRuntime().maxMemory(); this.javaVersion = System.getProperty("java.version"); this.javaVendor = System.getProperty("java.vendor"); this.symmetricVersion = Version.version(); this.timezoneOffset = AppUtils.getTimezoneOffset(); Calendar cal = Calendar.getInstance(); cal.set(Calendar.MILLISECOND, 0); this.heartbeatTime = cal.getTime(); }
/** * If {@link NodeGroupChannelWindow}s are defined for this channel, then * check to see if the time (according to the offset passed in) is within on * of the configured windows. */ public boolean inTimeWindow(List<NodeGroupChannelWindow> windows, String targetNodeId) { if (windows != null && windows.size() > 0) { for (NodeGroupChannelWindow window : windows) { String timezoneOffset = null; List<NodeHost> hosts = nodeService.findNodeHosts(targetNodeId); if (hosts.size() > 0) { timezoneOffset = hosts.get(0).getTimezoneOffset(); } else { timezoneOffset = AppUtils.getTimezoneOffset(); } if (window.inTimeWindow(timezoneOffset)) { return true; } } return false; } else { return true; } }
public boolean updateNode(Node node) { boolean updated = sqlTemplate.update( getSql("updateNodeSql"), new Object[] { node.getNodeGroupId(), node.getExternalId(), node.getDatabaseType(), node.getDatabaseVersion(), node.getSchemaVersion(), node.getSymmetricVersion(), node.getSyncUrl(), new Date(), node.isSyncEnabled() ? 1 : 0, AppUtils.getTimezoneOffset(), node.getBatchToSendCount(), node.getBatchInErrorCount(), node.getCreatedAtNodeId(), node.getDeploymentType(), node.getNodeId() }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP, Types.INTEGER, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR }) == 1; return updated; }
public void save(Node node) { if (!updateNode(node)) { sqlTemplate.update( getSql("insertNodeSql"), new Object[] { node.getNodeGroupId(), node.getExternalId(), node.getDatabaseType(), node.getDatabaseVersion(), node.getSchemaVersion(), node.getSymmetricVersion(), node.getSyncUrl(), new Date(), node.isSyncEnabled() ? 1 : 0, AppUtils.getTimezoneOffset(), node.getBatchToSendCount(), node.getBatchInErrorCount(), node.getCreatedAtNodeId(), node.getDeploymentType(), node.getNodeId() }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP, Types.INTEGER, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR }); } }
objectValue = String.format("%s %s", FormatUtils.TIMESTAMP_FORMATTER.format(randomDate()), AppUtils.getTimezoneOffset()); } else if (type == Types.DATE) { objectValue = DateUtils.truncate(randomDate(), Calendar.DATE);