Skip to content
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

FEATURE: Create new api asyncBopPipedUpsert. #657

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

brido4125
Copy link
Collaborator

Motivation

아래 캐시 동기화에 필요한 기능 이슈를 해결하기 위해 구현한다.
https://github.com/jam2in/arcus-works/issues/426

구현 로직

캐시 서버는 bop insert와 bop upsert 요청에 대해
아래와 같이 동일한 인자와 형식을 가지고 있습니다.

bop insert <key> <bkey> [<eflag>] <bytes> [create <attributes>] [noreply|pipe|getrim]\r\n<data>\r\n
bop upsert <key> <bkey> [<eflag>] <bytes> [create <attributes>] [noreply|pipe|getrim]\r\n<data>\r\n

그래서 기존의 asyncCollectionPipedInsert()를 활용하여
piped upsert를 가능하도록 구현하였습니다.

단건 upsert의 경우도 아래와 같이 asyncCollectionInsert
사용하여 구현되어 있습니다.

@Override
  public CollectionFuture<Boolean> asyncBopUpsert(String key, long bkey,
                                                  byte[] elementFlag, Object value,
                                                  CollectionAttributes attributesForCreate) {

    BTreeUtil.validateBkey(bkey);
    BTreeUpsert<Object> bTreeUpsert = new BTreeUpsert<Object>(value, elementFlag, null, attributesForCreate);

    return asyncCollectionInsert(key, String.valueOf(bkey), bTreeUpsert,
            collectionTranscoder);
  }

즉, 이러한 구현이 단건과 다건 api에 대한 일관적으로 구현된 형태입니다.

@brido4125 brido4125 self-assigned this Aug 22, 2023
@brido4125 brido4125 force-pushed the new/bopPipedUpsert branch 2 times, most recently from b70e141 to bcab24e Compare August 22, 2023 08:22
@brido4125 brido4125 requested a review from uhm0311 August 22, 2023 08:35
Assert.assertEquals(elementCount, upsertResult.size());
int idx = 0;
for (Element<Object> elem : upsertResult.values()) {
Assert.assertEquals(elem.getValue(), "upsertValue" + idx);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bkey도 맞는지 확인해봅시다.

0, false, false).get();
Long idx = 0L;
for (Long bKey : resultMap.keySet()) {
Assert.assertEquals(idx, bKey);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value도 맞는지 확인해봅시다.

0, false, false).get();
Long idx = 0L;
for (Long bKey : resultMap.keySet()) {
Assert.assertEquals(idx, bKey);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value 맞는지 확인해봅시다.

.get();
int idx = 0;
for (Element<Object> elem : resultMap.values()) {
Assert.assertEquals(elem.getValue(), "upsertValue" + idx);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bkey도 맞는지 확인해봅시다.

.get();
int idx = 0;
for (Element<Object> elem : resultMap.values()) {
Assert.assertEquals(elem.getValue(), "upsertValue" + idx);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bkey도 맞는지 확인해봅시다.

@brido4125 brido4125 requested a review from uhm0311 August 23, 2023 02:08
@jhpark816 jhpark816 added the merged next time PR will be merged next time. label Aug 23, 2023
@jhpark816
Copy link
Collaborator

@uhm0311 @brido4125
리뷰는 진행해 주시고, merge는 향후 버전에 반영하기 위해 나중에 처리할 예정임을 참고 바랍니다.

upsertElem.put(i, "upsertValue" + i);
}
CollectionAttributes attr = new CollectionAttributes();
mc.asyncBopPipedInsertBulk(KEY, insertElem, attr);
Copy link
Collaborator

@uhm0311 uhm0311 Aug 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future.get() 호출합시다.

}
upsertElem.put(i, "upsertValue" + i);
}
mc.asyncBopPipedInsertBulk(KEY, insertElem, new CollectionAttributes());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future.get() 호출

}

CollectionAttributes collectionAttributes = new CollectionAttributes();
mc.asyncMopPipedInsertBulk(KEY, insertElem, collectionAttributes);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future.get() 호출

}

CollectionAttributes collectionAttributes = new CollectionAttributes();
mc.asyncBopPipedUpsertBulk(KEY, insertElem, collectionAttributes);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future.get() 호출

upsertElem.add(new Element<Object>(i, "upsertValue" + i, new byte[]{(byte) 1}));
}
CollectionAttributes attr = new CollectionAttributes();
mc.asyncBopPipedInsertBulk(KEY, insertElem, attr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future.get() 호출

mc.asyncBopPipedInsertBulk(KEY, insertElem, attr);

//when
mc.asyncBopPipedUpsertBulk(KEY, upsertElem, attr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future.get() 호출

CollectionAttributes attr = new CollectionAttributes();

//when
mc.asyncBopPipedUpsertBulk(KEY, elements, attr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future.get() 호출

CollectionAttributes attr = new CollectionAttributes();

//when
mc.asyncBopPipedUpsertBulk(KEY, elements, attr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future.get() 호출

@junghoon-vans
Copy link
Contributor

junghoon-vans commented Sep 12, 2023

@brido4125
커밋메시지 부분 오타있습니다. INTERNAL이 아니라 INTREANL이라고 적혀있네요.

@uhm0311
Copy link
Collaborator

uhm0311 commented Sep 20, 2023

@brido4125
리뷰가 모두 반영되지 않은 것 같습니다.
다른 의견이 있다면 말씀해주세요.

@brido4125 brido4125 changed the title INTREANL: Create new api asyncBopPipedUpsert. INTERNAL: Create new api asyncBopPipedUpsert. Sep 20, 2023
@uhm0311
Copy link
Collaborator

uhm0311 commented Oct 10, 2023

@brido4125
1.13.4 버전이 릴리즈 되었으니 리뷰 반영을 재개해주시기 바랍니다.
혹은 리뷰 의견에 이견이 있다면 코멘트 바랍니다.

@brido4125 brido4125 force-pushed the new/bopPipedUpsert branch 2 times, most recently from 1b07c1f to 1a4ccbb Compare October 10, 2023 07:22
@brido4125 brido4125 changed the title INTERNAL: Create new api asyncBopPipedUpsert. FEATURE: Create new api asyncBopPipedUpsert. Oct 10, 2023
int idx = 0;
for (Element<Object> elem : upsertResult.values()) {
Assert.assertEquals(elem.getValue(), "upsertValue" + idx);
Assert.assertEquals(elem.getLongBkey(), idx);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다른 곳과 일관성 있게 Bkey를 먼저 확인하고 그 다음에 Value를 확인합시다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영하였습니다.

@brido4125 brido4125 requested a review from jhpark816 October 10, 2023 08:02
@uhm0311 uhm0311 force-pushed the develop branch 2 times, most recently from 07918e6 to ae2a82f Compare April 2, 2024 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged next time PR will be merged next time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants