Search in sources :

Example 6 with RepositoryInfo

use of com.emc.storageos.coordinator.client.model.RepositoryInfo in project coprhd-controller by CoprHD.

the class LocalRepository method getRepositoryInfo.

/**
 * @return RepositoryState
 * @throws InvalidRepositoryInfoException
 */
public RepositoryInfo getRepositoryInfo() throws LocalRepositoryException, InvalidRepositoryInfoException {
    final String prefix = "getRepositoryState(): ";
    _log.debug(prefix);
    final String[] cmd1 = { _SYSTOOL_CMD, _SYSTOOL_LIST };
    List<SoftwareVersion> versions = toSoftwareVersionList(prefix + _SYSTOOL_LIST, exec(prefix, cmd1));
    final String[] cmd2 = { _SYSTOOL_CMD, _SYSTOOL_GET_DEFAULT };
    final SoftwareVersion current = toSoftwareVersionList(prefix + _SYSTOOL_GET_DEFAULT, exec(prefix, cmd2)).get(0);
    _log.debug(prefix + "current={} versions={}", current, Strings.repr(versions));
    return new RepositoryInfo(current, versions);
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo)

Example 7 with RepositoryInfo

use of com.emc.storageos.coordinator.client.model.RepositoryInfo in project coprhd-controller by CoprHD.

the class SchedulerConfig method getSofttwareWithRetry.

private void getSofttwareWithRetry() throws Exception, InterruptedException {
    int retryTimes = 0;
    RepositoryInfo targetInfo = null;
    CoordinatorClient coordinatorClient = coordinator.getCoordinatorClient();
    while (retryTimes <= MAX_VERSION_RETRY_TIMES) {
        retryTimes++;
        targetInfo = coordinatorClient.getTargetInfo(RepositoryInfo.class);
        if (targetInfo == null) {
            log.info("can't get version, try {} seconds later", MAX_VERSION_RETRY_INTERVAL / 1000);
            Thread.sleep(MAX_VERSION_RETRY_INTERVAL);
            continue;
        }
        this.softwareVersion = targetInfo.getCurrentVersion().toString();
        log.info("Version: {}", softwareVersion);
        break;
    }
    if (targetInfo == null) {
        throw new Exception("Can't get version information from coordinator client");
    }
}
Also used : RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint)

Example 8 with RepositoryInfo

use of com.emc.storageos.coordinator.client.model.RepositoryInfo 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 9 with RepositoryInfo

use of com.emc.storageos.coordinator.client.model.RepositoryInfo in project coprhd-controller by CoprHD.

the class ClusterInfoMapper method toClusterInfo.

public static ClusterInfo toClusterInfo(final ClusterState controlNodesState, final Map<Service, RepositoryInfo> controlNodesInfo, final Map<Service, ConfigVersion> controlNodesConfigVersions, final RepositoryInfo targetRepository, final PropertyInfoExt targetProperty) {
    ClusterInfo toClusterInfo = new ClusterInfo();
    toClusterInfo.setCurrentState((controlNodesState != ClusterState.STABLE) ? controlNodesState.toString() : ClusterState.STABLE.toString());
    if (!controlNodesInfo.isEmpty()) {
        toClusterInfo.setControlNodes(new HashMap<String, NodeState>());
        for (Map.Entry<Service, RepositoryInfo> entry : controlNodesInfo.entrySet()) {
            addControlNodeInfo(toClusterInfo, entry.getKey().getNodeId(), entry.getValue(), controlNodesConfigVersions != null ? controlNodesConfigVersions.get(entry.getKey()) : null);
        }
    }
    if (targetRepository != null) {
        addTargetInfo(toClusterInfo, targetRepository, targetProperty);
    }
    return toClusterInfo;
}
Also used : ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) NodeState(com.emc.vipr.model.sys.ClusterInfo.NodeState) RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo) Service(com.emc.storageos.coordinator.common.Service) HashMap(java.util.HashMap) Map(java.util.Map)

Example 10 with RepositoryInfo

use of com.emc.storageos.coordinator.client.model.RepositoryInfo in project coprhd-controller by CoprHD.

the class UpgradeCoordinatorClientTest method testNodeIdentifier.

@Test
public void testNodeIdentifier() {
    List<String> nodelist = _coordinator.getAllNodes();
    System.out.println("Number of Nodes found " + nodelist.size());
    Iterator<String> nodeIter = nodelist.iterator();
    while (nodeIter.hasNext()) {
        String currentnode = nodeIter.next();
        System.out.println("Node ID " + currentnode);
        try {
            RepositoryInfo info = _coordinator.getRepositoryInfo(currentnode);
        } catch (CoordinatorClientException e) {
            System.out.println("Version List is null");
        }
    }
}
Also used : RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException) Test(org.junit.Test)

Aggregations

RepositoryInfo (com.emc.storageos.coordinator.client.model.RepositoryInfo)17 SoftwareVersion (com.emc.storageos.coordinator.client.model.SoftwareVersion)10 CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)6 ClusterInfo (com.emc.vipr.model.sys.ClusterInfo)6 IOException (java.io.IOException)6 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)5 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)5 Service (com.emc.storageos.coordinator.common.Service)4 InvalidSoftwareVersionException (com.emc.storageos.coordinator.exceptions.InvalidSoftwareVersionException)4 ServiceUnavailableException (com.emc.storageos.svcs.errorhandling.resources.ServiceUnavailableException)4 LocalRepositoryException (com.emc.storageos.systemservices.exceptions.LocalRepositoryException)4 RemoteRepositoryException (com.emc.storageos.systemservices.exceptions.RemoteRepositoryException)4 CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)3 ArrayList (java.util.ArrayList)3 Path (javax.ws.rs.Path)3 Test (org.junit.Test)3 ConfigVersion (com.emc.storageos.coordinator.client.model.ConfigVersion)2 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)2 PropertyInfoRestRep (com.emc.storageos.model.property.PropertyInfoRestRep)2 LocalRepository (com.emc.storageos.systemservices.impl.upgrade.LocalRepository)2