Exemplo n.º 1
0
func (h *HostCallbacks) Deleted(zkPath string) {
	logger.Debugf("HostCallbacks.Deleted(%s)", zkPath)
	hostName, poolName := h.splitPath(zkPath)
	if pool := h.config.Pools[poolName]; pool != nil {
		pool.DelServer(hostName)
	}
}
Exemplo n.º 2
0
func (p *RuleCallbacks) Created(zkPath, jsonBlob string) {
	logger.Debugf("RuleCallbacks.Created(%s, %s)", zkPath, jsonBlob)
	var rule config.Rule
	if err := json.Unmarshal([]byte(jsonBlob), &rule); err != nil {
		logger.Errorf("%s unmarshalling %s as rule", err.Error(), jsonBlob)
		return
	}
	p.config.AddRule(rule)
}
Exemplo n.º 3
0
func (p *PortCallbacks) Changed(zkPath, jsonBlob string) {
	logger.Debugf("PortCallbacks.Changed(%s)", zkPath, jsonBlob)
	var port config.Port
	if err := json.Unmarshal([]byte(jsonBlob), &port); err != nil {
		logger.Errorf("%s unmarshalling %s as port", err.Error(), jsonBlob)
		return
	}
	p.config.UpdatePort(port)
}
Exemplo n.º 4
0
func (p *PoolCallbacks) Changed(path, jsonBlob string) {
	logger.Debugf("PoolCallbacks.Changed(%s, %s)", path, jsonBlob)
	var zkPool zk.ZkPool
	if err := json.Unmarshal([]byte(jsonBlob), &zkPool); err != nil {
		logger.Errorf("%s unmarshalling %s as pool", err.Error(), jsonBlob)
		return
	}
	p.config.UpdatePool(zkPool.Pool(nil))
}
Exemplo n.º 5
0
func (p *PoolCallbacks) Created(zkPath, jsonBlob string) {
	logger.Debugf("PoolCallbacks.Created(%s, %s)", zkPath, jsonBlob)
	var zkPool zk.ZkPool
	if err := json.Unmarshal([]byte(jsonBlob), &zkPool); err != nil {
		logger.Errorf("%s unmarshalling %s as pool", err.Error(), jsonBlob)
		return
	}
	p.config.AddPool(zkPool.Pool(map[string]config.Host{}))
}
Exemplo n.º 6
0
func (p *TrieCallbacks) Changed(path, jsonBlob string) {
	logger.Debugf("TrieCallbacks.Changed(%s, %s)", path, jsonBlob)
	var trie config.Trie
	if err := json.Unmarshal([]byte(jsonBlob), &trie); err != nil {
		logger.Errorf("%s unmarshalling %s as trie", err.Error(), jsonBlob)
		return
	}
	p.config.UpdateTrie(trie)
}
Exemplo n.º 7
0
func (p *PortCallbacks) Deleted(zkPath string) {
	logger.Debugf("PortCallbacks.Deleted(%s)", zkPath)
	port, err := strconv.ParseUint(path.Base(zkPath), 10, 16)
	if err != nil {
		logger.Errorf("%s interpreting base of %s as uint16", err.Error(), zkPath)
		return
	}
	p.config.DelPort(uint16(port))
	p.router.DelPort(uint16(port))
}
Exemplo n.º 8
0
func (p *TrieCallbacks) Created(zkPath, jsonBlob string) {
	logger.Debugf("TrieCallbacks.Created(%s, %s)", zkPath, jsonBlob)
	var trie config.Trie
	err := json.Unmarshal([]byte(jsonBlob), &trie)
	if err != nil {
		logger.Errorf("%s unmarshalling %s as trie", err.Error(), jsonBlob)
		return
	}
	p.config.AddTrie(trie)
}
Exemplo n.º 9
0
func (p *Pool) RunChecks() {
	for {
		select {
		case <-time.After(p.Config.HealthzEvery):
			for _, server := range p.Servers {
				go server.CheckStatus(p.Config.HealthzTimeout)
			}
		case <-p.killCh:
			logger.Debugf("[pool %s] stopping checks", p.Name)
			return
		}
	}
}
Exemplo n.º 10
0
func (h *HostCallbacks) Created(zkPath, jsonBlob string) {
	logger.Debugf("HostCallbacks.Created(%s, %s)", zkPath, jsonBlob)
	hostName, poolName := h.splitPath(zkPath)

	var host config.Host
	if err := json.Unmarshal([]byte(jsonBlob), &host); err != nil {
		logger.Errorf("%s unmarshalling %s as host", err.Error(), jsonBlob)
		return
	}

	if pool := h.config.Pools[poolName]; pool != nil {
		pool.AddServer(hostName, h.config.ConstructServer(host))
	}
}
Exemplo n.º 11
0
func (p *PoolCallbacks) Deleted(zkPath string) {
	logger.Debugf("PoolCallbacks.Deleted(%s)", zkPath)
	p.config.DelPool(path.Base(zkPath))
}
Exemplo n.º 12
0
func (p *TrieCallbacks) Deleted(zkPath string) {
	logger.Debugf("TrieCallbacks.Deleted(%s)", zkPath)
	p.config.DelTrie(path.Base(zkPath))
}