Exemplo n.º 1
0
func getAllProxySlowop() map[string][]*router.SlowOpInfo {
	proxies, err := models.ProxyList(unsafeZkConn, globalEnv.ProductName(), nil)
	if err != nil {
		log.ErrorErrorf(err, "get proxy list failed")
		return nil
	}

	ret := make(map[string][]*router.SlowOpInfo)
	for _, p := range proxies {
		m, err := p.DebugVars()
		if err != nil {
			log.WarnErrorf(err, "get proxy debug varsfailed")
		}
		if m["router"] != nil {
			route := m["router"].(map[string]interface{})
			if route["slowop"] != nil {
				ops := make([]*router.SlowOpInfo, 0, 10)
				for _, elem := range route["slowop"].([]interface{}) {
					op := elem.(map[string]interface{})
					s := &router.SlowOpInfo{
						Time:     op["time"].(string),
						Key:      op["key"].(string),
						Duration: int64(op["duration"].(float64)),
						Reqs:     int64(op["req"].(float64)),
					}
					ops = append(ops, s)
				}
				ret[p.Id] = ops
			}
		}
	}
	return ret
}
Exemplo n.º 2
0
func apiGetProxyList(param martini.Params) (int, string) {
	proxies, err := models.ProxyList(safeZkConn, globalEnv.ProductName(), nil)
	if err != nil {
		log.Warning(err)
		return 500, err.Error()
	}
	b, err := json.MarshalIndent(proxies, " ", "  ")
	return 200, string(b)
}
Exemplo n.º 3
0
func runProxyList() error {
	proxies, err := models.ProxyList(zkConn, productName, nil)
	if err != nil {
		log.Warning(err)
		return err
	}
	b, _ := json.MarshalIndent(proxies, " ", "  ")
	fmt.Println(string(b))
	return nil
}
Exemplo n.º 4
0
func apiGetProxyList(param martini.Params) (int, string) {
	conn := CreateZkConn()
	defer conn.Close()

	proxies, err := models.ProxyList(conn, productName, nil)
	if err != nil {
		log.Warning(err)
		return 500, err.Error()
	}
	b, err := json.MarshalIndent(proxies, " ", "  ")
	return 200, string(b)
}
Exemplo n.º 5
0
func getAllProxyOps() int64 {
	proxies, err := models.ProxyList(unsafeZkConn, globalEnv.ProductName(), nil)
	if err != nil {
		log.Warning(err)
		return -1
	}

	var total int64
	for _, p := range proxies {
		i, err := p.Ops()
		if err != nil {
			log.Warning(err)
		}
		total += i
	}
	return total
}
Exemplo n.º 6
0
// for debug
func getAllProxyDebugVars() map[string]map[string]interface{} {
	proxies, err := models.ProxyList(unsafeZkConn, globalEnv.ProductName(), nil)
	if err != nil {
		log.Warning(err)
		return nil
	}

	ret := make(map[string]map[string]interface{})
	for _, p := range proxies {
		m, err := p.DebugVars()
		if err != nil {
			log.Warning(err)
		}
		ret[p.Id] = m
	}
	return ret
}
Exemplo n.º 7
0
func getAllProxyOps() int64 {
	proxies, err := models.ProxyList(unsafeZkConn, globalEnv.ProductName(), nil)
	if err != nil {
		log.ErrorErrorf(err, "get proxy list failed")
		return -1
	}

	var total int64
	for _, p := range proxies {
		i, err := p.Ops()
		if err != nil {
			log.WarnErrorf(err, "get proxy ops failed")
		}
		total += i
	}
	return total
}
Exemplo n.º 8
0
func getAllProxyOps() int64 {
	conn := CreateZkConn()
	defer conn.Close()
	proxies, err := models.ProxyList(conn, productName, nil)
	if err != nil {
		log.Warning(err)
		return -1
	}

	var total int64
	for _, p := range proxies {
		i, err := p.Ops()
		if err != nil {
			log.Warning(err)
		}
		total += i
	}
	return total
}
Exemplo n.º 9
0
// for debug
func getAllProxyDebugVars() map[string]map[string]interface{} {
	conn := CreateZkConn()
	defer conn.Close()
	proxies, err := models.ProxyList(conn, productName, nil)
	if err != nil {
		log.Warning(err)
		return nil
	}

	ret := make(map[string]map[string]interface{})
	for _, p := range proxies {
		m, err := p.DebugVars()
		if err != nil {
			log.Warning(err)
		}
		ret[p.Id] = m
	}
	return ret
}