-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
INTERNAL: add PipeOperationImpl to reduce duplicate code #872
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋ฆฌ๋ทฐ ์๋ฃ
src/main/java/net/spy/memcached/protocol/ascii/PipeOperationImpl.java
Outdated
Show resolved
Hide resolved
src/main/java/net/spy/memcached/protocol/ascii/PipeOperationImpl.java
Outdated
Show resolved
Hide resolved
src/main/java/net/spy/memcached/protocol/ascii/PipeOperationImpl.java
Outdated
Show resolved
Hide resolved
src/main/java/net/spy/memcached/protocol/ascii/PipeOperationImpl.java
Outdated
Show resolved
Hide resolved
@uhm0311 @jhpark816 ๋ค์ ๋ฆฌ๋ทฐ ๋ถํ๋๋ฆฝ๋๋ค. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ผ๋ถ ๋ฆฌ๋ทฐ
false, "EFLAG_MISMATCH", CollectionResponse.EFLAG_MISMATCH); | ||
|
||
protected static final OperationStatus EXIST_CANCELED = new CollectionOperationStatus( | ||
false, "collection canceled", CollectionResponse.CANCELED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
STORE_CANCELED
์ EXIST_CANCELED
๋ ์ฌ์ค์ ๊ฐ์ ๊ฐ์ฒด์
๋๋ค.
CANCELED
๊ฐ์ฒด ํ๋๋ก ํต์ผํ๋ฉด ๋ ๊ฒ ๊ฐ์ต๋๋ค.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์๋ ํํ์ wasCancelled() ๋ฉ์๋๋ฅผ ์ฌ๊ธฐ ํด๋์ค์ ๋๋ฉด ๋ ๊ฒ ๊ฐ์ต๋๋ค.
protected void wasCancelled() {
OperationStatus status = new CollectionOperationStatus(
false, "collection canceled", CollectionResponse.CANCELED);
getCallback().receivedStatus(status);
}
if (isSingleKey) { | ||
// Only one NOT_MY_KEY is provided in response of | ||
// single key piped operation when redirection. | ||
addRedirectSingleKeyOperation(line, keys.get(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bulk ์ฐ์ฐ์ธ ๊ฒฝ์ฐ์๋ isNotPiped()์ด๋ฉด singleKey์ผ ๊ฒ์
๋๋ค.
์ด ๊ฒฝ์ฐ, addRedirectSingleKeyOperation() ํธ์ถํฉ๋๋ค.
Bulk ์ฐ์ฐ์ ๊ธฐ์กด ์ฝ๋๋ isNotPiped() ์ฌ๋ถ์ ๊ด๊ณ ์์ด
addRedirectMultiKeyOperation() ํธ์ถํ์์ต๋๋ค.
๋ฌธ์ ๊ฐ ์๋ ์ง ํ์ธ ๋ฐ๋๋๋ค.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋ฉํฐํค ์ฐ์ฐ์ ๊ฒฝ์ฐ Redirect๊ฐ ํ์ํ ํค๋ง์ ์๋ก์ด ์ฐ์ฐ ๊ฐ์ฒด์ ๋ณต์ ํ๋ ๋ก์ง์ด ์์ต๋๋ค.
๋ฐ๋ผ์ ํ์ฌ ์ํ๋ก๋ ์๋ง ์ด๋ฏธ ์ฒ๋ฆฌ๊ฐ ์๋ฃ๋ ํค๋ ๊ทธ๋๋ก Redirect ๋์ด ์ค๋ณต ์ ์ฉ๋ ๊ฒ์ผ๋ก ๋ณด์
๋๋ค.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ถ๊ฐ ๋ฆฌ๋ทฐ
private int index = 0; | ||
private boolean readUntilLastLine = false; | ||
|
||
protected PipeOperationImpl(List<String> keys, CollectionPipe collectionPipe, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keys ์ธ์๋ง์ผ๋ก๋ ์๋ ๊ฒฝ์ฐ๋ฅผ ๊ตฌ๋ถํ๊ธฐ๊ฐ ์ด๋ ต์ต๋๋ค.
- single key pipe
- multiple key pipe, but key count == 1
์ด๋ฅผ ๊ตฌ๋ถํ๋ ค๋ฉด, boolean isBulk
์ธ์๋ฅผ ์ถ๊ฐํ๊ฑฐ๋
collectionPipe ์ธ์๋ฅผ ํตํด isBulk ์ธ์ง๋ฅผ ํ์ธํด์ผ ํฉ๋๋ค.
throw new IllegalArgumentException("No keys provided"); | ||
} | ||
this.keys = keys; | ||
this.isSingleKey = keys.size() == 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isSingleKey
์ฌ์ฉ๋๋ ๊ณณ์ ๋ณด๋,
multiple key pipe์ธ bulk ์ฐ์ฐ์ด ์๋์ ํ์ธํ๊ณ ๊ทธ์ ๋ฐ๋ผ ์ฒ๋ฆฌํ๊ธฐ ์ํจ์ผ๋ก ๋ณด์
๋๋ค.
๋ฐ๋ผ์, ๋จ์ํ keys.size()๋ก ๋น๊ตํ๋ ๊ฒ์ ๋ง์ง ์๊ณ ,
collectionPipe๊ฐ CollectionBulkInsert ํ์
์ด ์๋ ์ง๋ฅผ ํ์ธํด์ผ ํ ๊ฒ ๊ฐ์ต๋๋ค.
} else { | ||
index++; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ง๋ฌธ์
๋๋ค.
isNotPiped() ๊ฒฝ์ฐ์์ NOT_MY_KEY ์๋ต์ ๋ฐ์ผ๋ฉด,
single key pipe์ด๋ multi key pipe์ด๋ ๊ด๊ณ์์ด ์๋ ๋ก์ง์ ์ฌ์ฉํ ์ ์๋์?
addRedirectSingleKeyOperation(line, keys.get(index));
transitionState(OperationState.REDIRECT);
๐ Related Issue
โจ๏ธ What I did