Skip to content

Commit

Permalink
Create single entry point for system verification
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi authored and wendigo committed May 27, 2024
1 parent 81a8bcf commit d52b459
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
6 changes: 2 additions & 4 deletions core/trino-main/src/main/java/io/trino/server/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@
import static com.google.common.collect.MoreCollectors.toOptional;
import static io.airlift.discovery.client.ServiceAnnouncement.ServiceAnnouncementBuilder;
import static io.airlift.discovery.client.ServiceAnnouncement.serviceAnnouncement;
import static io.trino.server.TrinoSystemRequirements.verifyJvmRequirements;
import static io.trino.server.TrinoSystemRequirements.verifySystemTimeIsReasonable;
import static io.trino.server.TrinoSystemRequirements.verifySystemRequirements;
import static java.lang.String.format;
import static java.nio.file.LinkOption.NOFOLLOW_LINKS;
import static java.util.function.Predicate.not;
Expand All @@ -101,8 +100,7 @@ private void doStart(String trinoVersion)
Locale.setDefault(Locale.US);

long startTime = System.nanoTime();
verifyJvmRequirements();
verifySystemTimeIsReasonable();
verifySystemRequirements();

Logger log = Logger.get(Server.class);
log.info("Java version: %s", StandardSystemProperty.JAVA_VERSION.value());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ final class TrinoSystemRequirements

private TrinoSystemRequirements() {}

public static void verifyJvmRequirements()
public static void verifySystemRequirements()
{
verifyJvmRequirements();
verifySystemTimeIsReasonable();
}

private static void verifyJvmRequirements()
{
verifyJavaVersion();
verify64BitJvm();
Expand Down Expand Up @@ -183,7 +189,7 @@ private static void verifyUtf8()
* Perform a sanity check to make sure that the year is reasonably current, to guard against
* issues in third party libraries.
*/
public static void verifySystemTimeIsReasonable()
private static void verifySystemTimeIsReasonable()
{
int currentYear = DateTime.now().year().get();
if (currentYear < 2024) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,13 @@

import org.junit.jupiter.api.Test;

import static io.trino.server.TrinoSystemRequirements.verifyJvmRequirements;
import static io.trino.server.TrinoSystemRequirements.verifySystemTimeIsReasonable;
import static io.trino.server.TrinoSystemRequirements.verifySystemRequirements;

public class TestTrinoSystemRequirements
{
@Test
public void testVerifyJvmRequirements()
public void testVerifySystemRequirements()
{
verifyJvmRequirements();
}

@Test
public void testSystemTimeSanityCheck()
{
verifySystemTimeIsReasonable();
verifySystemRequirements();
}
}

0 comments on commit d52b459

Please sign in to comment.