示例#1
0
func Test_SourceServer(t *testing.T) {

	hp := config.HostPort{Host: "localhost", Port: 44444}
	err, poollink := pool.NewFlumePoolLink(hp)
	if nil != err {
		t.Fail()
	}

	list := list.New()
	list.PushFront(poollink)
	sourceserver := newSourceServer("location", list)

	go func() { sourceserver.start() }()

	for i := 0; i < 100; i++ {
		_, message := decodeCommand([]byte(LOG))
		sourceserver.buffChannel <- message
	}
	time.Sleep(10 * time.Second)
	sourceserver.stop()
}
示例#2
0
func (self *SourceManager) initFlumeClientPool(business string, flumenodes []config.HostPort) []*pool.FlumePoolLink {

	pools := make([]*pool.FlumePoolLink, 0, 10)
	for _, hp := range flumenodes {
		poollink, ok := self.hp2flumeClientPool[hp]
		if !ok {
			err, tmppool := pool.NewFlumePoolLink(hp)
			if nil != err {
				self.sourceManagerLog.Println("SOURCE_MANGER|INIT FLUMEPOOLLINE|FAIL|%s", err)
				continue
			}
			poollink = tmppool
			self.hp2flumeClientPool[hp] = poollink
		}

		defer func() {
			if nil == poollink {
				return
			}
			if err := recover(); nil != err {
				self.sourceManagerLog.Printf("SOURCE_MANGER|CREATE FLUMECLIENT|FAIL|[%s]\n", hp)
				poollink = nil
			}
		}()

		if nil == poollink {
			continue
		}

		poollink.AttachBusiness(business)
		pools = append(pools, poollink)
	}
	self.sourceManagerLog.Printf("SOURCE_MANGER|CREATE FLUMECLIENT|SUCCESS|[%s,%d]\n", business, len(flumenodes))

	return pools
}