Class IP2LocationSettings

java.lang.Object
com.iizix.server.geo.ip2location.IP2LocationSettings

public final class IP2LocationSettings extends Object
Assembles the IP2Location service configuration from the server settings: the database directory, the IP2LocationService.Builder and the RecoveryConfig. The values themselves are read through the typed, range-checked getters of ServerSettings; this class only turns them into the objects the co.mindus.ip2location library takes, so that the library stays free of any server type.
Author:
Christopher Mindus
  • Method Details

    • resolveDatabaseDirectory

      public static Path resolveDatabaseDirectory(ServerSettings settings, File currentDirectory, int clusterIndex)
      Resolves the database directory. A relative ServerSettings.getIP2LocationDatabasePath() is taken relative to the server's current directory. A clustered instance (index at least 1) gets its own directory by the suffix "#"+index, so that two JVMs never replace each other's memory-mapped files; index 0 uses the path as configured.
      Parameters:
      settings - The server settings.
      currentDirectory - The server's current directory.
      clusterIndex - The cluster index, 0 for an unclustered server.
      Returns:
      The absolute database directory.
    • createBuilder

      public static IP2LocationService.Builder createBuilder(ServerSettings settings, Path directory, IEventLogger logger)
      Creates the service builder from the settings.
      Parameters:
      settings - The server settings.
      directory - The resolved database directory, see resolveDatabaseDirectory(ServerSettings, File, int).
      logger - The event logger to install.
      Returns:
      The builder, enabled according to the settings and carrying the token. Building a service from it throws IllegalStateException when the token is empty.
    • createRecoveryConfig

      public static RecoveryConfig createRecoveryConfig(ServerSettings settings)
      Creates the recovery configuration from the settings.
      Parameters:
      settings - The server settings.
      Returns:
      The recovery configuration.