Skip to content

Commit

Permalink
QueryService add rpc api GOMAXPROCS and FileServiceCache (#18330)
Browse files Browse the repository at this point in the history
1. Add QueryService rpc api
1. GOMAXPROCS, set/get pod runtime.GOMAXPROCS()
2. FileServiceCache and FileServiceCacheEvict protocal
- Next: implement the function handleFileServiceCacheRequest(), and handleFileServiceCacheEvictRequest() @reusee
2. inc `MORPCLatestVersion` = `MORPCVersion3`, caused by new apis are used for third-part calls.

Approved by: @reusee, @zhangxu19830126, @daviszhen, @sukki37
  • Loading branch information
xzxiong committed Aug 28, 2024
1 parent 32836c1 commit 8f02aee
Show file tree
Hide file tree
Showing 16 changed files with 9,536 additions and 3,441 deletions.
48 changes: 47 additions & 1 deletion pkg/cnservice/server_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ package cnservice

import (
"context"
"github.com/matrixorigin/matrixone/pkg/container/types"
"runtime"
"runtime/debug"
"strings"

"go.uber.org/zap"

"github.com/matrixorigin/matrixone/pkg/common/moerr"
"github.com/matrixorigin/matrixone/pkg/common/morpc"
"github.com/matrixorigin/matrixone/pkg/container/types"
"github.com/matrixorigin/matrixone/pkg/defines"
"github.com/matrixorigin/matrixone/pkg/fileservice"
"github.com/matrixorigin/matrixone/pkg/lockservice"
Expand Down Expand Up @@ -84,6 +88,10 @@ func (s *service) initQueryCommandHandler() {
s.queryService.AddHandleFunc(query.CmdMethod_GetReplicaCount, s.handleGetReplicaCount, false)
s.queryService.AddHandleFunc(query.CmdMethod_CtlReader, s.handleCtlReader, false)
s.queryService.AddHandleFunc(query.CmdMethod_ResetSession, s.handleResetSession, false)
s.queryService.AddHandleFunc(query.CmdMethod_GOMAXPROCS, s.handleGoMaxProcs, false)
s.queryService.AddHandleFunc(query.CmdMethod_GOMEMLIMIT, s.handleGoMemLimit, false)
s.queryService.AddHandleFunc(query.CmdMethod_FileServiceCache, s.handleFileServiceCacheRequest, false)
s.queryService.AddHandleFunc(query.CmdMethod_FileServiceCacheEvict, s.handleFileServiceCacheEvictRequest, false)
}

func (s *service) handleKillConn(ctx context.Context, req *query.Request, resp *query.Response, _ *morpc.Buffer) error {
Expand Down Expand Up @@ -489,3 +497,41 @@ func (s *service) handleResetSession(
resp.ResetSessionResponse.Success = true
return nil
}

func (s *service) handleGoMaxProcs(
ctx context.Context, req *query.Request, resp *query.Response, _ *morpc.Buffer,
) error {
resp.GoMaxProcsResponse.MaxProcs = int32(runtime.GOMAXPROCS(int(req.GoMaxProcsRequest.MaxProcs)))
logutil.Info("QueryService::GoMaxProcs",
zap.String("op", "set"),
zap.Int32("in", req.GoMaxProcsRequest.MaxProcs),
zap.Int32("out", resp.GoMaxProcsResponse.MaxProcs),
)
return nil
}

func (s *service) handleGoMemLimit(
ctx context.Context, req *query.Request, resp *query.Response, _ *morpc.Buffer,
) error {
resp.GoMemLimitResponse.MemLimitBytes = int64(debug.SetMemoryLimit(req.GoMemLimitRequest.MemLimitBytes))
logutil.Info("QueryService::GoMemLimit",
zap.String("op", "set"),
zap.Int64("in", req.GoMemLimitRequest.MemLimitBytes),
zap.Int64("out", resp.GoMemLimitResponse.MemLimitBytes),
)
return nil
}

func (s *service) handleFileServiceCacheRequest(
ctx context.Context, req *query.Request, resp *query.Response, _ *morpc.Buffer,
) error {
resp.FileServiceCacheResponse.Message = "Not Implemented"
return nil
}

func (s *service) handleFileServiceCacheEvictRequest(
ctx context.Context, req *query.Request, resp *query.Response, _ *morpc.Buffer,
) error {
resp.FileServiceCacheEvictResponse.Message = "Not Implemented"
return nil
}
Loading

0 comments on commit 8f02aee

Please sign in to comment.