Search in sources :

Example 1 with VersionComparator

use of com.sequenceiq.cloudbreak.util.VersionComparator in project cloudbreak by hortonworks.

the class StackImageUpdateService method isCbVersionOk.

public boolean isCbVersionOk(Stack stack) {
    CloudbreakDetails cloudbreakDetails = componentConfigProviderService.getCloudbreakDetails(stack.getId());
    VersionComparator versionComparator = new VersionComparator();
    String version = StringUtils.substringBefore(cloudbreakDetails.getVersion(), "-");
    int compare = versionComparator.compare(() -> version, () -> MIN_VERSION);
    return compare >= 0;
}
Also used : CloudbreakDetails(com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails) VersionComparator(com.sequenceiq.cloudbreak.util.VersionComparator)

Example 2 with VersionComparator

use of com.sequenceiq.cloudbreak.util.VersionComparator in project cloudbreak by hortonworks.

the class StackStopRestrictionService method isCbVersionBeforeMinVersion.

private boolean isCbVersionBeforeMinVersion(String cbVersion, String minVersion) {
    VersionComparator versionComparator = new VersionComparator();
    String version = StringUtils.substringBefore(cbVersion, "-");
    int compare = versionComparator.compare(() -> version, () -> minVersion);
    return compare < 0;
}
Also used : VersionComparator(com.sequenceiq.cloudbreak.util.VersionComparator)

Example 3 with VersionComparator

use of com.sequenceiq.cloudbreak.util.VersionComparator in project cloudbreak by hortonworks.

the class MountDisks method isCbVersionPostOptimisation.

private boolean isCbVersionPostOptimisation(Stack stack) {
    CloudbreakDetails cloudbreakDetails = componentConfigProviderService.getCloudbreakDetails(stack.getId());
    VersionComparator versionComparator = new VersionComparator();
    String version = substringBefore(cloudbreakDetails.getVersion(), "-");
    int compare = versionComparator.compare(() -> version, () -> MIN_VERSION);
    return compare >= 0;
}
Also used : CloudbreakDetails(com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails) VersionComparator(com.sequenceiq.cloudbreak.util.VersionComparator)

Example 4 with VersionComparator

use of com.sequenceiq.cloudbreak.util.VersionComparator in project cloudbreak by hortonworks.

the class ComponentVersionComparator method permitCmAndStackUpgradeByComponentVersion.

boolean permitCmAndStackUpgradeByComponentVersion(String currentVersion, String newVersion) {
    boolean result = false;
    if (currentVersion != null && newVersion != null) {
        VersionPrefix prefixMatcher = new VersionPrefix();
        if (prefixMatcher.prefixMatch(() -> currentVersion, () -> newVersion, MAJOR)) {
            VersionComparator comparator = new VersionComparator();
            result = comparator.compare(() -> currentVersion, () -> newVersion) < 0;
        }
    }
    return result;
}
Also used : VersionPrefix(com.sequenceiq.cloudbreak.cloud.VersionPrefix) VersionComparator(com.sequenceiq.cloudbreak.util.VersionComparator)

Example 5 with VersionComparator

use of com.sequenceiq.cloudbreak.util.VersionComparator in project cloudbreak by hortonworks.

the class MixedPackageVersionComparator method getComponentsWithNewerVersionThanTheTarget.

public Map<String, String> getComponentsWithNewerVersionThanTheTarget(Map<String, String> targetProducts, String targetCmVersion, Set<ParcelInfo> activeParcels, String activeCmVersion) {
    VersionComparator versionComparator = new VersionComparator();
    Map<String, String> componentsWithNewerVersion = activeParcels.stream().filter(parcelInfo -> compareParcelVersions(parcelInfo, targetProducts, versionComparator)).collect(Collectors.toMap(ParcelInfo::getName, ParcelInfo::getVersion));
    if (versionComparator.compare(() -> activeCmVersion, () -> targetCmVersion) > 0) {
        componentsWithNewerVersion.put(CM.getDisplayName(), activeCmVersion);
    }
    return componentsWithNewerVersion;
}
Also used : ParcelInfo(com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo) Service(org.springframework.stereotype.Service) CollectionUtils(org.springframework.util.CollectionUtils) Map(java.util.Map) Optional(java.util.Optional) Set(java.util.Set) VersionComparator(com.sequenceiq.cloudbreak.util.VersionComparator) Collectors(java.util.stream.Collectors) CM(com.sequenceiq.cloudbreak.cloud.model.catalog.ImagePackageVersion.CM) VersionComparator(com.sequenceiq.cloudbreak.util.VersionComparator)

Aggregations

VersionComparator (com.sequenceiq.cloudbreak.util.VersionComparator)7 CloudbreakDetails (com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails)2 Versioned (com.sequenceiq.cloudbreak.common.type.Versioned)2 CloudStorageSupportedV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.CloudStorageSupportedV4Response)1 VersionPrefix (com.sequenceiq.cloudbreak.cloud.VersionPrefix)1 Image (com.sequenceiq.cloudbreak.cloud.model.Image)1 CM (com.sequenceiq.cloudbreak.cloud.model.catalog.ImagePackageVersion.CM)1 ParcelInfo (com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Service (org.springframework.stereotype.Service)1 CollectionUtils (org.springframework.util.CollectionUtils)1