jubilee 1.1.0-java → 1.1.2-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 962679d3298e64379fab6c97420d891b247fab19
4
- data.tar.gz: ce3372e3ee9fc1a9b560f3f4e19ab505127848b7
3
+ metadata.gz: c16cf766d7efe95d751c3632278689d12f7e291d
4
+ data.tar.gz: 998dc3e19d08b137d4544c4df3cf1e6bd65eb0f2
5
5
  SHA512:
6
- metadata.gz: 2e64bb1443a88d24451f2ff4001c5efcb49d64fe28bdd4c6ea2b998e492b646c7f0c277a836a44fd09b81e497b83ee8a7c983d07bbedd2d36f464bbf9de1afd3
7
- data.tar.gz: c0b37d5dbc739f36e5345ad19b60cb8f6fa4fed6e9508e4b73685c29cca67f41c2e13ebb5cb44f4db9be6fd4097931c3699760af8fc05bbfbbcaf72554d81935
6
+ metadata.gz: f5b84abe8c288243b2f22718cc612b1d04a66458a3d31846b90011aff2b86acfa0c5f9e1d7e92be93d706f5df3c794d526969ffa3ac096dceaad2e51f12bb7c8
7
+ data.tar.gz: 7e4845162385349ba33158c10bde3f0be547068b1f0191b484998fa18ccd6bbb4d99c93d872daf921ac8248910cebd7de3900acf6594eecf61966b4109e82653
data/CHANGELOG CHANGED
@@ -1,3 +1,31 @@
1
+ Release 1.1.1
2
+ =============
3
+
4
+ fix clustering
5
+ enable loading options from config file
6
+
7
+ Release 1.1.0
8
+ =============
9
+
10
+ exit gracefully if java version is not supported.
11
+ fix inifinite loop in RackInput #gets and #each
12
+ change jruby requirement to 1.7.5
13
+ monkey patch Rack::Chunked::Body so that rails won't chunk it's streaming body.
14
+ server name change to constant
15
+ add HTTP_VERSION rack header
16
+ fix multiple value header
17
+ change default port to 8080
18
+ add lazy rack environment hash from wunderboss
19
+ Date header moved to vertx
20
+ update vertx: keep-alive if http 1.1 and not requested to closed connection, or http 1.0 and requested to do so, otherwise close connection
21
+ add 'Date' and 'Server' http general header
22
+ set bodybuf max capacity
23
+ remove worker_threads option since vertx can scale itself
24
+ replace scaffold implementation of rackIOError with RubyIO
25
+ instead of allocate a new class every time initialize a RubyIORackInput class, get the one from runtime.
26
+ update vertx to 2.1M3-SNAPSHOT
27
+
28
+
1
29
  Release 1.0.2
2
30
  =============
3
31
 
data/Rakefile CHANGED
@@ -33,6 +33,7 @@ Jeweler::Tasks.new do |gem|
33
33
  gem.authors = ["Isaiah Peng"]
34
34
  gem.version = Jubilee::Version::STRING
35
35
  gem.platform = "java"
36
+ gem.files.include "lib/jubilee/jubilee.jar"
36
37
  # dependencies defined in Gemfile
37
38
  end
38
39
  Jeweler::RubygemsDotOrgTasks.new
@@ -68,7 +69,10 @@ end
68
69
 
69
70
  require 'ant'
70
71
 
71
- directory "pkg/classes"
72
+ DEST_PATH = "pkg/classes"
73
+ RESOURCE_PATH = "java/resources"
74
+
75
+ directory DEST_PATH
72
76
 
73
77
  desc "Clean up build artifacts"
74
78
  task :clean do
@@ -79,17 +83,23 @@ end
79
83
  BUILDTIME_LIB_DIR = File.join(File.dirname(__FILE__), "jars")
80
84
 
81
85
  desc "Compile the extension, need jdk7 because vertx relies on it"
82
- task :compile => "pkg/classes" do |t|
86
+ task :compile => [DEST_PATH, "#{DEST_PATH}/META-INF"] do |t|
83
87
  ant.javac :srcdir => "java", :destdir => t.prerequisites.first,
84
- :source => "1.7", :target => "1.7", :debug => true,
88
+ :source => "1.7", :target => "1.7", :debug => true, :includeantruntime => false,
85
89
  :classpath => "${java.class.path}:${sun.boot.class.path}:jars/vertx-core-2.1M3-SNAPSHOT.jar:jars/netty-all-4.0.13.Final.jar:jars/jackson-core-2.2.2.jar:jars/jackson-databind-2.2.2.jar:jars/jackson-annotations-2.2.2.jar:jars/hazelcast-2.6.3.jar"
86
90
  end
87
91
 
92
+ desc "Copy META-INF"
93
+ task "#{DEST_PATH}/META-INF" => ["#{RESOURCE_PATH}/META-INF", "#{RESOURCE_PATH}/default-cluster.xml"] do |t|
94
+ FileUtils.cp_r t.prerequisites.first, t.name, verbose: true
95
+ cp t.prerequisites[1], DEST_PATH, verbose: true
96
+ end
97
+
88
98
  desc "Build the jar"
89
99
  task :jar => [:clean, :compile] do
90
- ant.jar :basedir => "pkg/classes", :destfile => "lib/jubilee/jubilee.jar", :includes => "**/*.class"
100
+ ant.jar :basedir => "pkg/classes", :destfile => "lib/jubilee/jubilee.jar"
91
101
  end
92
-
102
+
93
103
  task :build => :jar
94
104
 
95
105
  desc "Run the specs"
@@ -2,4 +2,4 @@ source "https://rubygems.org"
2
2
  gem 'sinatra'
3
3
  gem 'haml'
4
4
 
5
- gem 'jubilee', '1.1.0.rc2'
5
+ gem 'jubilee'
@@ -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.0.rc2)
7
+ jubilee (1.1.1-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 (= 1.1.0.rc2)
26
+ jubilee
27
27
  sinatra
@@ -12,7 +12,7 @@ Vertx::EventBus.register_handler('logout') do |message|
12
12
  Vertx::SharedData.get_set(:users).delete(message.body)
13
13
  end
14
14
 
15
- # register the user and return the pervious users
15
+ # register the user and return the previous users
16
16
  Vertx::EventBus.register_handler('login') do |message|
17
17
  user = message.body
18
18
  users = Vertx::SharedData.get_set(:users).add(user)
@@ -1,12 +1,17 @@
1
1
  # Listen to port 3000
2
2
  listen 3000
3
3
 
4
- # the ssl certification path
5
- ssl_keystore "jubilee/keystore.jks"
4
+ # enable https mode
5
+ ssl keystore: "keystore.jks", password: "hellojubilee"
6
6
 
7
- # the ssl certification key
8
- ssl_password "helloworld"
7
+ # the directory where the rack app seats in
8
+ working_directory "chatapp"
9
9
 
10
- pid "tmp/jubilee.pid"
11
- stderr_path "log/jubilee.stderr.log"
12
- stdout_path "log/jubilee.stdout.log"
10
+ # rack environment
11
+ environment "development"
12
+
13
+ eventbus "/eventbus", inbound: [{}], outbound: [{}]
14
+
15
+ clustering true
16
+
17
+ debug true
Binary file
Binary file
@@ -0,0 +1 @@
1
+ org.vertx.java.spi.cluster.impl.hazelcast.HazelcastClusterManagerFactory
@@ -0,0 +1,133 @@
1
+ <hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-basic.xsd"
2
+ xmlns="http://www.hazelcast.com/schema/config"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4
+ <properties>
5
+ <property name="hazelcast.mancenter.enabled">false</property>
6
+ <property name="hazelcast.memcache.enabled">false</property>
7
+ <property name="hazelcast.rest.enabled">false</property>
8
+ <property name="hazelcast.wait.seconds.before.join">0</property>
9
+ <property name="hazelcast.logging.type">jdk</property>
10
+ </properties>
11
+ <group>
12
+ <name>dev</name>
13
+ <password>dev-pass</password>
14
+ </group>
15
+ <network>
16
+ <port auto-increment="true">5701</port>
17
+ <join>
18
+ <multicast enabled="true">
19
+ <multicast-group>224.2.2.3</multicast-group>
20
+ <multicast-port>54327</multicast-port>
21
+ </multicast>
22
+ <tcp-ip enabled="false">
23
+ <interface>192.168.1.28</interface>
24
+ </tcp-ip>
25
+ <aws enabled="false">
26
+ <access-key>my-access-key</access-key>
27
+ <secret-key>my-secret-key</secret-key>
28
+ <region>us-east-1</region>
29
+ </aws>
30
+ </join>
31
+ <!--
32
+ If you have more than one network interface, edit this to select which
33
+ one you want to use
34
+ <interfaces enabled="true">
35
+ <interface>192.168.1.16</interface>
36
+ </interfaces>
37
+ -->
38
+
39
+ <symmetric-encryption enabled="false">
40
+ <!--
41
+ encryption algorithm such as DES/ECB/PKCS5Padding, PBEWithMD5AndDES,
42
+ AES/CBC/PKCS5Padding, Blowfish, DESede
43
+ -->
44
+ <algorithm>PBEWithMD5AndDES</algorithm>
45
+ <!-- salt value to use when generating the secret key -->
46
+ <salt>thesalt</salt>
47
+ <!-- pass phrase to use when generating the secret key -->
48
+ <password>thepass</password>
49
+ <!-- iteration count to use when generating the secret key -->
50
+ <iteration-count>19</iteration-count>
51
+ </symmetric-encryption>
52
+ <asymmetric-encryption enabled="false">
53
+ <!-- encryption algorithm -->
54
+ <algorithm>RSA/NONE/PKCS1PADDING</algorithm>
55
+ <!-- private key password -->
56
+ <keyPassword>thekeypass</keyPassword>
57
+ <!-- private key alias -->
58
+ <keyAlias>local</keyAlias>
59
+ <!-- key store type -->
60
+ <storeType>JKS</storeType>
61
+ <!-- key store password -->
62
+ <storePassword>thestorepass</storePassword>
63
+ <!-- path to the key store -->
64
+ <storePath>keystore</storePath>
65
+ </asymmetric-encryption>
66
+ </network>
67
+ <executor-service>
68
+ <core-pool-size>4</core-pool-size>
69
+ <max-pool-size>20</max-pool-size>
70
+ <keep-alive-seconds>60</keep-alive-seconds>
71
+ </executor-service>
72
+ <map name="subs">
73
+ <!--
74
+ Number of backups. If 1 is set as the backup-count for example, then all entries of
75
+ the map will be copied to another JVM for fail-safety. 0 means no backup.
76
+ -->
77
+ <backup-count>1</backup-count>
78
+ <!--
79
+ Maximum number of seconds for each entry to stay in the map. Entries that are
80
+ older than <time-to-live-seconds> and not updated for <time-to-live-seconds>
81
+ will get automatically evicted from the map.
82
+ Any integer between 0 and Integer.MAX_VALUE. 0 means infinite. Default is 0.
83
+ -->
84
+ <time-to-live-seconds>0</time-to-live-seconds>
85
+ <!--
86
+ Maximum number of seconds for each entry to stay idle in the map. Entries that are
87
+ idle(not touched) for more than <max-idle-seconds> will get
88
+ automatically evicted from the map. Entry is touched if get, put or containsKey is called.
89
+ Any integer between 0 and Integer.MAX_VALUE. 0 means infinite. Default is 0.
90
+ -->
91
+ <max-idle-seconds>0</max-idle-seconds>
92
+ <!--
93
+ Valid values are:
94
+ NONE (no eviction),
95
+ LRU (Least Recently Used),
96
+ LFU (Least Frequently Used).
97
+ NONE is the default.
98
+ -->
99
+ <eviction-policy>NONE</eviction-policy>
100
+ <!--
101
+ Maximum size of the map. When max size is reached,
102
+ map is evicted based on the policy defined.
103
+ Any integer between 0 and Integer.MAX_VALUE. 0 means
104
+ Integer.MAX_VALUE. Default is 0.
105
+ -->
106
+ <max-size policy="cluster_wide_map_size">0</max-size>
107
+ <!--
108
+ When max. size is reached, specified percentage of
109
+ the map will be evicted. Any integer between 0 and 100.
110
+ If 25 is set for example, 25% of the entries will
111
+ get evicted.
112
+ -->
113
+ <eviction-percentage>25</eviction-percentage>
114
+ <!--
115
+ While recovering from split-brain (network partitioning),
116
+ map entries in the small cluster will merge into the bigger cluster
117
+ based on the policy set here. When an entry merge into the
118
+ cluster, there might an existing entry with the same key already.
119
+ Values of these entries might be different for that same key.
120
+ Which value should be set for the key? Conflict is resolved by
121
+ the policy set here. Default policy is hz.ADD_NEW_ENTRY
122
+
123
+ There are built-in merge policies such as
124
+ hz.NO_MERGE ; no entry will merge.
125
+ hz.ADD_NEW_ENTRY ; entry will be added if the merging entry's key
126
+ doesn't exist in the cluster.
127
+ hz.HIGHER_HITS ; entry with the higher hits wins.
128
+ hz.LATEST_UPDATE ; entry with the latest update wins.
129
+ -->
130
+ <merge-policy>hz.LATEST_UPDATE</merge-policy>
131
+
132
+ </map>
133
+ </hazelcast>
@@ -27,8 +27,6 @@ public class RubyServer extends RubyObject {
27
27
  private String eventBusPrefix;
28
28
  private int port;
29
29
  private String host;
30
- private int clusterPort;
31
- private String clusterHost;
32
30
 
33
31
  public static void createServerClass(Ruby runtime) {
34
32
  RubyModule mJubilee = runtime.defineModule("Jubilee");
@@ -62,36 +60,25 @@ public class RubyServer extends RubyObject {
62
60
  RubyHash options = config.convertToHash();
63
61
  RubySymbol port_k = runtime.newSymbol("Port");
64
62
  RubySymbol host_k = runtime.newSymbol("Host");
65
- RubySymbol cluster_port_k = runtime.newSymbol("cluster_port");
66
- RubySymbol cluster_host_k = runtime.newSymbol("cluster_host");
67
63
  RubySymbol ssl_k = runtime.newSymbol("ssl");
68
- RubySymbol keystore_path_k = runtime.newSymbol("keystore_path");
69
- RubySymbol keystore_password_k = runtime.newSymbol("keystore_password");
64
+ RubySymbol ssl_keystore_k = runtime.newSymbol("ssl_keystore");
65
+ RubySymbol ssl_password_k = runtime.newSymbol("ssl_password");
70
66
  RubySymbol eventbus_prefix_k = runtime.newSymbol("eventbus_prefix");
71
67
 
72
68
  /* retrieve from passed in options */
73
- this.port = Integer.parseInt(options.op_aref(context, port_k).toString());
74
- this.host = options.op_aref(context, host_k).toString();
69
+ this.port = RubyNumeric.num2int(options.op_aref(context, port_k));
70
+ this.host = options.op_aref(context, host_k).asJavaString();
75
71
 
76
72
  this.ssl = options.op_aref(context, ssl_k).isTrue();
77
- if (options.has_key_p(keystore_path_k).isTrue()) {
78
- this.keyStorePath = options.op_aref(context, keystore_path_k).toString();
79
- this.keyStorePassword = options.op_aref(context, keystore_password_k).toString();
73
+ if (this.ssl) {
74
+ this.keyStorePath = options.op_aref(context, ssl_keystore_k).asJavaString();
75
+ if (options.has_key_p(ssl_password_k).isTrue())
76
+ this.keyStorePassword = options.op_aref(context, ssl_password_k).asJavaString();
80
77
  }
81
78
  if (options.has_key_p(eventbus_prefix_k).isTrue())
82
- this.eventBusPrefix = options.op_aref(context, eventbus_prefix_k).toString();
79
+ this.eventBusPrefix = options.op_aref(context, eventbus_prefix_k).asJavaString();
83
80
 
84
- /* init vertx */
85
- if (options.has_key_p(cluster_host_k).isTrue()) {
86
- this.clusterHost = options.op_aref(context, cluster_host_k).toString();
87
- if (options.has_key_p(cluster_port_k).isTrue()) {
88
- this.clusterPort = Integer.parseInt(options.op_aref(context, cluster_port_k).toString());
89
- this.vertx = JubileeVertx.init(clusterPort, clusterHost);
90
- }
91
- this.vertx = JubileeVertx.init(clusterHost);
92
- } else {
93
- this.vertx = JubileeVertx.init();
94
- }
81
+ this.vertx = JubileeVertx.vertx();
95
82
 
96
83
  httpServer = vertx.createHttpServer();
97
84
  try {
@@ -2,8 +2,6 @@ package org.jruby.jubilee.vertx;
2
2
 
3
3
  import org.vertx.java.core.Vertx;
4
4
  import org.vertx.java.core.VertxFactory;
5
- import org.vertx.java.core.eventbus.EventBus;
6
- import org.vertx.java.core.shareddata.SharedData;
7
5
 
8
6
  /**
9
7
  * Created with IntelliJ IDEA.
@@ -12,27 +10,27 @@ import org.vertx.java.core.shareddata.SharedData;
12
10
  * Time: 15:24
13
11
  */
14
12
  public class JubileeVertx {
15
- public static Vertx vertx;
16
- private JubileeVertx() {
17
- }
18
- public static synchronized Vertx init(int port, String host) {
19
- if (vertx != null) return vertx;
20
- vertx = VertxFactory.newVertx(port, host);
21
- return vertx;
22
- }
23
- public static synchronized Vertx init(String host) {
24
- if (vertx != null) return vertx;
25
- vertx = VertxFactory.newVertx(host);
26
- return vertx;
27
- }
28
- public static synchronized Vertx init() {
29
- if (vertx != null) return vertx;
30
- vertx = VertxFactory.newVertx();
31
- return vertx;
32
- }
13
+ public static Vertx vertx;
14
+ private JubileeVertx() {
15
+ }
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;
30
+ }
33
31
 
34
- public synchronized static Vertx vertx() {
35
- if (vertx == null) init();
36
- return vertx;
37
- }
32
+ public synchronized static Vertx vertx() {
33
+ if (JubileeVertx.vertx == null) init();
34
+ return JubileeVertx.vertx;
35
+ }
38
36
  }
data/lib/jubilee/cli.rb CHANGED
@@ -51,9 +51,8 @@ module Jubilee
51
51
  @options = {
52
52
  debug: false,
53
53
  daemon: false,
54
- Port: 8080,
55
- Host: "0.0.0.0",
56
54
  ssl: false,
55
+ Port: 8080,
57
56
  environment: ENV["RACK_ENV"] || "development"
58
57
  }
59
58
  @parser = OptionParser.new do |o|
@@ -72,7 +71,7 @@ module Jubilee
72
71
  o.on "-p", "--port PORT", "Defind which PORT the server should bind" do |arg|
73
72
  @options[:Port] = arg.to_i
74
73
  end
75
- o.on "--host HOST", "Defind which HOST the server should bind, default 0.0.0.0" do |arg|
74
+ o.on "-b", "--host HOST", "Defind which HOST the server should bind, default 0.0.0.0" do |arg|
76
75
  @options[:Host] = arg
77
76
  end
78
77
  o.on "-e", "--environment ENV", "Rack environment" do |arg|
@@ -84,10 +83,10 @@ module Jubilee
84
83
  @options[:ssl] = true
85
84
  end
86
85
  o.on "--ssl-keystore PATH", "SSL keystore path" do |arg|
87
- @options[:keystore_path] = arg
86
+ @options[:ssl_keystore] = arg
88
87
  end
89
88
  o.on "--ssl-password PASS", "SSL keystore password" do |arg|
90
- @options[:keystore_password] = arg
89
+ @options[:ssl_keystore] = arg
91
90
  end
92
91
  o.separator ""
93
92
  o.separator "Event bus options:"
@@ -100,10 +99,10 @@ module Jubilee
100
99
  o.on "--cluster", "Enable clustering" do
101
100
  @options[:cluster_host] = "0.0.0.0"
102
101
  end
103
- o.on "--cluster-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|
104
- @options[:cluster_host] = port
102
+ 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|
103
+ @options[:cluster_port] = port.to_i
105
104
  end
106
- o.on "--cluster-host", "If the cluster option has also been specified then this determines which host address will be used for cluster communication with other Vert.x instances. By default it will try and pick one from the available interfaces. If you have more than one interface and you want to use a specific one, specify it here." do |host|
105
+ o.on "--cluster-host HOST", "If the cluster option has also been specified then this determines which host address will be used for cluster communication with other Vert.x instances. By default it will try and pick one from the available interfaces. If you have more than one interface and you want to use a specific one, specify it here." do |host|
107
106
  @options[:cluster_host] = host
108
107
  end
109
108
 
@@ -112,7 +111,7 @@ module Jubilee
112
111
  o.on "--verbose", "Log low level debug information" do
113
112
  @options[:debug] = true
114
113
  end
115
- o.on "-q", "--quiet" do
114
+ o.on "-q", "--quiet", "Disable logging" do
116
115
  @options[:quiet] = true
117
116
  end
118
117
  end
@@ -16,6 +16,16 @@ module Jubilee
16
16
  @block = block
17
17
 
18
18
  reload
19
+ # initialize vertx as early as possible
20
+ if chost = @options[:cluster_host]
21
+ if cport = @options[:cluster_port]
22
+ org.jruby.jubilee.vertx.JubileeVertx.init(cport.to_java(:int), chost.to_java)
23
+ else
24
+ org.jruby.jubilee.vertx.JubileeVertx.init(chost.to_java)
25
+ end
26
+ else
27
+ org.jruby.jubilee.vertx.JubileeVertx.init()
28
+ end
19
29
  end
20
30
 
21
31
  def reload
@@ -39,29 +49,28 @@ module Jubilee
39
49
  # listen "127.0.0.1:3000" # listen to port 3000 on the loopback interface
40
50
  # listen "[::1]:3000" # listen to port 3000 on the IPv6 loopback interface
41
51
  def listen(address)
42
- @options[:host], @options[:port] = expand_addr(address)
52
+ @options[:Host], @options[:Port] = expand_addr(address, :listen)
43
53
  end
44
54
 
45
55
  # sets the working directory for jubilee
46
56
  def working_directory(path)
47
- path = File.expand_path(path)
48
- if config_file && config_file[0] != ?/ && ! File.readable?("#{path}/#{config_file}")
49
- raise ArgumentError,
50
- "config_file=#{config_file} would not be accessible in" \
51
- " working_directory=#{path}"
52
- end
53
- @options[:chdir] = path
57
+ @options[:chdir] = File.expand_path(path)
58
+ end
59
+
60
+ # sets the RACK_ENV environment variable
61
+ def environment(env)
62
+ @options[:environment] = env
54
63
  end
55
64
 
56
65
  # set the event bus bridge prefix, prefix, options
57
- # eventbus /eventbus, inbound: {foo:bar}, outbound: {foo: bar}
66
+ # eventbus /eventbus, inbound: [{foo:bar}], outbound: [{foo: bar}]
58
67
  # will set the event bus prefix as eventbus "/eventbus", it can be
59
68
  # connected via new EventBus("http://localhost:8080/eventbus"), inbound and
60
69
  # outbound options are security measures that will filter the messages
61
70
  def eventbus(prefix, options = {})
62
- @options[:event_bus][:prefix] = prefix
63
- @options[:event_bus][:inbound] = options[:inbound]
64
- @options[:event_bus][:outbound] = options[:outbound]
71
+ @options[:eventbus_prefix] = prefix
72
+ @options[:eventbus_inbound] = options[:inbound]
73
+ @options[:eventbus_outbound] = options[:outbound]
65
74
  end
66
75
 
67
76
  # Set the host and port to be discovered by other jubilee instances in the network
@@ -74,10 +83,10 @@ module Jubilee
74
83
  # clustering "0.0.0.0:5701"
75
84
  # clustering 5701
76
85
  def clustering(address)
77
- if addr == true
86
+ if address == true
78
87
  @options[:cluster_host] = "0.0.0.0"
79
88
  else
80
- @options[:cluster_host], @options[:cluster_port] = expand_addr(address)
89
+ @options[:cluster_host], @options[:cluster_port] = expand_addr(address, :clustering)
81
90
  end
82
91
  end
83
92
 
@@ -88,7 +97,7 @@ module Jubilee
88
97
 
89
98
  # enable daemon mode
90
99
  def daemonize(bool)
91
- set_bool(:debug, bool)
100
+ set_bool(:deamon, bool)
92
101
  end
93
102
 
94
103
  # enable https mode, provide the :keystore path and password
@@ -130,8 +139,8 @@ module Jubilee
130
139
  inner_app
131
140
  end
132
141
 
133
- def expand_addr(addr)
134
- return ["0.0.0.0", addr] if addr === Integer
142
+ def expand_addr(addr, var = nil)
143
+ return ["0.0.0.0", addr] if addr.is_a?(Fixnum)
135
144
  case addr
136
145
  when %r{\A(?:\*:)?(\d+)\z}
137
146
  ["0.0.0.0", $1]
Binary file
@@ -2,8 +2,8 @@ require 'rack/methodoverride'
2
2
  module Jubilee
3
3
  class Server < VertxServer
4
4
  def initialize(app, opts = {})
5
- options = {Port: 8080, ssl: false}.merge(opts)
6
- if (options[:ssl]) && options[:keystore_path].nil?
5
+ options = {Host: "0.0.0.0", Port: 8080, ssl: false}.merge(opts)
6
+ if (options[:ssl]) && options[:ssl_keystore].nil?
7
7
  raise ArgumentError, "Please provide a keystore for ssl"
8
8
  end
9
9
  super(Application.new(app), options)
@@ -2,7 +2,7 @@ module Jubilee
2
2
  module Version
3
3
  MAJOR = 1
4
4
  MINOR = 1
5
- PATCH = 0
5
+ PATCH = 2
6
6
  BUILD = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
data/lib/jubilee.rb CHANGED
@@ -3,6 +3,7 @@ require File.join(File.dirname(__FILE__), "../jars/jackson-databind-2.2.2.jar")
3
3
  require File.join(File.dirname(__FILE__), "../jars/jackson-annotations-2.2.2.jar")
4
4
  require File.join(File.dirname(__FILE__), "../jars/hazelcast-2.6.3.jar")
5
5
  require File.join(File.dirname(__FILE__), "../jars/vertx-core-2.1M3-SNAPSHOT.jar")
6
+ require File.join(File.dirname(__FILE__), "../jars/vertx-hazelcast-2.1M3-SNAPSHOT.jar")
6
7
  require File.join(File.dirname(__FILE__), "../jars/netty-all-4.0.13.Final.jar")
7
8
 
8
9
  require 'jubilee/jubilee.jar'
@@ -33,7 +33,7 @@ feature "basic sinatra test" do
33
33
  uri = URI.parse("#{Capybara.app_host}/some_page.html")
34
34
  Net::HTTP.start(uri.host, uri.port) do |http|
35
35
  request = Net::HTTP::Get.new(uri.request_uri)
36
- request.add_field('If-Modified-Since', 'Sat, 31 Dec 2050 00:00:00 GMT')
36
+ request.add_field('If-Modified-Since', 'Mon, 30 Dec 2013 22:20:25 GMT')
37
37
  response = http.request(request)
38
38
  response.code.should == "304"
39
39
  end
@@ -6,6 +6,5 @@ class TestJubileeCLI < MiniTest::Unit::TestCase
6
6
  cli = Jubilee::CLI.new(["app.rb"])
7
7
  cli.parse_options
8
8
  assert_equal "app.rb", cli.options[:rackup]
9
- assert_equal 8080, cli.options[:Port]
10
9
  end
11
10
  end
@@ -4,6 +4,12 @@ require 'jubilee/configuration'
4
4
  class TestConfig < MiniTest::Unit::TestCase
5
5
 
6
6
  def setup
7
+ @tmp = Tempfile.new("jubilee_config")
8
+ end
9
+
10
+ def teardown
11
+ @tmp.close
12
+ @tmp.unlink
7
13
  end
8
14
 
9
15
  def test_load
@@ -13,17 +19,68 @@ class TestConfig < MiniTest::Unit::TestCase
13
19
  end
14
20
 
15
21
  def test_config_invalid
16
- tmp = Tempfile.new("jubilee_config")
17
- tmp.syswrite(%q(abcd "helloword"))
22
+ @tmp.syswrite(%q(abcd "helloword"))
18
23
  assert_raises(NoMethodError) do
19
- Jubilee::Configuration.new(config_file: tmp.path)
24
+ Jubilee::Configuration.new(config_file: @tmp.path)
20
25
  end
21
26
  end
22
27
 
28
+ def test_config_listen_on_port
29
+ @tmp.syswrite(%q(listen 3000))
30
+ options = Jubilee::Configuration.new(config_file: @tmp.path).options
31
+ assert_equal(3000, options[:Port])
32
+ assert_equal("0.0.0.0", options[:Host])
33
+ end
34
+
35
+ def test_config_listen_on_host_and_port
36
+ @tmp.syswrite(%q(listen "localhost:3000"))
37
+ options = Jubilee::Configuration.new(config_file: @tmp.path).options
38
+ assert_equal(3000, options[:Port])
39
+ assert_equal("127.0.0.1", options[:Host])
40
+ end
41
+
42
+ def test_config_ssl
43
+ @tmp.syswrite(%q(ssl keystore: "keystore.jks", password: "helloworld"))
44
+ options = Jubilee::Configuration.new(config_file: @tmp.path).options
45
+ assert_equal("keystore.jks", options[:ssl_keystore])
46
+ assert_equal("helloworld", options[:ssl_password])
47
+ assert options[:ssl]
48
+ end
49
+
50
+ def test_config_eventbus
51
+ @tmp.syswrite(%q(eventbus "/eb", inbound: [{}], outbound: [{}]))
52
+ options = Jubilee::Configuration.new(config_file: @tmp.path).options
53
+ assert_equal("/eb", options[:eventbus_prefix])
54
+ end
55
+
56
+ def test_config_file_clustering_true
57
+ @tmp.syswrite(%q(clustering true))
58
+ options = Jubilee::Configuration.new(config_file: @tmp.path).options
59
+ assert_equal("0.0.0.0", options[:cluster_host])
60
+ end
61
+
62
+ def test_config_file_clustering_host_and_port
63
+ @tmp.syswrite(%q(clustering "localhost:5701"))
64
+ options = Jubilee::Configuration.new(config_file: @tmp.path).options
65
+ assert_equal("127.0.0.1", options[:cluster_host])
66
+ assert_equal(5701, options[:cluster_port])
67
+ end
68
+
69
+ def test_config_file_working_directory
70
+ @tmp.syswrite(%q(working_directory "chatapp"))
71
+ options = Jubilee::Configuration.new(config_file: @tmp.path).options
72
+ assert_match(/chatapp/, options[:chdir])
73
+ end
74
+
75
+ def test_config_file_environment
76
+ @tmp.syswrite(%q(environment "test"))
77
+ options = Jubilee::Configuration.new(config_file: @tmp.path).options
78
+ assert_equal("test", options[:environment])
79
+ end
80
+
23
81
  def test_config_non_exist
24
- tmp = Tempfile.new("jubilee_config")
25
- path = tmp.path
26
- tmp.close!
82
+ path = @tmp.path
83
+ @tmp.close!
27
84
  assert_raises(Errno::ENOENT) do
28
85
  Jubilee::Configuration.new(config_file: path)
29
86
  end
@@ -49,8 +49,8 @@ class TestJubileeServer < MiniTest::Unit::TestCase
49
49
  def test_url_scheme_for_https
50
50
  app = lambda { |env| [200, {}, [env['rack.url_scheme']]] }
51
51
  @server = Jubilee::Server.new(app, {port:@port, ssl:true,
52
- keystore_path: File.join(File.dirname(__FILE__), "../../examples/jubilee/server-keystore.jks"),
53
- keystore_password: "wibble"})
52
+ ssl_keystore: File.join(File.dirname(__FILE__), "../../examples/keystore.jks"),
53
+ ssl_password: "hellojubilee"})
54
54
  @server.start
55
55
  sleep 0.1
56
56
  http = Net::HTTP.new @host, @port
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: 1.1.0
4
+ version: 1.1.2
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-09 00:00:00.000000000 Z
11
+ date: 2014-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -88,8 +88,7 @@ files:
88
88
  - examples/client/sockjs-0.3.4.min.js
89
89
  - examples/client/vertxbus.js
90
90
  - examples/jubilee.conf.rb
91
- - examples/jubilee/keystore.jks
92
- - examples/jubilee/server-keystore.jks
91
+ - examples/keystore.jks
93
92
  - jars/hazelcast-2.6.3.jar
94
93
  - jars/jackson-annotations-2.2.2.jar
95
94
  - jars/jackson-core-2.2.2.jar
@@ -97,6 +96,8 @@ files:
97
96
  - jars/netty-all-4.0.13.Final.jar
98
97
  - jars/vertx-core-2.1M3-SNAPSHOT.jar
99
98
  - jars/vertx-hazelcast-2.1M3-SNAPSHOT.jar
99
+ - java/resources/META-INF/services/org.vertx.java.core.spi.cluster.ClusterManagerFactory
100
+ - java/resources/default-cluster.xml
100
101
  - java/src/jubilee/JubileeService.java
101
102
  - java/src/org/jruby/jubilee/Const.java
102
103
  - java/src/org/jruby/jubilee/RackApplication.java
Binary file
Binary file