Search in sources :

Example 16 with CoordinatorException

use of com.emc.storageos.coordinator.exceptions.CoordinatorException in project coprhd-controller by CoprHD.

the class APINotifier method notifyChangeToAuthsvc.

/**
 * Call the internode URI on all authSvc endpoints to reload
 */
public void notifyChangeToAuthsvc() {
    try {
        AuthSvcInternalApiClientIterator authSvcItr = new AuthSvcInternalApiClientIterator(_authSvcEndPointLocator, _coordinator);
        while (authSvcItr.hasNext()) {
            String endpoint = authSvcItr.peek().toString();
            _log.info("sending request to endpoint: " + endpoint);
            try {
                ClientResponse response = authSvcItr.post(_URI_AUTH_RELOAD, null);
                if (response.getStatus() != ClientResponse.Status.OK.getStatusCode()) {
                    _log.error("Failed to reload authN providers on endpoint {} response {}", endpoint, response.toString());
                }
            } catch (Exception e) {
                _log.error("Caught exception trying to reload an authsvc on {} continuing", endpoint, e);
            }
        }
    } catch (CoordinatorException e) {
        _log.error("Caught coordinator exception trying to find an authsvc endpoint", e);
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) AuthSvcInternalApiClientIterator(com.emc.storageos.security.authentication.AuthSvcInternalApiClientIterator) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException)

Example 17 with CoordinatorException

use of com.emc.storageos.coordinator.exceptions.CoordinatorException in project coprhd-controller by CoprHD.

the class VdcConfigHelper method updateDbSvcConfig.

public void updateDbSvcConfig(String svcName, String key, String value) {
    String kind = coordinator.getDbConfigPath(svcName);
    try {
        List<Configuration> configs = coordinator.queryAllConfiguration(coordinator.getSiteId(), kind);
        if (configs == null) {
            String errMsg = "No " + svcName + " config found in the current vdc";
            log.error(errMsg);
            throw new IllegalStateException(errMsg);
        }
        for (Configuration config : configs) {
            if (config.getId() == null) {
                // version Znodes, e.g., /config/dbconfig/1.1
                continue;
            }
            if (config.getId().equals(Constants.GLOBAL_ID)) {
                continue;
            }
            config.setConfig(key, value);
            coordinator.persistServiceConfiguration(coordinator.getSiteId(), config);
        }
    } catch (CoordinatorException e) {
        throw new IllegalStateException(e);
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException)

Example 18 with CoordinatorException

use of com.emc.storageos.coordinator.exceptions.CoordinatorException in project coprhd-controller by CoprHD.

the class ControllerLockingServiceImpl method acquirePersistentLock.

@Override
public boolean acquirePersistentLock(String lockName, String clientName, long seconds) {
    if (lockName == null || lockName.isEmpty()) {
        return false;
    }
    try {
        Throwable t = null;
        DistributedPersistentLock lock = null;
        boolean acquired = false;
        if (seconds >= 0) {
            log.info("Attempting to acquire lock: " + lockName + (seconds > 0 ? (" for a maximum of " + seconds + " seconds.") : ""));
            while (seconds-- >= 0 && !acquired) {
                try {
                    lock = _coordinator.getPersistentLock(lockName);
                    acquired = lock.acquireLock(clientName);
                } catch (CoordinatorException ce) {
                    t = ce;
                    Thread.sleep(1000);
                }
            }
        } else if (seconds == -1) {
            log.info("Attempting to acquire lock: " + lockName + " for as long as it takes.");
            while (true) {
                try {
                    lock = _coordinator.getPersistentLock(lockName);
                    acquired = lock.acquireLock(clientName);
                } catch (CoordinatorException ce) {
                    t = ce;
                    Thread.sleep(1000);
                }
            }
        } else {
            log.error("Invalid value for seconds to acquireLock");
            return false;
        }
        if (lock == null || !acquired) {
            if (t != null) {
                log.error(String.format("Acquisition of mutex lock: %s failed with Exception: ", lockName), t);
            } else {
                log.error(String.format("Acquisition of mutex lock: %s failed", lockName));
            }
            return false;
        }
        log.info("Acquired lock: " + lockName);
        return true;
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        return false;
    } catch (Exception e) {
        return false;
    }
}
Also used : DistributedPersistentLock(com.emc.storageos.coordinator.client.service.DistributedPersistentLock) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException)

Example 19 with CoordinatorException

use of com.emc.storageos.coordinator.exceptions.CoordinatorException in project coprhd-controller by CoprHD.

the class PasswordUtils method getUserPassword.

/**
 * get user's encpassword from system properties
 *
 * @param username
 * @return
 */
public String getUserPassword(String username) {
    PropertyInfo props = null;
    try {
        props = coordinator.getPropertyInfo();
    } catch (CoordinatorException e) {
        _log.error("Access local user properties failed", e);
        return null;
    }
    if (props == null) {
        _log.error("Access local user properties failed");
        return null;
    }
    String encpassword = props.getProperty("system_" + username + "_encpassword");
    if (StringUtils.isBlank(encpassword)) {
        _log.error("No password set for user {} ", username);
        return null;
    }
    return encpassword;
}
Also used : CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) PropertyInfo(com.emc.storageos.model.property.PropertyInfo)

Example 20 with CoordinatorException

use of com.emc.storageos.coordinator.exceptions.CoordinatorException in project coprhd-controller by CoprHD.

the class DisasterRecoveryService method precheckForSwitchover.

/*
     * Internal method to check whether failover from active to standby is allowed
     */
protected void precheckForSwitchover(String standbyUuid) {
    Site standby = null;
    if (drUtil.isStandby()) {
        throw APIException.badRequests.operationOnlyAllowedOnActiveSite();
    }
    try {
        standby = drUtil.getSiteFromLocalVdc(standbyUuid);
    } catch (CoordinatorException e) {
        throw APIException.internalServerErrors.switchoverPrecheckFailed(standby.getUuid(), "Standby uuid is not valid, can't find it");
    }
    if (standbyUuid.equals(drUtil.getActiveSite().getUuid())) {
        throw APIException.internalServerErrors.switchoverPrecheckFailed(standby.getName(), "Can't switchover to an active site");
    }
    if (!drUtil.isSiteUp(standbyUuid)) {
        throw APIException.internalServerErrors.switchoverPrecheckFailed(standby.getName(), "Standby site is not up");
    }
    if (standby.getState() != SiteState.STANDBY_SYNCED) {
        throw APIException.internalServerErrors.switchoverPrecheckFailed(standby.getName(), "Standby site is not fully synced");
    }
    List<Site> existingSites = drUtil.listSites();
    for (Site site : existingSites) {
        ClusterInfo.ClusterState state = coordinator.getControlNodesState(site.getUuid());
        if (state != ClusterInfo.ClusterState.STABLE) {
            log.info("Site {} is not stable {}", site.getUuid(), state);
            throw APIException.internalServerErrors.switchoverPrecheckFailed(standby.getName(), String.format("Site %s is not stable", site.getName()));
        }
    }
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)

Aggregations

CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)29 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)19 UnknownHostException (java.net.UnknownHostException)14 KeeperException (org.apache.zookeeper.KeeperException)13 PropertyInfoMapper.decodeFromString (com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString)12 IOException (java.io.IOException)12 Site (com.emc.storageos.coordinator.client.model.Site)6 Configuration (com.emc.storageos.coordinator.common.Configuration)6 EnsurePath (org.apache.curator.utils.EnsurePath)6 Service (com.emc.storageos.coordinator.common.Service)5 PropertyInfo (com.emc.storageos.model.property.PropertyInfo)3 ClusterInfo (com.emc.vipr.model.sys.ClusterInfo)3 ArrayList (java.util.ArrayList)3 CuratorTransaction (org.apache.curator.framework.api.transaction.CuratorTransaction)3 CuratorTransactionFinal (org.apache.curator.framework.api.transaction.CuratorTransactionFinal)3 CoordinatorClientImpl (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl)2 ZkPath (com.emc.storageos.coordinator.common.impl.ZkPath)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)2 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)2