thinp_xml 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/bin/cache_xml +3 -1
- data/features/cache_create.feature +19 -10
- data/lib/thinp_xml/cache/builder.rb +10 -2
- data/lib/thinp_xml/cache/emit.rb +1 -1
- data/lib/thinp_xml/cache/metadata.rb +2 -1
- data/lib/thinp_xml/version.rb +1 -1
- data/spec/cache_builder_spec.rb +31 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTA2MWY0ZGYyYWVlYTc2ZGRmMzM4ZTE2Y2FjNGZlZmM1NDliOWRlMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDk1MDhkMjFiZmI5MzY0NGQxOWJhYTBjNTgyNjFmYzhmY2U3MTA3Nw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDMzZTdiZWU5ZTA3NmU5YzJlYzYxZjkyY2E4OTEyZTE0YjA2ZmFiZjg1ZmI3
|
10
|
+
OGNkNmEzOTdjMjhlZDE2NjdjYTBkNzE2MTI0YzI3MmUxMDgxNGRjODcxZjFj
|
11
|
+
ZTk4M2JmZTg5ODhiNmMwZmMxOGRhMGU3OWVjMTg4Yzg4YTQ3NjE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWUyNGVkZTNhNzQ1MDEzMjQ3ZWI4MGYxZmQzNTY5YjZkN2ZkZDE1NDMzMWMy
|
14
|
+
YzIxYWMxMjMwZDQxZjQ2M2QxNDQwMDY2Y2E5MTAzZjFjZDkxMjJkZjVhY2E4
|
15
|
+
OGU4NGU4ZWJmN2E3MDgwMjI0OTUxNmMxNDlhNWRiMmJhZjRjYzU=
|
data/bin/cache_xml
CHANGED
@@ -48,6 +48,7 @@ CacheCommandLine = CommandLine::Parser.new do
|
|
48
48
|
value_switch :mapping_policy, :layout, '--layout'
|
49
49
|
value_switch :dirty_percentage, :percentage, '--dirty-percent'
|
50
50
|
value_switch :policy, :string, '--policy'
|
51
|
+
value_switch :hint_width, :int, '--hint-width'
|
51
52
|
|
52
53
|
global do
|
53
54
|
switches :help
|
@@ -55,7 +56,7 @@ CacheCommandLine = CommandLine::Parser.new do
|
|
55
56
|
|
56
57
|
command :create do
|
57
58
|
switches :nr_cache_blocks, :uuid, :block_size, :nr_mappings,
|
58
|
-
:mapping_policy, :dirty_percentage, :policy
|
59
|
+
:mapping_policy, :dirty_percentage, :policy, :hint_width
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
@@ -85,6 +86,7 @@ class Dispatcher
|
|
85
86
|
b.mapping_policy = opts.fetch(:mapping_policy, :random)
|
86
87
|
b.dirty_percentage = opts.fetch(:dirty_percentage, 0)
|
87
88
|
b.policy_name = opts.fetch(:policy, 'mq')
|
89
|
+
b.hint_width = opts.fetch(:hint_width, 4)
|
88
90
|
md = b.generate
|
89
91
|
write_xml(md, STDOUT)
|
90
92
|
end
|
@@ -4,7 +4,7 @@ Feature: I can create new metadata
|
|
4
4
|
When I cache_xml create
|
5
5
|
Then the stdout should contain:
|
6
6
|
"""
|
7
|
-
<superblock uuid="" block_size="128" nr_cache_blocks="0" policy="mq">
|
7
|
+
<superblock uuid="" block_size="128" nr_cache_blocks="0" policy="mq" hint_width="4">
|
8
8
|
</superblock>
|
9
9
|
"""
|
10
10
|
|
@@ -12,7 +12,7 @@ Feature: I can create new metadata
|
|
12
12
|
When I cache_xml create --uuid 'one two three'
|
13
13
|
Then the stdout should contain:
|
14
14
|
"""
|
15
|
-
<superblock uuid="one two three" block_size="128" nr_cache_blocks="0" policy="mq">
|
15
|
+
<superblock uuid="one two three" block_size="128" nr_cache_blocks="0" policy="mq" hint_width="4">
|
16
16
|
</superblock>
|
17
17
|
"""
|
18
18
|
|
@@ -20,7 +20,7 @@ Feature: I can create new metadata
|
|
20
20
|
When I cache_xml create --block-size 512
|
21
21
|
Then the stdout should contain:
|
22
22
|
"""
|
23
|
-
<superblock uuid="" block_size="512" nr_cache_blocks="0" policy="mq">
|
23
|
+
<superblock uuid="" block_size="512" nr_cache_blocks="0" policy="mq" hint_width="4">
|
24
24
|
</superblock>
|
25
25
|
"""
|
26
26
|
|
@@ -28,7 +28,7 @@ Feature: I can create new metadata
|
|
28
28
|
When I cache_xml create --nr-cache-blocks 345
|
29
29
|
Then the stdout should contain:
|
30
30
|
"""
|
31
|
-
<superblock uuid="" block_size="128" nr_cache_blocks="345" policy="mq">
|
31
|
+
<superblock uuid="" block_size="128" nr_cache_blocks="345" policy="mq" hint_width="4">
|
32
32
|
</superblock>
|
33
33
|
"""
|
34
34
|
|
@@ -36,7 +36,7 @@ Feature: I can create new metadata
|
|
36
36
|
When I cache_xml create --nr-cache-blocks uniform[123..124]
|
37
37
|
Then the stdout should contain:
|
38
38
|
"""
|
39
|
-
<superblock uuid="" block_size="128" nr_cache_blocks="123" policy="mq">
|
39
|
+
<superblock uuid="" block_size="128" nr_cache_blocks="123" policy="mq" hint_width="4">
|
40
40
|
</superblock>
|
41
41
|
"""
|
42
42
|
|
@@ -44,7 +44,7 @@ Feature: I can create new metadata
|
|
44
44
|
When I cache_xml create --nr-cache-blocks 3 --nr-mappings 3 --layout linear
|
45
45
|
Then the stdout should contain:
|
46
46
|
"""
|
47
|
-
<superblock uuid="" block_size="128" nr_cache_blocks="3" policy="mq">
|
47
|
+
<superblock uuid="" block_size="128" nr_cache_blocks="3" policy="mq" hint_width="4">
|
48
48
|
<mapping cache_block="0" origin_block="0" dirty="false"/>
|
49
49
|
<mapping cache_block="1" origin_block="1" dirty="false"/>
|
50
50
|
<mapping cache_block="2" origin_block="2" dirty="false"/>
|
@@ -55,7 +55,7 @@ Feature: I can create new metadata
|
|
55
55
|
When I cache_xml create --nr-cache-blocks 3 --nr-mappings 3 --layout linear --dirty-percent 100
|
56
56
|
Then the stdout should contain:
|
57
57
|
"""
|
58
|
-
<superblock uuid="" block_size="128" nr_cache_blocks="3" policy="mq">
|
58
|
+
<superblock uuid="" block_size="128" nr_cache_blocks="3" policy="mq" hint_width="4">
|
59
59
|
<mapping cache_block="0" origin_block="0" dirty="true"/>
|
60
60
|
<mapping cache_block="1" origin_block="1" dirty="true"/>
|
61
61
|
<mapping cache_block="2" origin_block="2" dirty="true"/>
|
@@ -66,11 +66,20 @@ Feature: I can create new metadata
|
|
66
66
|
When I cache_xml create --nr-cache-blocks 3 --nr-mappings 3 --layout linear --policy fred
|
67
67
|
Then the stdout should contain:
|
68
68
|
"""
|
69
|
-
<superblock uuid="" block_size="128" nr_cache_blocks="3" policy="fred">
|
69
|
+
<superblock uuid="" block_size="128" nr_cache_blocks="3" policy="fred" hint_width="4">
|
70
70
|
<mapping cache_block="0" origin_block="0" dirty="false"/>
|
71
71
|
<mapping cache_block="1" origin_block="1" dirty="false"/>
|
72
72
|
<mapping cache_block="2" origin_block="2" dirty="false"/>
|
73
73
|
</superblock>
|
74
74
|
"""
|
75
|
-
|
76
|
-
|
75
|
+
|
76
|
+
Scenario: Take the hint width
|
77
|
+
When I cache_xml create --nr-cache-blocks 3 --nr-mappings 3 --layout linear --hint-width 8
|
78
|
+
Then the stdout should contain:
|
79
|
+
"""
|
80
|
+
<superblock uuid="" block_size="128" nr_cache_blocks="3" policy="mq" hint_width="8">
|
81
|
+
<mapping cache_block="0" origin_block="0" dirty="false"/>
|
82
|
+
<mapping cache_block="1" origin_block="1" dirty="false"/>
|
83
|
+
<mapping cache_block="2" origin_block="2" dirty="false"/>
|
84
|
+
</superblock>
|
85
|
+
"""
|
@@ -5,7 +5,7 @@ require 'thinp_xml/cache/metadata'
|
|
5
5
|
module CacheXML
|
6
6
|
class Builder
|
7
7
|
attr_accessor :uuid, :block_size, :nr_cache_blocks, :policy_name
|
8
|
-
attr_reader :mapping_policy, :nr_mappings, :dirty_percentage
|
8
|
+
attr_reader :mapping_policy, :nr_mappings, :dirty_percentage, :hint_width
|
9
9
|
|
10
10
|
def initialize
|
11
11
|
@uuid = ''
|
@@ -15,10 +15,13 @@ module CacheXML
|
|
15
15
|
@mapping_policy = :random
|
16
16
|
@nr_mappings = 0
|
17
17
|
@dirty_percentage = 0
|
18
|
+
@hint_width = 4
|
18
19
|
end
|
19
20
|
|
20
21
|
def generate
|
21
|
-
superblock = Superblock.new(@uuid, @block_size.to_i,
|
22
|
+
superblock = Superblock.new(@uuid, @block_size.to_i,
|
23
|
+
@nr_cache_blocks.to_i,
|
24
|
+
@policy_name, @hint_width)
|
22
25
|
mappings = []
|
23
26
|
|
24
27
|
case @mapping_policy
|
@@ -78,6 +81,11 @@ module CacheXML
|
|
78
81
|
@dirty_percentage = n
|
79
82
|
end
|
80
83
|
|
84
|
+
def hint_width=(n)
|
85
|
+
raise "invalid hint width (#{n})" if n > 128 || ((n % 4) != 0)
|
86
|
+
@hint_width = n
|
87
|
+
end
|
88
|
+
|
81
89
|
private
|
82
90
|
def valid_policy(sym)
|
83
91
|
[:random, :linear].member?(sym)
|
data/lib/thinp_xml/cache/emit.rb
CHANGED
@@ -11,7 +11,7 @@ module CacheXML
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def emit_superblock(sb, &block)
|
14
|
-
@e.emit_tag(sb, 'superblock', :uuid, :block_size, :nr_cache_blocks, :policy, &block)
|
14
|
+
@e.emit_tag(sb, 'superblock', :uuid, :block_size, :nr_cache_blocks, :policy, :hint_width, &block)
|
15
15
|
end
|
16
16
|
|
17
17
|
def emit_mapping(m)
|
data/lib/thinp_xml/version.rb
CHANGED
data/spec/cache_builder_spec.rb
CHANGED
@@ -70,14 +70,43 @@ describe "CacheXML::Builder" do
|
|
70
70
|
describe "policy name" do
|
71
71
|
it "should be 'mq' by default" do
|
72
72
|
@b.policy_name.should == 'mq'
|
73
|
-
@b.generate.superblock.
|
73
|
+
@b.generate.superblock.policy.should == 'mq'
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should reflect changes" do
|
77
77
|
n = 'most_recently_not_used_least'
|
78
78
|
@b.policy_name = n
|
79
79
|
@b.policy_name.should == n
|
80
|
-
@b.generate.superblock.
|
80
|
+
@b.generate.superblock.policy.should == n
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "hint width" do
|
85
|
+
it "should be '4' by default" do
|
86
|
+
@b.hint_width.should == 4
|
87
|
+
@b.generate.superblock.hint_width.should == 4
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should allow a hint size between 4 and 128, mod 4" do
|
91
|
+
0.upto(132) do |n|
|
92
|
+
if (((n % 4) == 0) && n <= 128)
|
93
|
+
@b.hint_width = n
|
94
|
+
@b.hint_width.should == n
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should disallow other hint sizes" do
|
100
|
+
[3, 7, 23, 93, 129].each do |n|
|
101
|
+
expect do
|
102
|
+
@b.hint_width = n
|
103
|
+
end.to raise_error
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should reflect changes" do
|
108
|
+
@b.hint_width = 12
|
109
|
+
@b.generate.superblock.hint_width.should == 12
|
81
110
|
end
|
82
111
|
end
|
83
112
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thinp_xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Thornber
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ejt_command_line
|