コード例 #1
0
ファイル: service_client.go プロジェクト: timani/bbs
func (db *serviceClient) NewBBSLockRunner(logger lager.Logger, bbsPresence *models.BBSPresence, retryInterval, lockTTL time.Duration) (ifrit.Runner, error) {
	bbsPresenceJSON, err := models.ToJSON(bbsPresence)
	if err != nil {
		return nil, err
	}
	return locket.NewLock(logger, db.consulClient, locket.LockSchemaPath("bbs_lock"), bbsPresenceJSON, db.clock, retryInterval, lockTTL), nil
}
コード例 #2
0
ファイル: main_test.go プロジェクト: cfibmers/nsync
				ghttp.RespondWith(200, `{"error":{},"desired_lrp_scheduling_infos":	[]}`),
			)

			fakeBBS.RouteToHandler("POST", "/v1/domains/upsert",
				ghttp.RespondWith(200, `{}`),
			)

			fakeBBS.RouteToHandler("POST", "/v1/desired_lrp/desire",
				ghttp.RespondWith(200, `{}`),
			)
		})

		JustBeforeEach(func() {
			process = startBulker(true)

			_, err := consulRunner.NewClient().KV().DeleteTree(locket.LockSchemaPath(bulkerLockName), nil)
			Expect(err).ToNot(HaveOccurred())
		})

		AfterEach(func() {
			ginkgomon.Interrupt(process, interruptTimeout)
		})

		It("exits with an error", func() {
			Eventually(process.Wait(), 5*domainTTL).Should(Receive(HaveOccurred()))
		})
	})

	Context("when the bulker initially does not have the lock", func() {
		var nsyncLockClaimerProcess ifrit.Process
コード例 #3
0
ファイル: service_client.go プロジェクト: emc-xchallenge/tps
func TPSWatcherLockSchemaPath() string {
	return locket.LockSchemaPath(TPSWatcherLockSchemaKey)
}
コード例 #4
0
func RouteEmitterLockSchemaPath() string {
	return locket.LockSchemaPath(RouteEmitterLockSchemaKey)
}
コード例 #5
0
ファイル: service_client.go プロジェクト: timani/bbs
func BBSLockSchemaPath() string {
	return locket.LockSchemaPath(BBSLockSchemaKey)
}
コード例 #6
0
ファイル: service_client.go プロジェクト: timani/bbs
func CellSchemaPath(cellID string) string {
	return locket.LockSchemaPath(CellSchemaKey, cellID)
}
コード例 #7
0
ファイル: service_client.go プロジェクト: timani/bbs
func CellSchemaRoot() string {
	return locket.LockSchemaPath(CellSchemaKey)
}
コード例 #8
0
package main_test

import (
	"github.com/cloudfoundry-incubator/bbs/cmd/bbs/testrunner"
	"github.com/cloudfoundry-incubator/locket"
	"github.com/tedsuo/ifrit/ginkgomon"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("MasterLock", func() {
	Context("when the bbs cannot obtain the bbs lock", func() {
		BeforeEach(func() {
			err := consulSession.AcquireLock(locket.LockSchemaPath("bbs_lock"), []byte{})
			Expect(err).NotTo(HaveOccurred())

			bbsRunner = testrunner.New(bbsBinPath, bbsArgs)
			bbsRunner.StartCheck = "bbs.lock.acquiring-lock"

			bbsProcess = ginkgomon.Invoke(bbsRunner)
		})

		AfterEach(func() {
			ginkgomon.Kill(bbsProcess)
			consulSession.Destroy()
		})

		It("is not reachable", func() {
			_, err := client.Domains()
			Expect(err).To(HaveOccurred())
コード例 #9
0
ファイル: master_lock_test.go プロジェクト: timani/bbs
import (
	"github.com/cloudfoundry-incubator/bbs/cmd/bbs/testrunner"
	"github.com/cloudfoundry-incubator/locket"
	"github.com/pivotal-golang/clock"
	"github.com/tedsuo/ifrit"
	"github.com/tedsuo/ifrit/ginkgomon"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("MasterLock", func() {
	Context("when the bbs cannot obtain the bbs lock", func() {
		var competingBBSLockProcess ifrit.Process
		BeforeEach(func() {
			competingBBSLock := locket.NewLock(logger, consulClient, locket.LockSchemaPath("bbs_lock"), []byte{}, clock.NewClock(), locket.RetryInterval, locket.LockTTL)
			competingBBSLockProcess = ifrit.Invoke(competingBBSLock)

			bbsRunner = testrunner.New(bbsBinPath, bbsArgs)
			bbsRunner.StartCheck = "bbs.lock.acquiring-lock"

			bbsProcess = ginkgomon.Invoke(bbsRunner)
		})

		AfterEach(func() {
			ginkgomon.Kill(competingBBSLockProcess)
		})

		It("is not reachable", func() {
			_, err := client.Domains(logger)
			Expect(err).To(HaveOccurred())
コード例 #10
0
func ConvergerLockSchemaPath() string {
	return locket.LockSchemaPath(ConvergerLockSchemaKey)
}
コード例 #11
0
ファイル: main_test.go プロジェクト: emc-xchallenge/nsync
		itIsMissingDomain()

		It("exits with an error", func() {
			Eventually(process.Wait(), 2*domainTTL).Should(Receive(HaveOccurred()))
		})
	})

	Context("when the bulker initially does not have the lock", func() {
		var otherSession *consuladapter.Session

		BeforeEach(func() {
			heartbeatInterval = 1 * time.Second

			otherSession = consulRunner.NewSession("other-session")
			err := otherSession.AcquireLock(locket.LockSchemaPath(bulkerLockName), []byte("something-else"))
			Expect(err).NotTo(HaveOccurred())
		})

		JustBeforeEach(func() {
			process = startBulker(false)
		})

		AfterEach(func() {
			ginkgomon.Interrupt(process, interruptTimeout)
		})

		itIsMissingDomain()

		Context("when the lock becomes available", func() {
			BeforeEach(func() {
コード例 #12
0
	})

	Context("when the auctioneer cannot acquire the lock on startup", func() {
		var task *rep.Task

		BeforeEach(func() {
			task = &rep.Task{
				TaskGuid: "task-guid",
				Domain:   "test",
				Resource: rep.Resource{
					MemoryMB: 124,
					DiskMB:   456,
					RootFs:   "some-rootfs",
				},
			}
			err := consulSession.AcquireLock(locket.LockSchemaPath("auctioneer_lock"), []byte{})
			Expect(err).NotTo(HaveOccurred())

			runner.StartCheck = "auctioneer.lock-bbs.lock.acquiring-lock"

			auctioneerProcess = ifrit.Background(runner)
		})

		It("should not advertise its presence, and should not be reachable", func() {
			Eventually(func() error {
				return auctioneerClient.RequestTaskAuctions([]*auctioneer.TaskStartRequest{
					&auctioneer.TaskStartRequest{*task},
				})
			}).Should(HaveOccurred())
		})
コード例 #13
0
ファイル: main_test.go プロジェクト: cfibmers/auctioneer
	Context("when the auctioneer cannot acquire the lock on startup", func() {
		var task *rep.Task
		var competingAuctioneerProcess ifrit.Process

		BeforeEach(func() {
			task = &rep.Task{
				TaskGuid: "task-guid",
				Domain:   "test",
				Resource: rep.Resource{
					MemoryMB: 124,
					DiskMB:   456,
					RootFs:   "some-rootfs",
				},
			}

			competingAuctioneerLock := locket.NewLock(logger, consulClient, locket.LockSchemaPath("auctioneer_lock"), []byte{}, clock.NewClock(), 500*time.Millisecond, 10*time.Second)
			competingAuctioneerProcess = ifrit.Invoke(competingAuctioneerLock)

			runner.StartCheck = "auctioneer.lock-bbs.lock.acquiring-lock"

			auctioneerProcess = ifrit.Background(runner)
		})

		AfterEach(func() {
			ginkgomon.Kill(competingAuctioneerProcess)
		})

		It("should not advertise its presence, and should not be reachable", func() {
			Eventually(func() error {
				return auctioneerClient.RequestTaskAuctions([]*auctioneer.TaskStartRequest{
					&auctioneer.TaskStartRequest{*task},
コード例 #14
0
func LockSchemaPath() string {
	return locket.LockSchemaPath(LockSchemaKey)
}
コード例 #15
0
ファイル: main_test.go プロジェクト: emc-xchallenge/converger
			Eventually(runner, 5*time.Second).Should(gbytes.Say("acquire-lock-succeeded"))

			consulRunner.DestroySession("converger")
		})

		It("exits with an error", func() {
			Eventually(runner, exitDuration).Should(Exit(1))
		})
	})

	Context("when the converger initially does not have the lock", func() {
		var otherSession *consuladapter.Session

		BeforeEach(func() {
			otherSession = consulRunner.NewSession("other-session")
			err := otherSession.AcquireLock(locket.LockSchemaPath("converge_lock"), []byte("something-else"))
			Expect(err).NotTo(HaveOccurred())

			startConverger()
		})

		itIsInactive()

		Describe("when the lock becomes available", func() {
			BeforeEach(func() {
				otherSession.Destroy()
				time.Sleep(convergeRepeatInterval + 10*time.Millisecond)
			})

			Describe("when a running task with a dead cell is present", func() {
				JustBeforeEach(createRunningTaskWithDeadCell)
コード例 #16
0
ファイル: service_client.go プロジェクト: cf-routing/nsync
func NysncBulkerLockSchemaPath() string {
	return locket.LockSchemaPath(NysncBulkerLockSchemaKey)
}