acelyc111 commented on code in PR #1916:
URL: 
https://github.com/apache/incubator-pegasus/pull/1916#discussion_r1505260154


##########
go-client/session/meta_call.go:
##########
@@ -133,3 +163,16 @@ func (c *metaCall) issueBackupMetas(ctx context.Context) {
                }(i)
        }
 }
+
+func (c *metaCall) getMetaServiceForwardAddress(resp metaResponse) 
*base.RPCAddress {
+       rep, ok := resp.(*replication.QueryCfgResponse)
+       if !ok || rep.GetErr().Errno != base.ERR_FORWARD_TO_OTHERS.String() {
+               return nil
+       } else if rep.GetPartitions() == nil || len(rep.GetPartitions()) == 0 {
+               return nil
+       } else {
+               return rep.Partitions[0].Primary
+
+       }
+

Review Comment:
   Remove the extra blank line.
   ```suggestion
   ```



##########
go-client/session/meta_session_test.go:
##########
@@ -118,11 +118,28 @@ func TestMetaManager_FirstMetaDead(t *testing.T) {
        for i := 0; i < 3; i++ {
                call := newMetaCall(mm.currentLeader, mm.metas, func(rpcCtx 
context.Context, ms *metaSession) (metaResponse, error) {
                        return ms.queryConfig(rpcCtx, "temp")
-               })
+               }, []string{"0.0.0.0:12345", "0.0.0.0:34603", "0.0.0.0:34602", 
"0.0.0.0:34601"})
                // This a trick for testing. If metaCall issue to other meta, 
not only to the leader, this nil channel will cause panic.
                call.backupCh = nil
                metaResp, err := call.Run(context.Background())
                assert.Nil(t, err)
                assert.Equal(t, metaResp.GetErr().Errno, base.ERR_OK.String())
        }
 }
+
+// This case mocks the case that the server primary meta is not in the client 
metalist.

Review Comment:
   The meta servers in the test are 0.0.0.0:3460{1..3}, which one is "not in 
the client metalist" ?



##########
go-client/session/meta_session_test.go:
##########
@@ -118,11 +118,28 @@ func TestMetaManager_FirstMetaDead(t *testing.T) {
        for i := 0; i < 3; i++ {
                call := newMetaCall(mm.currentLeader, mm.metas, func(rpcCtx 
context.Context, ms *metaSession) (metaResponse, error) {
                        return ms.queryConfig(rpcCtx, "temp")
-               })
+               }, []string{"0.0.0.0:12345", "0.0.0.0:34603", "0.0.0.0:34602", 
"0.0.0.0:34601"})
                // This a trick for testing. If metaCall issue to other meta, 
not only to the leader, this nil channel will cause panic.
                call.backupCh = nil
                metaResp, err := call.Run(context.Background())
                assert.Nil(t, err)
                assert.Equal(t, metaResp.GetErr().Errno, base.ERR_OK.String())
        }
 }
+
+// This case mocks the case that the server primary meta is not in the client 
metalist.
+// And the client will forward to the primary meta automatically.
+func TestNodeSession_ForwardToPrimaryMeta(t *testing.T) {
+       defer leaktest.Check(t)()
+
+       metaList := []string{"0.0.0.0:34601", "0.0.0.0:34602", "0.0.0.0:34603"}
+
+       for i := 0; i < 3; i++ {
+               mm := NewMetaManager(metaList[i:i+1], NewNodeSession)
+               defer mm.Close()
+               resp, err := mm.QueryConfig(context.Background(), "temp")
+               println(resp)

Review Comment:
   Remove the debugging perpose print.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to