Class: Vertx::SharedData

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/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:

  • Cluster wide maps which can be accessed from any node of the cluster
  • Cluster wide locks which can be used to give exclusive access to resources across the cluster
  • Cluster wide counters used to maintain counts consistently across the cluster
  • Local maps for sharing data safely in the same Vert.x instance

Please see the documentation for more information.

Instance Method Summary (collapse)

Instance Method Details

- (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)


35
36
37
38
39
40
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/shared_data.rb', line 35

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::AsyncMap.new(ar.result) : 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 a cluster wide 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)


67
68
69
70
71
72
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/shared_data.rb', line 67

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::Counter.new(ar.result) : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling get_counter(name)"
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)


76
77
78
79
80
81
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/shared_data.rb', line 76

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

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

This method returns an undefined value.

Get a cluster wide lock with the specified name. The lock will be passed to the handler when it is available.

Parameters:

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

Yields:

  • the handler

Raises:

  • (ArgumentError)


45
46
47
48
49
50
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/shared_data.rb', line 45

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::Lock.new(ar.result) : 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

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)


57
58
59
60
61
62
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/shared_data.rb', line 57

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::Lock.new(ar.result) : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling get_lock_with_timeout(name,timeout)"
end