Skip to content

Commit

Permalink
Add arbiter count to client volfile (#8)
Browse files Browse the repository at this point in the history
Add arbiter-count to client volfile under afr xlator

Signed-off-by: Shree Vatsa N <[email protected]>
  • Loading branch information
vatsa287 authored Apr 6, 2023
1 parent 470a153 commit ca6c4a4
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 8 deletions.
33 changes: 33 additions & 0 deletions samples/replica3_arbiter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "vol1",
"id": "e79048bf-ac4d-47cf-8d1f-0a07366ff1ea",
"distribute_groups": [
{
"replica_count": 3,
"arbiter_count": 1,
"storage_units": [
{
"path": "/exports/vol1/s1",
"port": 4501,
"node": {
"name": "server1"
}
},
{
"path": "/exports/vol1/s2",
"port": 4502,
"node": {
"name": "server2"
}
},
{
"path": "/exports/vol1/s3",
"port": 4503,
"node": {
"name": "server3"
}
}
]
}
]
}
20 changes: 13 additions & 7 deletions spec/replicate_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ require "spec"

require "../src/volgen"

REPLICA_TMPL = File.read("templates/client.vol.j2")
SHD_TMPL = File.read("templates/shd.vol.j2")
REP2_VOLDATA_JSON = File.read("samples/replica2.json")
DIST_REP2_VOLDATA_JSON = File.read("samples/dist_replica2.json")
REP3_VOLDATA_JSON = File.read("samples/replica3.json")
DIST_REP3_VOLDATA_JSON = File.read("samples/dist_replica3.json")
TIEBREAKER_VOLDATA_JSON = File.read("samples/tiebreaker.json")
REPLICA_TMPL = File.read("templates/client.vol.j2")
SHD_TMPL = File.read("templates/shd.vol.j2")
REP2_VOLDATA_JSON = File.read("samples/replica2.json")
DIST_REP2_VOLDATA_JSON = File.read("samples/dist_replica2.json")
REP3_VOLDATA_JSON = File.read("samples/replica3.json")
DIST_REP3_VOLDATA_JSON = File.read("samples/dist_replica3.json")
TIEBREAKER_VOLDATA_JSON = File.read("samples/tiebreaker.json")
REP3_ARBITER_VOLDATA_JSON = File.read("samples/replica3_arbiter.json")

describe Volgen do
context "Volfile generation of Replica volumes" do
Expand Down Expand Up @@ -46,5 +47,10 @@ describe Volgen do
volfile = Volgen.generate(SHD_TMPL, DIST_REP3_VOLDATA_JSON)
volfile.should eq File.read("spec/sample_output/shd_dist_replica3.vol")
end

it "checks if volfile rendered for Arbiter volume" do
volfile = Volgen.generate(REPLICA_TMPL, REP3_ARBITER_VOLDATA_JSON)
volfile.should eq File.read("spec/sample_output/replica3_arbiter.vol")
end
end
end
79 changes: 79 additions & 0 deletions spec/sample_output/replica3_arbiter.vol
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
volume vol1-client-0
type protocol/client
option transport.socket.read-fail-log false
option volfile-key /vol1
option remote-subvolume /exports/vol1/s1
option remote-host server1
option remote-port 4501
end-volume

volume vol1-client-1
type protocol/client
option transport.socket.read-fail-log false
option volfile-key /vol1
option remote-subvolume /exports/vol1/s2
option remote-host server2
option remote-port 4502
end-volume

volume vol1-client-2
type protocol/client
option transport.socket.read-fail-log false
option volfile-key /vol1
option remote-subvolume /exports/vol1/s3
option remote-host server3
option remote-port 4503
end-volume

volume vol1-replicate-0
type cluster/replicate
option arbiter-count 1
option data-self-heal on
option granular-entry-heal on
option iam-self-heal-daemon off
option metadata-self-heal on
option entry-self-heal on
option read-hash-mode 5
option afr-pending-xattr vol1-client-0,vol1-client-1,vol1-client-2
subvolumes vol1-client-0 vol1-client-1 vol1-client-2
end-volume

volume vol1-utime
type features/utime
option noatime on
subvolumes vol1-replicate-0
end-volume

volume vol1-write-behind
type performance/write-behind
option flush-behind on
option write-behind on
subvolumes vol1-utime
end-volume

volume vol1-open-behind
type performance/open-behind
option read-after-open yes
subvolumes vol1-write-behind
end-volume

volume vol1-quick-read
type performance/quick-read
subvolumes vol1-open-behind
end-volume

volume vol1-md-cache
type performance/md-cache
subvolumes vol1-quick-read
end-volume

volume vol1-io-threads
type performance/io-threads
subvolumes vol1-md-cache
end-volume

volume vol1
type debug/io-stats
option volume-id e79048bf-ac4d-47cf-8d1f-0a07366ff1ea
subvolumes vol1-io-threads
end-volume
2 changes: 1 addition & 1 deletion src/volgen.cr
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module Volgen
include Crinja::Object::Auto
include JSON::Serializable

property type = "", replica_count = 0, redundancy_count = 0, storage_units = [] of StorageUnit
property type = "", replica_count = 0, redundancy_count = 0, arbiter_count = 0, storage_units = [] of StorageUnit
end

class VolfileElement
Expand Down
3 changes: 3 additions & 0 deletions templates/client.vol.j2
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
{% if dist_grp.redundancy_count > 0 %}
option redundancy {{ dist_grp.redundancy_count }}
{% endif %}
{% if dist_grp.replica_count > 0 and dist_grp.arbiter_count > 0 %}
option arbiter-count {{ dist_grp.arbiter_count }}
{% endif %}
option data-self-heal on
option granular-entry-heal on
option iam-self-heal-daemon off
Expand Down
3 changes: 3 additions & 0 deletions templates/shd.vol.j2
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
{% if dist_grp.redundancy_count > 0 %}
option redundancy {{ dist_grp.redundancy_count }}
{% endif %}
{% if dist_grp.replica_count > 0 and dist_grp.arbiter_count > 0 %}
option arbiter-count {{ dist_grp.arbiter_count }}
{% endif %}
option data-self-heal on
option granular-entry-heal on
option iam-self-heal-daemon on
Expand Down

0 comments on commit ca6c4a4

Please sign in to comment.