Beispiel #1
0
func (s *server) chooseTopology(topology *goshawk.Topology) (*goshawk.Topology, error) {
	var config *configuration.Configuration
	if s.configFile != "" {
		var err error
		config, err = configuration.LoadConfigurationFromPath(s.configFile)
		if err != nil {
			return nil, err
		}
	}

	switch {
	case topology == nil && config == nil:
		return nil, fmt.Errorf("Local data store is empty and no external config supplied. Must supply config with -config")
	case topology == nil:
		return goshawk.NewTopology(config), nil
	case config == nil:
		return topology, nil
	case topology.Configuration.Equal(config):
		return topology, nil
	case topology.ClusterId != config.ClusterId:
		return nil, fmt.Errorf("Local data store is configured for cluster '%v', but supplied config is for cluster '%v'. Cannot continue. Either adjust config or use clean data directory", topology.ClusterId, config.ClusterId)
	default:
		return nil, fmt.Errorf("Topology change not currently supported. Sorry.")
	}
}
Beispiel #2
0
func (s *server) signalReloadConfig() {
	if s.configFile == "" {
		log.Println("Attempt to reload config failed as no path to configuration provided on command line.")
		return
	}
	config, err := configuration.LoadConfigurationFromPath(s.configFile)
	if err != nil {
		log.Println("Cannot reload config due to error:", err)
		return
	}
	s.transmogrifier.RequestConfigurationChange(config)
}
Beispiel #3
0
func (s *server) signalReloadConfig() {
	if s.configFile == "" {
		log.Println("Attempt to reload config failed as no path to configuration provided on command line.")
		return
	}
	config, err := configuration.LoadConfigurationFromPath(s.configFile)
	if err != nil {
		log.Println("Cannot reload config due to error:", err)
		return
	}
	localHost, remoteHosts, err := config.LocalRemoteHosts(s.port)
	if err != nil {
		log.Println("Cannot reload config due to error:", err)
		return
	}
	s.connectionManager.SetDesiredServers(localHost, remoteHosts)
	log.Println("Reloaded configuration.")
}
Beispiel #4
0
func (s *server) commandLineConfig() (*configuration.Configuration, error) {
	if s.configFile != "" {
		return configuration.LoadConfigurationFromPath(s.configFile)
	}
	return nil, nil
}