FEATURE: Add 'memcached start|stop|list' command to manage server znode#17
FEATURE: Add 'memcached start|stop|list' command to manage server znode#17
Conversation
namsic
left a comment
There was a problem hiding this comment.
일부 리뷰
조회 명령의 출력 결과 예시를 PR 설명에 추가해줄 수 있나요?
cmd/memcached/list.go
Outdated
| if len(serviceCodeServers) == 0 { | ||
| fmt.Printf("No servers found for service code '%s'.\n", serviceCode) | ||
| os.Exit(1) | ||
| } |
There was a problem hiding this comment.
acl list와 마찬가지로
아래 Total 보여주고 있으므로 별도로 처리하지 않아도 될 것 같습니다.
cmd/memcached/listall.go
Outdated
| serviceCodes, _, err := zkConn.Children(path.Join(internal.ArcusCacheListPath)) | ||
| if err != nil { | ||
| fmt.Fprintln(os.Stderr, err) | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| var statuses []serviceStatus | ||
| for _, sc := range serviceCodes { | ||
| serviceCodeServers, _ := getServiceCodeServers(zkConn, sc) |
There was a problem hiding this comment.
cache_server_mapping은 서비스코드 단위로 디렉토리가 분리되어 있지 않으므로,
어떤 서비스코드를 조회하더라도 /arcus/cache_server_mapping의 모든 children을 탐색하게 됩니다.
현재 구현에서 서비스코드가 많으면 같은 znode를 서비스코드 수만큼 중복 조회하고, ZK에 많은 연산이 보내지게 됩니다.
cache_server_mapping을 탐색하면서 map[string][]string 형태의 서비스코드 + 노드 목록을 만들어 두면,
여러 서비스코드에 대한 정보 조회 시 재사용할 수 있습니다.
| command := fmt.Sprintf(memcachedStartCommandTemplate, | ||
| memcachedPath, memcachedPath, memcachedPath, memcachedPath, memcachedPath, | ||
| port, string(globalConfig), os.Getenv("ZK_ADDR")) | ||
|
|
||
| ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) | ||
| defer cancel() | ||
| errChan := make(chan error, 1) | ||
| go func() { | ||
| errChan <- session.Run(command) | ||
| }() | ||
| select { | ||
| case err := <-errChan: | ||
| if err != nil { | ||
| fmt.Fprintln(os.Stderr, err) | ||
| os.Exit(1) | ||
| } | ||
| case <-ctx.Done(): | ||
| continue | ||
| } |
There was a problem hiding this comment.
두 방안 모두 무방하다고 하셔서, 기존 레거시코드 구현을 그대로 유지하고자 timeout으로 구현했습니다.
|
|
cmd/memcached/listall.go
Outdated
| status := "OK" | ||
| if len(serviceCodeServers) > 0 { | ||
| if onlineCnt == 0 { | ||
| status = "DOWN" | ||
| } | ||
| } |
There was a problem hiding this comment.
online / offline 정보와 중복이므로, 별도로 제공할 필요 없어 보입니다.
서버가 모두 떨어진 경우에만 DOWN이고 그 외에는 OK 처리하고 있는데,
이러한 구분 기준도 별도 설명 없이는 직관적으로 파악하기 어렵습니다.
There was a problem hiding this comment.
status부분은 제거하겠습니다. listall명령시 아래와 같이 응답하도록 수정했습니다.
SERVICE CODE TOTAL ONLINE OFFLINE
------------------------------------------------------------
test 2 0 2
5f3b94f to
0585acb
Compare
memcached 출력기존에 단일 serviceCode의 memcached 서버를 출력하는
출력결과의 예시는 아래와 같습니다. 기본적으로 전체 결과에 관해서 출력해주고, serviceCode 명령 인자가 있다면 해당 serviceCode에 대한 결과를 추가로 출력해줍니다.
|
0585acb to
9f23d9b
Compare
namsic
left a comment
There was a problem hiding this comment.
우선 이대로 반영하고, 나중에 일부 구현 리팩토링 해두겠습니다.
🔗 Related Issue
⌨️ What I did
이전 arcus.sh의
memcached start | stop | list기능을 arcus-cli에서도 동작하도록 합니다.memcached start <serviceCode> [ip:port..]/arcus/cache_list/<serviceCode>znode에 저장된, 전역 옵션으로 수행합니다.memcached stop <serviceCode> [ip:port...]-P옵션을 통해 pid를 미리 저장하고, 해당 pid를 통해 프로세스를 종료합니다.memcached list <serviceCode>memcached listall