Created
April 18, 2015 07:04
-
-
Save jtruelove/6798fccab92c45401904 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/main/java/io/vertx/core/Vertx.java b/src/main/java/io/vertx/core/Vertx.java | |
index af83f3a..521968b 100644 | |
--- a/src/main/java/io/vertx/core/Vertx.java | |
+++ b/src/main/java/io/vertx/core/Vertx.java | |
@@ -441,6 +441,13 @@ public interface Vertx extends Measured { | |
*/ | |
boolean isClustered(); | |
+ /** | |
+ * The number of verticle instances associated to a deployment id | |
+ * | |
+ * @return the number of verticles associated to a deployment id or -1 if there are none | |
+ */ | |
+ int getInstanceCount(String deploymentId); | |
+ | |
/** | |
* Safely execute some blocking code. | |
* <p> | |
diff --git a/src/main/java/io/vertx/core/impl/VertxImpl.java b/src/main/java/io/vertx/core/impl/VertxImpl.java | |
index 67f089b..1f7f749 100644 | |
--- a/src/main/java/io/vertx/core/impl/VertxImpl.java | |
+++ b/src/main/java/io/vertx/core/impl/VertxImpl.java | |
@@ -137,6 +137,7 @@ public class VertxImpl implements VertxInternal, MetricsProvider { | |
this.deploymentManager = new DeploymentManager(this); | |
this.metrics = initialiseMetrics(options); | |
this.haEnabled = options.isClustered() && options.isHAEnabled(); | |
+ | |
if (options.isClustered()) { | |
this.clusterManager = getClusterManager(options); | |
this.clusterManager.setVertx(this); | |
@@ -202,6 +203,16 @@ public class VertxImpl implements VertxInternal, MetricsProvider { | |
} | |
} | |
+ @Override | |
+ public int getInstanceCount(String deploymentId) { | |
+ Deployment deployment = deploymentManager.getDeployment(deploymentId); | |
+ if (deployment != null) { | |
+ return deployment.deploymentOptions().getInstances(); | |
+ } | |
+ | |
+ return -1; | |
+ } | |
+ | |
/** | |
* @return The FileSystem implementation for the OS | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment