Documentation ¶
Overview ¶
* Project: CurveCli * Created Date: 2022-09-02 * Author: chengyi (Cyber-SiKu)
* Project: CurveCli * Created Date: 2023-12-26 * Author: wsehjk
Index ¶
- Constants
- Variables
- func Addr2IpPort(addr string) (string, uint32, *cmderror.CmdError)
- func AskConfirmation(promptStr string, confirm string) bool
- func CalcString2Signature(in string, secretKet string) string
- func CopysetKey2PoolidCopysetid(copysetKey uint64) (uint32, uint32)
- func CurvefsPath2ClientPath(curvefsPath string, mountpointInfo *mountinfo.MountInfo) string
- func GetCopysetKey(poolid uint64, copysetid uint64) uint64
- func GetCurveFSMountPoints() ([]*mountinfo.MountInfo, *cmderror.CmdError)
- func GetDefaultCheckTime(opType CheckOperatorType) time.Duration
- func GetIndexSlice(source []string, target []string) []int
- func GetOpNumSubUri(opName string) string
- func GetPoolLogicalAllocSubUri(poolName string) string
- func GetPoolLogicalCapacitySubUri(poolName string) string
- func GetPoolTotalChunkSizeName(poolName string) string
- func GetPoolUsedChunkSizeName(poolName string) string
- func GetString2Signature(date uint64, owner string) string
- func GetTimeofDayUs() (uint64, *cmderror.CmdError)
- func IsAligned(value uint64, alignment uint64) bool
- func IsAlpha(r rune) bool
- func IsDigit(r rune) bool
- func IsUpper(r rune) bool
- func IsValidFsname(fsName string) bool
- func IsValidPath(path string) bool
- func ListMap2ListSortByKeys(rows []map[string]string, headers []string, keys []string) [][]string
- func Map2List(row map[string]string, headers []string) []string
- func ParseThrottleType(typeStr string) (nameserver2.ThrottleType, *cmderror.CmdError)
- func Path2CurvefsPath(path string, mountpoint *mountinfo.MountInfo) string
- func PeerAddressToAddr(peer string) (string, *cmderror.CmdError)
- func PeertoAddr(peer *common.Peer) (string, *cmderror.CmdError)
- func RmWitespaceStr(str string) string
- func SplitMountpoint(mountpoint string) ([]string, *cmderror.CmdError)
- func StringList2Uint32List(strList []string) ([]uint32, error)
- func StringList2Uint64List(strList []string) ([]uint64, error)
- func ToUnderscoredName(src string) string
- func Topology2Map(topo *topology.ListTopologyResponse) (map[string]interface{}, *cmderror.CmdError)
- func TranslateBitmapLocation(bitmapLocation string) (common.BitmapLocation, *cmderror.CmdError)
- func TranslateFileType(fileType string) (nameserver2.FileType, *cmderror.CmdError)
- func TranslateFsType(fsType string) (common.FSType, *cmderror.CmdError)
- type BsCopysetInfoStatus
- type COPYSET_HEALTH_STATUS
- type COPYSET_STATE
- type CheckOperatorType
- type ClUSTER_HEALTH_STATUS
- type CopysetInfoStatus
- type MetaserverInfo
- type Pool
- type PoolInfo
- type ServerInfo
- type ZoneInfo
Constants ¶
const ( COPYSET_OK_STR = "ok" COPYSET_WARN_STR = "warn" COPYSET_ERROR_STR = "error" COPYSET_NOTEXIST_STR = "not exist" )
const ( CLUSTER_ID = "clusterid" POOL_LIST = "poollist" )
const ( TYPE_DIR = "dir" TYPE_FILE = "file" )
const ( ROW_ROLE = "role" ROW_ADDR = "addr" ROW_ALLOC = "alloc" ROW_ALLOC_SIZE = "allocatedSize" ROW_BLOCKSIZE = "blocksize" ROW_CAPACITY = "capacity" ROW_CHILD_LIST = "childList" ROW_CHILD_TYPE = "childType" ROW_CHUNK = "chunk" ROW_CHUNKSERVER = "chunkserver" ROW_CHUNK_SIZE = "chunkSize" ROW_COPYSET = "copyset" ROW_COPYSET_ID = "copysetId" ROW_COPYSET_KEY = "copysetKey" ROW_CREATE_TIME = "createTime" ROW_CREATED = "created" ROW_CTIME = "ctime" ROW_DUMMY_ADDR = "dummyAddr" ROW_END = "end" ROW_EPOCH = "epoch" ROW_EXPLAIN = "explain" ROW_EXTERNAL_ADDR = "externalAddr" ROW_FILE = "file" ROW_FILE_NAME = "fileName" ROW_FILE_SIZE = "fileSize" ROW_FILE_TYPE = "fileType" ROW_FILE_LENGTH = "fileLength" ROW_FS_ID = "fsId" ROW_FS_NAME = "fsName" ROW_FS_TYPE = "fsType" ROW_GROUP = "group" ROW_HOSTNAME = "hostname" ROW_ID = "id" ROW_INODE_ID = "inodeId" ROW_INTERNAL_ADDR = "internalAddr" ROW_IP = "ip" ROW_KEY = "key" ROW_LEADER = "leader" ROW_FOLLOWER = "follower" ROW_OLDLEADER = "oldLeader" ROW_LEADER_PEER = "leaderPeer" ROW_LEFT = "left" ROW_LENGTH = "length" ROW_LOCATION = "location" ROW_LOG_GAP = "logGap" ROW_LOGICALPOOL = "logicalpool" ROW_METASERVER = "metaserver" ROW_METASERVER_ADDR = "metaserverAddr" ROW_MOUNT_NUM = "mountNum" ROW_MOUNTPOINT = "mountpoint" ROW_NAME = "name" ROW_NLINK = "nlink" ROW_NUM = "num" ROW_ONLINE_STATE = "onlineState" ROW_OPERATION = "operation" ROW_OPNAME = "opname" ROW_ORIGINAL_PATH = "originalPath" ROW_OWNER = "owner" ROW_PARENT = "parent" ROW_PARENT_ID = "parentId" ROW_PARTITION_ID = "partitionId" ROW_PEER = "peer" ROW_PEER_ADDR = "peerAddr" ROW_PEER_ID = "peerId" ROW_PEER_NUMBER = "peerNumber" ROW_PHYPOOL = "phyPool" ROW_PATH = "path" ROW_POOL = "pool" ROW_POOL_ID = "poolId" ROW_PORT = "port" ROW_PROGRESS = "progress" ROW_READONLY = "readonly" ROW_REASON = "reason" ROW_RECOVERING = "recovering" ROW_RECYCLABLE = "recyclable" ROW_RECYCLE = "recycle" ROW_RESULT = "result" ROW_SCAN = "scan" ROW_LASTSCAN = "last Scan" ROW_LAST_SCAN_CONSISTENT = "last Scan Consistent" ROW_SEGMENT = "segment" ROW_SEGMENT_SIZE = "segmentSize" ROW_SEQ = "seq" ROW_SERVER = "server" ROW_SIZE = "size" ROW_SRC = "src" ROW_START = "start" ROW_STATE = "state" ROW_STATUS = "status" ROW_HEALTHY = "healthy" ROW_UNHEALTHY = "unhealthy" ROW_STRIPE = "stripe" ROW_SUM_IN_DIR = "sumInDir" ROW_TASK_ID = "task id" ROW_TERM = "term" ROW_THROTTLE = "throttle" ROW_TOTAL = "total" ROW_TYPE = "type" ROW_USED = "used" ROW_INODE_NUM = "inodeNum" ROW_USER = "user" ROW_VERSION = "version" ROW_ZONE = "zone" ROW_AVAILFLAG = "availFlag" ROW_DRYRUN = "dryrun" ROW_HEALTHY_COUNT = "healthyCount" ROW_UNHEALTHY_COUNT = "unhealthyCount" ROW_HEALTHY_RATIO = "ratio" ROW_UNHEALTHY_RATIO = "unhealthyRatio" ROW_FORMAT_PERCENT = "formatPercent" ROW_TASKTYPE = "taskType" ROW_ISLAZY = "isLazy" ROW_NEXTSTEP = "nextStep" ROW_TIME = "time" ROW_SNAPSHOTNAME = "snapshotName" ROW_RW_STATUS = "rwStatus" ROW_DISK_STATE = "diskState" ROW_COPYSET_NUM = "copysetNum" ROW_DISK_CAPACITY = "diskCapacity" ROW_DISK_USED = "diskUsed" ROW_UNHEALTHY_COPYSET = "unhealthyCopyset" ROW_UNHEALTHY_COPYSET_RATIO = "unhealthyCopysetRatio" ROW_EXT_ADDR = "extAddr" ROW_SNAPSHOT_ID = "snapshotId" ROW_SNAPSHOT_NAME = "snapshotName" ROW_SNAPSHOT_SEQNUM = "snapshotSeqNum" // s3 ROW_S3CHUNKINFO_CHUNKID = "s3ChunkId" ROW_S3CHUNKINFO_LENGTH = "s3Length" ROW_S3CHUNKINFO_OFFSET = "s3Offset" ROW_S3CHUNKINFO_SIZE = "s3Size" // value ROW_VALUE_ADD = "add" ROW_VALUE_DEL = "del" ROW_VALUE_DNE = "DNE" ROW_VALUE_FAILED = "failed" ROW_VALUE_LOGICAL = "logical" ROW_VALUE_NO_RECOVERING = "" ROW_VALUE_NO_VALUE = "-" ROW_VALUE_NULL = "null" ROW_VALUE_OFFLINE = "offline" ROW_VALUE_ONLINE = "online" ROW_VALUE_PHYSICAL = "physical" ROW_VALUE_RECOVERING_OUT = "recovering from out" ROW_VALUE_SUCCESS = "success" ROW_VALUE_UNKNOWN = "unknown" ROW_VALUE_TRUE = "true" ROW_VALUE_FALSE = "false" )
const ( TYPE_POOL = "pool" TYPE_SERVER = "server" TYPE_ZONE = "zone" TYPE_PHYPOOL = "physicalpool" TYPE_LGPOOL = "logicalpool" )
topology type
const ( PATH_REGEX = `^(/[^/ ]*)+/?$` FS_NAME_REGEX = "^([a-z0-9]+\\-?)+$" K_STRING_TRUE = "true" ROOT_PATH = "/" RECYCLEBIN_PATH = "/RecycleBin" FALSE_STRING = "false" )
const ( LabelKey = "label" ClientTarget = "client" EtcdTarget = "etcd" MdsTarget = "mds" ChunkServerTarget = "chunkserver" SnapshotTarget = "snapshot" SnapshotServerTarget = "snapshotcloneserver" TargetKey = "targets" JobKey = "job" OutputFile = "target.json" TargetPathFlag = "path" )
const (
CURVEFS_MOUNTPOINT_FSTYPE = "fuse"
)
const HEALTH = "health"
Variables ¶
var ( CopysetState_name = map[uint32]string{ 1: "leader", 2: "transferring", 3: "candidate", 4: "follower", 5: "error", 6: "uninitialized", 7: "shutting", 8: "shutdown", } CopysetState_Avaliable = map[uint32]bool{ 1: true, 2: true, 3: true, 4: true, 5: false, 6: false, 7: false, 8: false, } )
var (
CheckOperatorName_value = map[string]int32{
"operator": 1,
"change_peer": 2,
"add_peer": 3,
"remove_peer": 4,
"transfer_leader": 5,
}
)
var (
ClusterHealthStatus_Str = map[int32]string{
1: "ok",
2: "warn",
3: "error",
}
)
var ClusterHealthStatus_StrWithColor = map[int32]string{ 1: color.Green.Sprint(CopysetHealthStatus_Str[1]), 2: color.Yellow.Sprint(CopysetHealthStatus_Str[2]), 3: color.Red.Sprint(CopysetHealthStatus_Str[3]), 4: color.Red.Sprint(CopysetHealthStatus_Str[4]), }
var ( CopysetHealthStatus_Str = map[int32]string{ 1: COPYSET_OK_STR, 2: COPYSET_WARN_STR, 3: COPYSET_ERROR_STR, 4: COPYSET_NOTEXIST_STR, } )
var CopysetHealthStatus_StrWithColor = map[int32]string{ 1: color.Green.Sprint(CopysetHealthStatus_Str[1]), 2: color.Yellow.Sprint(CopysetHealthStatus_Str[2]), 3: color.Red.Sprint(CopysetHealthStatus_Str[3]), 4: color.Red.Sprint(CopysetHealthStatus_Str[4]), }
Functions ¶
func AskConfirmation ¶
func CalcString2Signature ¶
func CopysetKey2PoolidCopysetid ¶
return poolid, copysetid
func CurvefsPath2ClientPath ¶
func GetCopysetKey ¶
func GetCurveFSMountPoints ¶
func GetDefaultCheckTime ¶
func GetDefaultCheckTime(opType CheckOperatorType) time.Duration
func GetIndexSlice ¶
func GetOpNumSubUri ¶
func GetString2Signature ¶
func GetTimeofDayUs ¶
func IsValidFsname ¶
func IsValidPath ¶
func ListMap2ListSortByKeys ¶
func ParseThrottleType ¶
func ParseThrottleType(typeStr string) (nameserver2.ThrottleType, *cmderror.CmdError)
func Path2CurvefsPath ¶
make sure path' abs path start with mountpoint.MountPoint
func StringList2Uint32List ¶
func StringList2Uint64List ¶
func ToUnderscoredName ¶
func Topology2Map ¶
func Topology2Map(topo *topology.ListTopologyResponse) (map[string]interface{}, *cmderror.CmdError)
func TranslateBitmapLocation ¶
func TranslateBitmapLocation(bitmapLocation string) (common.BitmapLocation, *cmderror.CmdError)
func TranslateFileType ¶
func TranslateFileType(fileType string) (nameserver2.FileType, *cmderror.CmdError)
Types ¶
type BsCopysetInfoStatus ¶
type BsCopysetInfoStatus struct { Info *bsheartbeat.CopySetInfo `json:"info,omitempty"` Peer2Status map[string]*bscopyset.CopysetStatusResponse `json:"peer status,omitempty"` }
type COPYSET_HEALTH_STATUS ¶
type COPYSET_HEALTH_STATUS int32
const ( COPYSET_OK COPYSET_HEALTH_STATUS = 1 COPYSET_WARN COPYSET_HEALTH_STATUS = 2 COPYSET_ERROR COPYSET_HEALTH_STATUS = 3 COPYSET_NOTEXIST COPYSET_HEALTH_STATUS = 4 )
func CheckBsCopySetHealth ¶
func CheckBsCopySetHealth(copysetIS *BsCopysetInfoStatus) (COPYSET_HEALTH_STATUS, []*cmderror.CmdError)
func CheckCopySetHealth ¶
func CheckCopySetHealth(copysetIS *CopysetInfoStatus) (COPYSET_HEALTH_STATUS, []*cmderror.CmdError)
The copyset is stored in n peers. Note the number of available peers as p. When p==n, the copy status is ok; when n>p>=n/2+1, the copy status is warn; when p<=n/2, the copy status is error.
The available status of the peer is online, and the op_status obtained from the copyStatus on the peer is ok, and the state of the copyStatus on the peer is the available status.
For the state available status of copysetStatus, please refer to CopysetState_Avaliable.
type COPYSET_STATE ¶
type COPYSET_STATE uint32
const ( STATE_LEADER COPYSET_STATE = 1 STATE_TRANSFERRING COPYSET_STATE = 2 STATE_CANDIDATE COPYSET_STATE = 3 STATE_FOLLOWER COPYSET_STATE = 4 STATE_ERROR COPYSET_STATE = 5 STATE_UNINITIALIZED COPYSET_STATE = 6 STATE_SHUTTING COPYSET_STATE = 7 STATE_SHUTDOWN COPYSET_STATE = 8 )
type CheckOperatorType ¶
type CheckOperatorType int32
const ( CheckOperatorTypeTotal CheckOperatorType = 1 CheckOperatorTypeChange CheckOperatorType = 2 CheckOperatorTypeAdd CheckOperatorType = 3 CheckOperatorTypeRemove CheckOperatorType = 4 CheckOperatorTypeTransfer CheckOperatorType = 5 )
func SupportOpName ¶
func SupportOpName(opName string) (CheckOperatorType, *cmderror.CmdError)
type ClUSTER_HEALTH_STATUS ¶
type ClUSTER_HEALTH_STATUS int32
const ( HEALTH_OK ClUSTER_HEALTH_STATUS = 1 HEALTH_WARN ClUSTER_HEALTH_STATUS = 2 HEALTH_ERROR ClUSTER_HEALTH_STATUS = 3 )
func CompareHealth ¶
func CompareHealth(a ClUSTER_HEALTH_STATUS, b ClUSTER_HEALTH_STATUS) ClUSTER_HEALTH_STATUS
type CopysetInfoStatus ¶
type CopysetInfoStatus struct { Info *heartbeat.CopySetInfo `json:"info,omitempty"` Peer2Status map[string]*copyset.CopysetStatusResponse `json:"peer status,omitempty"` }
type MetaserverInfo ¶
type MetaserverInfo struct {
topology.MetaServerInfo
}
type ServerInfo ¶
type ServerInfo struct { topology.ServerInfo Metaservers []*MetaserverInfo `json:"metaserverList"` }
type ZoneInfo ¶
type ZoneInfo struct { topology.ZoneInfo Servers []*ServerInfo `json:"serverList"` }