Exemple #1
0
func run(c *cli.Context) {
	validateFlags(c)
	setLogLevel(c)

	clientAddr := fmt.Sprintf("http://localhost:%d", c.Int(port))
	kvStore := kvstore.New(clientAddr, c.Int(healthPort))
	ioProvider := broker.NewFileProvider(c.String(dataDir), uint64(c.Int(segmentLength)), uint64(c.Int(numSegments)), time.Second)
	orch := orchestrator.New(clientAddr, uint(c.Int(numReplicas)), ioProvider, kvStore)

	broker.StartBrokerServer(c.Int(port), orch, ioProvider)
}
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("FileProvider", func() {
	var (
		tmpDir       string
		fileProvider *broker.FileProvider
	)

	BeforeEach(func() {
		var err error
		tmpDir, err = ioutil.TempDir("/tmp", "seg")
		Expect(err).ToNot(HaveOccurred())

		fileProvider = broker.NewFileProvider(tmpDir, 10, 3, 100*time.Millisecond)
	})

	AfterEach(func() {
		Expect(os.RemoveAll(tmpDir)).To(Succeed())
	})

	Context("ProvideWriter", func() {
		It("Provides the same writer for each unique name", func() {
			writer1 := fileProvider.ProvideWriter("some-name-1", 0)
			Expect(writer1).ToNot(BeNil())
			writer2 := fileProvider.ProvideWriter("some-name-1", 0)
			Expect(writer2).ToNot(BeNil())
			writer3 := fileProvider.ProvideWriter("some-name-2", 1)
			Expect(writer3).ToNot(BeNil())