jubilee 2.0.0.alpha1-java → 2.0.0.beta-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a77c3b1eb92007a671a033614f6e9d6d180a7a39
4
- data.tar.gz: 35b271e8177901264b12c8de526237dcb5921e11
3
+ metadata.gz: eb61786745898bab811507f1d76d6bbdc77e5485
4
+ data.tar.gz: 03df7c9f9b145f2287a1b453aef1e1159a85a899
5
5
  SHA512:
6
- metadata.gz: d2d2f76613e7482d3244ffa51adc727459fd171ae3a710421733de3e6f2e5bb41a7f1da20b4113242a64453cf12b66b22ac2ab89269d92493b18a04ebc8565b9
7
- data.tar.gz: 5822d5d9c68560a83b73194f2d9e23e6819c423eabd780cd770c52ffa1c5a0abda8c59abef3a7bec1972c809c7350e9607bfefcc4c4879518bdc932e4be84fd4
6
+ metadata.gz: 707de86b4d5b2bda6e5a10726209642f7d703533b59e7b6069683efa4202b960213118a384771150f27d2fa4848547641abb273788f5d64397dee5ca247ac362
7
+ data.tar.gz: a2fa31e40c0dae6c7e4e023c3293c157fd54984530277bdc1c586abee40ed6f078ddf228067bf0de2a554d78686954a35c5bb489913018844e07180d0a509b56
@@ -2,4 +2,4 @@ source "https://rubygems.org"
2
2
  gem 'sinatra'
3
3
  gem 'haml'
4
4
 
5
- gem 'jubilee'
5
+ gem 'jubilee', '2.0.0.alpha1'
@@ -4,7 +4,7 @@ GEM
4
4
  ffi (1.9.3-java)
5
5
  haml (4.0.4)
6
6
  tilt
7
- jubilee (1.1.3-java)
7
+ jubilee (2.0.0.alpha1-java)
8
8
  rack (>= 1.4.1)
9
9
  spoon (~> 0.0.4)
10
10
  rack (1.5.2)
@@ -23,5 +23,5 @@ PLATFORMS
23
23
 
24
24
  DEPENDENCIES
25
25
  haml
26
- jubilee
26
+ jubilee (= 2.0.0.alpha1)
27
27
  sinatra
@@ -8,7 +8,7 @@ package org.jruby.jubilee;
8
8
  */
9
9
  public final class Const {
10
10
 
11
- public static final String JUBILEE_VERSION = "Jubilee(1.1.0)";
11
+ public static final String JUBILEE_VERSION = "Jubilee(2.0.0)";
12
12
  public static final String HTTP_11 = "HTTP/1.1";
13
13
  public static final String HTTP_10 = "HTTP/1.0";
14
14
 
@@ -50,7 +50,9 @@ public class JubileeVerticle extends Verticle {
50
50
  if (config.containsField("event_bus")) {
51
51
  JsonArray allowAll = new JsonArray();
52
52
  allowAll.add(new JsonObject());
53
- vertx.createSockJSServer(httpServer).bridge(config.getObject("event_bus"), allowAll, allowAll);
53
+ JsonObject ebconf = new JsonObject();
54
+ ebconf.putString("prefix", config.getString("event_bus"));
55
+ vertx.createSockJSServer(httpServer).bridge(ebconf, allowAll, allowAll);
54
56
  }
55
57
  if (ssl) httpServer.setSSL(true).setKeyStorePath(config.getString("keystore_path"))
56
58
  .setKeyStorePassword(config.getString("keystore_password"));
@@ -2,6 +2,7 @@ package org.jruby.jubilee;
2
2
 
3
3
  import org.jruby.*;
4
4
  import org.jruby.anno.JRubyMethod;
5
+ import org.jruby.jubilee.vertx.JubileeVertx;
5
6
  import org.jruby.runtime.ObjectAllocator;
6
7
  import org.jruby.runtime.ThreadContext;
7
8
  import org.jruby.runtime.builtin.IRubyObject;
@@ -11,6 +12,11 @@ import org.vertx.java.core.json.JsonObject;
11
12
  import org.vertx.java.platform.PlatformLocator;
12
13
  import org.vertx.java.platform.PlatformManager;
13
14
 
15
+ import java.net.Inet6Address;
16
+ import java.net.InetAddress;
17
+ import java.net.NetworkInterface;
18
+ import java.net.SocketException;
19
+ import java.util.Enumeration;
14
20
  import java.util.HashMap;
15
21
  import java.util.Map;
16
22
 
@@ -39,7 +45,23 @@ public class RubyPlatformManager extends RubyObject {
39
45
  @JRubyMethod
40
46
  public IRubyObject initialize(ThreadContext context, IRubyObject config) {
41
47
  RubyHash options = config.convertToHash();
42
- pm = PlatformLocator.factory.createPlatformManager();
48
+ Ruby runtime = context.runtime;
49
+ RubySymbol clustered_k = runtime.newSymbol("clustered");
50
+ RubySymbol cluster_host_k = runtime.newSymbol("cluster_host");
51
+ RubySymbol cluster_port_k = runtime.newSymbol("cluster_port");
52
+ if (options.containsKey(clustered_k) && options.op_aref(context, clustered_k).isTrue()) {
53
+ int clusterPort = 0;
54
+ String clusterHost = null;
55
+ if (options.containsKey(cluster_port_k))
56
+ clusterPort = RubyNumeric.num2int(options.op_aref(context, cluster_port_k));
57
+ if (options.containsKey(cluster_host_k))
58
+ clusterHost = options.op_aref(context, cluster_host_k).asJavaString();
59
+ if (clusterHost == null) clusterHost = getDefaultAddress();
60
+ pm = PlatformLocator.factory.createPlatformManager(clusterPort, clusterHost);
61
+ } else {
62
+ pm = PlatformLocator.factory.createPlatformManager();
63
+ }
64
+ JubileeVertx.init(pm.vertx());
43
65
  int ins = RubyNumeric.num2int(options.op_aref(context, RubySymbol.newSymbol(context.runtime, "instances")));
44
66
  pm.deployVerticle("org.jruby.jubilee.JubileeVerticle", new JsonObject(parseOptions(options)),
45
67
  context.runtime.getJRubyClassLoader().getURLs(), ins, null, new AsyncResultHandler<String>() {
@@ -99,4 +121,30 @@ public class RubyPlatformManager extends RubyObject {
99
121
  map.put("ruby", runtime);
100
122
  return map;
101
123
  }
124
+ /*
125
+ Get default interface to use since the user hasn't specified one
126
+ */
127
+ private String getDefaultAddress() {
128
+ Enumeration<NetworkInterface> nets;
129
+ try {
130
+ nets = NetworkInterface.getNetworkInterfaces();
131
+ } catch (SocketException e) {
132
+ return null;
133
+ }
134
+ NetworkInterface netinf;
135
+ while (nets.hasMoreElements()) {
136
+ netinf = nets.nextElement();
137
+
138
+ Enumeration<InetAddress> addresses = netinf.getInetAddresses();
139
+
140
+ while (addresses.hasMoreElements()) {
141
+ InetAddress address = addresses.nextElement();
142
+ if (!address.isAnyLocalAddress() && !address.isMulticastAddress()
143
+ && !(address instanceof Inet6Address)) {
144
+ return address.getHostAddress();
145
+ }
146
+ }
147
+ }
148
+ return null;
149
+ }
102
150
  }
@@ -1,7 +1,6 @@
1
1
  package org.jruby.jubilee.vertx;
2
2
 
3
3
  import org.vertx.java.core.Vertx;
4
- import org.vertx.java.core.VertxFactory;
5
4
 
6
5
  /**
7
6
  * Created with IntelliJ IDEA.
@@ -13,24 +12,14 @@ public class JubileeVertx {
13
12
  public static Vertx vertx;
14
13
  private JubileeVertx() {
15
14
  }
16
- public static synchronized Vertx init(int port, String host) {
17
- if (JubileeVertx.vertx != null) return vertx;
18
- JubileeVertx.vertx = VertxFactory.newVertx(port, host);
19
- return JubileeVertx.vertx;
20
- }
21
- public static synchronized Vertx init(String host) {
22
- if (JubileeVertx.vertx != null) return vertx;
23
- JubileeVertx.vertx = VertxFactory.newVertx(host);
24
- return JubileeVertx.vertx;
25
- }
26
- public static synchronized Vertx init() {
27
- if (JubileeVertx.vertx != null) return vertx;
28
- JubileeVertx.vertx = VertxFactory.newVertx();
29
- return JubileeVertx.vertx;
15
+
16
+ public static void init(Vertx vertx) {
17
+ JubileeVertx.vertx = vertx;
30
18
  }
31
19
 
32
20
  public synchronized static Vertx vertx() {
33
- if (JubileeVertx.vertx == null) init();
21
+ if (JubileeVertx.vertx == null)
22
+ throw new RuntimeException("vertx is not initialized, do you run in jubilee server?");
34
23
  return JubileeVertx.vertx;
35
24
  }
36
25
  }
data/lib/jubilee/cli.rb CHANGED
@@ -107,7 +107,7 @@ module Jubilee
107
107
  o.separator ""
108
108
  o.separator "Clustering options:"
109
109
  o.on "--cluster", "Enable clustering" do
110
- @options[:cluster_host] = "0.0.0.0"
110
+ @options[:clustered] = true
111
111
  end
112
112
  o.on "--cluster-port PORT", "If the cluster option has also been specified then this determines which port will be used for cluster communication with other Vert.x instances. Default is 0 -which means 'chose a free ephemeral port. You don't usually need to specify this parameter unless you really need to bind to a specific port." do |port|
113
113
  @options[:cluster_port] = port.to_i
@@ -16,17 +16,6 @@ module Jubilee
16
16
  @block = block
17
17
 
18
18
  reload
19
- # initialize vertx as early as possible
20
- # XXX vertx is managed by PlatformManager now
21
- if chost = @options[:cluster_host]
22
- if cport = @options[:cluster_port]
23
- org.jruby.jubilee.vertx.JubileeVertx.init(cport.to_java(:int), chost.to_java)
24
- else
25
- org.jruby.jubilee.vertx.JubileeVertx.init(chost.to_java)
26
- end
27
- else
28
- org.jruby.jubilee.vertx.JubileeVertx.init()
29
- end
30
19
  end
31
20
 
32
21
  def reload
Binary file
@@ -3,7 +3,7 @@ module Jubilee
3
3
  MAJOR = 2
4
4
  MINOR = 0
5
5
  PATCH = 0
6
- BUILD = "alpha1"
6
+ BUILD = "beta"
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jubilee
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.alpha1
4
+ version: 2.0.0.beta
5
5
  platform: java
6
6
  authors:
7
7
  - Isaiah Peng
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-25 00:00:00.000000000 Z
11
+ date: 2014-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack