Class ProcessConfiguration.Builder

java.lang.Object
eu.cloudnetservice.driver.service.ProcessConfiguration.Builder
Enclosing class:
ProcessConfiguration

public static class ProcessConfiguration.Builder extends Object
Represents a builder for a process configuration.
Since:
4.0
  • Field Details

    • environment

      protected String environment
    • maxHeapMemorySize

      protected int maxHeapMemorySize
    • jvmOptions

      protected List<String> jvmOptions
    • processParameters

      protected List<String> processParameters
    • environmentVariables

      protected Map<String,String> environmentVariables
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • maxHeapMemorySize

      @NonNull public @NonNull ProcessConfiguration.Builder maxHeapMemorySize(@Range(from=50L,to=2147483647L) int maxHeapMemorySize)
      Sets the maximum amount of heap memory (in mb) the service is allowed to use. The given heap memory size must be at least 50 MB (less heap memory makes no sense when running a service).
      Parameters:
      maxHeapMemorySize - the maximum heap memory a service is allowed to use.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      IllegalArgumentException - if the given memory size is less than 50 mb.
    • environment

      Sets the name of the environment services using the created process configuration should use. Based on the environments the configuration and application files are selected and modified.
      Parameters:
      environment - the name of the environment the configuration should use.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given environment name is null.
    • environment

      Sets the name of the environment services using the created process configuration should use. Based on the environments the configuration and application files are selected and modified.
      Parameters:
      environment - the environment the configuration should use.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given environment is null.
    • jvmOptions

      Sets the jvm options which should get applied to the service command line. JVM options are there to configure the behaviour of the jvm, for example the garbage collector.

      The XmX and XmS options will always get appended based on the configured maximum heap memory size.

      This method will override all previously added jvm options. Furthermore, the given collection will be copied into this builder, meaning that changes to it will not reflect into the builder after the method call.

      Parameters:
      jvmOptions - the jvm options of the configuration.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given options collection is null.
    • modifyJvmOptions

      Modifies the jvm options of this builder. JVM options are there to configure the behaviour of the jvm, for example the garbage collector.

      The XmX and XmS options will always get appended based on the configured maximum heap memory size.

      Duplicate options will be omitted by the underlying collection. HOWEVER, adding the same option twice with a changed value to it will most likely result in the jvm to crash, beware!

      Parameters:
      modifier - the modifier to be applied to the already added jvm options of this builder.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given modifier is null.
    • processParameters

      @NonNull public @NonNull ProcessConfiguration.Builder processParameters(@NonNull @NonNull Collection<String> processParameters)
      Sets the process parameters which should get appended to the command line. Process parameters are there to configure the application, for example setting an option like --online-mode=true.

      This method will override all previously added process parameters options. Furthermore, the given collection will be copied into this builder, meaning that changes to it will not reflect into the builder after the method call.

      Parameters:
      processParameters - the process parameters of the configuration.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given parameters' collection is null.
    • modifyProcessParameters

      Modifies the process parameters which should get appended to the command line. Process parameters are there to configure the application, for example setting an option like --online-mode=true.

      Duplicate parameters will get omitted by the underlying collection.

      Parameters:
      modifier - the modifier to be applied to the already added process parameters of this builder.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given modifier is null.
    • environmentVariables

      @NonNull public @NonNull ProcessConfiguration.Builder environmentVariables(@NonNull @NonNull Map<String,String> environmentVariables)
      Sets the environment variables which should set in the environment the process runs in.

      This method will override all previously added environment variables options. Furthermore, the given map will be copied into this builder, meaning that changes to it will not reflect into the builder after the method call.

      Parameters:
      environmentVariables - the environment variables to apply to processes created based on this configuration.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given environment variables map is null.
    • modifyEnvironmentVariables

      @NonNull public @NonNull ProcessConfiguration.Builder modifyEnvironmentVariables(@NonNull @NonNull Consumer<Map<String,String>> modifier)
      Modifies the environment variables which should get appended to the environment of the process.
      Parameters:
      modifier - the modifier to be applied to the already added environment variables of this builder.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the modifier is null.
    • build

      Builds the process configuration based on the configuration of this builder.
      Returns:
      the created process configuration.
      Throws:
      NullPointerException - if no environment is specified for the configuration.