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

feat(all): change type of ClusterID from uint32 to int32 #566

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/varlogadm/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func start(c *cli.Context) error {
if err != nil {
return err
}
logger = logger.Named("adm").With(zap.Uint32("cid", uint32(clusterID)))
logger = logger.Named("adm").With(zap.Int32("cid", int32(clusterID)))
defer func() {
_ = logger.Sync()
}()
Expand Down
2 changes: 1 addition & 1 deletion cmd/varlogsn/varlogsn.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func start(c *cli.Context) error {
return fmt.Errorf("flagReplicationClientWriteBufferSize: %w", err)
}

logger = logger.Named("sn").With(zap.Uint32("cid", uint32(clusterID)), zap.Int32("snid", int32(storageNodeID)))
logger = logger.Named("sn").With(zap.Int32("cid", int32(clusterID)), zap.Int32("snid", int32(storageNodeID)))

meterProviderOpts, err := flags.ParseTelemetryFlags(context.Background(), c, "sn", storageNodeID.String(), clusterID)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/metarepos/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func newConfig(opts []Option) (config, error) {
}

cfg.logger = cfg.logger.Named("mr").With(
zap.Uint32("cid", uint32(cfg.clusterID)),
zap.Int32("cid", int32(cfg.clusterID)),
zap.Uint64("nodeid", uint64(cfg.nodeID)),
)

Expand Down
2 changes: 1 addition & 1 deletion internal/storagenode/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (dd *DataDir) String() string {
// Valid if the cluster ID and storage node ID are correct and the data directory is writable.
func (dd *DataDir) Valid(cid types.ClusterID, snid types.StorageNodeID) error {
if dd.ClusterID != cid {
return fmt.Errorf("unexpected cluster id %d", uint32(dd.ClusterID))
return fmt.Errorf("unexpected cluster id %d", dd.ClusterID)
}
if dd.StorageNodeID != snid {
return fmt.Errorf("unexpected storage node id %d", int32(dd.StorageNodeID))
Expand Down
6 changes: 3 additions & 3 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import (
"sync/atomic"
)

type ClusterID uint32
type ClusterID int32

var _ fmt.Stringer = (*ClusterID)(nil)

func ParseClusterID(s string) (ClusterID, error) {
id, err := strconv.ParseUint(s, 10, 32)
id, err := strconv.ParseInt(s, 10, 32)
return ClusterID(id), err
}

func (cid ClusterID) String() string {
return strconv.FormatUint(uint64(cid), 10)
return strconv.FormatInt(int64(cid), 10)
}

type StorageNodeID int32
Expand Down
86 changes: 43 additions & 43 deletions proto/mrpb/management.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions proto/mrpb/management.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ option (gogoproto.goproto_unrecognized_all) = false;
option (gogoproto.goproto_sizecache_all) = false;

message AddPeerRequest {
uint32 cluster_id = 1 [
int32 cluster_id = 1 [
(gogoproto.casttype) = "github.com/kakao/varlog/pkg/types.ClusterID",
(gogoproto.customname) = "ClusterID"
];
Expand All @@ -29,7 +29,7 @@ message AddPeerRequest {
}

message RemovePeerRequest {
uint32 cluster_id = 1 [
int32 cluster_id = 1 [
(gogoproto.casttype) = "github.com/kakao/varlog/pkg/types.ClusterID",
(gogoproto.customname) = "ClusterID"
];
Expand All @@ -41,7 +41,7 @@ message RemovePeerRequest {
}

message GetClusterInfoRequest {
uint32 cluster_id = 1 [
int32 cluster_id = 1 [
(gogoproto.casttype) = "github.com/kakao/varlog/pkg/types.ClusterID",
(gogoproto.customname) = "ClusterID"
];
Expand All @@ -54,7 +54,7 @@ message ClusterInfo {
bool learner = 3;
}

uint32 cluster_id = 1 [
int32 cluster_id = 1 [
(gogoproto.casttype) = "github.com/kakao/varlog/pkg/types.ClusterID",
(gogoproto.customname) = "ClusterID",
(gogoproto.jsontag) = "clusterId"
Expand Down
Loading