INTERNAL: changeRole logic when repl nodes updated. #822
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
๐ Related Issue
https://github.com/jam2in/arcus-works/issues/598
โจ๏ธ What I did
๊ธฐ์กด ReplLocator์ update ๋ฉ์๋๋
์ค๋ฒ๋ก๋ฉ๋์ด ์๋์ ๋ ๊ฐ์ง๋ฅผ ๊ฐ์ง๋ค.
public void update(Collection<MemcachedNode> toAttach, Collection<MemcachedNode> toDelete)
public void update(Collection<MemcachedNode> toAttach, Collection<MemcachedNode> toDelete, Collection<MemcachedReplicaGroup> changeRoleGroups)
์ค์ ๋ก ์บ์ ๋ฆฌ์คํธ update ์ ์ฌ์ฉ์ ํธ์ถ๋๋ ๊ฒ์ ๋๋ฒ์งธ ๋ฉ์๋์ด๊ณ
Locator ์ธํฐํ์ด์ค๋ก๋ถํฐ ์์ ๋ฐ์ ๋ฉ์๋๋ ์ฒซ๋ฒ์งธ ๋ฉ์๋์ด๋ค.
์ ๋ ๋ฉ์๋๋ฅผ ๋ถ๋ฆฌํด์ ์ฌ์ฉํ์ง ์๊ณ
1๋ฒ ๋ฉ์๋๋ก ํต์ผํ๊ธฐ ์ํ ๋ชฉ์ ์ ๊ฐ์ง PR์ด๋ค.
ํต์ผ์ ํด์ผ ์ถํ
locator.update(...)
๋ฅผ ํตํดRepl๊ณผ Relp์ด ์ ์ฉ๋์ง ์์ ๊ฒฝ์ฐ๋ฅผ ํ๋ฒ์ ๋ค๋ฃฐ ์ ์๋ค.
changeRoleGroups ์ธ์๋ switch over ๋๋ fail over๊ฐ ๋ฐ์ํ Repl ๊ทธ๋ฃน์ ์ปฌ๋ ์ ์ ๋ชจ์๋๋ค.
์ถํ master <-> slave ๊ฐ์ ์ญํ ๋ณ๊ฒฝ์ ์ํํ๊ธฐ ์ํจ์ด๋ค.
์ ๋ฆฌํ์๋ฉด ํ๋์ ๋ฉ์๋๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด update์
changeRoleGroups ์ธ์๋ฅผ ์ ๊ฑฐํ๋ PR์ด๋ค.
๋ก์ง ์ค๋ช
switch over ๋๋ fail over์ธ ๊ฒฝ์ฐ๋ oldSlave์ newMaster๊ฐ ์กด์ฌํ๋ค.
์ฆ, attachNodes์ master node๊ฐ ๋ ๋ ธ๋๋ ์๊ณ ์๋ก์ด Slave๊ฐ ๋ ๋ ธ๋๋ ์กด์ฌํ ์ ์๋ค.
๊ธฐ์กด ๋ก์ง์ locator ๋ด์์ remove -> changeRole -> add ์์ผ๋ก ๋ก์ง์ ์ฒ๋ฆฌํ๋ค.
์ค๊ฐ์ changeRole์ ํ๊ฒ ๋๋ฉด old master๋ slave๋ก
master candidate์ธ slave๋ new master๋ก ์น๊ฒฉํ๋ค.
๊ธฐ์กด ๋ก์ง์ ์๋ฅผ ๋ค๋ฉด ์๋์ ๊ฐ๋ค.
๋ณ๊ฒฝ๋ ๋ก์ง์ changeRole -> remove -> add ์์ผ๋ก update๋ฅผ ์งํํ๋ค.
์ฐธ๊ณ ๋ก remove ๋ก์ง์ MemcachedReplicaGroupImpl์
deleteMemcachedNode ์์ ์ํํ๋ค.