Search in sources :

Example 86 with Configuration

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;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration)

Example 87 with Configuration

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);
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) IOException(java.io.IOException)

Aggregations

Configuration (com.emc.storageos.coordinator.common.Configuration)87 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)16 InterProcessLock (org.apache.curator.framework.recipes.locks.InterProcessLock)11 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)9 IOException (java.io.IOException)9 CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)8 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)8 Site (com.emc.storageos.coordinator.client.model.Site)7 UnknownHostException (java.net.UnknownHostException)7 KeeperException (org.apache.zookeeper.KeeperException)7 PropertyInfoMapper.decodeFromString (com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString)6 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 Test (org.junit.Test)6 Matchers.anyString (org.mockito.Matchers.anyString)3 MigrationStatus (com.emc.storageos.coordinator.client.model.MigrationStatus)2 PropertyInfoExt (com.emc.storageos.coordinator.client.model.PropertyInfoExt)2 DrUtil (com.emc.storageos.coordinator.client.service.DrUtil)2 CoordinatorClientInetAddressMap (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)2 SiteConfigRestRep (com.emc.storageos.model.dr.SiteConfigRestRep)2