use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.
the class BuildRestRequest method makeClient.
public static Client makeClient(final ClientConfig config, final CoordinatorClient coordinator, final String auth, final String protocol, final String user, final String password) throws Exception {
if (StringUtils.isEmpty(protocol)) {
throw InternalServerErrorException.internalServerErrors.customServiceExecutionFailed("Protocol not defined" + protocol);
}
if (!protocol.equals("https")) {
logger.error("Only Https is supported. Protocol:{} is not supported", protocol);
throw InternalServerErrorException.internalServerErrors.customServiceExecutionFailed("Protocol not supported" + protocol);
}
final SSLContext context = SSLContext.getInstance("SSL");
final ViPRX509TrustManager trustManager = new ViPRX509TrustManager(coordinator);
context.init(null, new TrustManager[] { trustManager }, null);
config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(null, context));
final Client client = Client.create(config);
if (auth.equals(CustomServicesConstants.AuthType.BASIC.name())) {
if (!(StringUtils.isEmpty(user) && StringUtils.isEmpty(password))) {
client.addFilter(new HTTPBasicAuthFilter(user, password));
} else {
logger.error("user:{} or password not defined", user);
throw InternalServerErrorException.internalServerErrors.customServiceExecutionFailed("User or password not defined");
}
}
return client;
}
use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.
the class DbMigrationCheckpointTest method verifyMigrationInterrupted.
/**
* Verify if migration checkpoint information is saved to ZK
*
* @param version target schema version for migration
*/
private void verifyMigrationInterrupted(String version) {
CoordinatorClient coordinator = getCoordinator();
Assert.assertEquals(MigrationStatus.RUNNING, coordinator.getMigrationStatus());
String checkpoint = getCheckpoint(version);
log.info("Current migration checkpoint: {}", checkpoint);
Assert.assertNotNull(checkpoint);
String failedCallbackName = com.emc.storageos.db.server.upgrade.util.callbacks2.Resource3NewFlagsInitializer.class.getSimpleName();
Assert.assertNotSame(failedCallbackName, checkpoint);
}
use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.
the class DbMigrationCheckpointTest method verifyMigrationFailed.
/**
* Verify if migration checkpoint information is saved to ZK
*
* @param version target schema version for migration
*/
private void verifyMigrationFailed(String version) {
CoordinatorClient coordinator = getCoordinator();
Assert.assertEquals(MigrationStatus.FAILED, coordinator.getMigrationStatus());
String checkpoint = getCheckpoint(version);
log.info("Current migration checkpoint: {}", checkpoint);
Assert.assertNotNull(checkpoint);
String failedCallbackName = com.emc.storageos.db.server.upgrade.util.callbacks2.Resource3NewFlagsInitializer.class.getSimpleName();
Assert.assertNotSame(failedCallbackName, checkpoint);
}
use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.
the class DbMigrationCheckpointTest method verifyMigrationDone.
/**
* Verify if migration checkpoint information is cleared after migration done
*
* @param version target schema version for migration
*/
private void verifyMigrationDone(String version) {
CoordinatorClient coordinator = getCoordinator();
Assert.assertEquals(MigrationStatus.DONE, coordinator.getMigrationStatus());
String checkpoint = getCheckpoint(version);
Assert.assertNull(checkpoint);
}
use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.
the class AbstractManager method isQuorumMaintained.
/**
* Check if node_count/2 + 1 dbsvc instances are active on other nodes in the cluster
* so that if the current node is powered off, a quorum will still be maintained.
*
* @return true if a quorum can be maintained, false otherwise
*/
protected boolean isQuorumMaintained() {
if (nodeCount == 1) {
log.info("There's no way to maintain quorum on single node deployments. Proceed anyway.");
return true;
}
int quorumNodeCnt = nodeCount / 2 + 1;
CoordinatorClient coordinatorClient = coordinator.getCoordinatorClient();
List<Service> allActiveDbsvcs = coordinatorClient.locateAllSvcsAllVers(Constants.DBSVC_NAME);
List<String> otherActiveDbsvcIds = new ArrayList<>();
String mySvcId = coordinator.getMySvcId();
String localDbSvcId = "db" + mySvcId.substring(mySvcId.lastIndexOf("-"));
for (Service activeDbsvc : allActiveDbsvcs) {
if (!localDbSvcId.equals(activeDbsvc.getId())) {
otherActiveDbsvcIds.add(activeDbsvc.getId());
}
}
log.info("List of active dbsvc instances on other nodes: {}, expect {} instances to maintain quorum", otherActiveDbsvcIds, quorumNodeCnt);
boolean isMaintained = otherActiveDbsvcIds.size() >= quorumNodeCnt;
if (!isMaintained) {
log.info("quorum would lost if reboot the current node. Retrying...");
}
return isMaintained;
}
Aggregations