コード例 #1
0
ファイル: main.go プロジェクト: glestaris/clique
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,
		})
	}
}
コード例 #2
0
ファイル: dispatcher_test.go プロジェクト: glestaris/clique
	"net"

	"github.com/Sirupsen/logrus"
	"github.com/ice-stuff/clique/api"
	"github.com/ice-stuff/clique/dispatcher"
	"github.com/ice-stuff/clique/dispatcher/fakes"
	"github.com/ice-stuff/clique/transfer"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Dispatcher", func() {
	var (
		fakeScheduler             *fakes.FakeScheduler
		fakeTransferInterruptible *fakes.FakeInterruptible
		fakeTransferClient        *fakes.FakeTransferClient
		fakeApiRegistry           *fakes.FakeApiRegistry
		logger                    *logrus.Logger
		dsptchr                   *dispatcher.Dispatcher
	)

	BeforeEach(func() {
		fakeScheduler = new(fakes.FakeScheduler)
		fakeApiRegistry = new(fakes.FakeApiRegistry)
		logger = &logrus.Logger{
			Out:       GinkgoWriter,
			Level:     logrus.DebugLevel,
			Formatter: new(logrus.TextFormatter),
		}

		dsptchr = &dispatcher.Dispatcher{
			Scheduler: fakeScheduler,