right_agent 2.2.0-x86-mingw32 → 2.2.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -62,7 +62,7 @@ module RightScale
62
62
  end
63
63
  true
64
64
  end
65
-
65
+
66
66
  # Write pid to pid file
67
67
  #
68
68
  # === Return
@@ -78,7 +78,7 @@ module RightScale
78
78
  end
79
79
  true
80
80
  end
81
-
81
+
82
82
  # Update associated command protocol port
83
83
  #
84
84
  # === Parameters
@@ -89,6 +89,9 @@ module RightScale
89
89
  # true:: Always return true
90
90
  def set_command_options(options)
91
91
  content = { :listen_port => options[:listen_port], :cookie => options[:cookie] }
92
+ # This is requried to preserve cookie value to be saved as string,
93
+ # and not as escaped binary data
94
+ content[:cookie].force_encoding('utf-8')
92
95
  open(@cookie_file,'w') { |f| f.write(YAML.dump(content)) }
93
96
  File.chmod(0600, @cookie_file)
94
97
  true
@@ -103,10 +106,10 @@ module RightScale
103
106
  File.delete(@cookie_file) if File.exists?(@cookie_file)
104
107
  true
105
108
  end
106
-
109
+
107
110
  # Read pid file content
108
111
  # Empty hash if pid file does not exist or content cannot be loaded
109
- #
112
+ #
110
113
  # === Return
111
114
  # content(Hash):: Hash containing 3 keys :pid, :cookie and :port
112
115
  def read_pid
@@ -137,7 +140,7 @@ module RightScale
137
140
  def to_s
138
141
  path = @pid_file
139
142
  end
140
-
143
+
141
144
  private
142
145
 
143
146
  # Check whether there is a process running with the given pid
@@ -27,6 +27,24 @@ require 'json'
27
27
 
28
28
  require File.normalize_path(File.join(File.dirname(__FILE__), 'message_pack'))
29
29
 
30
+ module JSONSerializer
31
+ def self.load(source)
32
+
33
+ if source.respond_to? :to_str
34
+ source = source.to_str
35
+ elsif source.respond_to? :to_io
36
+ source = source.to_io.read
37
+ else
38
+ source = source.read
39
+ end
40
+ source.force_encoding("UTF-8") if source.respond_to?(:force_encoding)
41
+ JSON.load(source)
42
+ end
43
+
44
+ def self.dump(*args)
45
+ JSON.dump(*args)
46
+ end
47
+ end
30
48
 
31
49
  # Monkey patch common classes to support MessagePack serialization
32
50
  # As with JSON, unserializing them is manual using existing methods such as parse
@@ -103,8 +121,8 @@ module RightScale
103
121
  private
104
122
 
105
123
  # Supported serialization formats
106
- SERIALIZERS = {:msgpack => MessagePack, :json => JSON}.freeze
107
- MSGPACK_FIRST_SERIALIZERS = [MessagePack, JSON].freeze
124
+ SERIALIZERS = {:msgpack => MessagePack, :json => JSONSerializer}.freeze
125
+ MSGPACK_FIRST_SERIALIZERS = [MessagePack, JSONSerializer].freeze
108
126
  JSON_FIRST_SERIALIZERS = MSGPACK_FIRST_SERIALIZERS.clone.reverse.freeze
109
127
  FORMATS = (SERIALIZERS.keys + [:secure]).freeze
110
128
  DEFAULT_FORMAT = :msgpack
data/right_agent.gemspec CHANGED
@@ -25,8 +25,8 @@ require 'rbconfig'
25
25
 
26
26
  Gem::Specification.new do |spec|
27
27
  spec.name = 'right_agent'
28
- spec.version = '2.2.0'
29
- spec.date = '2014-05-06'
28
+ spec.version = '2.2.1'
29
+ spec.date = '2014-05-07'
30
30
  spec.authors = ['Lee Kirchhoff', 'Raphael Simon', 'Tony Spataro', 'Scott Messier']
31
31
  spec.email = 'lee@rightscale.com'
32
32
  spec.homepage = 'https://github.com/rightscale/right_agent'
@@ -64,13 +64,13 @@ describe RightScale::Serializer do
64
64
 
65
65
  it "should use preferred serializer if specified and not cascade to others" do
66
66
  serializer = RightScale::Serializer.new(:json)
67
- flexmock(serializer).should_receive(:cascade_serializers).with(:dump, "hello", [JSON]).once
67
+ flexmock(serializer).should_receive(:cascade_serializers).with(:dump, "hello", [JSONSerializer]).once
68
68
  serializer.dump("hello")
69
69
  end
70
70
 
71
71
  it "should raise SerializationError if packet could not be serialized and not try other serializer" do
72
72
  flexmock(MessagePack).should_receive(:dump).with("hello").and_raise(StandardError).once
73
- flexmock(JSON).should_receive(:dump).with("hello").and_raise(StandardError).once
73
+ flexmock(JSONSerializer).should_receive(:dump).with("hello").and_raise(StandardError).once
74
74
  serializer = RightScale::Serializer.new(:msgpack)
75
75
  lambda { serializer.dump("hello") }.should raise_error(RightScale::Serializer::SerializationError)
76
76
  serializer = RightScale::Serializer.new(:json)
@@ -87,7 +87,7 @@ describe RightScale::Serializer do
87
87
  it "should be able to override preferred format" do
88
88
  serializer = RightScale::Serializer.new(:json)
89
89
  flexmock(serializer).should_receive(:cascade_serializers).with(:dump, "hello", [MessagePack]).once
90
- flexmock(serializer).should_receive(:cascade_serializers).with(:dump, "hello", [JSON]).never
90
+ flexmock(serializer).should_receive(:cascade_serializers).with(:dump, "hello", [JSONSerializer]).never
91
91
  serializer.dump("hello", :msgpack)
92
92
  end
93
93
 
@@ -133,13 +133,13 @@ describe RightScale::Serializer do
133
133
 
134
134
  it "should cascade through available serializers" do
135
135
  serializer = RightScale::Serializer.new
136
- flexmock(serializer).should_receive(:cascade_serializers).with(:load, "olleh", [JSON, MessagePack], nil).once
136
+ flexmock(serializer).should_receive(:cascade_serializers).with(:load, "olleh", [JSONSerializer, MessagePack], nil).once
137
137
  serializer.load("olleh")
138
138
  end
139
139
 
140
140
  it "should try all supported formats (MessagePack, JSON)" do
141
141
  flexmock(MessagePack).should_receive(:load).with("olleh").and_raise(StandardError).once
142
- flexmock(JSON).should_receive(:load).with("olleh").and_raise(StandardError).once
142
+ flexmock(JSONSerializer).should_receive(:load).with("olleh").and_raise(StandardError).once
143
143
  lambda { RightScale::Serializer.new.load("olleh") }.should raise_error(RightScale::Serializer::SerializationError)
144
144
  end
145
145
 
@@ -147,14 +147,14 @@ describe RightScale::Serializer do
147
147
  object = [1, 2, 3]
148
148
  serialized = object.to_json
149
149
  flexmock(MessagePack).should_receive(:load).with(serialized).never
150
- flexmock(JSON).should_receive(:load).with(serialized).and_return(object).once
150
+ flexmock(JSONSerializer).should_receive(:load).with(serialized).and_return(object).once
151
151
  RightScale::Serializer.new(:msgpack).load(serialized)
152
152
  end
153
153
 
154
154
  it "should try MessagePack format first if looks like MessagePack even if JSON preferred" do
155
155
  object = [1, 2, 3]
156
156
  serialized = object.to_msgpack
157
- flexmock(JSON).should_receive(:load).with(serialized).never
157
+ flexmock(JSONSerializer).should_receive(:load).with(serialized).never
158
158
  flexmock(MessagePack).should_receive(:load).with(serialized).and_return(object).once
159
159
  RightScale::Serializer.new(:json).load(serialized)
160
160
  end
@@ -180,7 +180,7 @@ describe RightScale::Serializer do
180
180
 
181
181
  it "should raise SerializationError if packet could not be unserialized" do
182
182
  flexmock(MessagePack).should_receive(:load).with("olleh").and_raise(StandardError).once
183
- flexmock(JSON).should_receive(:load).with("olleh").and_raise(StandardError).once
183
+ flexmock(JSONSerializer).should_receive(:load).with("olleh").and_raise(StandardError).once
184
184
  serializer = RightScale::Serializer.new
185
185
  lambda { serializer.load("olleh") }.should raise_error(RightScale::Serializer::SerializationError)
186
186
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  prerelease:
6
6
  platform: x86-mingw32
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-05-06 00:00:00.000000000 Z
15
+ date: 2014-05-07 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: right_support
@@ -444,7 +444,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
444
444
  version: '0'
445
445
  segments:
446
446
  - 0
447
- hash: -916798744986717735
447
+ hash: 354755465369324207
448
448
  requirements: []
449
449
  rubyforge_project:
450
450
  rubygems_version: 1.8.26