public class VertxImpl extends Object implements VertxInternal, MetricsProvider
Modifier and Type | Method and Description |
---|---|
boolean |
cancelTimer(long id)
Cancels the timer with the specified
id . |
void |
close()
Stop the the Vertx instance and release any resources held by it.
|
void |
close(Handler<AsyncResult<Void>> completionHandler)
Like
Vertx.close() but the completionHandler will be called when the close is complete |
static Context |
context() |
DatagramSocket |
createDatagramSocket()
Create a datagram socket using default options
|
DatagramSocket |
createDatagramSocket(DatagramSocketOptions options)
Create a datagram socket using the specified options
|
DnsClient |
createDnsClient(int port,
String host)
Create a DNS client to connect to a DNS server at the specified host and port
|
EventLoopContext |
createEventLoopContext(String deploymentID,
JsonObject config,
ClassLoader tccl) |
HttpClient |
createHttpClient()
Create a HTTP/HTTPS client using default options
|
HttpClient |
createHttpClient(HttpClientOptions options)
Create a HTTP/HTTPS client using the specified options
|
HttpServer |
createHttpServer()
Create an HTTP/HTTPS server using default options
|
HttpServer |
createHttpServer(HttpServerOptions serverOptions)
Create an HTTP/HTTPS server using the specified options
|
NetClient |
createNetClient()
Create a TCP/SSL client using default options
|
NetClient |
createNetClient(NetClientOptions options)
Create a TCP/SSL client using the specified options
|
NetServer |
createNetServer()
Create a TCP/SSL server using default options
|
NetServer |
createNetServer(NetServerOptions options)
Create a TCP/SSL server using the specified options
|
ContextImpl |
createWorkerContext(boolean multiThreaded,
String deploymentID,
JsonObject config,
ClassLoader tccl) |
Set<String> |
deploymentIDs()
Return a Set of deployment IDs for the currently deployed deploymentIDs.
|
void |
deployVerticle(String name)
Deploy a verticle instance given a name.
|
void |
deployVerticle(String name,
DeploymentOptions options)
Like
Vertx.deployVerticle(Verticle) but DeploymentOptions are provided to configure the
deployment. |
void |
deployVerticle(String name,
DeploymentOptions options,
Handler<AsyncResult<String>> completionHandler)
Like
Vertx.deployVerticle(String, Handler) but DeploymentOptions are provided to configure the
deployment. |
void |
deployVerticle(String name,
Handler<AsyncResult<String>> completionHandler)
Like
Vertx.deployVerticle(String) but the completionHandler will be notified when the deployment is complete. |
void |
deployVerticle(Verticle verticle)
Deploy a verticle instance that you have created yourself.
|
void |
deployVerticle(Verticle verticle,
DeploymentOptions options)
Like
Vertx.deployVerticle(Verticle) but DeploymentOptions are provided to configure the
deployment. |
void |
deployVerticle(Verticle verticle,
DeploymentOptions options,
Handler<AsyncResult<String>> completionHandler)
Like
Vertx.deployVerticle(Verticle, Handler) but DeploymentOptions are provided to configure the
deployment. |
void |
deployVerticle(Verticle verticle,
Handler<AsyncResult<String>> completionHandler)
Like
Vertx.deployVerticle(Verticle) but the completionHandler will be notified when the deployment is complete. |
EventBus |
eventBus()
Get the event bus object.
|
<T> void |
executeBlocking(Handler<Future<T>> blockingCodeHandler,
boolean ordered,
Handler<AsyncResult<T>> asyncResultHandler)
Safely execute some blocking code.
|
<T> void |
executeBlocking(Handler<Future<T>> blockingCodeHandler,
Handler<AsyncResult<T>> asyncResultHandler)
Like
Vertx.executeBlocking(Handler, boolean, Handler) called with ordered = true. |
<T> void |
executeBlockingInternal(Action<T> action,
Handler<AsyncResult<T>> resultHandler) |
void |
failDuringFailover(boolean fail) |
void |
failoverCompleteHandler(FailoverCompleteHandler failoverCompleteHandler) |
FileSystem |
fileSystem()
Get the filesystem object.
|
ClusterManager |
getClusterManager() |
ContextImpl |
getContext()
Get the current context
|
Deployment |
getDeployment(String deploymentID) |
io.netty.channel.EventLoopGroup |
getEventLoopGroup() |
protected FileSystem |
getFileSystem() |
Metrics |
getMetrics()
Returns the metrics implementation.
|
String |
getNodeID() |
ContextImpl |
getOrCreateContext()
Gets the current context, or creates one if there isn't one
|
ExecutorService |
getWorkerPool() |
boolean |
isClustered()
Is this Vert.x instance clustered?
|
boolean |
isKilled() |
boolean |
isMetricsEnabled()
Whether the metrics are enabled for this measured object
|
VertxMetrics |
metricsSPI() |
io.netty.channel.EventLoopGroup |
nettyEventLoopGroup()
Return the Netty EventLoopGroup used by Vert.x
|
TimeoutStream |
periodicStream(long delay)
Returns a periodic timer as a read stream.
|
void |
registerVerticleFactory(VerticleFactory factory)
Register a
VerticleFactory that can be used for deploying Verticles based on an identifier. |
File |
resolveFile(String fileName) |
void |
runOnContext(Handler<Void> task)
Puts the handler on the event queue for the current context so it will be run asynchronously ASAP after all
preceeding events have been handled.
|
long |
setPeriodic(long delay,
Handler<Long> handler)
Set a periodic timer to fire every
delay milliseconds, at which point handler will be called with
the id of the timer. |
long |
setTimer(long delay,
Handler<Long> handler)
Set a one-shot timer to fire after
delay milliseconds, at which point handler will be called with
the id of the timer. |
SharedData |
sharedData()
Get the shared data object.
|
Map<ServerID,HttpServerImpl> |
sharedHttpServers() |
Map<ServerID,NetServerImpl> |
sharedNetServers() |
void |
simulateKill() |
TimeoutStream |
timerStream(long delay)
Returns a one-shot timer as a read stream.
|
void |
undeploy(String deploymentID)
Undeploy a verticle deployment.
|
void |
undeploy(String deploymentID,
Handler<AsyncResult<Void>> completionHandler)
Like
Vertx.undeploy(String) but the completionHandler will be notified when the undeployment is complete. |
void |
unregisterVerticleFactory(VerticleFactory factory)
Unregister a
VerticleFactory |
Set<VerticleFactory> |
verticleFactories()
Return the Set of currently registered verticle factories.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clusteredVertx, currentContext, vertx, vertx
protected FileSystem getFileSystem()
public DatagramSocket createDatagramSocket(DatagramSocketOptions options)
Vertx
createDatagramSocket
in interface Vertx
options
- the options to usepublic DatagramSocket createDatagramSocket()
Vertx
createDatagramSocket
in interface Vertx
public NetServer createNetServer(NetServerOptions options)
Vertx
createNetServer
in interface Vertx
options
- the options to usepublic NetServer createNetServer()
Vertx
createNetServer
in interface Vertx
public NetClient createNetClient(NetClientOptions options)
Vertx
createNetClient
in interface Vertx
options
- the options to usepublic NetClient createNetClient()
Vertx
createNetClient
in interface Vertx
public FileSystem fileSystem()
Vertx
fileSystem
in interface Vertx
public SharedData sharedData()
Vertx
sharedData
in interface Vertx
public HttpServer createHttpServer(HttpServerOptions serverOptions)
Vertx
createHttpServer
in interface Vertx
serverOptions
- the options to usepublic HttpServer createHttpServer()
Vertx
createHttpServer
in interface Vertx
public HttpClient createHttpClient(HttpClientOptions options)
Vertx
createHttpClient
in interface Vertx
options
- the options to usepublic HttpClient createHttpClient()
Vertx
createHttpClient
in interface Vertx
public EventBus eventBus()
Vertx
public long setPeriodic(long delay, Handler<Long> handler)
Vertx
delay
milliseconds, at which point handler
will be called with
the id of the timer.setPeriodic
in interface Vertx
delay
- the delay in milliseconds, after which the timer will firehandler
- the handler that will be called with the timer ID when the timer firespublic TimeoutStream periodicStream(long delay)
Vertx
delay
milliseconds after
the ReadStream.handler(io.vertx.core.Handler<T>)
has been called.periodicStream
in interface Vertx
delay
- the delay in milliseconds, after which the timer will firepublic long setTimer(long delay, Handler<Long> handler)
Vertx
delay
milliseconds, at which point handler
will be called with
the id of the timer.public TimeoutStream timerStream(long delay)
Vertx
delay
milliseconds after
the ReadStream.handler(io.vertx.core.Handler<T>)
has been called.timerStream
in interface Vertx
delay
- the delay in milliseconds, after which the timer will firepublic void runOnContext(Handler<Void> task)
Vertx
runOnContext
in interface Vertx
task
- - a handler representing the action to executepublic ExecutorService getWorkerPool()
getWorkerPool
in interface VertxInternal
public io.netty.channel.EventLoopGroup getEventLoopGroup()
getEventLoopGroup
in interface VertxInternal
public ContextImpl getOrCreateContext()
Vertx
getOrCreateContext
in interface VertxInternal
getOrCreateContext
in interface Vertx
public Map<ServerID,HttpServerImpl> sharedHttpServers()
sharedHttpServers
in interface VertxInternal
public Map<ServerID,NetServerImpl> sharedNetServers()
sharedNetServers
in interface VertxInternal
public boolean isMetricsEnabled()
Measured
isMetricsEnabled
in interface Measured
public Metrics getMetrics()
MetricsProvider
getMetrics
in interface MetricsProvider
public boolean cancelTimer(long id)
Vertx
id
.cancelTimer
in interface Vertx
id
- The id of the timer to cancelpublic EventLoopContext createEventLoopContext(String deploymentID, JsonObject config, ClassLoader tccl)
createEventLoopContext
in interface VertxInternal
public DnsClient createDnsClient(int port, String host)
Vertx
createDnsClient
in interface Vertx
port
- the porthost
- the hostpublic ContextImpl createWorkerContext(boolean multiThreaded, String deploymentID, JsonObject config, ClassLoader tccl)
createWorkerContext
in interface VertxInternal
public static Context context()
public ContextImpl getContext()
VertxInternal
getContext
in interface VertxInternal
public ClusterManager getClusterManager()
getClusterManager
in interface VertxInternal
public void close()
Vertx
The instance cannot be used after it has been closed.
The actual close is asynchronous and may not complete until after the call has returned.
public void close(Handler<AsyncResult<Void>> completionHandler)
Vertx
Vertx.close()
but the completionHandler will be called when the close is completepublic void deployVerticle(Verticle verticle)
Vertx
Vert.x will assign the verticle a context and start the verticle.
The actual deploy happens asynchronously and may not complete until after the call has returned.
deployVerticle
in interface Vertx
verticle
- the verticle instance to deploy.public void deployVerticle(Verticle verticle, Handler<AsyncResult<String>> completionHandler)
Vertx
Vertx.deployVerticle(Verticle)
but the completionHandler will be notified when the deployment is complete.
If the deployment is successful the result will contain a string representing the unique deployment ID of the deployment.
This deployment ID can subsequently be used to undeploy the verticle.
deployVerticle
in interface Vertx
verticle
- the verticle instance to deploycompletionHandler
- a handler which will be notified when the deployment is completepublic void deployVerticle(String name, Handler<AsyncResult<String>> completionHandler)
Vertx
Vertx.deployVerticle(String)
but the completionHandler will be notified when the deployment is complete.
If the deployment is successful the result will contain a String representing the unique deployment ID of the deployment.
This deployment ID can subsequently be used to undeploy the verticle.
deployVerticle
in interface Vertx
name
- The identifiercompletionHandler
- a handler which will be notified when the deployment is completepublic void deployVerticle(Verticle verticle, DeploymentOptions options)
Vertx
Vertx.deployVerticle(Verticle)
but DeploymentOptions
are provided to configure the
deployment.deployVerticle
in interface Vertx
verticle
- the verticle instance to deployoptions
- the deployment options.public void deployVerticle(Verticle verticle, DeploymentOptions options, Handler<AsyncResult<String>> completionHandler)
Vertx
Vertx.deployVerticle(Verticle, Handler)
but DeploymentOptions
are provided to configure the
deployment.deployVerticle
in interface Vertx
verticle
- the verticle instance to deployoptions
- the deployment options.completionHandler
- a handler which will be notified when the deployment is completepublic void deployVerticle(String name)
Vertx
Given the name, Vert.x selects a VerticleFactory
instance to use to instantiate the verticle.
For the rules on how factories are selected please consult the user manual.
deployVerticle
in interface Vertx
name
- the name.public void deployVerticle(String name, DeploymentOptions options)
Vertx
Vertx.deployVerticle(Verticle)
but DeploymentOptions
are provided to configure the
deployment.deployVerticle
in interface Vertx
name
- the nameoptions
- the deployment options.public void deployVerticle(String name, DeploymentOptions options, Handler<AsyncResult<String>> completionHandler)
Vertx
Vertx.deployVerticle(String, Handler)
but DeploymentOptions
are provided to configure the
deployment.deployVerticle
in interface Vertx
name
- the nameoptions
- the deployment options.completionHandler
- a handler which will be notified when the deployment is completepublic String getNodeID()
getNodeID
in interface VertxInternal
public void undeploy(String deploymentID)
Vertx
The actual undeployment happens asynchronously and may not complete until after the method has returned.
public void undeploy(String deploymentID, Handler<AsyncResult<Void>> completionHandler)
Vertx
Vertx.undeploy(String)
but the completionHandler will be notified when the undeployment is complete.public Set<String> deploymentIDs()
Vertx
deploymentIDs
in interface Vertx
public void registerVerticleFactory(VerticleFactory factory)
Vertx
VerticleFactory
that can be used for deploying Verticles based on an identifier.registerVerticleFactory
in interface Vertx
factory
- the factory to registerpublic void unregisterVerticleFactory(VerticleFactory factory)
Vertx
VerticleFactory
unregisterVerticleFactory
in interface Vertx
factory
- the factory to unregisterpublic Set<VerticleFactory> verticleFactories()
Vertx
verticleFactories
in interface Vertx
public <T> void executeBlockingInternal(Action<T> action, Handler<AsyncResult<T>> resultHandler)
executeBlockingInternal
in interface VertxInternal
public <T> void executeBlocking(Handler<Future<T>> blockingCodeHandler, boolean ordered, Handler<AsyncResult<T>> asyncResultHandler)
Vertx
Executes the blocking code in the handler blockingCodeHandler
using a thread from the worker pool.
When the code is complete the handler resultHandler
will be called with the result on the original context
(e.g. on the original event loop of the caller).
A Future
instance is passed into blockingCodeHandler
. When the blocking code successfully completes,
the handler should call the Future.complete(T)
or Future.complete(Object)
method, or the Future.fail(java.lang.Throwable)
method if it failed.
executeBlocking
in interface Vertx
T
- the type of the resultblockingCodeHandler
- handler representing the blocking code to runordered
- if true then if executeBlocking is called several times on the same context, the executions
for that context will be executed serially, not in parallel. if false then they will be no ordering
guaranteesasyncResultHandler
- handler that will be called when the blocking code is completepublic <T> void executeBlocking(Handler<Future<T>> blockingCodeHandler, Handler<AsyncResult<T>> asyncResultHandler)
Vertx
Vertx.executeBlocking(Handler, boolean, Handler)
called with ordered = true.executeBlocking
in interface Vertx
public boolean isClustered()
Vertx
isClustered
in interface Vertx
public io.netty.channel.EventLoopGroup nettyEventLoopGroup()
Vertx
nettyEventLoopGroup
in interface Vertx
public void simulateKill()
simulateKill
in interface VertxInternal
public Deployment getDeployment(String deploymentID)
getDeployment
in interface VertxInternal
public void failoverCompleteHandler(FailoverCompleteHandler failoverCompleteHandler)
failoverCompleteHandler
in interface VertxInternal
public boolean isKilled()
isKilled
in interface VertxInternal
public void failDuringFailover(boolean fail)
failDuringFailover
in interface VertxInternal
public VertxMetrics metricsSPI()
metricsSPI
in interface VertxInternal
public File resolveFile(String fileName)
resolveFile
in interface VertxInternal
Copyright © 2015. All Rights Reserved.