mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-11-24 08:46:54 +08:00
move error to a separate file
This file contains metric names for all errors The naming convention is ErrorSomeThing = "error.some.thing"
This commit is contained in:
@@ -218,11 +218,11 @@ func (n *Needle) ReadBytes(bytes []byte, offset int64, size Size, version Versio
|
||||
if n.Size != size {
|
||||
// cookie is not always passed in for this API. Use size to do preliminary checking.
|
||||
if OffsetSize == 4 && offset < int64(MaxPossibleVolumeSize) {
|
||||
stats.VolumeServerRequestCounter.WithLabelValues("errorSizeMismatchOffsetSize").Inc()
|
||||
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorSizeMismatchOffsetSize).Inc()
|
||||
glog.Errorf("entry not found1: offset %d found id %x size %d, expected size %d", offset, n.Id, n.Size, size)
|
||||
return ErrorSizeMismatch
|
||||
}
|
||||
stats.VolumeServerRequestCounter.WithLabelValues("errorSizeMismatch").Inc()
|
||||
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorSizeMismatch).Inc()
|
||||
return fmt.Errorf("entry not found: offset %d found id %x size %d, expected size %d", offset, n.Id, n.Size, size)
|
||||
}
|
||||
switch version {
|
||||
@@ -238,7 +238,7 @@ func (n *Needle) ReadBytes(bytes []byte, offset int64, size Size, version Versio
|
||||
checksum := util.BytesToUint32(bytes[NeedleHeaderSize+size : NeedleHeaderSize+size+NeedleChecksumSize])
|
||||
newChecksum := NewCRC(n.Data)
|
||||
if checksum != newChecksum.Value() {
|
||||
stats.VolumeServerRequestCounter.WithLabelValues("errorCRC").Inc()
|
||||
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorCRC).Inc()
|
||||
return errors.New("CRC error! Data On Disk Corrupted")
|
||||
}
|
||||
n.Checksum = newChecksum
|
||||
@@ -271,7 +271,7 @@ func (n *Needle) readNeedleDataVersion2(bytes []byte) (err error) {
|
||||
n.DataSize = util.BytesToUint32(bytes[index : index+4])
|
||||
index = index + 4
|
||||
if int(n.DataSize)+index > lenBytes {
|
||||
stats.VolumeServerRequestCounter.WithLabelValues("errorIndexOutOfRange").Inc()
|
||||
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorIndexOutOfRange).Inc()
|
||||
return fmt.Errorf("index out of range %d", 1)
|
||||
}
|
||||
n.Data = bytes[index : index+int(n.DataSize)]
|
||||
@@ -283,7 +283,7 @@ func (n *Needle) readNeedleDataVersion2(bytes []byte) (err error) {
|
||||
n.NameSize = uint8(bytes[index])
|
||||
index = index + 1
|
||||
if int(n.NameSize)+index > lenBytes {
|
||||
stats.VolumeServerRequestCounter.WithLabelValues("errorIndexOutOfRange").Inc()
|
||||
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorIndexOutOfRange).Inc()
|
||||
return fmt.Errorf("index out of range %d", 2)
|
||||
}
|
||||
n.Name = bytes[index : index+int(n.NameSize)]
|
||||
@@ -293,7 +293,7 @@ func (n *Needle) readNeedleDataVersion2(bytes []byte) (err error) {
|
||||
n.MimeSize = uint8(bytes[index])
|
||||
index = index + 1
|
||||
if int(n.MimeSize)+index > lenBytes {
|
||||
stats.VolumeServerRequestCounter.WithLabelValues("errorIndexOutOfRange").Inc()
|
||||
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorIndexOutOfRange).Inc()
|
||||
return fmt.Errorf("index out of range %d", 3)
|
||||
}
|
||||
n.Mime = bytes[index : index+int(n.MimeSize)]
|
||||
@@ -301,7 +301,7 @@ func (n *Needle) readNeedleDataVersion2(bytes []byte) (err error) {
|
||||
}
|
||||
if index < lenBytes && n.HasLastModifiedDate() {
|
||||
if LastModifiedBytesLength+index > lenBytes {
|
||||
stats.VolumeServerRequestCounter.WithLabelValues("errorIndexOutOfRange").Inc()
|
||||
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorIndexOutOfRange).Inc()
|
||||
return fmt.Errorf("index out of range %d", 4)
|
||||
}
|
||||
n.LastModified = util.BytesToUint64(bytes[index : index+LastModifiedBytesLength])
|
||||
@@ -309,7 +309,7 @@ func (n *Needle) readNeedleDataVersion2(bytes []byte) (err error) {
|
||||
}
|
||||
if index < lenBytes && n.HasTtl() {
|
||||
if TtlBytesLength+index > lenBytes {
|
||||
stats.VolumeServerRequestCounter.WithLabelValues("errorIndexOutOfRange").Inc()
|
||||
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorIndexOutOfRange).Inc()
|
||||
return fmt.Errorf("index out of range %d", 5)
|
||||
}
|
||||
n.Ttl = LoadTTLFromBytes(bytes[index : index+TtlBytesLength])
|
||||
@@ -317,13 +317,13 @@ func (n *Needle) readNeedleDataVersion2(bytes []byte) (err error) {
|
||||
}
|
||||
if index < lenBytes && n.HasPairs() {
|
||||
if 2+index > lenBytes {
|
||||
stats.VolumeServerRequestCounter.WithLabelValues("errorIndexOutOfRange").Inc()
|
||||
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorIndexOutOfRange).Inc()
|
||||
return fmt.Errorf("index out of range %d", 6)
|
||||
}
|
||||
n.PairsSize = util.BytesToUint16(bytes[index : index+2])
|
||||
index += 2
|
||||
if int(n.PairsSize)+index > lenBytes {
|
||||
stats.VolumeServerRequestCounter.WithLabelValues("errorIndexOutOfRange").Inc()
|
||||
stats.VolumeServerRequestCounter.WithLabelValues(stats.ErrorIndexOutOfRange).Inc()
|
||||
return fmt.Errorf("index out of range %d", 7)
|
||||
}
|
||||
end := index + int(n.PairsSize)
|
||||
|
||||
Reference in New Issue
Block a user