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);
}
}
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);
}
}
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;
}
}
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;
}
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()));
}
}
}
Aggregations