Top Description Fields Constructors Methods
io.vertx.core.impl.launcher.commands

public Class BareCommand

extends ClasspathHandler
Class Inheritance
Known Direct Subclasses
io.vertx.core.impl.launcher.commands.RunCommand
Annotations
@Summary:Creates a bare instance of vert.x.
@Description:This command launches a vert.x instance but do not deploy any verticles. It will receive a verticle if another node of the cluster dies.
@Name:bare
Imports
io.vertx.core.AsyncResult, .Vertx, .VertxException, .VertxOptions, io.vertx.core.cli.annotations.*, io.vertx.core.eventbus.AddressHelper, .EventBusOptions, io.vertx.core.impl.VertxBuilder, io.vertx.core.impl.launcher.VertxLifecycleHooks, io.vertx.core.impl.logging.Logger, io.vertx.core.json.DecodeException, .JsonObject, io.vertx.core.spi.launcher.ExecutionContext, java.io.File, .FileNotFoundException, java.lang.reflect.Method, java.util.Enumeration, .Objects, .Properties, .Scanner, java.util.concurrent.CountDownLatch, .TimeUnit, java.util.concurrent.atomic.AtomicReference

Command to create a bare instance of vert.x.
Author
Clement Escoffier

Field Summary

Modifier and TypeField and Description
protected String
protected int
protected String
protected int
private static final ThreadLocal<Logger>
public static final String
protected Runnable
protected String
public static final String
protected VertxOptions
protected int
protected Vertx
public static final String
public static final String
protected String
Inherited from io.vertx.core.impl.launcher.commands.ClasspathHandler:
classpathlogmanagerPATH_SEP

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected static void
addShutdownHook(Vertx
the vert.x instance, must not be null
vertx
,
Logger
the log, must not be null
log
,
Runnable
the action, may be null
action
)

Registers a shutdown hook closing the given vert.x instance when the JVM is terminating.

protected void
afterStartingVertx(Vertx
the created vert.x instance.
instance
)

Hook called after starting vert.x.

protected void
beforeStartingVertx(VertxOptions
the deployment options
options
)

Hook called before starting vert.x.

public static void
configureFromSystemProperties(Object options, String prefix)

This is used as workaround to retain the existing behavior of the Vert.x CLI and won't be executed in other situation.

protected VertxBuilder
createVertxBuilder(JsonObject config)
References Deprecated JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

protected String

Returns:

Get default interface to use since the user hasn't specified one.
getDefaultAddress
()
Deprecated as of 4.0, this method is no longer used.

protected EventBusOptions

Returns:

the event bus options.
getEventBusOptions
()

protected EventBusOptions

Returns:

the event bus options.
getEventBusOptions
(JsonObject jsonObject)
References Deprecated JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

public boolean

Returns:

whether or not the vert.x instance should be launched in high-availability mode. This implementation returns true.
getHA
()

protected JsonObject
getJsonFromFileOrString(String jsonFileOrString, String argName)
References Deprecated JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

private static Method
getSetter(String fieldName, Class<?> clazz)

public static Runnable
getTerminationRunnable(Vertx
the vert.x instance, must not be null
vertx
,
Logger
the log, must not be null
log
,
Runnable
the action, may be null
action
)

Gets the termination runnable used to close the Vert.x instance.

public boolean

Returns:

whether or not the vert.x instance should be clustered. This implementation returns true.
isClustered
()

public void
run()

Implements io.vertx.core.spi.launcher.Command.run.

Starts the vert.x instance.

public void
run(Runnable
the action, can be null
action
)

Starts the vert.x instance and sets the final action (called when vert.x is closed).

public void
setClusterHost(String
the cluster host
host
)

Sets the cluster host.

public void
setClusterPort(int
the port
port
)

Sets the cluster port.

public void
setClusterPublicHost(String
the host
host
)

Sets the cluster public host.

public void
setClusterPublicPort(int
the port
port
)

Sets the cluster public port.

public void
setExecutionContext(ExecutionContext
the context to inject for testing.
context
)

For testing purpose only.

public void
setHAGroup(String
the name of the group, default to __DEFAULT__.
group
)

Sets the HA group name.

public void
setQuorum(int
the quorum, default to 1.
quorum
)

Sets the quorum option.

public void
setVertxOptions(String
the configuration
vertxOptions
)

The Vert.x options, it can be a json file or a json string.

protected Vertx

Returns:

the created instance of vert.x
startVertx
()

Starts the vert.x instance.

public synchronized Vertx

Returns:

the vert.x instance if created.
vertx
()

Inherited from io.vertx.core.impl.launcher.commands.ClasspathHandler:
createcreatecreateClassloaderdeploynewInstancesetClasspath

Field Detail

clusterHostback to summary
protected String clusterHost
clusterPortback to summary
protected int clusterPort
clusterPublicHostback to summary
protected String clusterPublicHost
clusterPublicPortback to summary
protected int clusterPublicPort
configureFromSystemPropertiesback to summary
private static final ThreadLocal<Logger> configureFromSystemProperties
DEPLOYMENT_OPTIONS_PROP_PREFIXback to summary
public static final String DEPLOYMENT_OPTIONS_PROP_PREFIX
finalActionback to summary
protected Runnable finalAction
haGroupback to summary
protected String haGroup
METRICS_OPTIONS_PROP_PREFIXback to summary
public static final String METRICS_OPTIONS_PROP_PREFIX
optionsback to summary
protected VertxOptions options
quorumback to summary
protected int quorum
vertxback to summary
protected Vertx vertx
VERTX_EVENTBUS_PROP_PREFIXback to summary
public static final String VERTX_EVENTBUS_PROP_PREFIX
VERTX_OPTIONS_PROP_PREFIXback to summary
public static final String VERTX_OPTIONS_PROP_PREFIX
vertxOptionsback to summary
protected String vertxOptions

Constructor Detail

BareCommandback to summary
public BareCommand()

Method Detail

addShutdownHookback to summary
protected static void addShutdownHook(Vertx vertx, Logger log, Runnable action)

Registers a shutdown hook closing the given vert.x instance when the JVM is terminating. Optionally, an action can be executed after the termination of the Vertx instance.

Parameters
vertx:Vertx

the vert.x instance, must not be null

log:Logger

the log, must not be null

action:Runnable

the action, may be null

afterStartingVertxback to summary
protected void afterStartingVertx(Vertx instance)

Hook called after starting vert.x.

Parameters
instance:Vertx

the created vert.x instance.

beforeStartingVertxback to summary
protected void beforeStartingVertx(VertxOptions options)

Hook called before starting vert.x.

Parameters
options:VertxOptions

the deployment options

configureFromSystemPropertiesback to summary
public static void configureFromSystemProperties(Object options, String prefix)

This is used as workaround to retain the existing behavior of the Vert.x CLI and won't be executed in other situation.

createVertxBuilderback to summary
protected VertxBuilder createVertxBuilder(JsonObject config)

References Deprecated

JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

getDefaultAddressback to summary
protected String getDefaultAddress()

Deprecated

as of 4.0, this method is no longer used.

Returns:String

Get default interface to use since the user hasn't specified one.

Annotations
@Deprecated
getEventBusOptionsback to summary
protected EventBusOptions getEventBusOptions()
Returns:EventBusOptions

the event bus options.

getEventBusOptionsback to summary
protected EventBusOptions getEventBusOptions(JsonObject jsonObject)

References Deprecated

JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Returns:EventBusOptions

the event bus options.

getHAback to summary
public boolean getHA()
Returns:boolean

whether or not the vert.x instance should be launched in high-availability mode. This implementation returns true.

getJsonFromFileOrStringback to summary
protected JsonObject getJsonFromFileOrString(String jsonFileOrString, String argName)

References Deprecated

JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

getSetterback to summary
private static Method getSetter(String fieldName, Class<?> clazz)
getTerminationRunnableback to summary
public static Runnable getTerminationRunnable(Vertx vertx, Logger log, Runnable action)

Gets the termination runnable used to close the Vert.x instance.

Parameters
vertx:Vertx

the vert.x instance, must not be null

log:Logger

the log, must not be null

action:Runnable

the action, may be null

isClusteredback to summary
public boolean isClustered()
Returns:boolean

whether or not the vert.x instance should be clustered. This implementation returns true.

runback to summary
public void run()

Implements io.vertx.core.spi.launcher.Command.run.

Starts the vert.x instance.

Annotations
@Override
runback to summary
public void run(Runnable action)

Starts the vert.x instance and sets the final action (called when vert.x is closed).

Parameters
action:Runnable

the action, can be null

setClusterHostback to summary
public void setClusterHost(String host)

Sets the cluster host.

Parameters
host:String

the cluster host

Annotations
@Option
longName:cluster-host
argName:host
@Description:host to bind to for cluster communication. If this is not specified vert.x will attempt to choose one from the available interfaces.
setClusterPortback to summary
public void setClusterPort(int port)

Sets the cluster port.

Parameters
port:int

the port

Annotations
@Option
longName:cluster-port
argName:port
@Description:Port to use for cluster communication. Default is 0 which means choose a spare random port.
@DefaultValue:0
setClusterPublicHostback to summary
public void setClusterPublicHost(String host)

Sets the cluster public host.

Parameters
host:String

the host

Annotations
@Option
longName:cluster-public-host
argName:public-host
@Description:Public host to bind to for cluster communication. If not specified, Vert.x will use the same as cluster host.
setClusterPublicPortback to summary
public void setClusterPublicPort(int port)

Sets the cluster public port.

Parameters
port:int

the port

Annotations
@Option
longName:cluster-public-port
argName:public-port
@Description:Public port to use for cluster communication. Default is -1 which means same as cluster port.
@DefaultValue:-1
setExecutionContextback to summary
public void setExecutionContext(ExecutionContext context)

For testing purpose only.

Parameters
context:ExecutionContext

the context to inject for testing.

setHAGroupback to summary
public void setHAGroup(String group)

Sets the HA group name.

Parameters
group:String

the name of the group, default to __DEFAULT__.

Annotations
@Option
longName:hagroup
argName:group
@Description:used in conjunction with -ha this specifies the HA group this node will join. There can be multiple HA groups in a cluster. Nodes will only failover to other nodes in the same group. Defaults to \'__DEFAULT__\'.
@DefaultValue:__DEFAULT__
setQuorumback to summary
public void setQuorum(int quorum)

Sets the quorum option.

Parameters
quorum:int

the quorum, default to 1.

Annotations
@Option
longName:quorum
argName:q
@Description:Used in conjunction with -ha this specifies the minimum number of nodes in the cluster for any HA deploymentIDs to be active. Defaults to 1.
@DefaultValue:-1
setVertxOptionsback to summary
public void setVertxOptions(String vertxOptions)

The Vert.x options, it can be a json file or a json string.

Parameters
vertxOptions:String

the configuration

Annotations
@Option
longName:options
argName:options
@Description:Specifies the Vert.x options. It should reference either a JSON file which represents the options OR be a JSON string.
startVertxback to summary
protected Vertx startVertx()

Starts the vert.x instance.

Returns:Vertx

the created instance of vert.x

Annotations
@SuppressWarnings:ThrowableResultOfMethodCallIgnored
vertxback to summary
public synchronized Vertx vertx()
Returns:Vertx

the vert.x instance if created.