cassie 1.1.7 → 1.2.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 516dd219afc382e2f7ccebfa43998423d51d75a9
4
- data.tar.gz: e2e3a2d435b809d9643189ced3173d41f60b8eab
3
+ metadata.gz: 5bb6cb16602c5cb41e80bdb4b4ad94be40c1da78
4
+ data.tar.gz: 4917f132273bd32583d55c50c3d83a8a14cac85e
5
5
  SHA512:
6
- metadata.gz: 71762ac6ddf825494856ba4e8bf4a5fc2f90ac6bc7b5d31c5b9f015d8e5e175056dcfdea28d6206829562eeb7ed3f23734e286b1f24e62002fe4f978e257fe93
7
- data.tar.gz: 28097a2f129db304102ea029aff231723ea011af6768590d1f3b40b1a9a193b069f4c3890fcd5e73cce4ae9a6f54fa4b0038059154aa9b6c91c9b1b45f44cda0
6
+ metadata.gz: 9f4f335f7fe3ecf6011ed9af858cba5cbe0d621523f59831245c1fd14730a590fdbb0b0b6538037194c25d4471a8e08d41b401ce69c085be62a0ebba8cf31f40
7
+ data.tar.gz: adf8a2beb2069df8812ce33de0996265dbcec108bba7cf848fe892fca20f9587e562828e0d9129f699f76d0688569ec00d39f2e8c2d680681e025100411012c8
@@ -11,6 +11,7 @@ module Cassie::ConnectionHandler
11
11
 
12
12
  included do
13
13
  include Instrumentation
14
+ CREATE_CLUSTER_LOCK = Mutex.new
14
15
  end
15
16
 
16
17
  # The cluster connection and metadata. This cluster connection is
@@ -50,7 +51,13 @@ module Cassie::ConnectionHandler
50
51
  protected
51
52
 
52
53
  def initialize_cluster
53
- Cassandra.cluster(configuration.try(:symbolize_keys))
54
+ CREATE_CLUSTER_LOCK.synchronize do
55
+ # check to see if another thread
56
+ # initialized the cluster while
57
+ # we waited on lock to be available
58
+ # e.g. this ||= is critical
59
+ @cluster ||= Cassandra.cluster(configuration.try(:symbolize_keys))
60
+ end
54
61
  end
55
62
  end
56
63
  end
@@ -5,9 +5,10 @@ module Cassie::ConnectionHandler
5
5
 
6
6
  included do
7
7
  include Instrumentation
8
+ CREATE_SESSION_LOCK = Mutex.new
8
9
  end
9
10
 
10
- # Sessions cache containint sessions that
11
+ # Sessions cache containing sessions that
11
12
  # have been opened to the {#cluster}
12
13
  # @return [Hash{String => Cassandra::Session}] The underlying driver sessions, keyed by keyspaced name
13
14
  # @!parse attr_reader :sessions
@@ -18,16 +19,29 @@ module Cassie::ConnectionHandler
18
19
  # Fetches a session from the sessions cache.
19
20
  # If no session has been opened to the requested keyspace
20
21
  # a new session is created to the {#cluster} and cached.
22
+ # @note this method is thread-safe, only one session will be opened
23
+ # per keyspace regardless of how many threads are accessing.
24
+ # @note there is no connection pooling happening here, +cassandra_driver+
25
+ # manages per node connection pools within the +Session+ object.
21
26
  # @param [String] keyspace The keyspace used for session scope. If +nil+, session will not be scoped (scoped to global space).
22
27
  # @return [Cassandra::Session]
23
28
  def session(keyspace=self.keyspace)
24
- sessions[keyspace] || initialize_session(keyspace)
29
+ return sessions[keyspace] || initialize_session(keyspace)
25
30
  end
26
31
 
27
32
  protected
28
33
 
34
+ # thread safe initialization
35
+ # only one session should be initialized
36
+ # per keyspace
29
37
  def initialize_session(keyspace)
30
- @sessions[keyspace] = cluster.connect(keyspace)
38
+ CREATE_SESSION_LOCK.synchronize do
39
+ # check to see if another thread
40
+ # initialized the session while
41
+ # we waited on lock to be available
42
+ # e.g. this ||= is critical
43
+ @sessions[keyspace] ||= cluster.connect(keyspace)
44
+ end
31
45
  end
32
46
  end
33
47
  end
@@ -98,8 +98,8 @@ module Cassie
98
98
  t1=Time.now
99
99
 
100
100
  IO.popen(command) do |io|
101
- @status=Process.waitpid2(io.pid)[1]
102
- @output=io.read.sub(/\n\z/, "")
101
+ @output= io.read.sub(/\n+\z/, "")
102
+ @status= Process.waitpid2(io.pid)[1]
103
103
  end
104
104
 
105
105
  @duration=Time.now-t1
@@ -1,3 +1,3 @@
1
1
  module Cassie
2
- VERSION = "1.1.7"
2
+ VERSION = "1.2.0.pre1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cassie
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 1.2.0.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Prothro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-25 00:00:00.000000000 Z
11
+ date: 2017-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cassandra-driver
@@ -269,9 +269,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
269
269
  version: '0'
270
270
  required_rubygems_version: !ruby/object:Gem::Requirement
271
271
  requirements:
272
- - - ">="
272
+ - - ">"
273
273
  - !ruby/object:Gem::Version
274
- version: '0'
274
+ version: 1.3.1
275
275
  requirements: []
276
276
  rubyforge_project:
277
277
  rubygems_version: 2.5.2