use of com.emc.storageos.coordinator.common.Configuration in project coprhd-controller by CoprHD.
the class BackupOps method getCurrentBackupInfo.
private Map<String, String> getCurrentBackupInfo() {
Configuration cfg = coordinatorClient.queryConfiguration(coordinatorClient.getSiteId(), BackupConstants.PULL_RESTORE_STATUS, Constants.GLOBAL_ID);
Map<String, String> allItems = (cfg == null) ? new HashMap<String, String>() : cfg.getAllConfigs(false);
// The map should has only 4 entries: _kind, _id, backupname and isLocal
if (!allItems.isEmpty() && allItems.size() != 4) {
log.error("Invalid current backup info from zk: {}", allItems);
throw new RuntimeException("invalid current backup info from zk");
}
return allItems;
}
use of com.emc.storageos.coordinator.common.Configuration in project coprhd-controller by CoprHD.
the class LoggingMBean method init.
/**
* If there has been a dynamic log level change, pick up and reuse the log level from
* coordinator service.
*/
public void init() {
_log.trace("Entered init()");
if (_isInitDelayed) {
_log.info("Scheduling the initialization in {} seconds.", _initDelayInSeconds);
Executors.newSingleThreadScheduledExecutor().schedule(new Runnable() {
@Override
public void run() {
_log.info("Starting coordinator client");
try {
_coordinator.start();
} catch (IOException e) {
_log.error("failed to start coordinator client:", e);
return;
}
init();
}
}, _initDelayInSeconds, TimeUnit.SECONDS);
_isInitDelayed = false;
return;
}
_log.debug("Starting the log level resetter thread");
Thread thread = new Thread(_resetterRunnable);
thread.setName("LogLevelResetter");
thread.start();
_log.debug("Initializing logger for {}", _logName);
Configuration config = getLogLevelConfig();
if (config == null) {
_log.info("No previous dynamic log change for {} found in ZK", _logName);
return;
}
LogLevelConfig logLevelConfig = parseLogLevelConfig(config);
if (logLevelConfig.expiration.before(Calendar.getInstance())) {
_log.info("config should have expired at {}, now is {}", logLevelConfig.expiration.getTime(), Calendar.getInstance().getTime());
} else {
_log.info("Setting log level for {} to level {} and scope {} according to previous change", new Object[] { _logName, logLevelConfig.level, logLevelConfig.scope });
setLoggerLevelByScope(logLevelConfig.level, getLogScope(logLevelConfig.scope));
// Schedule the polling thread which reverts expired dynamic log level changes.
long nextRun = logLevelConfig.expiration.getTimeInMillis() - System.currentTimeMillis();
_log.info("Try to reset the log level in {} milliseconds", nextRun);
_resetterRunnable.snooze(nextRun);
}
}
Aggregations