Commit 4d73d206 authored by Levin Zimmermann's avatar Levin Zimmermann

go/neo/proto: Enum order has changed in migration to msgpack format

parent 854d865f
...@@ -174,21 +174,24 @@ var ErrDecodeOverflow = errors.New("decode: buffer overflow") ...@@ -174,21 +174,24 @@ var ErrDecodeOverflow = errors.New("decode: buffer overflow")
// ---- messages ---- // ---- messages ----
//neo:proto enum //neo:proto enum
type ErrorCode uint32 type CellState int8
const ( const (
ACK ErrorCode = iota // Write-only cell. Last transactions are missing because storage is/was down
DENIED // for a while, or because it is new for the partition. It usually becomes
NOT_READY // UP_TO_DATE when replication is done.
OID_NOT_FOUND OUT_OF_DATE CellState = iota //short: O // XXX tag prefix name ?
TID_NOT_FOUND // Normal state: cell is writable/readable, and it isn't planned to drop it.
OID_DOES_NOT_EXIST UP_TO_DATE //short: U
PROTOCOL_ERROR // Same as UP_TO_DATE, except that it will be discarded as soon as another
REPLICATION_ERROR // node finishes to replicate it. It means a partition is moved from 1 node
CHECKING_ERROR // to another. It is also discarded immediately if out-of-date.
BACKEND_NOT_IMPLEMENTED FEEDING //short: F
NON_READABLE_CELL // A check revealed that data differs from other replicas. Cell is neither
READ_ONLY_ACCESS // readable nor writable.
INCOMPLETE_TRANSACTION CORRUPTED //short: C
// Not really a state: only used in network messages to tell storages to drop
// partitions.
DISCARDED //short: D
) )
// XXX move this to neo.clusterState wrapping proto.ClusterState? // XXX move this to neo.clusterState wrapping proto.ClusterState?
...@@ -229,12 +232,21 @@ const ( ...@@ -229,12 +232,21 @@ const (
) )
//neo:proto enum //neo:proto enum
type NodeType int8 type ErrorCode uint32
const ( const (
MASTER NodeType = iota ACK ErrorCode = iota
STORAGE DENIED
CLIENT NOT_READY
ADMIN OID_NOT_FOUND
TID_NOT_FOUND
OID_DOES_NOT_EXIST
PROTOCOL_ERROR
REPLICATION_ERROR
CHECKING_ERROR
BACKEND_NOT_IMPLEMENTED
NON_READABLE_CELL
READ_ONLY_ACCESS
INCOMPLETE_TRANSACTION
) )
//neo:proto enum //neo:proto enum
...@@ -247,24 +259,12 @@ const ( ...@@ -247,24 +259,12 @@ const (
) )
//neo:proto enum //neo:proto enum
type CellState int8 type NodeType int8
const ( const (
// Write-only cell. Last transactions are missing because storage is/was down MASTER NodeType = iota
// for a while, or because it is new for the partition. It usually becomes STORAGE
// UP_TO_DATE when replication is done. CLIENT
OUT_OF_DATE CellState = iota //short: O // XXX tag prefix name ? ADMIN
// Normal state: cell is writable/readable, and it isn't planned to drop it.
UP_TO_DATE //short: U
// Same as UP_TO_DATE, except that it will be discarded as soon as another
// node finishes to replicate it. It means a partition is moved from 1 node
// to another. It is also discarded immediately if out-of-date.
FEEDING //short: F
// A check revealed that data differs from other replicas. Cell is neither
// readable nor writable.
CORRUPTED //short: C
// Not really a state: only used in network messages to tell storages to drop
// partitions.
DISCARDED //short: D
) )
// NodeID is a node identifier, 4-bytes signed integer // NodeID is a node identifier, 4-bytes signed integer
......
...@@ -68,7 +68,7 @@ func (p *Error) neoMsgEncodedLenM() int { ...@@ -68,7 +68,7 @@ func (p *Error) neoMsgEncodedLenM() int {
func (p *Error) neoMsgEncodeM(data []byte) { func (p *Error) neoMsgEncodeM(data []byte) {
data[0] = byte(msgpack.FixArray_4 | 2) data[0] = byte(msgpack.FixArray_4 | 2)
data[1] = byte(msgpack.FixExt1) data[1] = byte(msgpack.FixExt1)
data[2] = 0 data[2] = 2
if !(0 <= p.Code && p.Code <= 0x7f) { if !(0 <= p.Code && p.Code <= 0x7f) {
panic("p.Code: invalid ErrorCode enum value)") panic("p.Code: invalid ErrorCode enum value)")
} }
...@@ -93,8 +93,8 @@ func (p *Error) neoMsgDecodeM(data []byte) (int, error) { ...@@ -93,8 +93,8 @@ func (p *Error) neoMsgDecodeM(data []byte) (int, error) {
if op := msgpack.Op(data[1]); op != msgpack.FixExt1 { if op := msgpack.Op(data[1]); op != msgpack.FixExt1 {
return 0, mdecodeOpErr("Error.Code", op, msgpack.FixExt1) return 0, mdecodeOpErr("Error.Code", op, msgpack.FixExt1)
} }
if enumType := data[2]; enumType != 0 { if enumType := data[2]; enumType != 2 {
return 0, mdecodeEnumTypeErr("Error.Code", enumType, 0) return 0, mdecodeEnumTypeErr("Error.Code", enumType, 2)
} }
{ {
v := data[3] v := data[3]
...@@ -280,7 +280,7 @@ func (p *RequestIdentification) neoMsgEncodedLenM() int { ...@@ -280,7 +280,7 @@ func (p *RequestIdentification) neoMsgEncodedLenM() int {
func (p *RequestIdentification) neoMsgEncodeM(data []byte) { func (p *RequestIdentification) neoMsgEncodeM(data []byte) {
data[0] = byte(msgpack.FixArray_4 | 7) data[0] = byte(msgpack.FixArray_4 | 7)
data[1] = byte(msgpack.FixExt1) data[1] = byte(msgpack.FixExt1)
data[2] = 2 data[2] = 4
if !(0 <= p.NodeType && p.NodeType <= 0x7f) { if !(0 <= p.NodeType && p.NodeType <= 0x7f) {
panic("p.NodeType: invalid NodeType enum value)") panic("p.NodeType: invalid NodeType enum value)")
} }
...@@ -350,8 +350,8 @@ func (p *RequestIdentification) neoMsgDecodeM(data []byte) (int, error) { ...@@ -350,8 +350,8 @@ func (p *RequestIdentification) neoMsgDecodeM(data []byte) (int, error) {
if op := msgpack.Op(data[1]); op != msgpack.FixExt1 { if op := msgpack.Op(data[1]); op != msgpack.FixExt1 {
return 0, mdecodeOpErr("RequestIdentification.NodeType", op, msgpack.FixExt1) return 0, mdecodeOpErr("RequestIdentification.NodeType", op, msgpack.FixExt1)
} }
if enumType := data[2]; enumType != 2 { if enumType := data[2]; enumType != 4 {
return 0, mdecodeEnumTypeErr("RequestIdentification.NodeType", enumType, 2) return 0, mdecodeEnumTypeErr("RequestIdentification.NodeType", enumType, 4)
} }
{ {
v := data[3] v := data[3]
...@@ -497,7 +497,7 @@ func (p *AcceptIdentification) neoMsgEncodedLenM() int { ...@@ -497,7 +497,7 @@ func (p *AcceptIdentification) neoMsgEncodedLenM() int {
func (p *AcceptIdentification) neoMsgEncodeM(data []byte) { func (p *AcceptIdentification) neoMsgEncodeM(data []byte) {
data[0] = byte(msgpack.FixArray_4 | 3) data[0] = byte(msgpack.FixArray_4 | 3)
data[1] = byte(msgpack.FixExt1) data[1] = byte(msgpack.FixExt1)
data[2] = 2 data[2] = 4
if !(0 <= p.NodeType && p.NodeType <= 0x7f) { if !(0 <= p.NodeType && p.NodeType <= 0x7f) {
panic("p.NodeType: invalid NodeType enum value)") panic("p.NodeType: invalid NodeType enum value)")
} }
...@@ -523,8 +523,8 @@ func (p *AcceptIdentification) neoMsgDecodeM(data []byte) (int, error) { ...@@ -523,8 +523,8 @@ func (p *AcceptIdentification) neoMsgDecodeM(data []byte) (int, error) {
if op := msgpack.Op(data[1]); op != msgpack.FixExt1 { if op := msgpack.Op(data[1]); op != msgpack.FixExt1 {
return 0, mdecodeOpErr("AcceptIdentification.NodeType", op, msgpack.FixExt1) return 0, mdecodeOpErr("AcceptIdentification.NodeType", op, msgpack.FixExt1)
} }
if enumType := data[2]; enumType != 2 { if enumType := data[2]; enumType != 4 {
return 0, mdecodeEnumTypeErr("AcceptIdentification.NodeType", enumType, 2) return 0, mdecodeEnumTypeErr("AcceptIdentification.NodeType", enumType, 4)
} }
{ {
v := data[3] v := data[3]
...@@ -1050,7 +1050,7 @@ func (p *NotifyNodeInformation) neoMsgEncodeM(data []byte) { ...@@ -1050,7 +1050,7 @@ func (p *NotifyNodeInformation) neoMsgEncodeM(data []byte) {
a := &p.NodeList[i] a := &p.NodeList[i]
data[0] = byte(msgpack.FixArray_4 | 5) data[0] = byte(msgpack.FixArray_4 | 5)
data[1] = byte(msgpack.FixExt1) data[1] = byte(msgpack.FixExt1)
data[2] = 2 data[2] = 4
if !(0 <= (*a).Type && (*a).Type <= 0x7f) { if !(0 <= (*a).Type && (*a).Type <= 0x7f) {
panic("(*a).Type: invalid NodeType enum value)") panic("(*a).Type: invalid NodeType enum value)")
} }
...@@ -1121,8 +1121,8 @@ func (p *NotifyNodeInformation) neoMsgDecodeM(data []byte) (int, error) { ...@@ -1121,8 +1121,8 @@ func (p *NotifyNodeInformation) neoMsgDecodeM(data []byte) (int, error) {
if op := msgpack.Op(data[1]); op != msgpack.FixExt1 { if op := msgpack.Op(data[1]); op != msgpack.FixExt1 {
return 0, mdecodeOpErr("NotifyNodeInformation.Type", op, msgpack.FixExt1) return 0, mdecodeOpErr("NotifyNodeInformation.Type", op, msgpack.FixExt1)
} }
if enumType := data[2]; enumType != 2 { if enumType := data[2]; enumType != 4 {
return 0, mdecodeEnumTypeErr("NotifyNodeInformation.Type", enumType, 2) return 0, mdecodeEnumTypeErr("NotifyNodeInformation.Type", enumType, 4)
} }
{ {
v := data[3] v := data[3]
...@@ -1588,7 +1588,7 @@ func (p *AnswerPartitionTable) neoMsgEncodeM(data []byte) { ...@@ -1588,7 +1588,7 @@ func (p *AnswerPartitionTable) neoMsgEncodeM(data []byte) {
data = data[1+n:] data = data[1+n:]
} }
data[0] = byte(msgpack.FixExt1) data[0] = byte(msgpack.FixExt1)
data[1] = 4 data[1] = 0
if !(0 <= (*a).State && (*a).State <= 0x7f) { if !(0 <= (*a).State && (*a).State <= 0x7f) {
panic("(*a).State: invalid CellState enum value)") panic("(*a).State: invalid CellState enum value)")
} }
...@@ -1676,8 +1676,8 @@ func (p *AnswerPartitionTable) neoMsgDecodeM(data []byte) (int, error) { ...@@ -1676,8 +1676,8 @@ func (p *AnswerPartitionTable) neoMsgDecodeM(data []byte) (int, error) {
if op := msgpack.Op(data[0]); op != msgpack.FixExt1 { if op := msgpack.Op(data[0]); op != msgpack.FixExt1 {
return 0, mdecodeOpErr("AnswerPartitionTable.State", op, msgpack.FixExt1) return 0, mdecodeOpErr("AnswerPartitionTable.State", op, msgpack.FixExt1)
} }
if enumType := data[1]; enumType != 4 { if enumType := data[1]; enumType != 0 {
return 0, mdecodeEnumTypeErr("AnswerPartitionTable.State", enumType, 4) return 0, mdecodeEnumTypeErr("AnswerPartitionTable.State", enumType, 0)
} }
{ {
v := data[2] v := data[2]
...@@ -1820,7 +1820,7 @@ func (p *SendPartitionTable) neoMsgEncodeM(data []byte) { ...@@ -1820,7 +1820,7 @@ func (p *SendPartitionTable) neoMsgEncodeM(data []byte) {
data = data[1+n:] data = data[1+n:]
} }
data[0] = byte(msgpack.FixExt1) data[0] = byte(msgpack.FixExt1)
data[1] = 4 data[1] = 0
if !(0 <= (*a).State && (*a).State <= 0x7f) { if !(0 <= (*a).State && (*a).State <= 0x7f) {
panic("(*a).State: invalid CellState enum value)") panic("(*a).State: invalid CellState enum value)")
} }
...@@ -1908,8 +1908,8 @@ func (p *SendPartitionTable) neoMsgDecodeM(data []byte) (int, error) { ...@@ -1908,8 +1908,8 @@ func (p *SendPartitionTable) neoMsgDecodeM(data []byte) (int, error) {
if op := msgpack.Op(data[0]); op != msgpack.FixExt1 { if op := msgpack.Op(data[0]); op != msgpack.FixExt1 {
return 0, mdecodeOpErr("SendPartitionTable.State", op, msgpack.FixExt1) return 0, mdecodeOpErr("SendPartitionTable.State", op, msgpack.FixExt1)
} }
if enumType := data[1]; enumType != 4 { if enumType := data[1]; enumType != 0 {
return 0, mdecodeEnumTypeErr("SendPartitionTable.State", enumType, 4) return 0, mdecodeEnumTypeErr("SendPartitionTable.State", enumType, 0)
} }
{ {
v := data[2] v := data[2]
...@@ -2026,7 +2026,7 @@ func (p *NotifyPartitionChanges) neoMsgEncodeM(data []byte) { ...@@ -2026,7 +2026,7 @@ func (p *NotifyPartitionChanges) neoMsgEncodeM(data []byte) {
data = data[1+n:] data = data[1+n:]
} }
data[0] = byte(msgpack.FixExt1) data[0] = byte(msgpack.FixExt1)
data[1] = 4 data[1] = 0
if !(0 <= (*a).CellInfo.State && (*a).CellInfo.State <= 0x7f) { if !(0 <= (*a).CellInfo.State && (*a).CellInfo.State <= 0x7f) {
panic("(*a).CellInfo.State: invalid CellState enum value)") panic("(*a).CellInfo.State: invalid CellState enum value)")
} }
...@@ -2114,8 +2114,8 @@ func (p *NotifyPartitionChanges) neoMsgDecodeM(data []byte) (int, error) { ...@@ -2114,8 +2114,8 @@ func (p *NotifyPartitionChanges) neoMsgDecodeM(data []byte) (int, error) {
if op := msgpack.Op(data[0]); op != msgpack.FixExt1 { if op := msgpack.Op(data[0]); op != msgpack.FixExt1 {
return 0, mdecodeOpErr("NotifyPartitionChanges.CellInfo.State", op, msgpack.FixExt1) return 0, mdecodeOpErr("NotifyPartitionChanges.CellInfo.State", op, msgpack.FixExt1)
} }
if enumType := data[1]; enumType != 4 { if enumType := data[1]; enumType != 0 {
return 0, mdecodeEnumTypeErr("NotifyPartitionChanges.CellInfo.State", enumType, 4) return 0, mdecodeEnumTypeErr("NotifyPartitionChanges.CellInfo.State", enumType, 0)
} }
{ {
v := data[2] v := data[2]
...@@ -6056,7 +6056,7 @@ func (p *AnswerPartitionList) neoMsgEncodeM(data []byte) { ...@@ -6056,7 +6056,7 @@ func (p *AnswerPartitionList) neoMsgEncodeM(data []byte) {
data = data[1+n:] data = data[1+n:]
} }
data[0] = byte(msgpack.FixExt1) data[0] = byte(msgpack.FixExt1)
data[1] = 4 data[1] = 0
if !(0 <= (*a).State && (*a).State <= 0x7f) { if !(0 <= (*a).State && (*a).State <= 0x7f) {
panic("(*a).State: invalid CellState enum value)") panic("(*a).State: invalid CellState enum value)")
} }
...@@ -6144,8 +6144,8 @@ func (p *AnswerPartitionList) neoMsgDecodeM(data []byte) (int, error) { ...@@ -6144,8 +6144,8 @@ func (p *AnswerPartitionList) neoMsgDecodeM(data []byte) (int, error) {
if op := msgpack.Op(data[0]); op != msgpack.FixExt1 { if op := msgpack.Op(data[0]); op != msgpack.FixExt1 {
return 0, mdecodeOpErr("AnswerPartitionList.State", op, msgpack.FixExt1) return 0, mdecodeOpErr("AnswerPartitionList.State", op, msgpack.FixExt1)
} }
if enumType := data[1]; enumType != 4 { if enumType := data[1]; enumType != 0 {
return 0, mdecodeEnumTypeErr("AnswerPartitionList.State", enumType, 4) return 0, mdecodeEnumTypeErr("AnswerPartitionList.State", enumType, 0)
} }
{ {
v := data[2] v := data[2]
...@@ -6199,7 +6199,7 @@ func (p *NodeList) neoMsgEncodedLenM() int { ...@@ -6199,7 +6199,7 @@ func (p *NodeList) neoMsgEncodedLenM() int {
func (p *NodeList) neoMsgEncodeM(data []byte) { func (p *NodeList) neoMsgEncodeM(data []byte) {
data[0] = byte(msgpack.FixArray_4 | 1) data[0] = byte(msgpack.FixArray_4 | 1)
data[1] = byte(msgpack.FixExt1) data[1] = byte(msgpack.FixExt1)
data[2] = 2 data[2] = 4
if !(0 <= p.NodeType && p.NodeType <= 0x7f) { if !(0 <= p.NodeType && p.NodeType <= 0x7f) {
panic("p.NodeType: invalid NodeType enum value)") panic("p.NodeType: invalid NodeType enum value)")
} }
...@@ -6216,8 +6216,8 @@ func (p *NodeList) neoMsgDecodeM(data []byte) (int, error) { ...@@ -6216,8 +6216,8 @@ func (p *NodeList) neoMsgDecodeM(data []byte) (int, error) {
if op := msgpack.Op(data[1]); op != msgpack.FixExt1 { if op := msgpack.Op(data[1]); op != msgpack.FixExt1 {
return 0, mdecodeOpErr("NodeList.NodeType", op, msgpack.FixExt1) return 0, mdecodeOpErr("NodeList.NodeType", op, msgpack.FixExt1)
} }
if enumType := data[2]; enumType != 2 { if enumType := data[2]; enumType != 4 {
return 0, mdecodeEnumTypeErr("NodeList.NodeType", enumType, 2) return 0, mdecodeEnumTypeErr("NodeList.NodeType", enumType, 4)
} }
{ {
v := data[3] v := data[3]
...@@ -6335,7 +6335,7 @@ func (p *AnswerNodeList) neoMsgEncodeM(data []byte) { ...@@ -6335,7 +6335,7 @@ func (p *AnswerNodeList) neoMsgEncodeM(data []byte) {
a := &p.NodeList[i] a := &p.NodeList[i]
data[0] = byte(msgpack.FixArray_4 | 5) data[0] = byte(msgpack.FixArray_4 | 5)
data[1] = byte(msgpack.FixExt1) data[1] = byte(msgpack.FixExt1)
data[2] = 2 data[2] = 4
if !(0 <= (*a).Type && (*a).Type <= 0x7f) { if !(0 <= (*a).Type && (*a).Type <= 0x7f) {
panic("(*a).Type: invalid NodeType enum value)") panic("(*a).Type: invalid NodeType enum value)")
} }
...@@ -6397,8 +6397,8 @@ func (p *AnswerNodeList) neoMsgDecodeM(data []byte) (int, error) { ...@@ -6397,8 +6397,8 @@ func (p *AnswerNodeList) neoMsgDecodeM(data []byte) (int, error) {
if op := msgpack.Op(data[1]); op != msgpack.FixExt1 { if op := msgpack.Op(data[1]); op != msgpack.FixExt1 {
return 0, mdecodeOpErr("AnswerNodeList.Type", op, msgpack.FixExt1) return 0, mdecodeOpErr("AnswerNodeList.Type", op, msgpack.FixExt1)
} }
if enumType := data[2]; enumType != 2 { if enumType := data[2]; enumType != 4 {
return 0, mdecodeEnumTypeErr("AnswerNodeList.Type", enumType, 2) return 0, mdecodeEnumTypeErr("AnswerNodeList.Type", enumType, 4)
} }
{ {
v := data[3] v := data[3]
...@@ -6899,7 +6899,7 @@ func (p *AnswerTweakPartitionTable) neoMsgEncodeM(data []byte) { ...@@ -6899,7 +6899,7 @@ func (p *AnswerTweakPartitionTable) neoMsgEncodeM(data []byte) {
data = data[1+n:] data = data[1+n:]
} }
data[0] = byte(msgpack.FixExt1) data[0] = byte(msgpack.FixExt1)
data[1] = 4 data[1] = 0
if !(0 <= (*a).State && (*a).State <= 0x7f) { if !(0 <= (*a).State && (*a).State <= 0x7f) {
panic("(*a).State: invalid CellState enum value)") panic("(*a).State: invalid CellState enum value)")
} }
...@@ -6977,8 +6977,8 @@ func (p *AnswerTweakPartitionTable) neoMsgDecodeM(data []byte) (int, error) { ...@@ -6977,8 +6977,8 @@ func (p *AnswerTweakPartitionTable) neoMsgDecodeM(data []byte) (int, error) {
if op := msgpack.Op(data[0]); op != msgpack.FixExt1 { if op := msgpack.Op(data[0]); op != msgpack.FixExt1 {
return 0, mdecodeOpErr("AnswerTweakPartitionTable.State", op, msgpack.FixExt1) return 0, mdecodeOpErr("AnswerTweakPartitionTable.State", op, msgpack.FixExt1)
} }
if enumType := data[1]; enumType != 4 { if enumType := data[1]; enumType != 0 {
return 0, mdecodeEnumTypeErr("AnswerTweakPartitionTable.State", enumType, 4) return 0, mdecodeEnumTypeErr("AnswerTweakPartitionTable.State", enumType, 0)
} }
{ {
v := data[2] v := data[2]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment