Search in sources :

Example 6 with Version

use of com.github.zafarkhaja.semver.Version in project grafikon by jub77.

the class MainFrame method getInfoText.

private String getInfoText(String txt) {
    log.debug(txt);
    Version version = model.getVersionInfo().getVersionWithoutBuild();
    return String.format("%s%n%s", version.toString(), txt);
}
Also used : Version(com.github.zafarkhaja.semver.Version)

Example 7 with Version

use of com.github.zafarkhaja.semver.Version in project steve by RWTH-i5-IDSG.

the class GithubReleaseCheckService method getReport.

// -------------------------------------------------------------------------
// Private helpers
// -------------------------------------------------------------------------
private static ReleaseReport getReport(ReleaseResponse response) {
    String githubVersion = extractVersion(response);
    Version build = Version.valueOf(SteveConfiguration.CONFIG.getSteveVersion());
    Version github = Version.valueOf(githubVersion);
    boolean isGithubMoreRecent = github.greaterThan(build);
    String downloadUrl = decideDownloadUrl(response);
    ReleaseReport ur = new ReleaseReport(isGithubMoreRecent);
    ur.setGithubVersion(githubVersion);
    ur.setDownloadUrl(downloadUrl);
    ur.setHtmlUrl(response.getHtmlUrl());
    return ur;
}
Also used : ReleaseReport(de.rwth.idsg.steve.web.dto.ReleaseReport) Version(com.github.zafarkhaja.semver.Version)

Example 8 with Version

use of com.github.zafarkhaja.semver.Version in project incubator-pulsar by apache.

the class BrokerVersionFilter method filter.

/**
 * From the given set of available broker candidates, filter those using the version numbers.
 *
 * @param brokers
 *            The currently available brokers that have not already been filtered.
 * @param bundleToAssign
 *            The data for the bundle to assign.
 * @param loadData
 *            The load data from the leader broker.
 * @param conf
 *            The service configuration.
 */
public void filter(Set<String> brokers, BundleData bundleToAssign, LoadData loadData, ServiceConfiguration conf) throws BrokerFilterBadVersionException {
    if (!conf.isPreferLaterVersions()) {
        return;
    }
    com.github.zafarkhaja.semver.Version latestVersion = null;
    try {
        latestVersion = getLatestVersionNumber(brokers, loadData);
        LOG.info("Latest broker version found was [{}]", latestVersion);
    } catch (Exception x) {
        LOG.warn("Disabling PreferLaterVersions feature; reason: " + x.getMessage());
        throw new BrokerFilterBadVersionException("Cannot determine newest broker version: " + x.getMessage());
    }
    int numBrokersLatestVersion = 0;
    int numBrokersOlderVersion = 0;
    Iterator<String> brokerIterator = brokers.iterator();
    while (brokerIterator.hasNext()) {
        String broker = brokerIterator.next();
        BrokerData data = loadData.getBrokerData().get(broker);
        String brokerVersion = data.getLocalData().getBrokerVersionString();
        com.github.zafarkhaja.semver.Version brokerVersionVersion = Version.valueOf(brokerVersion);
        if (brokerVersionVersion.equals(latestVersion)) {
            LOG.debug("Broker [{}] is running the latest version ([{}])", broker, brokerVersion);
            ++numBrokersLatestVersion;
        } else {
            LOG.info("Broker [{}] is running an older version ([{}]); latest version is [{}]", broker, brokerVersion, latestVersion);
            ++numBrokersOlderVersion;
            brokerIterator.remove();
        }
    }
    if (numBrokersOlderVersion == 0) {
        LOG.info("All {} brokers are running the latest version [{}]", numBrokersLatestVersion, latestVersion);
    }
}
Also used : Version(com.github.zafarkhaja.semver.Version) BrokerFilterBadVersionException(org.apache.pulsar.broker.loadbalance.BrokerFilterBadVersionException) BrokerData(org.apache.pulsar.broker.BrokerData) BrokerFilterBadVersionException(org.apache.pulsar.broker.loadbalance.BrokerFilterBadVersionException) ManagedLedgerException(org.apache.bookkeeper.mledger.ManagedLedgerException)

Example 9 with Version

use of com.github.zafarkhaja.semver.Version in project incubator-pulsar by apache.

the class BrokerVersionFilterTest method testLatestVersion.

@Test
public void testLatestVersion() {
    LoadData loadData = initLoadData();
    Set<String> brokers = new TreeSet<>();
    brokers.add("broker1");
    brokers.add("broker2");
    brokers.add("broker3");
    BrokerVersionFilter filter = new BrokerVersionFilter();
    try {
        Version latestVersion = filter.getLatestVersionNumber(brokers, loadData);
        Assert.assertEquals(latestVersion.getMajorVersion(), 1);
        Assert.assertEquals(latestVersion.getMinorVersion(), 2);
        Assert.assertEquals(latestVersion.getPatchVersion(), 0);
    } catch (BrokerFilterBadVersionException bad) {
        Assert.fail(bad.getMessage(), bad);
    }
    ServiceConfiguration configuration = new ServiceConfiguration();
    configuration.setPreferLaterVersions(true);
    try {
        filter.filter(brokers, null, loadData, configuration);
        // Only one broker is running the latest version
        Assert.assertEquals(brokers.size(), 1);
    } catch (BrokerFilterBadVersionException bad) {
        Assert.fail(bad.getMessage(), bad);
    }
}
Also used : BrokerFilterBadVersionException(org.apache.pulsar.broker.loadbalance.BrokerFilterBadVersionException) BrokerVersionFilter(org.apache.pulsar.broker.loadbalance.impl.BrokerVersionFilter) LoadData(org.apache.pulsar.broker.loadbalance.LoadData) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) Version(com.github.zafarkhaja.semver.Version) TreeSet(java.util.TreeSet) Test(org.testng.annotations.Test)

Example 10 with Version

use of com.github.zafarkhaja.semver.Version in project cf-java-client by cloudfoundry.

the class InfoTest method info.

@Test
public void info() {
    this.cloudFoundryClient.info().get(GetInfoRequest.builder().build()).as(StepVerifier::create).consumeNextWith(response -> {
        Version expected = Version.valueOf(SUPPORTED_API_VERSION);
        Version actual = Version.valueOf(response.getApiVersion());
        assertThat(actual).isLessThanOrEqualTo(expected);
    }).expectComplete().verify(Duration.ofMinutes(5));
}
Also used : Version(com.github.zafarkhaja.semver.Version) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

Version (com.github.zafarkhaja.semver.Version)27 Test (org.junit.Test)6 File (java.io.File)4 IOException (java.io.IOException)4 BrokerFilterBadVersionException (org.apache.pulsar.broker.loadbalance.BrokerFilterBadVersionException)3 JsonWriter (com.serotonin.json.JsonWriter)2 JsonObject (com.serotonin.json.type.JsonObject)2 JsonString (com.serotonin.json.type.JsonString)2 JsonTypeReader (com.serotonin.json.type.JsonTypeReader)2 StringWriter (java.io.StringWriter)2 HashMap (java.util.HashMap)2 TreeMap (java.util.TreeMap)2 ManagedLedgerException (org.apache.bookkeeper.mledger.ManagedLedgerException)2 HttpPost (org.apache.http.client.methods.HttpPost)2 StringEntity (org.apache.http.entity.StringEntity)2 BrokerData (org.apache.pulsar.broker.BrokerData)2 Plugin (org.syncany.plugins.Plugin)2 UpgradeServerVersion (org.talend.dataprep.api.service.upgrade.UpgradeServerVersion)2 NonNull (android.support.annotation.NonNull)1 MongoCluster (com.antwerkz.bottlerocket.clusters.MongoCluster)1