Search in sources :

Example 16 with CoordinatorClient

use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.

the class SchedulerConfig method persistBackupUploadStatus.

/**
 * Persist upload status to ZK
 */
public void persistBackupUploadStatus(BackupUploadStatus status) {
    Map<String, String> allItems = (status != null) ? status.getAllItems() : null;
    if (allItems == null || allItems.size() == 0) {
        return;
    }
    ConfigurationImpl config = new ConfigurationImpl();
    config.setKind(BackupConstants.BACKUP_UPLOAD_STATUS);
    config.setId(Constants.GLOBAL_ID);
    log.info("Setting upload status: {}", status);
    for (Map.Entry<String, String> entry : allItems.entrySet()) {
        config.setConfig(entry.getKey(), entry.getValue());
    }
    CoordinatorClient coordinatorClient = coordinator.getCoordinatorClient();
    coordinatorClient.persistServiceConfiguration(coordinatorClient.getSiteId(), config);
    log.info("Persist backup upload status to zk successfully");
}
Also used : CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl) TypeMap(com.emc.storageos.db.client.impl.TypeMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 17 with CoordinatorClient

use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.

the class SchedulerConfig method isClusterUpgrading.

private boolean isClusterUpgrading() {
    try {
        RepositoryInfo target = coordinator.getTargetInfo(RepositoryInfo.class);
        SoftwareVersion targetVersion = target.getCurrentVersion();
        SoftwareVersion currentVersion = new LocalRepository().getRepositoryInfo().getCurrentVersion();
        log.info("The current version={} target version={}", currentVersion, targetVersion);
        if (!currentVersion.equals(targetVersion)) {
            log.info("The current version is NOT equals to target version");
            return true;
        }
    } catch (Exception e) {
        log.error("Failed to get versions e=", e);
        // failed to read data from zk, so no need to do backup at this time
        return true;
    }
    CoordinatorClient coordinatorClient = coordinator.getCoordinatorClient();
    String currentDbSchemaVersion = coordinatorClient.getCurrentDbSchemaVersion();
    String targetDbSchemaVersion = coordinatorClient.getTargetDbSchemaVersion();
    log.info("Current db schema version: {}, target db schema version: {}.", currentDbSchemaVersion, targetDbSchemaVersion);
    if (currentDbSchemaVersion == null || !currentDbSchemaVersion.equalsIgnoreCase(targetDbSchemaVersion)) {
        log.warn("Current version is not equal to the target version");
        return true;
    }
    ClusterState state = coordinatorClient.getControlNodesState();
    log.info("Current control nodes' state: {}", state);
    if (state == ClusterState.STABLE || state == ClusterState.SYNCING || state == ClusterState.DEGRADED) {
        return false;
    }
    return true;
}
Also used : ClusterState(com.emc.vipr.model.sys.ClusterInfo.ClusterState) SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo) LocalRepository(com.emc.storageos.systemservices.impl.upgrade.LocalRepository) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient)

Example 18 with CoordinatorClient

use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.

the class SchedulerConfig method persist.

public void persist() {
    CoordinatorClient coordinatorClient = coordinator.getCoordinatorClient();
    ConfigurationImpl cfg = new ConfigurationImpl();
    cfg.setKind(Constants.BACKUP_SCHEDULER_CONFIG);
    cfg.setId(Constants.GLOBAL_ID);
    cfg.setConfig(BackupConstants.BACKUP_TAGS_RETAINED, StringUtils.join(this.retainedBackups, ','));
    cfg.setConfig(BackupConstants.BACKUP_TAGS_UPLOADED, StringUtils.join(this.uploadedBackups, ','));
    coordinatorClient.persistServiceConfiguration(coordinatorClient.getSiteId(), cfg);
}
Also used : CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl)

Example 19 with CoordinatorClient

use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.

the class SchedulerConfig method isClusterNodeRecovering.

private boolean isClusterNodeRecovering() {
    RecoveryStatus.Status status = null;
    CoordinatorClient coordinatorClient = coordinator.getCoordinatorClient();
    Configuration cfg = coordinatorClient.queryConfiguration(Constants.NODE_RECOVERY_STATUS, Constants.GLOBAL_ID);
    if (cfg != null) {
        String statusStr = cfg.getConfig(RecoveryConstants.RECOVERY_STATUS);
        if (statusStr != null && statusStr.length() > 0) {
            status = RecoveryStatus.Status.valueOf(statusStr);
        }
    }
    log.info("Recovery status is: {}", status);
    if (status == RecoveryStatus.Status.INIT || status == RecoveryStatus.Status.PREPARING || status == RecoveryStatus.Status.REPAIRING || status == RecoveryStatus.Status.SYNCING) {
        return true;
    }
    return false;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) RecoveryStatus(com.emc.vipr.model.sys.recovery.RecoveryStatus)

Example 20 with CoordinatorClient

use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.

the class DistributedKeyStoreImpl method init.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.security.keystore.DistributedKeyStore#init(java.security.KeyStore.LoadStoreParameter)
     */
@Override
public void init(LoadStoreParameter param) throws SecurityException {
    if (param instanceof DistributedLoadKeyStoreParam) {
        DistributedLoadKeyStoreParam zkConnectionInfo = (DistributedLoadKeyStoreParam) param;
        CoordinatorClient coordinator = zkConnectionInfo.getCoordinator();
        coordConfigStoringHelper = new CoordinatorConfigStoringHelper(coordinator);
        generator = new KeyCertificatePairGenerator();
        generator.setKeyCertificateAlgorithmValuesHolder(new KeyCertificateAlgorithmValuesHolder(coordinator));
    } else {
        throw SecurityException.fatals.failedToInitializedKeystoreNeedDistKeystoreParams();
    }
}
Also used : CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient)

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