Search in sources :

Example 26 with CoordinatorClient

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;
}
Also used : SSLContext(javax.net.ssl.SSLContext) Client(com.sun.jersey.api.client.Client) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) ViPRX509TrustManager(com.emc.storageos.security.ssl.ViPRX509TrustManager) HTTPSProperties(com.sun.jersey.client.urlconnection.HTTPSProperties) HTTPBasicAuthFilter(com.sun.jersey.api.client.filter.HTTPBasicAuthFilter)

Example 27 with CoordinatorClient

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

Example 28 with CoordinatorClient

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

Example 29 with CoordinatorClient

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

Example 30 with CoordinatorClient

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;
}
Also used : ArrayList(java.util.ArrayList) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) Service(com.emc.storageos.coordinator.common.Service)

Aggregations

CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)49 Test (org.junit.Test)11 Base64TokenEncoder (com.emc.storageos.security.authentication.Base64TokenEncoder)8 TokenKeyGenerator (com.emc.storageos.security.authentication.TokenKeyGenerator)8 TokenMaxLifeValuesHolder (com.emc.storageos.security.authentication.TokenMaxLifeValuesHolder)8 Configuration (com.emc.storageos.coordinator.common.Configuration)7 DbClient (com.emc.storageos.db.client.DbClient)7 CassandraTokenManager (com.emc.storageos.auth.impl.CassandraTokenManager)6 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)6 StorageOSUserDAO (com.emc.storageos.db.client.model.StorageOSUserDAO)6 TokenOnWire (com.emc.storageos.security.authentication.TokenOnWire)6 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)5 URI (java.net.URI)5 Service (com.emc.storageos.coordinator.common.Service)4 InterVDCTokenCacheHelper (com.emc.storageos.security.geo.InterVDCTokenCacheHelper)4 ArrayList (java.util.ArrayList)4 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)3 BaseToken (com.emc.storageos.db.client.model.BaseToken)3 ProxyToken (com.emc.storageos.db.client.model.ProxyToken)3 Token (com.emc.storageos.db.client.model.Token)3