// joins a server to an existing cluster. func joinServer(s *influxdb.Server, u *url.URL, joinURLs []*url.URL) { // TODO: Use separate broker and data join urls. // Create data node on an existing data node. for _, joinURL := range joinURLs { if err := s.Join(u, joinURL); err != nil { log.Printf("join: failed to connect data node: %s: %s", u, err) } else { log.Printf("join: connected data node to %s", u) return } } log.Fatalf("join: failed to connect data node to any specified server") }
// initializes a new server that does not yet have an ID. func initializeServer(u *url.URL, s *influxdb.Server, b *influxdb.Broker, w io.Writer, initBroker bool) { // TODO: Create replica using the messaging client. if initBroker { // Create replica on broker. if err := b.CreateReplica(1, u); err != nil { log.Fatalf("replica creation error: %s", err) } } // Create messaging client. c := messaging.NewClient(1) c.SetLogOutput(w) if err := c.Open(filepath.Join(s.Path(), messagingClientFile), []*url.URL{b.URL()}); err != nil { log.Fatalf("messaging client error: %s", err) } if err := s.SetClient(c); err != nil { log.Fatalf("set client error: %s", err) } if initBroker { // Initialize the server. if err := s.Initialize(b.URL()); err != nil { log.Fatalf("server initialization error: %s", err) } } }
// opens the messaging client and attaches it to the server. func openServerClient(s *influxdb.Server, joinURLs []*url.URL) { c := messaging.NewClient(s.ID()) if err := c.Open(filepath.Join(s.Path(), messagingClientFile), joinURLs); err != nil { log.Fatalf("messaging client error: %s", err) } if err := s.SetClient(c); err != nil { log.Fatalf("set client error: %s", err) } }
// initializes a new server that does not yet have an ID. func initializeServer(s *influxdb.Server, b *messaging.Broker) { // TODO: Create replica using the messaging client. // Create replica on broker. if err := b.CreateReplica(1); err != nil { log.Fatalf("replica creation error: %s", err) } // Create messaging client. c := messaging.NewClient(1) if err := c.Open(filepath.Join(s.Path(), messagingClientFile), []*url.URL{b.URL()}); err != nil { log.Fatalf("messaging client error: %s", err) } if err := s.SetClient(c); err != nil { log.Fatalf("set client error: %s", err) } // Initialize the server. if err := s.Initialize(b.URL()); err != nil { log.Fatalf("server initialization error: %s", err) } }