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)

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

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

+ (Object) j_api_type


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

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class


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

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

+ (Object) unwrap(obj)


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

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

+ (Object) wrap(obj)


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

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)

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

def get_async_map(name=nil)
  if name.class == String && block_given?
    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) }))
  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)

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

def get_cluster_wide_map(name=nil)
  if name.class == String && block_given?
    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) }))
  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)

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

def get_counter(name=nil)
  if name.class == String && block_given?
    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) }))
  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)

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

def get_local_async_map(name=nil)
  if name.class == String && block_given?
    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) }))
  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)

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

def get_local_counter(name=nil)
  if name.class == String && block_given?
    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) }))
  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)

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

def get_local_lock(name=nil)
  if name.class == String && block_given?
    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) }))
  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)

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

def get_local_lock_with_timeout(name=nil,timeout=nil)
  if name.class == String && timeout.class == Fixnum && block_given?
    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) }))
  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)

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

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)

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

def get_lock(name=nil)
  if name.class == String && block_given?
    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) }))
  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)

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

def get_lock_with_timeout(name=nil,timeout=nil)
  if name.class == String && timeout.class == Fixnum && block_given?
    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) }))
  end
  raise ArgumentError, "Invalid arguments when calling get_lock_with_timeout(#{name},#{timeout})"
end