gemfire-jruby 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
@@ -0,0 +1,29 @@
1
+ Role must be specified as either 'client' or 'server'
2
+ ActiveSupport::Cache::GemFire.getInstance('server', {...})
3
+
4
+ Universal Required Options
5
+ These options are required for both clients and servers. The 'locators' is used by servers to join its peers. It is used by a client's pool to connect to the server tier.
6
+
7
+ 'region-name' == nameString
8
+ 'locators' == addressOrHostname:portNumber
9
+
10
+ Example:
11
+ ActiveSupport::Cache::GemFire.getInstance('server', {'region-name'=>'data, 'locators=>localhost:10355, , ...})
12
+
13
+ Client Options
14
+ 'caching-enabled' => 'true' || 'false' ... default is 'false'
15
+
16
+ Server Options
17
+ 'cacheserver-port'=> 40404 # required
18
+ 'data-policy' => 'partition' || 'replicate' # default is replicate
19
+ 'redundancy-level' => '0..3' # applicable only if 'data-policy' is 'partition'
20
+
21
+ Example of Creating a Server
22
+ require 'rubygems'
23
+ require 'lib/gemfire-jruby'
24
+ gfe = ActiveSupport::Cache::GemFire.getInstance('server', {'locators'=>'localhost:10355', 'region-name'=>'data', 'cacheserver-port'=>40405})
25
+
26
+ require 'rubygems'
27
+ require 'lib/gemfire-jruby'
28
+ gfe = ActiveSupport::Cache::GemFire.getInstance('client', {'locators'=>'localhost:10355', 'region-name'=>'data'})
29
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -103,6 +103,7 @@ href="GemFire.html">GemFire</a> cache.
103
103
  <a href="#M000009">increment</a>&nbsp;&nbsp;
104
104
  <a href="#M000006">keys</a>&nbsp;&nbsp;
105
105
  <a href="#M000002">new</a>&nbsp;&nbsp;
106
+ <a href="#M000012">query</a>&nbsp;&nbsp;
106
107
  <a href="#M000003">read</a>&nbsp;&nbsp;
107
108
  <a href="#M000004">write</a>&nbsp;&nbsp;
108
109
  </div>
@@ -151,7 +152,7 @@ href="GemFire.html">GemFire</a> cache.
151
152
  <div class="method-heading">
152
153
  <a href="GemFire.src/M000001.html" target="Code" class="method-signature"
153
154
  onclick="popupCode('GemFire.src/M000001.html');return false;">
154
- <span class="method-name">getInstance</span><span class="method-args">(hashOfGemFireProperties)</span>
155
+ <span class="method-name">getInstance</span><span class="method-args">(role, options={})</span>
155
156
  </a>
156
157
  </div>
157
158
 
@@ -164,8 +165,8 @@ href="GemFire.html">GemFire</a> instance and to launch <a
164
165
  href="GemFire.html">GemFire</a>.
165
166
  </p>
166
167
  <pre>
167
- There is an optional Hash that you can use to override any GemFire properties'.
168
- For example, GemFire.getInstance('locators' =&gt; 'localhost[10355]', 'mcast-port' =&gt; '0')
168
+ The required Hash is used to configure clients and servers.
169
+ For example, GemFire.getInstance('server', {'region-name'=&gt; 'data', 'locators' =&gt; 'localhost:10355'})
169
170
  </pre>
170
171
  <p>
171
172
  Since it is a Singleton, successive calls to <a
@@ -181,7 +182,7 @@ single instance that was instantiated by the first call.
181
182
  <div class="method-heading">
182
183
  <a href="GemFire.src/M000002.html" target="Code" class="method-signature"
183
184
  onclick="popupCode('GemFire.src/M000002.html');return false;">
184
- <span class="method-name">new</span><span class="method-args">(hashOfGemFireProperties)</span>
185
+ <span class="method-name">new</span><span class="method-args">(role, options)</span>
185
186
  </a>
186
187
  </div>
187
188
 
@@ -319,6 +320,20 @@ objects.
319
320
  </div>
320
321
  </div>
321
322
 
323
+ <div id="method-M000012" class="method-detail">
324
+ <a name="M000012"></a>
325
+
326
+ <div class="method-heading">
327
+ <a href="GemFire.src/M000012.html" target="Code" class="method-signature"
328
+ onclick="popupCode('GemFire.src/M000012.html');return false;">
329
+ <span class="method-name">query</span><span class="method-args">(queryString)</span>
330
+ </a>
331
+ </div>
332
+
333
+ <div class="method-description">
334
+ </div>
335
+ </div>
336
+
322
337
  <div id="method-M000003" class="method-detail">
323
338
  <a name="M000003"></a>
324
339
 
@@ -10,9 +10,9 @@
10
10
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 26</span>
14
- <span class="ruby-keyword kw">def</span> <span class="ruby-constant">GemFire</span>.<span class="ruby-identifier">getInstance</span>(<span class="ruby-identifier">hashOfGemFireProperties</span>)
15
- <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">instance</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">new</span>(<span class="ruby-identifier">hashOfGemFireProperties</span>={})
13
+ <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 29</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-constant">GemFire</span>.<span class="ruby-identifier">getInstance</span>(<span class="ruby-identifier">role</span>, <span class="ruby-identifier">options</span>={})
15
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">instance</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">new</span>(<span class="ruby-identifier">role</span>, <span class="ruby-identifier">options</span>)
16
16
  <span class="ruby-keyword kw">end</span></pre>
17
17
  </body>
18
18
  </html>
@@ -10,18 +10,30 @@
10
10
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 30</span>
14
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">hashOfGemFireProperties</span>)
15
- <span class="ruby-identifier">properties</span> = <span class="ruby-constant">Properties</span>.<span class="ruby-identifier">new</span>
16
- <span class="ruby-identifier">hashOfGemFireProperties</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
17
- <span class="ruby-identifier">properties</span>.<span class="ruby-identifier">setProperty</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
18
- <span class="ruby-keyword kw">end</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 101</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">role</span>, <span class="ruby-identifier">options</span>)
15
+ <span class="ruby-comment cmt"># fill the GemFire properties from the options</span>
16
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">check_required_options</span>(<span class="ruby-identifier">role</span>, <span class="ruby-identifier">options</span>)
17
+ <span class="ruby-comment cmt"># join the distributed system</span>
18
+ <span class="ruby-identifier">properties</span> = <span class="ruby-identifier">get_gemfire_properties</span>(<span class="ruby-identifier">role</span>, <span class="ruby-identifier">options</span>)
19
19
  <span class="ruby-identifier">system</span> = <span class="ruby-constant">DistributedSystem</span>.<span class="ruby-identifier">connect</span>(<span class="ruby-identifier">properties</span>)
20
- <span class="ruby-identifier">cache</span> = <span class="ruby-constant">CacheFactory</span>.<span class="ruby-identifier">create</span>(<span class="ruby-identifier">system</span>)
21
- <span class="ruby-ivar">@region</span> = <span class="ruby-identifier">cache</span>.<span class="ruby-identifier">getRegion</span>(<span class="ruby-constant">System</span>.<span class="ruby-identifier">getProperty</span>(<span class="ruby-value str">&quot;cachingRegionName&quot;</span>) <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;default&quot;</span>)
20
+ <span class="ruby-comment cmt"># create the cache ... this will read a cache.xml</span>
21
+ <span class="ruby-ivar">@cache</span> = <span class="ruby-constant">CacheFactory</span>.<span class="ruby-identifier">create</span>(<span class="ruby-identifier">system</span>)
22
+ <span class="ruby-comment cmt"># there is only one region</span>
23
+ <span class="ruby-identifier">regionAttributes</span> = <span class="ruby-keyword kw">nil</span>
24
+ <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">role</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'client'</span>) <span class="ruby-keyword kw">then</span>
25
+ <span class="ruby-comment cmt"># it's a client</span>
26
+ <span class="ruby-identifier">regionAttributes</span> = <span class="ruby-identifier">get_client_attributes</span>(<span class="ruby-identifier">options</span>)
27
+ <span class="ruby-keyword kw">else</span>
28
+ <span class="ruby-comment cmt"># it's a server</span>
29
+ <span class="ruby-identifier">cacheServer</span> = <span class="ruby-ivar">@cache</span>.<span class="ruby-identifier">addCacheServer</span>
30
+ <span class="ruby-identifier">cacheServer</span>.<span class="ruby-identifier">setPort</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value str">'cacheserver-port'</span>])
31
+ <span class="ruby-identifier">cacheServer</span>.<span class="ruby-identifier">start</span>
32
+ <span class="ruby-identifier">regionAttributes</span> = <span class="ruby-identifier">get_server_attributes</span>(<span class="ruby-identifier">options</span>)
33
+ <span class="ruby-keyword kw">end</span>
34
+ <span class="ruby-ivar">@region</span> = <span class="ruby-ivar">@cache</span>.<span class="ruby-identifier">createRegion</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value str">'region-name'</span>], <span class="ruby-identifier">regionAttributes</span>)
22
35
  <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">CacheException</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
23
36
  <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span>(<span class="ruby-node">&quot;GemfireCache Creation Error (#{e}): #{e.message}&quot;</span>)
24
- <span class="ruby-keyword kw">false</span>
25
37
  <span class="ruby-keyword kw">end</span></pre>
26
38
  </body>
27
39
  </html>
@@ -10,13 +10,12 @@
10
10
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 44</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 127</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read</span>(<span class="ruby-identifier">key</span>)
15
15
  <span class="ruby-keyword kw">super</span>
16
16
  <span class="ruby-ivar">@region</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">key</span>)
17
17
  <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">CacheException</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
18
18
  <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span>(<span class="ruby-node">&quot;GemfireCache Error (#{e}): #{e.message}&quot;</span>)
19
- <span class="ruby-keyword kw">false</span>
20
19
  <span class="ruby-keyword kw">end</span></pre>
21
20
  </body>
22
21
  </html>
@@ -10,14 +10,12 @@
10
10
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 53</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 135</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
15
15
  <span class="ruby-keyword kw">super</span>
16
16
  <span class="ruby-ivar">@region</span>.<span class="ruby-identifier">put</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
17
- <span class="ruby-keyword kw">true</span>
18
17
  <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">CacheException</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
19
18
  <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span>(<span class="ruby-node">&quot;GemfireCache Error (#{e}): #{e.message}&quot;</span>)
20
- <span class="ruby-keyword kw">false</span>
21
19
  <span class="ruby-keyword kw">end</span></pre>
22
20
  </body>
23
21
  </html>
@@ -10,13 +10,12 @@
10
10
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 63</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 143</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>)
15
15
  <span class="ruby-keyword kw">super</span>
16
16
  <span class="ruby-ivar">@region</span>.<span class="ruby-identifier">destroy</span>(<span class="ruby-identifier">key</span>)
17
17
  <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">CacheException</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
18
18
  <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span>(<span class="ruby-node">&quot;GemfireCache Error (#{e}): #{e.message}&quot;</span>)
19
- <span class="ruby-keyword kw">false</span>
20
19
  <span class="ruby-keyword kw">end</span></pre>
21
20
  </body>
22
21
  </html>
@@ -10,7 +10,7 @@
10
10
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 72</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 151</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">keys</span>
15
15
  <span class="ruby-ivar">@region</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">to_a</span>
16
16
  <span class="ruby-keyword kw">end</span></pre>
@@ -10,10 +10,13 @@
10
10
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 77</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 156</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">key</span>)
15
- <span class="ruby-keyword kw">super</span>
16
- <span class="ruby-ivar">@region</span>.<span class="ruby-identifier">containsKeyOnServer</span>(<span class="ruby-identifier">key</span>)
15
+ <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@region</span>.<span class="ruby-identifier">getAttributes</span>.<span class="ruby-identifier">getPoolName</span> <span class="ruby-keyword kw">then</span>
16
+ <span class="ruby-ivar">@region</span>.<span class="ruby-identifier">containsKey</span>(<span class="ruby-identifier">key</span>)
17
+ <span class="ruby-keyword kw">else</span>
18
+ <span class="ruby-ivar">@region</span>.<span class="ruby-identifier">containsKeyOnServer</span>(<span class="ruby-identifier">key</span>)
19
+ <span class="ruby-keyword kw">end</span>
17
20
  <span class="ruby-keyword kw">end</span></pre>
18
21
  </body>
19
22
  </html>
@@ -10,14 +10,11 @@
10
10
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 83</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 165</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear</span>
15
- <span class="ruby-keyword kw">super</span>
16
15
  <span class="ruby-ivar">@region</span>.<span class="ruby-identifier">clear</span>
17
- <span class="ruby-keyword kw">true</span>
18
16
  <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">CacheException</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
19
17
  <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span>(<span class="ruby-node">&quot;GemfireCache Error (#{e}): #{e.message}&quot;</span>)
20
- <span class="ruby-keyword kw">false</span>
21
18
  <span class="ruby-keyword kw">end</span></pre>
22
19
  </body>
23
20
  </html>
@@ -10,7 +10,7 @@
10
10
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 93</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 172</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">increment</span>(<span class="ruby-identifier">key</span>)
15
15
  <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Not supported by Gemfire&quot;</span>
16
16
  <span class="ruby-keyword kw">end</span></pre>
@@ -10,7 +10,7 @@
10
10
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 98</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 177</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">decrement</span>(<span class="ruby-identifier">key</span>)
15
15
  <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Not supported by Gemfire&quot;</span>
16
16
  <span class="ruby-keyword kw">end</span></pre>
@@ -10,7 +10,7 @@
10
10
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 103</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/gemfire-jruby.rb, line 182</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_matched</span>(<span class="ruby-identifier">matcher</span>)
15
15
  <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Not supported by Gemfire&quot;</span>
16
16
  <span class="ruby-keyword kw">end</span></pre>
data/doc/created.rid CHANGED
@@ -1 +1 @@
1
- Wed, 27 Jan 2010 11:29:26 -0800
1
+ Fri, 29 Jan 2010 10:49:13 -0800
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Wed Jan 27 11:29:25 -0800 2010</td>
59
+ <td>Fri Jan 29 10:45:01 -0800 2010</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -73,7 +73,7 @@
73
73
  <h3 class="section-bar">Required files</h3>
74
74
 
75
75
  <div class="name-list">
76
- activesupport&nbsp;&nbsp;
76
+ active_support&nbsp;&nbsp;
77
77
  </div>
78
78
  </div>
79
79
 
@@ -29,6 +29,7 @@
29
29
  <a href="classes/ActiveSupport/Cache/GemFire.html#M000009">increment (ActiveSupport::Cache::GemFire)</a><br />
30
30
  <a href="classes/ActiveSupport/Cache/GemFire.html#M000006">keys (ActiveSupport::Cache::GemFire)</a><br />
31
31
  <a href="classes/ActiveSupport/Cache/GemFire.html#M000002">new (ActiveSupport::Cache::GemFire)</a><br />
32
+ <a href="classes/ActiveSupport/Cache/GemFire.html#M000012">query (ActiveSupport::Cache::GemFire)</a><br />
32
33
  <a href="classes/ActiveSupport/Cache/GemFire.html#M000003">read (ActiveSupport::Cache::GemFire)</a><br />
33
34
  <a href="classes/ActiveSupport/Cache/GemFire.html#M000004">write (ActiveSupport::Cache::GemFire)</a><br />
34
35
  </div>
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gemfire-jruby}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alan McKean"]
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.email = %q{alan.mckean@gemstone.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
+ "README",
17
18
  "README.rdoc"
18
19
  ]
19
20
  s.files = [
data/lib/gemfire-jruby.rb CHANGED
@@ -30,77 +30,9 @@ module ActiveSupport
30
30
  self.instance ||= new(role, options)
31
31
  end
32
32
 
33
- def check_required_options(role, options)
34
- # role must be client or server
35
- if(role != 'client' && role != 'server') then
36
- raise "The member role must be either client or server"
37
- end
38
- # ensure that we are using locators ... no multicast distribution is allowed
39
- if (!options.include?('locators')) then
40
- raise "Locators must be specified in the options"
41
- end
42
- if (role == 'server' && !options.include?('cacheserver-port')) then
43
- raise "The server must have a cacheserver-port specified in the options"
44
- end
45
- if (!options.include?('region-name')) then
46
- raise "The region name must be specified in the options"
47
- end
48
- end
49
-
50
- def get_gemfire_properties(role, options)
51
- properties = Properties.new
52
- properties.setProperty('mcast-port', '0')
53
- options.each do |key, value|
54
- properties.setProperty(key, value) unless ((key == 'cacheserver-port') || (key == 'region-name') || (key == 'locators' && role == 'client'))
55
- end
56
- properties
57
- end
58
-
59
- def get_client_attributes(options)
60
- # configure the region attributes for client usage
61
- attributesFactory = AttributesFactory.new
62
- # clients have a Pool
63
- poolFactory = PoolManager.createFactory
64
- ipAndPort = options['locators'].split(':')
65
- puts ipAndPort[0]
66
- puts ipAndPort[1]
67
- poolFactory.addLocator(ipAndPort[0], ipAndPort[1].to_i)
68
- poolFactory.create("clientPool")
69
- # clients do no peer-to-peer distribution
70
- attributesFactory.setScope(Scope::LOCAL)
71
- # clients either cache data locally (DataPolicy::NORMAL) or not (DataPolicy::EMPTY)
72
- if (options['caching-enabled'] == 'true') then
73
- attributesFactory.setDataPolicy(DataPolicy::NORMAL)
74
- else
75
- attributesFactory.setDataPolicy(DataPolicy::EMPTY)
76
- end
77
- attributesFactory.setPoolName("clientPool")
78
- regionAttributes = attributesFactory.create
79
- end
80
-
81
- def get_server_attributes(options)
82
- attributesFactory = AttributesFactory.new
83
- if (options['data-policy'] == 'partition') then
84
- # it's a partitioned region
85
- attributesFactory.setDataPolicy(DataPolicy::PARTITION)
86
- if (options['redundant-copies']) then
87
- partitionAttributesFactory = PartitionAttributesFactory.new
88
- partitionattributesFactory.setRedundantCopies(options['redundant-copies'].to_s)
89
- partitionAttributes = partitionAttributesFactory.create
90
- attributesFactory.setPartitionAttributes(partitionAttributes)
91
- end
92
- elsif (!options['data-policy'] || (options['data-policy'] == 'replicate'))
93
- # it's a replicate region
94
- attributesFactory.setDataPolicy(DataPolicy::REPLICATE)
95
- else
96
- raise "Data policy must be either 'replicate', 'partition', or unset (the default is replicate)"
97
- end
98
- regionAttributes = attributesFactory.create
99
- end
100
-
101
33
  def initialize(role, options)
102
34
  # fill the GemFire properties from the options
103
- self.check_required_options(role, options)
35
+ check_required_options(role, options)
104
36
  # join the distributed system
105
37
  properties = get_gemfire_properties(role, options)
106
38
  system = DistributedSystem.connect(properties)
@@ -126,7 +58,7 @@ module ActiveSupport
126
58
  # Read a value from the GemFire cache. _key_ can be any JRuby object. Returns the value stored at _key_.
127
59
  def read(key)
128
60
  super
129
- @region.get(key)
61
+ Marshal.load(@region.get(Marshal.dump(key)))
130
62
  rescue CacheException => e
131
63
  logger.error("GemfireCache Error (#{e}): #{e.message}")
132
64
  end
@@ -134,7 +66,7 @@ module ActiveSupport
134
66
  # Write a value to the GemFire cache. _key_ is used to read the value from the cache and can be any JRuby object. Returns the value that was stored at _key_.
135
67
  def write(key, value)
136
68
  super
137
- @region.put(key, value)
69
+ @region.put(Marshal.dump(key), Marshal.dump(value))
138
70
  rescue CacheException => e
139
71
  logger.error("GemfireCache Error (#{e}): #{e.message}")
140
72
  end
@@ -183,6 +115,76 @@ module ActiveSupport
183
115
  raise "Not supported by Gemfire"
184
116
  end
185
117
 
118
+ private
119
+ def check_required_options(role, options)
120
+ # role must be client or server
121
+ if(role != 'client' && role != 'server') then
122
+ raise "The member role must be either client or server"
123
+ end
124
+ # ensure that we are using locators ... no multicast distribution is allowed
125
+ if (!options.include?('locators')) then
126
+ raise "Locators must be specified in the options"
127
+ end
128
+ if (role == 'server' && !options.include?('cacheserver-port')) then
129
+ raise "The server must have a cacheserver-port specified in the options"
130
+ end
131
+ if (!options.include?('region-name')) then
132
+ raise "The region name must be specified in the options"
133
+ end
134
+ end
135
+
136
+ def get_gemfire_properties(role, options)
137
+ properties = Properties.new
138
+ properties.setProperty('mcast-port', '0')
139
+ options.each do |key, value|
140
+ properties.setProperty(key, value) unless ((key == 'cacheserver-port') || (key == 'region-name') || (key == 'locators' && role == 'client'))
141
+ end
142
+ properties
143
+ end
144
+
145
+ def get_client_attributes(options)
146
+ # configure the region attributes for client usage
147
+ attributesFactory = AttributesFactory.new
148
+ # clients have a Pool
149
+ poolFactory = PoolManager.createFactory
150
+ ipAndPort = options['locators'].split(':')
151
+ puts ipAndPort[0]
152
+ puts ipAndPort[1]
153
+ poolFactory.addLocator(ipAndPort[0], ipAndPort[1].to_i)
154
+ poolFactory.create("clientPool")
155
+ # clients do no peer-to-peer distribution
156
+ attributesFactory.setScope(Scope::LOCAL)
157
+ # clients either cache data locally (DataPolicy::NORMAL) or not (DataPolicy::EMPTY)
158
+ if (options['caching-enabled'] == 'true') then
159
+ attributesFactory.setDataPolicy(DataPolicy::NORMAL)
160
+ else
161
+ attributesFactory.setDataPolicy(DataPolicy::EMPTY)
162
+ end
163
+ attributesFactory.setPoolName("clientPool")
164
+ regionAttributes = attributesFactory.create
165
+ end
166
+
167
+ def get_server_attributes(options)
168
+ attributesFactory = AttributesFactory.new
169
+ if (options['data-policy'] == 'partition') then
170
+ # it's a partitioned region
171
+ attributesFactory.setDataPolicy(DataPolicy::PARTITION)
172
+ if (options['redundant-copies']) then
173
+ partitionAttributesFactory = PartitionAttributesFactory.new
174
+ partitionattributesFactory.setRedundantCopies(options['redundant-copies'].to_s)
175
+ partitionAttributes = partitionAttributesFactory.create
176
+ attributesFactory.setPartitionAttributes(partitionAttributes)
177
+ end
178
+ elsif (!options['data-policy'] || (options['data-policy'] == 'replicate'))
179
+ # it's a replicate region
180
+ attributesFactory.setDataPolicy(DataPolicy::REPLICATE)
181
+ else
182
+ raise "Data policy must be either 'replicate', 'partition', or unset (the default is replicate)"
183
+ end
184
+ regionAttributes = attributesFactory.create
185
+ end
186
+
187
+ public
186
188
  def toList(selectResults)
187
189
  results = []
188
190
  iterator = selectResults.iterator
@@ -202,14 +204,14 @@ module ActiveSupport
202
204
  found
203
205
  end
204
206
 
205
- def query(queryString)
206
- queryService = @region.getAttributes.getPoolName ? PoolManager.find(@region).getQueryService : @cache.getQueryService
207
+ public
208
+ # Query the cache. Optional serverData arg allows querying local client cache
209
+ def query(queryString, serverData=true)
210
+ queryService = @region.getAttributes.getPoolName && serverData ? PoolManager.find(@region).getQueryService : @cache.getQueryService
207
211
  query = queryService.newQuery(queryString)
208
212
  result = query.execute
209
213
  selectResults?(result) ? toList(result) : result
210
214
  end
211
-
212
- private :check_required_options, :get_gemfire_properties, :get_server_attributes, :get_client_attributes,:toList, :selectResults?
213
215
  end
214
216
  end
215
217
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemfire-jruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alan McKean
@@ -30,6 +30,7 @@ extensions: []
30
30
 
31
31
  extra_rdoc_files:
32
32
  - LICENSE
33
+ - README
33
34
  - README.rdoc
34
35
  files:
35
36
  - .document
@@ -64,6 +65,7 @@ files:
64
65
  - lib/gemfire-jruby.rb
65
66
  - test/helper.rb
66
67
  - test/test_gemfire-jruby.rb
68
+ - README
67
69
  has_rdoc: true
68
70
  homepage: http://github.com/amckean/gemfire-jruby
69
71
  licenses: []