Class List Method List File List

# Class: Vertx::SharedData

Inherits:
  Object
  - Object
  - Vertx::SharedData
  show all
Defined in:
  /Users/julien/java/vertx-stack/stack-docs/target/rb/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)

- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (void) get_async_map(name = nil) { ... }
  Get the AsyncMap with the specified name.
- - (void) get_cluster_wide_map(name = nil) { ... }
  Get the cluster wide map with the specified name.
- - (void) get_counter(name = nil) { ... }
  Get an asynchronous counter.
- - (::Vertx::LocalMap) get_local_map(name = nil)
  Return a LocalMap with the specific name.
- - (void) get_lock(name = nil) { ... }
  Get an asynchronous lock with the specified name.
- - (void) get_lock_with_timeout(name = nil, timeout = nil) { ... }
  Like #get_lock but specifying a timeout.

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    35
    36
    37
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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`)

    102
    103
    104
    105
    106
    107
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/shared_data.rb', line 102

    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

### - (`::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:

- (`::Vertx::LocalMap`) —
  the msp

Raises:

- (`ArgumentError`)

    111
    112
    113
    114
    115
    116
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/shared_data.rb', line 111

    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.

Parameters:

- name (`String`) (defaults to: `nil`) —
  the name of the lock

Yields:

- the handler

Raises:

- (`ArgumentError`)

    80
    81
    82
    83
    84
    85
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/shared_data.rb', line 80

    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

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

    92
    93
    94
    95
    96
    97
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/shared_data.rb', line 92

    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