Class: Vertx::SharedData

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb

Overview

Shared data allows you to share data safely between different parts of your application in a safe way.

Shared data provides:

  • synchronous shared maps (local)
  • asynchronous maps (local or cluster-wide)
  • asynchronous locks (local or cluster-wide)
  • asynchronous counters (local or cluster-wide)

WARNING: In clustered mode, asynchronous maps/locks/counters rely on distributed data structures provided by the cluster manager. Beware that the latency relative to asynchronous maps/locks/counters operations can be much higher in clustered than in local mode.

Please see the documentation for more information.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


37
38
39
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 37

def @@j_api_type.accept?(obj)
  obj.class == SharedData
end

+ (Object) j_api_type



46
47
48
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 46

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



49
50
51
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 49

def self.j_class
  Java::IoVertxCoreShareddata::SharedData.java_class
end

+ (Object) unwrap(obj)



43
44
45
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 43

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)



40
41
42
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 40

def @@j_api_type.wrap(obj)
  SharedData.new(obj)
end

Instance Method Details

- (void) getAsyncMap(name, resultHandler) { ... }

This method returns an undefined value.

Get the AsyncMap with the specified name. When clustered, the map is accessible to all nodes in the cluster and data put into the map from any node is visible to to any other node.

WARNING: In clustered mode, asynchronous shared maps rely on distributed data structures provided by the cluster manager. Beware that the latency relative to asynchronous shared maps operations can be much higher in clustered than in local mode.

Parameters:

  • name (String)
    the name of the map

Yields:

  • the map will be returned asynchronously in this handler


219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 219

def get_async_map(*args)
  if args[0].class == String && true
    if (block_given?)
      return @j_del.java_method(:getAsyncMap, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::AsyncMap, nil, nil) : nil) } : promise)
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:getAsyncMap, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::AsyncMap, nil, nil) : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::Vertx::AsyncMap.j_api_type)
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_async_map(#{args[0]})"
  end
end

- (void) getClusterWideMap(name, resultHandler) { ... }

This method returns an undefined value.

Get the cluster wide map with the specified name. The map is accessible to all nodes in the cluster and data put into the map from any node is visible to to any other node.

Parameters:

  • name (String)
    the name of the map

Yields:

  • the map will be returned asynchronously in this handler


241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 241

def get_cluster_wide_map(*args)
  if args[0].class == String && true
    if (block_given?)
      return @j_del.java_method(:getClusterWideMap, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::AsyncMap, nil, nil) : nil) } : promise)
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:getClusterWideMap, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::AsyncMap, nil, nil) : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::Vertx::AsyncMap.j_api_type)
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_cluster_wide_map(#{args[0]})"
  end
end

- (void) getCounter(name, resultHandler) { ... }

This method returns an undefined value.

Get an asynchronous counter. The counter will be passed to the handler.

Parameters:

  • name (String)
    the name of the counter.

Yields:

  • the handler


71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 71

def get_counter(*args)
  if args[0].class == String && true
    if (block_given?)
      return @j_del.java_method(:getCounter, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Counter) : nil) } : promise)
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:getCounter, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Counter) : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::Vertx::Counter.j_api_type)
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_counter(#{args[0]})"
  end
end

- (void) getLocalAsyncMap(name, resultHandler) { ... }

This method returns an undefined value.

Get the AsyncMap with the specified name.

When clustered, the map is NOT accessible to all nodes in the cluster. Only the instance which created the map can put and retrieve data from this map.

Parameters:

  • name (String)
    the name of the map

Yields:

  • the map will be returned asynchronously in this handler


172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 172

def get_local_async_map(*args)
  if args[0].class == String && true
    if (block_given?)
      return @j_del.java_method(:getLocalAsyncMap, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::AsyncMap, nil, nil) : nil) } : promise)
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:getLocalAsyncMap, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::AsyncMap, nil, nil) : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::Vertx::AsyncMap.j_api_type)
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_local_async_map(#{args[0]})"
  end
end

- (void) getLocalCounter(name, resultHandler) { ... }

This method returns an undefined value.

Get an asynchronous local counter. The counter will be passed to the handler.

Parameters:

  • name (String)
    the name of the counter.

Yields:

  • the handler


193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 193

def get_local_counter(*args)
  if args[0].class == String && true
    if (block_given?)
      return @j_del.java_method(:getLocalCounter, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Counter) : nil) } : promise)
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:getLocalCounter, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Counter) : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::Vertx::Counter.j_api_type)
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_local_counter(#{args[0]})"
  end
end

- (void) getLocalLock(name, resultHandler) { ... }

This method returns an undefined value.

Get an asynchronous local lock with the specified name. The lock will be passed to the handler when it is available.

In general lock acquision is unordered, so that sequential attempts to acquire a lock, even from a single thread, can happen in non-sequential order.

Parameters:

  • name (String)
    the name of the lock

Yields:

  • the handler


123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 123

def get_local_lock(*args)
  if args[0].class == String && true
    if (block_given?)
      return @j_del.java_method(:getLocalLock, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Lock) : nil) } : promise)
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:getLocalLock, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Lock) : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::Vertx::Lock.j_api_type)
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_local_lock(#{args[0]})"
  end
end

- (void) getLocalLockWithTimeout(name, timeout, resultHandler) { ... }

This method returns an undefined value.

Like #get_local_lock but specifying a timeout. If the lock is not obtained within the timeout a failure will be sent to the handler.

In general lock acquision is unordered, so that sequential attempts to acquire a lock, even from a single thread, can happen in non-sequential order.

Parameters:

  • name (String)
    the name of the lock
  • timeout (Fixnum)
    the timeout in ms

Yields:

  • the handler


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 98

def get_local_lock_with_timeout(*args)
  if args[0].class == String && args[1].class == Fixnum && true
    if (block_given?)
      return @j_del.java_method(:getLocalLockWithTimeout, [Java::java.lang.String.java_class,Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],args[1],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Lock) : nil) } : promise)
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:getLocalLockWithTimeout, [Java::java.lang.String.java_class,Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],args[1],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Lock) : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::Vertx::Lock.j_api_type)
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_local_lock_with_timeout(#{args[0]},#{args[1]})"
  end
end

- (::Vertx::LocalMap) getLocalMap(name)

Return a LocalMap with the specific name.

Parameters:

  • name (String)
    the name of the map

Returns:



56
57
58
59
60
61
62
63
64
65
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 56

def get_local_map(*args)
  if args[0].class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:getLocalMap, [Java::java.lang.String.java_class]).call(args[0]),::Vertx::LocalMap, nil, nil)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_local_map(#{args[0]})"
  end
end

- (void) getLock(name, resultHandler) { ... }

This method returns an undefined value.

Get an asynchronous lock with the specified name. The lock will be passed to the handler when it is available.

In general lock acquision is unordered, so that sequential attempts to acquire a lock, even from a single thread, can happen in non-sequential order.

Parameters:

  • name (String)
    the name of the lock

Yields:

  • the handler


148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 148

def get_lock(*args)
  if args[0].class == String && true
    if (block_given?)
      return @j_del.java_method(:getLock, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Lock) : nil) } : promise)
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:getLock, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Lock) : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::Vertx::Lock.j_api_type)
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_lock(#{args[0]})"
  end
end

- (void) getLockWithTimeout(name, timeout, resultHandler) { ... }

This method returns an undefined value.

Like #get_lock but specifying a timeout. If the lock is not obtained within the timeout a failure will be sent to the handler.

In general lock acquision is unordered, so that sequential attempts to acquire a lock, even from a single thread, can happen in non-sequential order.

Parameters:

  • name (String)
    the name of the lock
  • timeout (Fixnum)
    the timeout in ms

Yields:

  • the handler


268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 268

def get_lock_with_timeout(*args)
  if args[0].class == String && args[1].class == Fixnum && true
    if (block_given?)
      return @j_del.java_method(:getLockWithTimeout, [Java::java.lang.String.java_class,Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],args[1],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Lock) : nil) } : promise)
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:getLockWithTimeout, [Java::java.lang.String.java_class,Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],args[1],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Lock) : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future,::Vertx::Lock.j_api_type)
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_lock_with_timeout(#{args[0]},#{args[1]})"
  end
end