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

api: hash by rev #8263

Merged
merged 7 commits into from
Jul 26, 2017
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
38 changes: 33 additions & 5 deletions Documentation/dev-guide/apispec/swagger/rpc.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -858,23 +858,23 @@
"tags": [
"Maintenance"
],
"summary": "Hash returns the hash of the local KV state for consistency checking purpose.\nThis is designed for testing; do not use this in production when there\nare ongoing transactions.",
"operationId": "Hash",
"summary": "HashKV computes the hash of all MVCC keys up to a given revision.",
"operationId": "HashKV",
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/etcdserverpbHashRequest"
"$ref": "#/definitions/etcdserverpbHashKVRequest"
}
}
],
"responses": {
"200": {
"description": "(empty)",
"schema": {
"$ref": "#/definitions/etcdserverpbHashResponse"
"$ref": "#/definitions/etcdserverpbHashKVResponse"
}
}
}
Expand Down Expand Up @@ -1552,14 +1552,42 @@
}
}
},
"etcdserverpbHashKVRequest": {
"type": "object",
"properties": {
"revision": {
"description": "revision is the key-value store revision for the hash operation.",
"type": "string",
"format": "int64"
}
}
},
"etcdserverpbHashKVResponse": {
"type": "object",
"properties": {
"compact_revision": {
"description": "compact_revision is the compacted revision of key-value store when hash begins.",
"type": "string",
"format": "int64"
},
"hash": {
"description": "hash is the hash value computed from the responding member's MVCC keys up to a given revision.",
"type": "integer",
"format": "int64"
},
"header": {
"$ref": "#/definitions/etcdserverpbResponseHeader"
}
}
},
"etcdserverpbHashRequest": {
"type": "object"
},
"etcdserverpbHashResponse": {
"type": "object",
"properties": {
"hash": {
"description": "hash is the hash value computed from the responding member's key-value store.",
"description": "hash is the hash value computed from the responding member's KV's backend.",
"type": "integer",
"format": "int64"
},
Expand Down
18 changes: 18 additions & 0 deletions etcdserver/api/v3rpc/maintenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ func (ms *maintenanceServer) Hash(ctx context.Context, r *pb.HashRequest) (*pb.H
return resp, nil
}

func (ms *maintenanceServer) HashKV(ctx context.Context, r *pb.HashKVRequest) (*pb.HashKVResponse, error) {
h, rev, compactRev, err := ms.kg.KV().HashByRev(r.Revision)
if err != nil {
return nil, togRPCError(err)
}

resp := &pb.HashKVResponse{Header: &pb.ResponseHeader{Revision: rev}, Hash: h, CompactRevision: compactRev}
ms.hdr.fill(resp.Header)
return resp, nil
}

func (ms *maintenanceServer) Alarm(ctx context.Context, ar *pb.AlarmRequest) (*pb.AlarmResponse, error) {
return ms.a.Alarm(ctx, ar)
}
Expand Down Expand Up @@ -203,6 +214,13 @@ func (ams *authMaintenanceServer) Hash(ctx context.Context, r *pb.HashRequest) (
return ams.maintenanceServer.Hash(ctx, r)
}

func (ams *authMaintenanceServer) HashKV(ctx context.Context, r *pb.HashKVRequest) (*pb.HashKVResponse, error) {
if err := ams.isAuthenticated(ctx); err != nil {
return nil, err
}
return ams.maintenanceServer.HashKV(ctx, r)
}

func (ams *authMaintenanceServer) Status(ctx context.Context, ar *pb.StatusRequest) (*pb.StatusResponse, error) {
return ams.maintenanceServer.Status(ctx, ar)
}
Expand Down
2 changes: 2 additions & 0 deletions etcdserver/etcdserverpb/etcdserver.pb.go

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

45 changes: 45 additions & 0 deletions etcdserver/etcdserverpb/gw/rpc.pb.gw.go

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

Loading