本文整理匯總了Golang中code/cloudfoundry/org/bbs/models.ActualLRP.CellId方法的典型用法代碼示例。如果您正苦於以下問題:Golang ActualLRP.CellId方法的具體用法?Golang ActualLRP.CellId怎麽用?Golang ActualLRP.CellId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類code/cloudfoundry/org/bbs/models.ActualLRP
的用法示例。
在下文中一共展示了ActualLRP.CellId方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
desiredLRP1 = model_helpers.NewValidDesiredLRP("to-unclaim-1").DesiredLRPSchedulingInfo()
unclaimingActualLRP1 = model_helpers.NewValidActualLRP("to-unclaim-1", 0)
desiredLRP2 = model_helpers.NewValidDesiredLRP("to-unclaim-2").DesiredLRPSchedulingInfo()
unclaimingActualLRP2 = model_helpers.NewValidActualLRP("to-unclaim-2", 1)
keysWithMissingCells = []*models.ActualLRPKeyWithSchedulingInfo{
{Key: &unclaimingActualLRP1.ActualLRPKey, SchedulingInfo: &desiredLRP1},
{Key: &unclaimingActualLRP2.ActualLRPKey, SchedulingInfo: &desiredLRP2},
}
keysToAuction = []*auctioneer.LRPStartRequest{&request1, &request2}
cellID = "cell-id"
instanceKey := models.NewActualLRPInstanceKey("instance-guid", cellID)
retiringActualLRP1.CellId = cellID
retiringActualLRP1.ActualLRPInstanceKey = instanceKey
retiringActualLRP1.State = models.ActualLRPStateClaimed
group1 := &models.ActualLRPGroup{Instance: retiringActualLRP1}
retiringActualLRP2.CellId = cellID
retiringActualLRP2.ActualLRPInstanceKey = instanceKey
retiringActualLRP2.State = models.ActualLRPStateClaimed
group2 := &models.ActualLRPGroup{Instance: retiringActualLRP2}
fakeLRPDB.ActualLRPGroupByProcessGuidAndIndexStub = func(_ lager.Logger, processGuid string, _ int32) (*models.ActualLRPGroup, error) {
if processGuid == retiringActualLRP1.ProcessGuid {
return group1, nil
}
if processGuid == retiringActualLRP2.ProcessGuid {
return group2, nil
示例2:
})
})
})
Context("when the LRP is Claimed or Running", func() {
var (
cellID string
cellPresence models.CellPresence
instanceKey models.ActualLRPInstanceKey
)
BeforeEach(func() {
cellID = "cell-id"
instanceKey = models.NewActualLRPInstanceKey("instance-guid", cellID)
actualLRP.CellId = cellID
actualLRP.ActualLRPInstanceKey = instanceKey
actualLRPGroup.Instance.State = models.ActualLRPStateClaimed
fakeActualLRPDB.ActualLRPGroupByProcessGuidAndIndexReturns(actualLRPGroup, nil)
})
Context("when the cell", func() {
Context("is present", func() {
BeforeEach(func() {
cellPresence = models.NewCellPresence(
cellID,
"cell1.addr",
"",
"the-zone",
models.NewCellCapacity(128, 1024, 6),
[]string{},
示例3:
_, err := db.Exec(queryStr, true, expireTime, actualLRP.ProcessGuid, actualLRP.Index, false)
Expect(err).NotTo(HaveOccurred())
})
It("removes the evacuating actual LRP", func() {
err := sqlDB.RemoveEvacuatingActualLRP(logger, &actualLRP.ActualLRPKey, &actualLRP.ActualLRPInstanceKey)
Expect(err).ToNot(HaveOccurred())
_, err = sqlDB.ActualLRPGroupByProcessGuidAndIndex(logger, guid, index)
Expect(err).To(HaveOccurred())
Expect(err).To(Equal(models.ErrResourceNotFound))
})
Context("when the actual lrp instance key is not the same", func() {
BeforeEach(func() {
actualLRP.CellId = "a different cell"
})
It("returns a ErrActualLRPCannotBeRemoved error", func() {
err := sqlDB.RemoveEvacuatingActualLRP(logger, &actualLRP.ActualLRPKey, &actualLRP.ActualLRPInstanceKey)
Expect(err).To(Equal(models.ErrActualLRPCannotBeRemoved))
})
})
Context("when the actualLRP is expired", func() {
BeforeEach(func() {
expireTime := fakeClock.Now().UnixNano()
queryStr := "UPDATE actual_lrps SET expire_time = ? WHERE process_guid = ? AND instance_index = ? AND evacuating = ?"
if test_helpers.UsePostgres() {
queryStr = test_helpers.ReplaceQuestionMarks(queryStr)
}
示例4:
It("does not emit any events", func() {
Consistently(actualHub.EmitCallCount).Should(Equal(0))
})
})
})
})
})
Context("when the instance is claimed", func() {
BeforeEach(func() {
actual.State = models.ActualLRPStateClaimed
})
Context("by another cell", func() {
BeforeEach(func() {
actual.CellId = "some-other-cell"
group := &models.ActualLRPGroup{Evacuating: afterActual}
fakeEvacuationDB.EvacuateActualLRPReturns(group, nil)
})
It("evacuates the LRP", func() {
response := models.EvacuationResponse{}
err := response.Unmarshal(responseRecorder.Body.Bytes())
Expect(err).NotTo(HaveOccurred())
Expect(response.KeepContainer).To(BeTrue())
Expect(response.Error).To(BeNil())
Expect(fakeEvacuationDB.EvacuateActualLRPCallCount()).To(Equal(1))
_, actualLRPKey, actualLRPInstanceKey, actualLrpNetInfo, ttl := fakeEvacuationDB.EvacuateActualLRPArgsForCall(0)
Expect(*actualLRPKey).To(Equal(actual.ActualLRPKey))
Expect(*actualLRPInstanceKey).To(Equal(*requestBody.ActualLrpInstanceKey))