Ejemplo n.º 1
0
func statCallback(w http.ResponseWriter, r *http.Request) {
	w.WriteHeader(200)
	fmt.Fprintf(w, "Version: %s\n", local.Version)
	fmt.Fprintf(w, "NumSession: %d\n", getProxySessionSize())
	if nil != dnsCache {
		fmt.Fprintf(w, "DNSCacheSize: %d\n", dnsCache.Len())
	}
	ots.Handle("stat", w)
	for _, p := range proxyTable {
		p.PrintStat(w)
	}
	dumpProxySessions(w)
}
Ejemplo n.º 2
0
func (proc *processorEventHander) OnEvent(event *Event, conn io.ReadWriteCloser) {
	procQPSTrack.IncMsgCount(1)
	if procGORoutinesCounter.Add(1) > int64(procConfig.MaxGORoutine) {
		procGORoutinesCounter.Add(-1)
		glog.Warningf("Too many[%d] goroutines in processor, discard incoming event.", procGORoutinesCounter.Get())
		return
	}
	go func() {
		start := time.Now().UnixNano()
		if event.GetType() == EventType_NOTIFY {
			procConfig.Proc.OnMessage(event.Msg, event.GetHashCode())
		} else {
			if event.GetTo() != getProcessorName() {
				fmt.Errorf("Recv msg %T to %s, but current processor is %s", event.Msg, event.GetTo(), getProcessorName())
				return
			}
			if event.GetType() == EventType_RESPONSE {
				triggerClientSessionRes(event.Msg, event.GetHashCode())
			} else {
				var res proto.Message
				if admin, ok := event.Msg.(*AdminRequest); ok {
					err := ots.Handle(admin.GetLine(), &adminEventWriter{event.GetHashCode()})
					res = &AdminResponse{}
					if err == io.EOF {
						res.(*AdminResponse).Close = proto.Bool(true)
					}
				} else {
					res = procConfig.Proc.OnRPC(event.Msg)
				}
				response(res, event, procipc)
			}
		}
		end := time.Now().UnixNano()
		cost := (end - start) / 1000000 //millsecs
		procLatencyTrack.AddCost(cost)
		procGORoutinesCounter.Add(-1)
	}()
}
Ejemplo n.º 3
0
func stackdumpCallback(w http.ResponseWriter, req *http.Request) {
	w.WriteHeader(200)
	ots.Handle("stackdump", w)
}
Ejemplo n.º 4
0
func statCallback(w http.ResponseWriter, req *http.Request) {
	w.WriteHeader(200)
	fmt.Fprintf(w, "Version:    %s\n", remote.Version)
	fmt.Fprintf(w, "NumSession: %d\n", remote.GetSessionTableSize())
	ots.Handle("stat", w)
}
Ejemplo n.º 5
0
func gcCallback(w http.ResponseWriter, req *http.Request) {
	w.WriteHeader(200)
	ots.Handle("gc", w)
}
Ejemplo n.º 6
0
func memdumpCallback(w http.ResponseWriter, req *http.Request) {
	w.WriteHeader(200)
	ots.Handle("MemProfile", w)
}