Search in sources :

Example 1 with DbOfflineEventInfo

use of com.emc.storageos.coordinator.client.model.DbOfflineEventInfo in project coprhd-controller by CoprHD.

the class DbDowntimeTracker method updateTrackerInfo.

/**
 * Update db offline event info in ZK.
 */
private void updateTrackerInfo(Site site, String serviceName, List<String> activeNodes) {
    String siteId = site.getUuid();
    log.info("Querying db tracker info from zk");
    Configuration config = coordinator.getCoordinatorClient().queryConfiguration(siteId, Constants.DB_DOWNTIME_TRACKER_CONFIG, serviceName);
    DbOfflineEventInfo dbOfflineEventInfo = new DbOfflineEventInfo(config);
    log.debug("DbofflineEnventInfo is {}", dbOfflineEventInfo.getEventInfo());
    long currentTimeStamp = TimeUtils.getCurrentTime();
    Long lastUpdateTimestamp = dbOfflineEventInfo.getLastUpdateTimestamp();
    long interval = 0L;
    if (lastUpdateTimestamp != null) {
        interval = Math.min((currentTimeStamp - lastUpdateTimestamp), TRACKER_CHECK_INTERVAL);
    }
    if (interval != 0L && interval < NO_NEED_UPDATE_LIMIT) {
        log.info("Have already updated within a few minutes, skipping this update");
        return;
    }
    dbOfflineEventInfo.setLastUpdateTimestamp(currentTimeStamp);
    log.info(String.format("Db tracker last check time: %d, current check time: %d, site: %s", lastUpdateTimestamp, currentTimeStamp, siteId));
    int nodeCount = site.getNodeCount();
    for (int i = 1; i <= nodeCount; i++) {
        String nodeId = "vipr" + i;
        if (activeNodes.contains(nodeId)) {
            dbOfflineEventInfo.setLastActiveTimestamp(nodeId, currentTimeStamp);
            log.info(String.format("Service(%s) of node(%s) last active timestamp has been updated to %s", serviceName, nodeId, currentTimeStamp));
            if (dbOfflineEventInfo.getOfflineTimeInMS(nodeId) != null) {
                dbOfflineEventInfo.setOfflineTimeInMS(nodeId, null);
                dbOfflineEventInfo.setKeyOfflineAlertInDay(nodeId, null);
                log.info("Service({}) of node({}) is recovered", serviceName, nodeId);
            }
        } else {
            Long lastOfflineInMS = dbOfflineEventInfo.getOfflineTimeInMS(nodeId);
            lastOfflineInMS = (lastOfflineInMS == null) ? 0 : lastOfflineInMS;
            long newOfflineTime = lastOfflineInMS + interval;
            dbOfflineEventInfo.setOfflineTimeInMS(nodeId, newOfflineTime);
            alertStatusCheck(nodeId, serviceName, dbOfflineEventInfo, newOfflineTime / TimeUtils.DAYS);
            log.info(String.format("Service(%s) of node(%s) has been unavailable for %s mins", serviceName, nodeId, newOfflineTime / TimeUtils.MINUTES));
        }
    }
    config = dbOfflineEventInfo.toConfiguration(serviceName);
    coordinator.getCoordinatorClient().persistServiceConfiguration(siteId, config);
    log.info("Persist db tracker info to zk successfully");
}
Also used : DbOfflineEventInfo(com.emc.storageos.coordinator.client.model.DbOfflineEventInfo) Configuration(com.emc.storageos.coordinator.common.Configuration) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint)

Example 2 with DbOfflineEventInfo

use of com.emc.storageos.coordinator.client.model.DbOfflineEventInfo in project coprhd-controller by CoprHD.

the class DbInfoUtils method checkDBOfflineInfo.

/**
 * Check offline event info to see if dbsvc/geodbsvc on this node could get started
 */
public static void checkDBOfflineInfo(CoordinatorClient coordinator, String serviceName, String dbDir, boolean enableAlert) {
    DbOfflineEventInfo dbOfflineEventInfo = getDbOfflineEventInfo(coordinator, serviceName);
    String localNodeId = coordinator.getInetAddessLookupMap().getNodeId();
    Long lastActiveTimestamp = dbOfflineEventInfo.geLastActiveTimestamp(localNodeId);
    long zkTimeStamp = (lastActiveTimestamp == null) ? TimeUtils.getCurrentTime() : lastActiveTimestamp;
    File localDbDir = new File(dbDir);
    Date lastModified = FileUtils.getLastModified(localDbDir);
    boolean isDirEmpty = lastModified == null || localDbDir.list().length == 0;
    long localTimeStamp = (isDirEmpty) ? TimeUtils.getCurrentTime() : lastModified.getTime();
    _log.info("Service timestamp in ZK is {}, local file is: {}", zkTimeStamp, localTimeStamp);
    long diffTime = (zkTimeStamp > localTimeStamp) ? (zkTimeStamp - localTimeStamp) : 0;
    checkDiffTime(diffTime, enableAlert);
    Long offlineTime = dbOfflineEventInfo.getOfflineTimeInMS(localNodeId);
    checkOfflineTime(offlineTime, isDirEmpty, enableAlert);
}
Also used : DbOfflineEventInfo(com.emc.storageos.coordinator.client.model.DbOfflineEventInfo) File(java.io.File) Date(java.util.Date)

Aggregations

DbOfflineEventInfo (com.emc.storageos.coordinator.client.model.DbOfflineEventInfo)2 Configuration (com.emc.storageos.coordinator.common.Configuration)1 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 File (java.io.File)1 Date (java.util.Date)1