Module: RubyHaze

Defined in:
lib/rubyhaze.rb,
lib/rubyhaze/node.rb,
lib/rubyhaze/client.rb,
lib/rubyhaze/mixins/proxy.rb,
lib/rubyhaze/mixins/compare.rb,
lib/rubyhaze/mixins/do_proxy.rb,
lib/rubyhaze/mixins/native_exception.rb

Defined Under Namespace

Modules: Mixins Classes: Config, Exception, GroupConfig, HazelcastException, List, Lock, Map, MapConfig, MultiMap, NetworkConfig, Queue, QueueConfig, Set, Topic, TopicConfig

Constant Summary collapse

Hash =
RubyHaze::Map
MODE =
"client"
GEM_JAR_PATH =
File.expand_path(File.dirname(__FILE__) + '/../../jars/hazelcast-client-1.9-RC.jar')
JAR_PATH =
(ENV['HAZELCAST_CLIENT_JAR_PATH'] || GEM_JAR_PATH)

Class Method Summary collapse

Class Method Details

.connected?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/rubyhaze.rb', line 30

def connected?
  !!@connected
end

.init(options = nil) ⇒ Object

To start a cluster we can pass a hash of options or nil to load it from ./hazelcast.yml if available and a Config object will be generated.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rubyhaze.rb', line 36

def init(options = nil)
  if connected?
    puts ">> Already connected with Hazelcast ..."
    false
  else
    if options
      config = RubyHaze::Config.new(options).proxy_object
      Hazelcast.init config
    else
      Hazelcast.cluster
    end
    @connected = true
  end
end

.method_missing(meth, *args, &blk) ⇒ Object

Proxying to Hazelcast class



72
73
74
75
76
77
78
# File 'lib/rubyhaze.rb', line 72

def method_missing(meth, *args, &blk)
  if Hazelcast.respond_to? meth
    Hazelcast.send meth, *args, &blk
  else
    super
  end
end

.random_uuidObject



56
57
58
# File 'lib/rubyhaze.rb', line 56

def random_uuid
  java.util.UUID.randomUUID.to_string
end

.respond_to?(meth) ⇒ Boolean

Proxying to Hazelcast class

Returns:

  • (Boolean)


67
68
69
# File 'lib/rubyhaze.rb', line 67

def respond_to?(meth)
  super || Hazelcast.respond_to?(meth)
end

.shutdownObject



51
52
53
54
# File 'lib/rubyhaze.rb', line 51

def shutdown
  @connected = false
  Hazelcast.shutdown
end

.valid_uuid?(uuid) ⇒ Boolean

Returns:

  • (Boolean)


60
61
62
63
64
# File 'lib/rubyhaze.rb', line 60

def valid_uuid?(uuid)
  !!(uuid.is_a?(String) &&
     uuid.size == 36 &&
     uuid =~ %r{^([A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12})$}i)
end