Permalink
Browse files

redeployer

  • Loading branch information...
purplefox committed Jul 27, 2012
2 parents d7598b9 + 353668f commit 2899b5347dc8dd5a60fada1e908d7d4a52ffc945
Showing with 878 additions and 163 deletions.
  1. +7 −0 vertx-examples/src/main/javascript/redeploy/mods/test-mod1/app.js
  2. +4 −0 vertx-examples/src/main/javascript/redeploy/mods/test-mod1/mod.json
  3. +7 −0 vertx-examples/src/main/modtest/mods/barmod/app.js
  4. +3 −0 vertx-examples/src/main/modtest/mods/barmod/mod.json
  5. +11 −0 vertx-examples/src/main/modtest/mods/foomod/app.js
  6. +3 −0 vertx-examples/src/main/modtest/mods/foomod/mod.json
  7. +3 −0 vertx-examples/src/main/modtest/mods/foomod/mod.json~
  8. +0 −1 vertx-examples/src/main/python/webapp/static_data.py
  9. +2 −8 ...ertx-lang-groovy/src/main/groovy/org/vertx/groovy/deploy/impl/groovy/GroovyVerticleFactory.groovy
  10. +3 −0 vertx-lang/vertx-lang-java/src/main/java/org/vertx/java/deploy/impl/java/JavaVerticleFactory.java
  11. +2 −4 vertx-lang/vertx-lang-jython/src/main/java/org/vertx/java/deploy/impl/jython/JythonVerticle.java
  12. +0 −4 ...lang/vertx-lang-jython/src/main/java/org/vertx/java/deploy/impl/jython/JythonVerticleFactory.java
  13. +0 −1 vertx-lang/vertx-lang-jython/src/main/python_scripts/core/handlers.py
  14. +0 −2 vertx-lang/vertx-lang-jython/src/main/python_scripts/core/javautils.py
  15. +0 −1 vertx-lang/vertx-lang-jython/src/main/python_scripts/core/net.py
  16. +2 −2 vertx-platform/src/main/java/org/vertx/java/deploy/Container.java
  17. +2 −2 vertx-platform/src/main/java/org/vertx/java/deploy/VerticleFactory.java
  18. +60 −0 vertx-platform/src/main/java/org/vertx/java/deploy/impl/CountingCompletionHandler.java
  19. +56 −0 vertx-platform/src/main/java/org/vertx/java/deploy/impl/Deployment.java
  20. +10 −0 vertx-platform/src/main/java/org/vertx/java/deploy/impl/ModuleReloader.java
  21. +283 −0 vertx-platform/src/main/java/org/vertx/java/deploy/impl/Redeployer.java
  22. +51 −0 vertx-platform/src/main/java/org/vertx/java/deploy/impl/VerticleHolder.java
  23. +116 −125 vertx-platform/src/main/java/org/vertx/java/deploy/impl/VerticleManager.java
  24. +2 −2 vertx-platform/src/main/java/org/vertx/java/deploy/impl/cli/Starter.java
  25. +4 −5 vertx-testframework/src/main/java/org/vertx/java/framework/TestBase.java
  26. +247 −0 vertx-testsuite/src/test/java/org/vertx/java/tests/core/redeploy/RedeployerTest.java
  27. +0 −1 vertx-testsuite/src/test/python_scripts/core/buffer/test_client.py
  28. +0 −1 vertx-testsuite/src/test/python_scripts/core/filesystem/test_client.py
  29. +0 −1 vertx-testsuite/src/test/python_scripts/core/isolation/test_client.py
  30. +0 −1 vertx-testsuite/src/test/python_scripts/core/parsetools/test_client.py
  31. +0 −1 vertx-testsuite/src/test/python_scripts/core/scriptloading/test_client.py
  32. +0 −1 vertx-testsuite/src/test/python_scripts/core/shareddata/test_client.py
@@ -0,0 +1,7 @@
+load("vertx.js")
+
+console.log("in test-mod1");
+
+vertx.createHttpServer().requestHandler(function(req) {
+ req.response.end("<html><body><h1>Hello from vert.x!</h1></body></html>");
+}).listen(8080, 'localhost');
@@ -0,0 +1,4 @@
+{
+ "main": "app.js",
+ "auto-redeploy": true
+}
@@ -0,0 +1,7 @@
+load('vertx.js')
+
+console.log("barmod loaded");
+
+function vertxStop() {
+ console.log("barmod unloaded");
+}
@@ -0,0 +1,3 @@
+{
+"main":"app.js"
+}
@@ -0,0 +1,11 @@
+load('vertx.js')
+
+console.log("in foomod");
+
+vertx.deployModule('barmod', null, 1, function(depID) {
+ vertx.setTimer(1000, function() {
+ vertx.undeployModule(depID);
+ })
+});
+
+
@@ -0,0 +1,3 @@
+{
+"main":"app.js"
+}
@@ -0,0 +1,3 @@
+{
+main:"app.js"
+}
@@ -1,4 +1,3 @@
-import vertx
from core.event_bus import EventBus
eb = EventBus
@@ -16,20 +16,14 @@
package org.vertx.groovy.deploy.impl.groovy
-import groovy.lang.Binding
-import groovy.lang.GroovyClassLoader
-import groovy.lang.GroovyCodeSource
-import groovy.lang.Script
+import java.lang.reflect.Method
import org.vertx.groovy.core.Vertx
import org.vertx.groovy.deploy.Container
import org.vertx.java.core.impl.VertxInternal
import org.vertx.java.deploy.Verticle
import org.vertx.java.deploy.VerticleFactory
-import org.vertx.java.deploy.impl.VertxLocator
import org.vertx.java.deploy.impl.VerticleManager
-
-import java.lang.reflect.Method
-import java.net.URL
+import org.vertx.java.deploy.impl.VertxLocator
/**
* @author <a href="http://tfox.org">Tim Fox</a>
@@ -60,6 +60,9 @@ private boolean isJavaSource(String main) {
}
public Verticle createVerticle(String main, ClassLoader loader) throws Exception {
+
+ System.out.println("creating verticle " + main);
+
ClassLoader cl = loader;
String className = main;
if (isJavaSource(main)) {
@@ -16,11 +16,9 @@
package org.vertx.java.deploy.impl.jython;
-import org.python.util.PythonInterpreter;
-import org.python.core.PyException;
-import org.python.core.PySystemState;
import org.python.core.Options;
-
+import org.python.core.PySystemState;
+import org.python.util.PythonInterpreter;
import org.vertx.java.core.logging.Logger;
import org.vertx.java.core.logging.impl.LoggerFactory;
import org.vertx.java.deploy.Verticle;
@@ -16,14 +16,10 @@
package org.vertx.java.deploy.impl.jython;
-import org.vertx.java.core.logging.Logger;
import org.vertx.java.deploy.Verticle;
import org.vertx.java.deploy.VerticleFactory;
import org.vertx.java.deploy.impl.VerticleManager;
-
-import java.util.List;
-
/**
* @author <a href="https://github.com/sjhorn">Scott Horn</a>
*/
@@ -15,7 +15,6 @@
import org.vertx.java.core.Handler
from core.buffer import Buffer
-from core.javautils import map_from_java, map_to_java
__author__ = "Scott Horn"
__email__ = "scott@hornmicro.com"
@@ -21,9 +21,7 @@
import sys
from types import *
-from java import lang
from java import util
-from java import io
__author__ = "Scott Horn"
__email__ = "scott@hornmicro.com"
@@ -23,7 +23,6 @@
import core.buffer
import core.streams
-from core.javautils import map_from_java, map_to_java
from core.handlers import CloseHandler, DoneHandler, ClosedHandler
from core.event_bus import EventBus
@@ -89,7 +89,7 @@ public void deployWorkerVerticle(String main, JsonObject config, int instances)
public void deployWorkerVerticle(String main, JsonObject config, int instances, Handler<String> doneHandler) {
URL[] currURLs = mgr.getDeploymentURLs();
File modDir = mgr.getDeploymentModDir();
- mgr.deploy(true, main, config, currURLs, instances, modDir, doneHandler);
+ mgr.deployVerticle(true, main, config, currURLs, instances, modDir, doneHandler);
}
/**
@@ -186,7 +186,7 @@ public void deployVerticle(String main, JsonObject config, int instances) {
public void deployVerticle(String main, JsonObject config, int instances, Handler<String> doneHandler) {
URL[] currURLs = mgr.getDeploymentURLs();
File modDir = mgr.getDeploymentModDir();
- mgr.deploy(false, main, config, currURLs, instances, modDir, doneHandler);
+ mgr.deployVerticle(false, main, config, currURLs, instances, modDir, doneHandler);
}
/**
@@ -17,10 +17,10 @@
package org.vertx.java.deploy;
-import java.util.ServiceLoader;
-
import org.vertx.java.deploy.impl.VerticleManager;
+import java.util.ServiceLoader;
+
/**
* @author <a href="http://tfox.org">Tim Fox</a>
*/
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011-2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.vertx.java.deploy.impl;
+
+import org.vertx.java.core.Handler;
+import org.vertx.java.core.impl.Context;
+
+/**
+ * @author <a href="http://tfox.org">Tim Fox</a>
+ */
+public class CountingCompletionHandler {
+
+ private final Context context;
+
+ CountingCompletionHandler(Context context) {
+ this.context = context;
+ }
+
+ int count;
+ int required;
+ Handler<Void> doneHandler;
+
+ synchronized void complete() {
+ count++;
+ checkDone();
+ }
+
+ synchronized void incRequired() {
+ required++;
+ }
+
+ synchronized void setHandler(Handler<Void> doneHandler) {
+ this.doneHandler = doneHandler;
+ checkDone();
+ }
+
+ void checkDone() {
+ if (doneHandler != null && count == required) {
+ context.execute(new Runnable() {
+ public void run() {
+ doneHandler.handle(null);
+ }
+ });
+ }
+ }
+}
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2011-2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.vertx.java.deploy.impl;
+
+import org.vertx.java.core.json.JsonObject;
+import org.vertx.java.deploy.VerticleFactory;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="http://tfox.org">Tim Fox</a>
+ */
+public class Deployment {
+ public final String name;
+ public final String modName;
+ public final int instances;
+ public final VerticleFactory factory;
+ public final JsonObject config;
+ public final URL[] urls;
+ public final File modDir;
+ public final List<VerticleHolder> verticles = new ArrayList<>();
+ public final List<String> childDeployments = new ArrayList<>();
+ public final String parentDeploymentName;
+ public final boolean autoRedeploy;
+
+ public Deployment(String name, String modName, int instances, VerticleFactory factory, JsonObject config,
+ URL[] urls, File modDir, String parentDeploymentName,
+ boolean autoRedeploy) {
+ this.name = name;
+ this.modName = modName;
+ this.instances = instances;
+ this.factory = factory;
+ this.config = config;
+ this.urls = urls;
+ this.modDir = modDir;
+ this.parentDeploymentName = parentDeploymentName;
+ this.autoRedeploy = autoRedeploy;
+ }
+}
@@ -0,0 +1,10 @@
+package org.vertx.java.deploy.impl;
+
+import java.util.Set;
+
+/**
+ * @author <a href="http://tfox.org">Tim Fox</a>
+ */
+public interface ModuleReloader {
+ void reloadModules(Set<Deployment> parents);
+}
Oops, something went wrong.

0 comments on commit 2899b53

Please sign in to comment.