public class Vertigo extends Object
This is the core API for working with Vertigo clusters and networks.
To create a Vertigo instance within a Vert.x Verticle,
simply pass the Verticle to the Vertigo
constructor.
Vertigo vertigo = new Vertigo(this);
To create a new network use the createNetwork(String)
methods.
All networks must be deployed to named clusters. Vertigo clusters are
simple collections of verticles that handle deployment and monitoring
of components within a Vertigo network. Cluster nodes can either be
deployed using the vertx command with the vertigo-cluster
module or programmatically using this API.
To deploy a cluster use the deployCluster(String, Handler) methods.
vertigo.deployCluster("test-cluster", new Handler<AsyncResult<ClusterManager>>() {
public void handle(AsyncResult<ClusterManager> result) {
if (result.succeeded()) {
ClusterManager cluster = result.result();
}
}
});
The ClusterManager can be used to operate on a specific cluster,
or networks can be deployed to named clusters through this API. To get
a running cluster call the getCluster(String) method. To
deploy a network to a cluster use the deployNetwork(String, NetworkConfig)
methods.
cluster.deployNetwork(network, new Handler>() { public void handle(AsyncResult result) { ActiveNetwork network = result.result(); } });
When a network is deployed to a cluster, the cluster first checks to determine whether the network is already running in the cluster. If the network is already running then the new configuration will be merged with the running configuration. This is important to remember. It allows users to reconfigure running networks, but it also means that a network deployment will not fail if a network of the same name is already running in the cluster. Networks should be named carefully in order to prevent merging two unrelated networks.
Clusters also provide a logical separation of networks within the Vert.x cluster. While Vertigo will merge networks of the same name within a single cluster, networks of the same name can be deployed in separate clusters simultaneously. Even if the network configurations are the same, Vertigo will ensure that event bus addresses do not clash across clusters, so it's okay to deploy, for instance, a "test" and "live" cluster within the same Vert.x cluster.
| Constructor and Description |
|---|
Vertigo(org.vertx.java.platform.Verticle verticle) |
Vertigo(org.vertx.java.core.Vertx vertx,
org.vertx.java.platform.Container container) |
| Modifier and Type | Method and Description |
|---|---|
NetworkConfig |
createNetwork(org.vertx.java.core.json.JsonObject json)
Creates a network configuration from json.
|
NetworkConfig |
createNetwork(String name)
Creates a new network.
|
Vertigo |
deployCluster(String cluster)
Deploys a single node cluster at the given address.
|
Vertigo |
deployCluster(String cluster,
org.vertx.java.core.Handler<org.vertx.java.core.AsyncResult<ClusterManager>> doneHandler)
Deploys a single node cluster at the given address.
|
Vertigo |
deployCluster(String cluster,
int nodes)
Deploys multiple nodes within a cluster at the given address.
|
Vertigo |
deployCluster(String cluster,
int nodes,
org.vertx.java.core.Handler<org.vertx.java.core.AsyncResult<ClusterManager>> doneHandler)
Deploys multiple nodes within a cluster at the given address.
|
Vertigo |
deployNetwork(String cluster,
org.vertx.java.core.json.JsonObject network)
Deploys a json network to a specific cluster.
|
Vertigo |
deployNetwork(String cluster,
org.vertx.java.core.json.JsonObject network,
org.vertx.java.core.Handler<org.vertx.java.core.AsyncResult<ActiveNetwork>> doneHandler)
Deploys a json network to a specific cluster.
|
Vertigo |
deployNetwork(String cluster,
NetworkConfig network)
Deploys a network to a specific cluster.
|
Vertigo |
deployNetwork(String cluster,
NetworkConfig network,
org.vertx.java.core.Handler<org.vertx.java.core.AsyncResult<ActiveNetwork>> doneHandler)
Deploys a network to a specific cluster.
|
Vertigo |
deployNetwork(String cluster,
String name)
Deploys a bare network to a specific cluster.
|
Vertigo |
deployNetwork(String cluster,
String name,
org.vertx.java.core.Handler<org.vertx.java.core.AsyncResult<ActiveNetwork>> doneHandler)
Deploys a bare network to a specific cluster.
|
ClusterManager |
getCluster(String cluster)
Returns a cluster manager for the given cluster.
|
Vertigo |
undeployNetwork(String cluster,
org.vertx.java.core.json.JsonObject network)
Undeploys a network from the given cluster from a json configuration.
|
Vertigo |
undeployNetwork(String cluster,
org.vertx.java.core.json.JsonObject network,
org.vertx.java.core.Handler<org.vertx.java.core.AsyncResult<Void>> doneHandler)
Undeploys a network from the given cluster from a json configuration.
|
Vertigo |
undeployNetwork(String cluster,
NetworkConfig network)
Undeploys a network from the given cluster.
|
Vertigo |
undeployNetwork(String cluster,
NetworkConfig network,
org.vertx.java.core.Handler<org.vertx.java.core.AsyncResult<Void>> doneHandler)
Undeploys a network from the given cluster.
|
Vertigo |
undeployNetwork(String cluster,
String name)
Undeploys a complete network from the given cluster.
|
Vertigo |
undeployNetwork(String cluster,
String name,
org.vertx.java.core.Handler<org.vertx.java.core.AsyncResult<Void>> doneHandler)
Undeploys a complete network from the given cluster.
|
public Vertigo(org.vertx.java.platform.Verticle verticle)
public Vertigo(org.vertx.java.core.Vertx vertx,
org.vertx.java.platform.Container container)
public NetworkConfig createNetwork(String name)
name - The network name.createNetwork(JsonObject)public NetworkConfig createNetwork(org.vertx.java.core.json.JsonObject json)
json - A json network configuration.createNetwork(String)public Vertigo deployCluster(String cluster)
cluster - The cluster event bus address.public Vertigo deployCluster(String cluster, org.vertx.java.core.Handler<org.vertx.java.core.AsyncResult<ClusterManager>> doneHandler)
cluster - The cluster event bus address.doneHandler - An asynchronous handler to be called once the cluster
has been deployed. The handler will be called with a ClusterManager
which can be used to manage networks running in the cluster.public Vertigo deployCluster(String cluster, int nodes)
cluster - The cluster event bus address.nodes - The number of nodes to deploy.public Vertigo deployCluster(String cluster, int nodes, org.vertx.java.core.Handler<org.vertx.java.core.AsyncResult<ClusterManager>> doneHandler)
cluster - The cluster event bus address.nodes - The number of nodes to deploy.doneHandler - An asynchronous handler to be called once the cluster
has been deployed. The handler will be called with a ClusterManager
which can be used to manage networks running in the cluster.public ClusterManager getCluster(String cluster)
cluster - The cluster address.public Vertigo deployNetwork(String cluster, String name)
The network will be deployed with no components and no connections. You
can add components and connections to the network with an ActiveNetwork
instance.
cluster - The cluster to which to deploy the network.name - The name of the network to deploy.public Vertigo deployNetwork(String cluster, String name, org.vertx.java.core.Handler<org.vertx.java.core.AsyncResult<ActiveNetwork>> doneHandler)
The network will be deployed with no components and no connections. You
can add components and connections to the network with an ActiveNetwork
instance.
cluster - The cluster to which to deploy the network.name - The name of the network to deploy.doneHandler - An asynchronous handler to be called once the network has
completed deployment. The handler will be called with an ActiveNetwork
instance which can be used to add or remove components and connections from
the network.public Vertigo deployNetwork(String cluster, org.vertx.java.core.json.JsonObject network)
The JSON network configuration will be converted to a NetworkConfig before
being deployed to the cluster. The conversion is done synchronously, so if the
configuration is invalid then this method may throw an exception.
cluster - The cluster to which to deploy the network.network - The JSON network configuration. For the configuration format see
the project documentation.public Vertigo deployNetwork(String cluster, org.vertx.java.core.json.JsonObject network, org.vertx.java.core.Handler<org.vertx.java.core.AsyncResult<ActiveNetwork>> doneHandler)
The JSON network configuration will be converted to a NetworkConfig before
being deployed to the cluster. The conversion is done synchronously, so if the
configuration is invalid then this method may throw an exception.
cluster - The cluster to which to deploy the network.network - The JSON network configuration. For the configuration format see
the project documentation.doneHandler - An asynchronous handler to be called once the network has
completed deployment. The handler will be called with an ActiveNetwork
instance which can be used to add or remove components and connections from
the network.public Vertigo deployNetwork(String cluster, NetworkConfig network)
If the given network configuration's name matches the name of a network that is already running in the cluster then the given configuration will be merged with the running network's configuration. This allows networks to be dynamically updated with partial configurations. If the configuration matches the already running configuration then no changes will occur, so it's not necessary to check whether a network is already running if the configuration has not been altered.
cluster - The cluster to which to deploy the network.network - The configuration of the network to deploy.public Vertigo deployNetwork(String cluster, NetworkConfig network, org.vertx.java.core.Handler<org.vertx.java.core.AsyncResult<ActiveNetwork>> doneHandler)
If the given network configuration's name matches the name of a network that is already running in the cluster then the given configuration will be merged with the running network's configuration. This allows networks to be dynamically updated with partial configurations. If the configuration matches the already running configuration then no changes will occur, so it's not necessary to check whether a network is already running if the configuration has not been altered.
cluster - The cluster to which to deploy the network.network - The configuration of the network to deploy.doneHandler - An asynchronous handler to be called once the network has
completed deployment. The handler will be called with an ActiveNetwork
instance which can be used to add or remove components and connections from
the network.public Vertigo undeployNetwork(String cluster, String name)
This method does not require a network configuration for undeployment. Vertigo will load the configuration from the fault-tolerant data store and undeploy components internally. This allows networks to be undeployed without the network configuration.
cluster - The cluster from which to undeploy the network.name - The name of the network to undeploy.public Vertigo undeployNetwork(String cluster, String name, org.vertx.java.core.Handler<org.vertx.java.core.AsyncResult<Void>> doneHandler)
This method does not require a network configuration for undeployment. Vertigo will load the configuration from the fault-tolerant data store and undeploy components internally. This allows networks to be undeployed without the network configuration.
cluster - The cluster from which to undeploy the network.name - The name of the network to undeploy.doneHandler - An asynchronous handler to be called once the network is undeployed.public Vertigo undeployNetwork(String cluster, org.vertx.java.core.json.JsonObject network)
The JSON configuration will immediately be converted to a NetworkConfig prior
to undeploying the network. In order to undeploy the entire network, the configuration
should be the same as the deployed configuration. Vertigo will use configuration
components to determine whether two configurations are identical. If the given
configuration is not identical to the running configuration, any components or
connections in the json configuration that are present in the running network
will be closed and removed from the running network.
cluster - The cluster from which to undeploy the network.network - The JSON configuration to undeploy. For the configuration format see
the project documentation.public Vertigo undeployNetwork(String cluster, org.vertx.java.core.json.JsonObject network, org.vertx.java.core.Handler<org.vertx.java.core.AsyncResult<Void>> doneHandler)
The JSON configuration will immediately be converted to a NetworkConfig prior
to undeploying the network. In order to undeploy the entire network, the configuration
should be the same as the deployed configuration. Vertigo will use configuration
components to determine whether two configurations are identical. If the given
configuration is not identical to the running configuration, any components or
connections in the json configuration that are present in the running network
will be closed and removed from the running network.
cluster - The cluster from which to undeploy the network.network - The JSON configuration to undeploy. For the configuration format see
the project documentation.doneHandler - An asynchronous handler to be called once the configuration is undeployed.public Vertigo undeployNetwork(String cluster, NetworkConfig network)
This method supports both partial and complete undeployment of networks. When
undeploying networks by specifying a NetworkConfig, the network configuration
should contain all components and connections that are being undeployed. If the
configuration's components and connections match all deployed components and
connections then the entire network will be undeployed.
cluster - The cluster from which to undeploy the network.network - The network configuration to undeploy.public Vertigo undeployNetwork(String cluster, NetworkConfig network, org.vertx.java.core.Handler<org.vertx.java.core.AsyncResult<Void>> doneHandler)
This method supports both partial and complete undeployment of networks. When
undeploying networks by specifying a NetworkConfig, the network configuration
should contain all components and connections that are being undeployed. If the
configuration's components and connections match all deployed components and
connections then the entire network will be undeployed.
cluster - The cluster from which to undeploy the network.network - The network configuration to undeploy.doneHandler - An asynchronous handler to be called once the configuration is undeployed.Copyright © 2013-2014. All Rights Reserved.