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;
}
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));
}
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);
}
}
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));
}
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;
}
Aggregations