Documentation ¶
Index ¶
- Constants
- Variables
- func APPConflictDatabase() string
- func AppDatabase() string
- func ApplyOpsFilter(key string) bool
- func DEBUG_LOG(arg0 interface{}, args ...interface{})
- func DelayFor(ms int64)
- func ExtractTs32(ts interface{}) int64
- func GetAllTimestamp(sources []*MongoSource) (map[string]TimestampNode, bson.MongoTimestamp, bson.MongoTimestamp, ...)
- func GetAndCompareVersion(session *mgo.Session, threshold string) (bool, error)
- func GetBalancerStatusByUrl(csUrl string) (bool, error)
- func GetColShardType(session *mgo.Session, namespace string) ([]string, string, error)
- func GetDBVersion(session *mgo.Session) (string, error)
- func GetDDLNamespace(log *oplog.PartialLog) string
- func GetNewestTimestampBySession(session *mgo.Session) (bson.MongoTimestamp, error)
- func GetNewestTimestampByUrl(url string) (bson.MongoTimestamp, error)
- func GetOldestTimestampBySession(session *mgo.Session) (bson.MongoTimestamp, error)
- func GetOldestTimestampByUrl(url string) (bson.MongoTimestamp, error)
- func Goodbye()
- func HasDuplicated(slice []string) bool
- func InitHttpApi(port int)
- func InitialLogger(logDir, logFile, level string, logBuffer bool, verbose bool) error
- func Int64ToString(v int64) string
- func IsNotFound(err error) bool
- func IsSharding(session *mgo.Session) bool
- func JournalFileName(identifier string) string
- func Map2Struct(data map[string]interface{}, tag string, ptr interface{}) error
- func MayBeRandom(port int) int
- func Mkdirs(dirs ...string) error
- func ParseMongoUrl(rawurl string) (string, map[string]string)
- func RunStatusMessage(status uint64) string
- func Struct2Map(ptr interface{}, tag string) (map[string]interface{}, error)
- func TimestampToInt64(ts bson.MongoTimestamp) int64
- func TimestampToLog(ts interface{}) string
- func TimestampToString(ts int64) string
- func Welcome()
- func WritePid(id string) (err error)
- func WritePidById(dir, id string) bool
- func YieldInMs(n int64)
- type ChunkRange
- type DBChunkMap
- type ElapsedTask
- type Int64Slice
- type Journal
- type MetricDelta
- type MongoConn
- type MongoSource
- type NS
- type OpsCounter
- type ReplicationMetric
- func (metric *ReplicationMetric) AddApply(incr uint64)
- func (metric *ReplicationMetric) AddCheckpoint(number uint64)
- func (metric *ReplicationMetric) AddConsume(incr uint64)
- func (metric *ReplicationMetric) AddFailed(incr uint64)
- func (metric *ReplicationMetric) AddFilter(incr uint64)
- func (metric *ReplicationMetric) AddGet(incr uint64)
- func (metric *ReplicationMetric) AddRetransmission(number uint64)
- func (metric *ReplicationMetric) AddSuccess(incr uint64)
- func (metric *ReplicationMetric) AddTableOps(table string, n uint64)
- func (metric *ReplicationMetric) AddTunnelTraffic(number uint64)
- func (metric *ReplicationMetric) Apply() uint64
- func (metric *ReplicationMetric) Get() uint64
- func (metric *ReplicationMetric) SetLSN(lsn int64)
- func (metric *ReplicationMetric) SetLSNACK(ack int64)
- func (metric *ReplicationMetric) SetLSNCheckpoint(ckpt int64)
- func (metric *ReplicationMetric) SetOplogAvg(size int64)
- func (metric *ReplicationMetric) SetOplogMax(max int64)
- func (metric *ReplicationMetric) Success() uint64
- func (metric *ReplicationMetric) TableOps() map[string]uint64
- func (metric *ReplicationMetric) Tps() uint64
- type ReplicationStatus
- type Sentinel
- type ShardCollection
- type ShardCollectionSpec
- type ShardingChunkMap
- type TableOps
- type TimestampNode
Constants ¶
const ( WorkGood uint64 = 0 GetReady uint64 = 1 FetchBad uint64 = 2 TunnelSendBad uint64 = 4 TunnelSyncBad uint64 = 8 ReplicaExecBad uint64 = 16 ConnectModePrimary = "primary" ConnectModeSecondaryPreferred = "secondaryPreferred" ConnectModeStandalone = "standalone" MajorityWriteConcern = "majority" GlobalDiagnosticPath = "diagnostic" // This is the time of golang was born to the world GolangSecurityTime = "2006-01-02T15:04:05Z" CheckpointStage = "ckptStage" StageOriginal = "original" StageFlushed = "flushed" StageRename = "rename" CheckpointName = "name" CheckpointAckTs = "ackTs" CheckpointSyncTs = "syncTs" )
const ( DBRefRef = "$ref" DBRefId = "$id" DBRefDb = "$db" LocalDB = "local" QueryTs = "ts" )
const ( JournalNothingOnDefault = iota JournalSampling JournalAll )
const ( FrequentInSeconds = 5 TimeFormat string = "2006-01-02 15:04:05" )
const ( KB = 1024 MB = 1024 * KB GB = 1024 * MB TB = 1024 * GB PB = 1024 * TB )
const ( METRIC_NONE = 0x0000000000000000 METRIC_CKPT_TIMES = 0x0000000000000001 METRIC_TUNNEL_TRAFFIC = 0x0000000000000010 METRIC_LSN_CKPT = 0x0000000000000100 METRIC_RETRANSIMISSION = 0x0000000000001000 METRIC_TPS = 0x0000000000010000 METRIC_SUCCESS = 0x0000000000100000 )
const ( ConfigDB = "config" SettingsCol = "settings" ShardCol = "shards" ChunkCol = "chunks" CollectionCol = "collections" HashedShard = "hashed" RangedShard = "ranged" ConifgShardLogInterval = 1 // s )
const (
BufferCapacity = 4 * 1024 * 1024
)
const OplogNS = "oplog.rs"
const (
OpsMax = 'z' - 'A'
)
const (
SampleFrequency = 1000
)
Variables ¶
var BRANCH = "$"
Build info
var (
HttpApi *nimo.HttpRestProvider
)
var JournalFilePattern = GlobalDiagnosticPath + string(filepath.Separator) + "%s.journal"
var SIGNALPROFILE = "$"
var SIGNALSTACK = "$"
var SentinelOptions struct { OplogDump int64 DuplicatedDump bool Pause bool TPS int64 }
SentinelOptions. option's value type should be String or Bool or Int64
Functions ¶
func APPConflictDatabase ¶
func APPConflictDatabase() string
func AppDatabase ¶
func AppDatabase() string
func ApplyOpsFilter ¶
func ExtractTs32 ¶
func ExtractTs32(ts interface{}) int64
func GetAllTimestamp ¶
func GetAllTimestamp(sources []*MongoSource) (map[string]TimestampNode, bson.MongoTimestamp, bson.MongoTimestamp, bson.MongoTimestamp, bson.MongoTimestamp, error)
* get all newest timestamp * return: * map: whole timestamp map, key: replset name, value: struct that includes the newest and oldest timestamp * bson.MongoTimestamp: the biggest of the newest timestamp * bson.MongoTimestamp: the smallest of the newest timestamp * error: error
func GetAndCompareVersion ¶
get current db version and compare to threshold. Return whether the result is bigger or equal to the input threshold.
func GetBalancerStatusByUrl ¶
get balancer status from config server
func GetColShardType ¶
func GetDBVersion ¶
get db version, return string with format like "3.0.1"
func GetDDLNamespace ¶
func GetDDLNamespace(log *oplog.PartialLog) string
func GetNewestTimestampBySession ¶
func GetNewestTimestampBySession(session *mgo.Session) (bson.MongoTimestamp, error)
get newest oplog
func GetNewestTimestampByUrl ¶
func GetNewestTimestampByUrl(url string) (bson.MongoTimestamp, error)
func GetOldestTimestampBySession ¶
func GetOldestTimestampBySession(session *mgo.Session) (bson.MongoTimestamp, error)
get oldest oplog
func GetOldestTimestampByUrl ¶
func GetOldestTimestampByUrl(url string) (bson.MongoTimestamp, error)
func HasDuplicated ¶
func InitHttpApi ¶
func InitHttpApi(port int)
func InitialLogger ¶
func Int64ToString ¶
func IsNotFound ¶
func IsSharding ¶
func JournalFileName ¶
func Map2Struct ¶
func MayBeRandom ¶
func RunStatusMessage ¶
func Struct2Map ¶
func TimestampToInt64 ¶
func TimestampToInt64(ts bson.MongoTimestamp) int64
func TimestampToLog ¶
func TimestampToLog(ts interface{}) string
func TimestampToString ¶
func WritePidById ¶
Types ¶
type ChunkRange ¶
type ChunkRange struct { // the minimum/maximum of the chunk range of multiple columns shard key has multiple values Mins []interface{} Maxs []interface{} }
type DBChunkMap ¶
type DBChunkMap map[string]*ShardCollection
type ElapsedTask ¶
type ElapsedTask struct { // timer trigger TimeLimit int64 // batch trigger BatchLimit int64 // contains filtered or unexported fields }
func NewThresholder ¶
func NewThresholder(timeLimit, batchLimit int64) *ElapsedTask
func (*ElapsedTask) Reset ¶
func (thresholder *ElapsedTask) Reset()
func (*ElapsedTask) Triiger ¶
func (thresholder *ElapsedTask) Triiger() bool
type Int64Slice ¶
type Int64Slice []int64
func (Int64Slice) Len ¶
func (p Int64Slice) Len() int
func (Int64Slice) Less ¶
func (p Int64Slice) Less(i, j int) bool
func (Int64Slice) Swap ¶
func (p Int64Slice) Swap(i, j int)
type Journal ¶
type Journal struct {
// contains filtered or unexported fields
}
func NewJournal ¶
func (*Journal) WriteRecord ¶
func (j *Journal) WriteRecord(oplog *oplog.PartialLog)
type MetricDelta ¶
struct used to mark the metric delta. Value: current value Delta: the difference between current value and previous value previous: store the previous value
func (*MetricDelta) Update ¶
func (o *MetricDelta) Update()
type MongoConn ¶
func NewMongoConn ¶
func (*MongoConn) AcquireReplicaSetName ¶
func (*MongoConn) HasOplogNs ¶
func (*MongoConn) HasUniqueIndex ¶
type MongoSource ¶
type OpsCounter ¶
type OpsCounter struct {
// contains filtered or unexported fields
}
one writer and multi readers
func (*OpsCounter) Add ¶
func (opsCounter *OpsCounter) Add(char byte, v uint64)
func (*OpsCounter) Map ¶
func (opsCounter *OpsCounter) Map() map[string]uint64
type ReplicationMetric ¶
type ReplicationMetric struct { NAME string SUBSCRIBE uint64 OplogFilter MetricDelta OplogGet MetricDelta OplogConsume MetricDelta OplogApply MetricDelta OplogSuccess MetricDelta OplogFail MetricDelta CheckpointTimes uint64 Retransmission uint64 TunnelTraffic uint64 LSN int64 LSNAck int64 LSNCheckpoint int64 OplogMaxSize int64 OplogAvgSize int64 TableOperations *TableOps // replication status ReplStatus ReplicationStatus }
func NewMetric ¶
func NewMetric(name string, subscribe uint64) *ReplicationMetric
func (*ReplicationMetric) AddApply ¶
func (metric *ReplicationMetric) AddApply(incr uint64)
func (*ReplicationMetric) AddCheckpoint ¶
func (metric *ReplicationMetric) AddCheckpoint(number uint64)
func (*ReplicationMetric) AddConsume ¶
func (metric *ReplicationMetric) AddConsume(incr uint64)
func (*ReplicationMetric) AddFailed ¶
func (metric *ReplicationMetric) AddFailed(incr uint64)
func (*ReplicationMetric) AddFilter ¶
func (metric *ReplicationMetric) AddFilter(incr uint64)
func (*ReplicationMetric) AddGet ¶
func (metric *ReplicationMetric) AddGet(incr uint64)
func (*ReplicationMetric) AddRetransmission ¶
func (metric *ReplicationMetric) AddRetransmission(number uint64)
func (*ReplicationMetric) AddSuccess ¶
func (metric *ReplicationMetric) AddSuccess(incr uint64)
func (*ReplicationMetric) AddTableOps ¶
func (metric *ReplicationMetric) AddTableOps(table string, n uint64)
func (*ReplicationMetric) AddTunnelTraffic ¶
func (metric *ReplicationMetric) AddTunnelTraffic(number uint64)
func (*ReplicationMetric) Apply ¶
func (metric *ReplicationMetric) Apply() uint64
func (*ReplicationMetric) Get ¶
func (metric *ReplicationMetric) Get() uint64
func (*ReplicationMetric) SetLSN ¶
func (metric *ReplicationMetric) SetLSN(lsn int64)
func (*ReplicationMetric) SetLSNACK ¶
func (metric *ReplicationMetric) SetLSNACK(ack int64)
func (*ReplicationMetric) SetLSNCheckpoint ¶
func (metric *ReplicationMetric) SetLSNCheckpoint(ckpt int64)
func (*ReplicationMetric) SetOplogAvg ¶
func (metric *ReplicationMetric) SetOplogAvg(size int64)
func (*ReplicationMetric) SetOplogMax ¶
func (metric *ReplicationMetric) SetOplogMax(max int64)
func (*ReplicationMetric) Success ¶
func (metric *ReplicationMetric) Success() uint64
func (*ReplicationMetric) TableOps ¶
func (metric *ReplicationMetric) TableOps() map[string]uint64
func (*ReplicationMetric) Tps ¶
func (metric *ReplicationMetric) Tps() uint64
type ReplicationStatus ¶
type ReplicationStatus uint64
func (*ReplicationStatus) Clear ¶
func (status *ReplicationStatus) Clear(s uint64)
func (*ReplicationStatus) GetStatusString ¶
func (status *ReplicationStatus) GetStatusString() string
func (*ReplicationStatus) IsGood ¶
func (status *ReplicationStatus) IsGood() bool
func (*ReplicationStatus) Update ¶
func (status *ReplicationStatus) Update(s uint64)
type ShardCollection ¶
type ShardCollection struct { Chunks []*ChunkRange // shard key may have multiple columns, for example {a:1, b:1, c:1} Keys []string ShardType string }
type ShardCollectionSpec ¶
func GetShardCollectionSpec ¶
func GetShardCollectionSpec(session *mgo.Session, log *oplog.PartialLog) *ShardCollectionSpec
type ShardingChunkMap ¶
type ShardingChunkMap map[string]map[string]*ShardCollection
{replset: {namespace: []ChunkRange} }
func GetChunkMapByUrl ¶
func GetChunkMapByUrl(csUrl string) (ShardingChunkMap, error)
type TableOps ¶
TableOps, count collection operations
func NewTableOps ¶
func NewTableOps() *TableOps
type TimestampNode ¶
type TimestampNode struct { Oldest bson.MongoTimestamp Newest bson.MongoTimestamp }