Пример #1
0
func newZkCell(name, zkaddr string) *zkCell {
	result := &zkCell{cellName: name, zkAddr: zkaddr, zcache: newZkCache()}
	result.ready = sync.NewCond(&result.mutex)
	result.states = stats.NewStates("", []string{"Disconnected", "Connecting", "Connected", "BackOff"}, time.Now(), CELL_DISCONNECTED)
	go result.backgroundRefresher()
	return result
}
Пример #2
0
func NewBinlogServer(mysqld *Mysqld) *BinlogServer {
	binlogServer := new(BinlogServer)
	binlogServer.mysqld = mysqld
	binlogServer.blsStats = newBlsStats()
	binlogServer.states = stats.NewStates("BinlogServerState", []string{
		"Disabled",
		"Enabled",
	}, time.Now(), BINLOG_SERVER_DISABLED)
	return binlogServer
}
Пример #3
0
func NewBinlogServer(mycnf *Mycnf) *BinlogServer {
	binlogServer := new(BinlogServer)
	binlogServer.mycnf = mycnf
	binlogServer.blsStats = newBlsStats()
	binlogServer.states = estats.NewStates("", []string{
		"Disabled",
		"Enabled",
	}, time.Now(), BINLOG_SERVER_DISABLED)
	return binlogServer
}
Пример #4
0
func RegisterCacheInvalidator() {
	if CacheInvalidationProcessor != nil {
		return
	}
	CacheInvalidationProcessor = NewInvalidationProcessor()
	CacheInvalidationProcessor.states = estats.NewStates("", []string{
		"Disabled",
		"Enabled",
	}, time.Now(), DISABLED)
	expvar.Publish("CacheInvalidationProcessor", estats.StrFunc(func() string { return CacheInvalidationProcessor.statsJSON() }))
}
Пример #5
0
func RegisterUpdateStreamService(mycnf *Mycnf) {
	if UpdateStreamRpcService != nil {
		//log.Warningf("Update Stream service already initialized")
		return
	}

	UpdateStreamRpcService = &UpdateStream{mycnf: mycnf}
	UpdateStreamRpcService.states = stats.NewStates("UpdateStreamState", []string{
		"Disabled",
		"Enabled",
	}, time.Now(), DISABLED)
	rpcwrap.RegisterAuthenticated(UpdateStreamRpcService)
}
Пример #6
0
func RegisterUpdateStreamService(mycnf *Mycnf) {
	if UpdateStreamRpcService != nil {
		//relog.Warning("Update Stream service already initialized")
		return
	}

	UpdateStreamRpcService = &UpdateStream{mycnf: mycnf}
	UpdateStreamRpcService.states = estats.NewStates("", []string{
		"Disabled",
		"Enabled",
	}, time.Now(), DISABLED)
	rpcwrap.RegisterAuthenticated(UpdateStreamRpcService)
	expvar.Publish("UpdateStreamRpcService", estats.StrFunc(func() string { return UpdateStreamRpcService.statsJSON() }))
}
Пример #7
0
func NewSqlQuery(config Config) *SqlQuery {
	sq := &SqlQuery{}
	sq.qe = NewQueryEngine(config)
	sq.states = stats.NewStates("", []string{
		stateName[NOT_SERVING],
		stateName[CLOSED],
		stateName[CONNECTING],
		stateName[ABORT],
		stateName[INITIALIZING],
		stateName[OPEN],
		stateName[SHUTTING_DOWN],
	}, time.Now(), NOT_SERVING)
	stats.PublishFunc("Voltron", func() string { return sq.statsJSON() })
	return sq
}
Пример #8
0
func NewBinlogController(ts topo.Server, dbConfig *mysql.ConnectionParams, keyspace string, source topo.SourceShard) *BinlogPlayerController {
	blc := &BinlogPlayerController{
		ts:          ts,
		dbConfig:    dbConfig,
		keyspace:    keyspace,
		source:      source,
		interrupted: make(chan struct{}, 1),
	}
	blc.states = stats.NewStates("", []string{
		"Connecting",
		"Playing",
		"Sleeping",
	}, time.Now(), BINLOG_PLAYER_CONNECTING)
	return blc
}
Пример #9
0
func NewSqlQuery(config Config) *SqlQuery {
	sq := &SqlQuery{}
	sq.qe = NewQueryEngine(config)
	sq.states = stats.NewStates("", []string{
		stateName[NOT_SERVING],
		stateName[CONNECTING],
		stateName[ABORT],
		stateName[INITIALIZING],
		stateName[SERVING],
		stateName[SHUTTING_DOWN],
	}, time.Now(), NOT_SERVING)
	stats.PublishJSONFunc("Voltron", sq.statsJSON)
	stats.Publish("TabletState", stats.IntFunc(sq.state.Get))
	return sq
}
Пример #10
0
func RegisterCacheInvalidator() {
	if CacheInvalidationProcessor != nil {
		return
	}
	CacheInvalidationProcessor = NewInvalidationProcessor()
	CacheInvalidationProcessor.states = estats.NewStates("RowcacheInvalidationState", []string{
		"Disabled",
		"Enabled",
	}, time.Now(), DISABLED)
	estats.Publish("RowcacheInvalidationCheckPoint", estats.StringFunc(func() string {
		if pos := CacheInvalidationProcessor.currentPosition; pos != nil {
			return pos.String()
		}
		return ""
	}))
}
Пример #11
0
func (cc *ConnCache) ConnForPath(zkPath string) (cn Conn, err error) {
	zcell, err := ZkCellFromZkPath(zkPath)
	if err != nil {
		return nil, &zookeeper.Error{Op: "dial", Code: zookeeper.ZBADARGUMENTS}
	}

	cc.mutex.Lock()
	if cc.zconnCellMap == nil {
		cc.mutex.Unlock()
		return nil, &zookeeper.Error{Op: "dial", Code: zookeeper.ZCLOSING}
	}

	conn, ok := cc.zconnCellMap[zcell]
	if !ok {
		conn = &cachedConn{}
		conn.states = stats.NewStates("CachedConn"+strings.Title(zcell), []string{"Disconnected", "Connecting", "Connected"}, time.Now(), DISCONNECTED)
		cc.zconnCellMap[zcell] = conn
	}
	cc.mutex.Unlock()

	// We only want one goroutine at a time trying to connect here, so keep the
	// lock during the zk dial process.
	conn.mutex.Lock()
	defer conn.mutex.Unlock()

	if conn.zconn != nil {
		return conn.zconn, nil
	}

	zkAddr, err := ZkPathToZkAddr(zkPath, cc.useZkocc)
	if err != nil {
		return nil, &zookeeper.Error{Op: "dial", Code: zookeeper.ZBADARGUMENTS}
	}

	cc.setState(zcell, conn, CONNECTING)
	if cc.useZkocc {
		conn.zconn, err = DialZkocc(zkAddr, *baseTimeout)
	} else {
		conn.zconn, err = cc.newZookeeperConn(zkAddr, zcell)
	}
	if conn.zconn != nil {
		cc.setState(zcell, conn, CONNECTED)
	} else {
		cc.setState(zcell, conn, DISCONNECTED)
	}
	return conn.zconn, err
}