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)


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

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

+ (Object) j_api_type



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

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



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

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

+ (Object) unwrap(obj)



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

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

+ (Object) wrap(obj)



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

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

Instance Method Details

- (void) get_async_map(name = nil) { ... }

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) (defaults to: nil)
    the name of the map

Yields:

  • the map will be returned asynchronously in this handler

Raises:

  • (ArgumentError)


71
72
73
74
75
76
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 71

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

- (void) get_cluster_wide_map(name = nil) { ... }

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) (defaults to: nil)
    the name of the map

Yields:

  • the map will be returned asynchronously in this handler

Raises:

  • (ArgumentError)


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

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

- (void) get_counter(name = nil) { ... }

This method returns an undefined value.

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

Parameters:

  • name (String) (defaults to: nil)
    the name of the counter.

Yields:

  • the handler

Raises:

  • (ArgumentError)


154
155
156
157
158
159
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 154

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

- (void) get_local_async_map(name = nil) { ... }

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) (defaults to: nil)
    the name of the map

Yields:

  • the map will be returned asynchronously in this handler

Raises:

  • (ArgumentError)


84
85
86
87
88
89
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 84

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

- (void) get_local_counter(name = nil) { ... }

This method returns an undefined value.

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

Parameters:

  • name (String) (defaults to: nil)
    the name of the counter.

Yields:

  • the handler

Raises:

  • (ArgumentError)


164
165
166
167
168
169
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 164

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

- (void) get_local_lock(name = nil) { ... }

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) (defaults to: nil)
    the name of the lock

Yields:

  • the handler

Raises:

  • (ArgumentError)


128
129
130
131
132
133
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 128

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

- (void) get_local_lock_with_timeout(name = nil, timeout = nil) { ... }

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) (defaults to: nil)
    the name of the lock
  • timeout (Fixnum) (defaults to: nil)
    the timeout in ms

Yields:

  • the handler

Raises:

  • (ArgumentError)


144
145
146
147
148
149
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 144

def get_local_lock_with_timeout(name=nil,timeout=nil)
  if name.class == String && timeout.class == Fixnum && true
    return @j_del.java_method(:getLocalLockWithTimeout, [Java::java.lang.String.java_class,Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(name,timeout,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Lock) : nil) } unless !block_given?))
  end
  raise ArgumentError, "Invalid arguments when calling get_local_lock_with_timeout(#{name},#{timeout})"
end

- (::Vertx::LocalMap) get_local_map(name = nil)

Return a LocalMap with the specific name.

Parameters:

  • name (String) (defaults to: nil)
    the name of the map

Returns:

Raises:

  • (ArgumentError)


173
174
175
176
177
178
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 173

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

- (void) get_lock(name = nil) { ... }

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) (defaults to: nil)
    the name of the lock

Yields:

  • the handler

Raises:

  • (ArgumentError)


98
99
100
101
102
103
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 98

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

- (void) get_lock_with_timeout(name = nil, timeout = nil) { ... }

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) (defaults to: nil)
    the name of the lock
  • timeout (Fixnum) (defaults to: nil)
    the timeout in ms

Yields:

  • the handler

Raises:

  • (ArgumentError)


114
115
116
117
118
119
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/shared_data.rb', line 114

def get_lock_with_timeout(name=nil,timeout=nil)
  if name.class == String && timeout.class == Fixnum && true
    return @j_del.java_method(:getLockWithTimeout, [Java::java.lang.String.java_class,Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(name,timeout,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Lock) : nil) } unless !block_given?))
  end
  raise ArgumentError, "Invalid arguments when calling get_lock_with_timeout(#{name},#{timeout})"
end