Exemple #1
0
func (c *influxdbCluster) startUDPListener(se subEntry, port string) (*net.UDPAddr, error) {
	conf := udp.Config{}
	conf.Enabled = true
	conf.BindAddress = fmt.Sprintf("%s:%s", c.udpBind, port)
	conf.Database = se.db
	conf.RetentionPolicy = se.rp
	conf.Buffer = c.udpBuffer
	conf.ReadBuffer = c.udpReadBuffer

	l := c.LogService.NewLogger(fmt.Sprintf("[udp:%s.%s] ", se.db, se.rp), log.LstdFlags)
	service := udp.NewService(conf, l)
	service.PointsWriter = c.PointsWriter
	err := service.Open()
	if err != nil {
		return nil, err
	}
	c.services[se] = service
	c.logger.Println("I! started UDP listener for", se.db, se.rp)
	return service.Addr(), nil
}
Exemple #2
0
func (s *influxdbCluster) startUDPListener(cluster, rp, port string) (*net.UDPAddr, error) {
	c := udp.Config{}
	c.Enabled = true
	c.BindAddress = fmt.Sprintf("%s:%s", s.udpBind, port)
	c.Database = cluster
	c.RetentionPolicy = rp
	c.Buffer = s.udpBuffer
	c.ReadBuffer = s.udpReadBuffer

	l := s.LogService.NewLogger(fmt.Sprintf("[udp:%s.%s] ", cluster, rp), log.LstdFlags)
	service := udp.NewService(c, l)
	service.PointsWriter = s.PointsWriter
	err := service.Open()
	if err != nil {
		return nil, err
	}
	s.services = append(s.services, service)
	s.logger.Println("I! started UDP listener for", cluster, rp)
	return service.Addr(), nil
}
Exemple #3
0
func (s *Service) startListener(db, rp string, u url.URL) (net.Addr, error) {
	switch u.Scheme {
	case "udp":
		c := udp.Config{}
		c.Enabled = true
		c.BindAddress = u.Host
		c.Database = db
		c.RetentionPolicy = rp
		c.Buffer = s.udpBuffer
		c.ReadBuffer = s.udpReadBuffer

		l := s.LogService.NewLogger(fmt.Sprintf("[udp:%s.%s] ", db, rp), log.LstdFlags)
		service := udp.NewService(c, l)
		service.PointsWriter = s.PointsWriter
		err := service.Open()
		if err != nil {
			return nil, err
		}
		s.services = append(s.services, service)
		s.logger.Println("I! started UDP listener for", db, rp)
		return service.Addr(), nil
	}
	return nil, fmt.Errorf("unsupported scheme %q", u.Scheme)
}