Beispiel #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)
}
Beispiel #2
0
var _ = Describe("Orchestrator", func() {
	var (
		mockKvStore     *mockKvStore
		mockPartManager *mockPartitionManager
		key             string
		clientAddr      string
		orch            *orchestrator.Orchestrator
	)

	BeforeEach(func() {
		key = "some-key"
		clientAddr = "some-addr"
		mockKvStore = newMockKvStore()
		mockPartManager = newMockPartitionManager()
		orch = orchestrator.New(clientAddr, 2, mockPartManager, mockKvStore)
	})

	Context("FetchLeader", func() {
		It("returns an already elected leader", func() {
			expectedLeader := "some-leader"
			mockKvStore.fetchLeaderTx <- expectedLeader
			mockKvStore.fetchLeaderOk <- true

			leaderUri, local := orch.FetchLeader(key)

			Expect(leaderUri).To(Equal(expectedLeader))
			Expect(local).To(BeFalse())
			Expect(mockKvStore.fetchLeaderRx).To(Receive(Equal(key)))
		})