public class NatsServerRunner
extends java.lang.Object
implements java.lang.AutoCloseable
| Modifier and Type | Class and Description |
|---|---|
static class |
NatsServerRunner.Builder |
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_PROCESS_CHECK_TRIES |
static long |
DEFAULT_PROCESS_CHECK_WAIT |
static int |
DEFAULT_RUN_CHECK_TRIES |
static long |
DEFAULT_RUN_CHECK_WAIT |
static java.lang.String |
ERROR_NOTE_PART_1 |
static java.lang.String |
ERROR_NOTE_PART_2 |
| Modifier | Constructor and Description |
|---|---|
|
NatsServerRunner()
Construct and start the Nats Server runner with all defaults:
use an automatically allocated port
no debug flag
jetstream not enabled
no custom config file
no config inserts
no custom args
|
|
NatsServerRunner(boolean debug)
Construct and start the Nats Server runner with defaults:
use an automatically allocated port
jetstream not enabled
no custom config file
no config inserts
no custom args
and this option:
|
|
NatsServerRunner(boolean debug,
boolean jetstream)
Construct and start the Nats Server runner with defaults:
Consider using
NatsServerRunner.Builder
use an automatically allocated port
no custom config file
no config inserts
no custom args
and these options: |
|
NatsServerRunner(int port,
boolean debug)
Construct and start the Nats Server runner with defaults:
jetstream not enabled
no custom config file
no config inserts
no custom args
and these options:
|
|
NatsServerRunner(int port,
boolean debug,
boolean jetstream)
Construct and start the Nats Server runner with defaults:
no custom config file
no config inserts
no custom args
and these options:
|
|
NatsServerRunner(int port,
boolean debug,
boolean jetstream,
java.lang.String configFilePath,
java.lang.String[] configInserts,
java.lang.String[] customArgs)
Construct and start the Nats Server runner with options
Consider using
NatsServerRunner.Builder |
protected |
NatsServerRunner(NatsServerRunner.Builder b) |
|
NatsServerRunner(NatsServerRunnerOptions natsServerRunnerOptions) |
|
NatsServerRunner(java.lang.String[] customArgs)
Construct and start the Nats Server runner with defaults:
Consider using
NatsServerRunner.Builder
use an automatically allocated port
no debug flag
jetstream not enabled
no custom config file
no config inserts
and these options: |
|
NatsServerRunner(java.lang.String[] customArgs,
boolean debug)
Construct and start the Nats Server runner with defaults:
Consider using
NatsServerRunner.Builder
use an automatically allocated port
jetstream not enabled
no custom config file
no config inserts
and these options: |
|
NatsServerRunner(java.lang.String[] customArgs,
boolean debug,
boolean jetstream)
Construct and start the Nats Server runner with defaults:
Consider using
NatsServerRunner.Builder
use an automatically allocated port
no custom config file
no config inserts
and these options: |
|
NatsServerRunner(java.lang.String[] customArgs,
int port,
boolean debug)
Construct and start the Nats Server runner with defaults:
Consider using
NatsServerRunner.Builder
jetstream not enabled
no custom config file
no config inserts
and these options: |
|
NatsServerRunner(java.lang.String configFilePath,
boolean debug)
Construct and start the Nats Server runner with defaults:
Consider using
NatsServerRunner.Builder
use an automatically allocated port
jetstream not enabled
no config inserts
no custom args
and these options: |
|
NatsServerRunner(java.lang.String configFilePath,
boolean debug,
boolean jetstream)
Construct and start the Nats Server runner with defaults:
Consider using
NatsServerRunner.Builder
use an automatically allocated port
jetstream not enabled
no custom config file
and these options: |
|
NatsServerRunner(java.lang.String configFilePath,
int port,
boolean debug)
Construct and start the Nats Server runner with defaults:
Consider using
NatsServerRunner.Builder
jetstream not enabled
no config inserts
no custom args
and these options: |
|
NatsServerRunner(java.lang.String configFilePath,
java.lang.String[] configInserts,
int port,
boolean debug)
Construct and start the Nats Server runner with defaults:
Consider using
NatsServerRunner.Builder
jetstream not enabled
no custom args
and these options: |
| Modifier and Type | Method and Description |
|---|---|
static NatsServerRunner.Builder |
builder()
Get a new Builder
|
static void |
clearPreferredServerPath() |
void |
close()
For AutoCloseable, calls shutdown(true).
|
java.lang.String |
getCmdLine()
Get the command line used to start the server
|
java.lang.String |
getConfigFile()
Get the absolute path of the config file
|
int |
getConfigPort() |
static java.util.logging.Level |
getDefaultOutputLevel() |
static java.util.function.Supplier<Output> |
getDefaultOutputSupplier() |
java.lang.String |
getExecutablePath()
The resolved server executable path being used
|
int |
getNatsPort() |
int |
getNonNatsPort() |
int |
getPort()
Get the port number.
|
java.lang.Integer |
getPort(java.lang.String key) |
static java.lang.String |
getPreferredServerPath() |
java.lang.String |
getURI()
Get the uri in the form nats://localhost:port
|
int |
getUserPort() |
static void |
setDefaultOutputLevel(java.util.logging.Level defaultOutputLevel) |
static void |
setDefaultOutputSupplier(java.util.function.Supplier<Output> outputSupplier) |
static void |
setPreferredServerPath(java.lang.String preferredServerPath) |
void |
shutdown()
Shut the server down, waiting (blocking)
|
void |
shutdown(boolean wait)
Shut the server down
|
public static final java.lang.String ERROR_NOTE_PART_1
public static final java.lang.String ERROR_NOTE_PART_2
public static long DEFAULT_PROCESS_CHECK_WAIT
public static int DEFAULT_PROCESS_CHECK_TRIES
public static long DEFAULT_RUN_CHECK_WAIT
public static int DEFAULT_RUN_CHECK_TRIES
public NatsServerRunner()
throws java.io.IOException
java.io.IOException - thrown when the server cannot startpublic NatsServerRunner(boolean debug)
throws java.io.IOException
debug - whether to start the server with the -DV flagsjava.io.IOException - thrown when the server cannot startpublic NatsServerRunner(boolean debug,
boolean jetstream)
throws java.io.IOException
NatsServerRunner.Builder
debug - whether to start the server with the -DV flagsjetstream - whether to enable JetStreamjava.io.IOException - thrown when the server cannot startpublic NatsServerRunner(int port,
boolean debug)
throws java.io.IOException
port - the port to start on or <=0 to use an automatically allocated portdebug - whether to start the server with the -DV flagsjava.io.IOException - thrown when the server cannot startpublic NatsServerRunner(int port,
boolean debug,
boolean jetstream)
throws java.io.IOException
port - the port to start on or <=0 to use an automatically allocated portdebug - whether to start the server with the -DV flagsjetstream - whether to enable JetStreamjava.io.IOException - thrown when the server cannot startpublic NatsServerRunner(java.lang.String configFilePath,
boolean debug)
throws java.io.IOException
NatsServerRunner.Builder
debug - whether to start the server with the -DV flagsconfigFilePath - path to a custom config filejava.io.IOException - thrown when the server cannot startpublic NatsServerRunner(java.lang.String configFilePath,
boolean debug,
boolean jetstream)
throws java.io.IOException
NatsServerRunner.Builder
debug - whether to start the server with the -DV flagsjetstream - whether to enable JetStreamconfigFilePath - path to a custom config filejava.io.IOException - thrown when the server cannot startpublic NatsServerRunner(java.lang.String configFilePath,
java.lang.String[] configInserts,
int port,
boolean debug)
throws java.io.IOException
NatsServerRunner.Builder
port - the port to start on or <=0 to use an automatically allocated portdebug - whether to start the server with the -DV flagsconfigFilePath - path to a custom config fileconfigInserts - an array of custom lines to add to the config filejava.io.IOException - thrown when the server cannot startpublic NatsServerRunner(java.lang.String configFilePath,
int port,
boolean debug)
throws java.io.IOException
NatsServerRunner.Builder
port - the port to start on or <=0 to use an automatically allocated portdebug - whether to start the server with the -DV flagsconfigFilePath - path to a custom config filejava.io.IOException - thrown when the server cannot startpublic NatsServerRunner(java.lang.String[] customArgs)
throws java.io.IOException
NatsServerRunner.Builder
customArgs - any custom args to add to the command linejava.io.IOException - thrown when the server cannot startpublic NatsServerRunner(java.lang.String[] customArgs,
boolean debug)
throws java.io.IOException
NatsServerRunner.Builder
debug - whether to start the server with the -DV flagscustomArgs - any custom args to add to the command linejava.io.IOException - thrown when the server cannot startpublic NatsServerRunner(java.lang.String[] customArgs,
boolean debug,
boolean jetstream)
throws java.io.IOException
NatsServerRunner.Builder
customArgs - any custom args to add to the command linedebug - whether to start the server with the -DV flagsjetstream - whether to enable JetStreamjava.io.IOException - thrown when the server cannot startpublic NatsServerRunner(java.lang.String[] customArgs,
int port,
boolean debug)
throws java.io.IOException
NatsServerRunner.Builder
customArgs - any custom args to add to the command lineport - the port to start on or <=0 to use an automatically allocated portdebug - whether to start the server with the -DV flagsjava.io.IOException - thrown when the server cannot startpublic NatsServerRunner(int port,
boolean debug,
boolean jetstream,
java.lang.String configFilePath,
java.lang.String[] configInserts,
java.lang.String[] customArgs)
throws java.io.IOException
NatsServerRunner.Builderport - the port to start on or <=0 to use an automatically allocated portdebug - whether to start the server with the -DV flagsjetstream - whether to enable JetStreamconfigFilePath - path to a custom config fileconfigInserts - an array of custom lines to add to the config filecustomArgs - any custom args to add to the command linejava.io.IOException - thrown when the server cannot startpublic NatsServerRunner(NatsServerRunnerOptions natsServerRunnerOptions) throws java.lang.Exception
java.lang.Exceptionprotected NatsServerRunner(NatsServerRunner.Builder b) throws java.io.IOException
java.io.IOExceptionpublic static NatsServerRunner.Builder builder()
public java.lang.String getExecutablePath()
public int getPort()
public int getUserPort()
public int getNatsPort()
public int getConfigPort()
public int getNonNatsPort()
public java.lang.Integer getPort(java.lang.String key)
public java.lang.String getConfigFile()
public java.lang.String getURI()
public java.lang.String getCmdLine()
public void shutdown(boolean wait)
throws java.lang.InterruptedException
wait - whether to block while waiting for the process to shut downjava.lang.InterruptedException - if the wait was interruptedpublic void shutdown()
throws java.lang.InterruptedException
java.lang.InterruptedException - if the wait was interruptedpublic void close()
throws java.lang.Exception
close in interface java.lang.AutoCloseablejava.lang.Exceptionpublic static java.util.function.Supplier<Output> getDefaultOutputSupplier()
public static void setDefaultOutputSupplier(java.util.function.Supplier<Output> outputSupplier)
public static java.util.logging.Level getDefaultOutputLevel()
public static void setDefaultOutputLevel(java.util.logging.Level defaultOutputLevel)
public static java.lang.String getPreferredServerPath()
public static void setPreferredServerPath(java.lang.String preferredServerPath)
public static void clearPreferredServerPath()