Exemplo n.º 1
0
func createTransferTasks(
	logger *logrus.Logger,
	cfg config.Config,
	dsptchr *dispatcher.Dispatcher,
) {
	logger.Debugf(
		"Found %d remote hosts for the initial transfers", len(cfg.RemoteHosts),
	)
	logger.Debugf("Size of initial transfers = %d bytes", cfg.InitTransferSize)

	for _, remoteHost := range cfg.RemoteHosts {
		host, portStr, err := net.SplitHostPort(remoteHost)
		if err != nil {
			logger.Fatalf("Parsing remote host `%s`: %s", remoteHost, err.Error())
		}
		port, err := strconv.ParseInt(portStr, 10, 16)
		if err != nil {
			logger.Fatalf(
				"Parsing remote host's port `%s`: %s",
				remoteHost, err.Error(),
			)
		}

		dsptchr.Create(api.TransferSpec{
			IP:   net.ParseIP(host),
			Port: uint16(port),
			Size: cfg.InitTransferSize,
		})
	}
}
Exemplo n.º 2
0
func NewMesosLib(master string, log *logrus.Logger, frameworkInfo *mesosproto.FrameworkInfo, ip string, port int) *MesosLib {
	m := &MesosLib{
		Log:           log,
		master:        master,
		frameworkInfo: frameworkInfo,
		ip:            ip,
		port:          port,
		Router:        mux.NewRouter(),
		events: events{
			mesosproto.Event_REGISTERED: make(chan *mesosproto.Event, 64),
			mesosproto.Event_OFFERS:     make(chan *mesosproto.Event, 64),
			mesosproto.Event_UPDATE:     make(chan *mesosproto.Event, 64),
		},
	}

	if m.ip == "" {
		name, err := os.Hostname()
		if err != nil {
			log.Fatalf("Failed to get hostname: %+v", err)
		}

		addrs, err := net.LookupHost(name)
		if err != nil {
			log.Fatalf("Failed to get address for hostname %q: %+v", name, err)
		}

		for _, addr := range addrs {
			if m.ip == "" || !strings.HasPrefix(addr, "127") {
				m.ip = addr
			}
		}
	}
	m.initAPI()
	return m
}
Exemplo n.º 3
0
func main() {
	var logrusLogger *logrus.Logger = logrus.New()
	logrusLogger.Formatter = new(logrus.JSONFormatter)

	if len(os.Args) != 2 {
		logrus.Error("Must pass an arg to test program...")
		os.Exit(0)
	}

	switch os.Args[1] {
	case "logrus.Fatal":
		logrusLogger.Fatal("fatal error")
	case "logrus.Fatalf":
		logrusLogger.Fatalf("fatal error%s", "fatal error")
	case "bark.Fatal":
		bark.NewLoggerFromLogrus(logrusLogger).Fatal("fatal error")
	case "bark.Fatalf":
		bark.NewLoggerFromLogrus(logrusLogger).Fatalf("fatal error%s", "fatal error")
	}

	logrus.Error("Expected fatal methods to exit...")
	os.Exit(0)
}