Example usage for java.lang String compare

List of usage examples for java.lang String compare

Introduction

In this page you can find the example usage for java.lang String compare.

Prototype

@SuppressWarnings("unchecked")
public static int compare(CharSequence cs1, CharSequence cs2) 

Source Link

Document

Compares two CharSequence instances lexicographically.

Usage

From source file:com.cloud.maint.UpgradeManagerImpl.java

@Override
public State registerForUpgrade(long hostId, String version) {
    State state = State.UpToDate;
    s_logger.debug("Minimal version is " + _minimalVersion + "; version is " + version
            + "; recommended version is " + _recommendedVersion);
    if (Version.compare(version, _minimalVersion) < 0) {
        state = State.RequiresUpdate;
    } else if (Version.compare(version, _recommendedVersion) < 0) {
        state = State.WaitingForUpdate;
    } else {//from w  ww.j a  v  a  2s. co  m
        state = State.UpToDate;
    }

    /*
    if (state != State.UpToDate) {
    AgentUpgradeVO vo = _upgradeDao.findById(hostId);
    if (vo == null) {
        vo = new AgentUpgradeVO(hostId, version, state);
        _upgradeDao.persist(vo);
    }
    }
    */

    return state;
}

From source file:com.vmware.bdd.manager.ClusterManager.java

private String getClusterCloneType() {
    String type = Configuration.getString("cluster.clone.service");
    if (StringUtils.isBlank(type)) {
        String version = "";
        VcContext.initVcContext();//from w w  w .  ja v a  2 s .  c  o  m
        version = VcContext.getVcVersion();
        if (!CommonUtil.isBlank(version)) {
            if (Version.compare(version, Constants.VCENTER_VERSION_6) < 0) {
                type = Constants.CLUSTER_CLONE_TYPE_FAST_CLONE;
            } else {
                logger.info(
                        "The VCenter version is equal or higher than 6.0. Set cluster clone type to instant.");
                type = Constants.CLUSTER_CLONE_TYPE_INSTANT_CLONE;
            }
        }
    }
    return type;
}

From source file:com.vmware.bdd.service.impl.ClusteringService.java

private void checkAndUpdateClusterCloneType(ClusterCreate clusterSpec, Container container) {
    String clusterName = clusterSpec.getName();
    String type = Configuration.getString("cluster.clone.service");
    if (StringUtils.isBlank(type)) {
        // check if there are any ESXi hosts with version lower than 6.0
        boolean isLowVersion = false;
        for (AbstractHost host : container.getAllHosts()) {
            String hostName = host.getName();
            final VcHost vchost = VcResourceUtils.findHost(hostName);
            AuAssert.check(vchost != null, String.format("can' find host: %1s in VC.", hostName));
            String version = vchost.getVersion();
            if (Version.compare(version, Constants.VCENTER_VERSION_6) < 0) {
                logger.info("Some ESXi host version is lower than 6.0.");
                isLowVersion = true;/* ww w.  ja  v  a 2 s  . c o  m*/
                break;
            }
        }

        // if some ESXi host version is lower than 6.0, update the cluster clone type to FAST
        if (isLowVersion) {
            ClusterEntity cluster = clusterEntityMgr.findByName(clusterName);
            String advProps = cluster.getAdvancedProperties();
            if (!CommonUtil.isBlank(advProps)) {
                Gson gson = new Gson();
                Map<String, String> advancedProperties = gson.fromJson(advProps, Map.class);
                String cloneType = advancedProperties.get("ClusterCloneType");
                if (!StringUtils.isBlank(cloneType)
                        && cloneType.equals(Constants.CLUSTER_CLONE_TYPE_INSTANT_CLONE)) {
                    cloneType = Constants.CLUSTER_CLONE_TYPE_FAST_CLONE;
                    advancedProperties.put("ClusterCloneType", cloneType);
                    cluster.setAdvancedProperties(gson.toJson(advancedProperties));
                    logger.info(
                            "Change cluster clone type to fast clone because of ESXi version lower than 6.0.");
                    clusterEntityMgr.update(cluster);
                    clusterSpec.setClusterCloneType(cloneType);
                }
            }
        }
    }
}