Search in sources :

Example 1 with OrderableSlsVersion

use of com.palantir.sls.versions.OrderableSlsVersion in project palantir-java-format by palantir.

the class PalantirJavaFormatSettings method injectedVersionIsOutdated.

boolean injectedVersionIsOutdated() {
    Optional<String> formatterVersion = computeFormatterVersion();
    Optional<OrderableSlsVersion> implementationVersion = OrderableSlsVersion.safeValueOf(getImplementationVersion().map(v -> v.replace(".dirty", "")).orElse(""));
    if (formatterVersion.isEmpty() || implementationVersion.isEmpty()) {
        return true;
    }
    OrderableSlsVersion injectedVersion = OrderableSlsVersion.valueOf(formatterVersion.get());
    return injectedVersion.compareTo(implementationVersion.get()) < 0;
}
Also used : OrderableSlsVersion(com.palantir.sls.versions.OrderableSlsVersion)

Example 2 with OrderableSlsVersion

use of com.palantir.sls.versions.OrderableSlsVersion in project atlasdb by palantir.

the class SingleLeaderPingerTest method recordsLeaderPingReturnedTrueWithOlderVersion.

@Test
public void recordsLeaderPingReturnedTrueWithOlderVersion() {
    OrderableSlsVersion oldTimeLockVersion = OrderableSlsVersion.valueOf("1.1.2");
    whenRemoteLeaderHasVersion(oldTimeLockVersion);
    LeaderPinger pinger = pingerWithVersion(OrderableSlsVersion.valueOf("2.1.1"));
    assertThat(pinger.pingLeaderWithUuid(REMOTE_UUID)).isEqualTo(LeaderPingResults.pingReturnedTrueWithOlderVersion(oldTimeLockVersion));
}
Also used : OrderableSlsVersion(com.palantir.sls.versions.OrderableSlsVersion) Test(org.junit.Test)

Example 3 with OrderableSlsVersion

use of com.palantir.sls.versions.OrderableSlsVersion in project atlasdb by palantir.

the class PingResultTest method pingResultIsJavaSerializable.

@Test
public void pingResultIsJavaSerializable() throws IOException, ClassNotFoundException {
    OrderableSlsVersion timeLockVersion = OrderableSlsVersion.valueOf("0.27.0");
    PingResult pr = PingResult.builder().timeLockVersion(timeLockVersion).isLeader(true).build();
    File file = tempFolder.newFile();
    try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file))) {
        out.writeObject(pr);
    }
    try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(file))) {
        PingResult deserializedPingResult = (PingResult) in.readObject();
        assertThat(deserializedPingResult.isLeader()).isTrue();
        assertThat(deserializedPingResult.timeLockVersion()).contains(timeLockVersion);
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) File(java.io.File) OrderableSlsVersion(com.palantir.sls.versions.OrderableSlsVersion) FileInputStream(java.io.FileInputStream) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Example 4 with OrderableSlsVersion

use of com.palantir.sls.versions.OrderableSlsVersion in project atlasdb by palantir.

the class SingleLeaderPingerTest method ignoresOlderVersionWhenGreenNodeShouldNotGainLeadership.

@Test
public void ignoresOlderVersionWhenGreenNodeShouldNotGainLeadership() {
    OrderableSlsVersion oldTimeLockVersion = OrderableSlsVersion.valueOf("1.1.2");
    whenRemoteLeaderHasVersion(oldTimeLockVersion);
    when(greenNodeLeadershipPrioritiser.shouldGreeningNodeBecomeLeader()).thenReturn(false);
    LeaderPinger pinger = pingerWithVersion(OrderableSlsVersion.valueOf("2.1.1"));
    assertThat(pinger.pingLeaderWithUuid(REMOTE_UUID)).isEqualTo(LeaderPingResults.pingReturnedTrue(REMOTE_UUID, HOST_AND_PORT));
}
Also used : OrderableSlsVersion(com.palantir.sls.versions.OrderableSlsVersion) Test(org.junit.Test)

Example 5 with OrderableSlsVersion

use of com.palantir.sls.versions.OrderableSlsVersion in project atlasdb by palantir.

the class PersistedRateLimitingLeadershipPrioritiser method shouldGreeningNodeBecomeLeader.

@Override
public boolean shouldGreeningNodeBecomeLeader() {
    OrderableSlsVersion currentVersion = timeLockVersion.orElse(null);
    Instant currentTime = clock.instant();
    boolean shouldBecomeLeader = shouldBecomeLeader(currentVersion, currentTime);
    if (shouldBecomeLeader) {
        greenNodeLeadershipAttemptHistory.setLatestAttemptTime(currentVersion, currentTime.toEpochMilli());
    }
    return shouldBecomeLeader;
}
Also used : Instant(java.time.Instant) OrderableSlsVersion(com.palantir.sls.versions.OrderableSlsVersion)

Aggregations

OrderableSlsVersion (com.palantir.sls.versions.OrderableSlsVersion)5 Test (org.junit.Test)3 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Instant (java.time.Instant)1