本文整理汇总了Golang中github.com/cloudfoundry-incubator/bbs/models.DesiredLRP.DesiredLRPRunInfo方法的典型用法代码示例。如果您正苦于以下问题:Golang DesiredLRP.DesiredLRPRunInfo方法的具体用法?Golang DesiredLRP.DesiredLRPRunInfo怎么用?Golang DesiredLRP.DesiredLRPRunInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry-incubator/bbs/models.DesiredLRP
的用法示例。
在下文中一共展示了DesiredLRP.DesiredLRPRunInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: DesireLRP
func (db *SQLDB) DesireLRP(logger lager.Logger, desiredLRP *models.DesiredLRP) error {
logger = logger.WithData(lager.Data{"process_guid": desiredLRP.ProcessGuid})
logger.Info("starting")
defer logger.Info("complete")
return db.transact(logger, func(logger lager.Logger, tx *sql.Tx) error {
routesData, err := json.Marshal(desiredLRP.Routes)
runInfo := desiredLRP.DesiredLRPRunInfo(db.clock.Now())
runInfoData, err := db.serializeModel(logger, &runInfo)
if err != nil {
logger.Error("failed-to-serialize-model", err)
return err
}
volumePlacement := &models.VolumePlacement{}
volumePlacement.DriverNames = []string{}
for _, mount := range desiredLRP.VolumeMounts {
volumePlacement.DriverNames = append(volumePlacement.DriverNames, mount.Driver)
}
volumePlacementData, err := db.serializeModel(logger, volumePlacement)
if err != nil {
logger.Error("failed-to-serialize-model", err)
return err
}
guid, err := db.guidProvider.NextGUID()
if err != nil {
logger.Error("failed-to-generate-guid", err)
return models.ErrGUIDGeneration
}
desiredLRP.ModificationTag = &models.ModificationTag{Epoch: guid, Index: 0}
_, err = db.insert(logger, tx, desiredLRPsTable,
SQLAttributes{
"process_guid": desiredLRP.ProcessGuid,
"domain": desiredLRP.Domain,
"log_guid": desiredLRP.LogGuid,
"annotation": desiredLRP.Annotation,
"instances": desiredLRP.Instances,
"memory_mb": desiredLRP.MemoryMb,
"disk_mb": desiredLRP.DiskMb,
"rootfs": desiredLRP.RootFs,
"volume_placement": volumePlacementData,
"modification_tag_epoch": desiredLRP.ModificationTag.Epoch,
"modification_tag_index": desiredLRP.ModificationTag.Index,
"routes": routesData,
"run_info": runInfoData,
},
)
if err != nil {
logger.Error("failed-inserting-desired", err)
return db.convertSQLError(err)
}
return nil
})
}
示例2:
)
JustBeforeEach(func() {
desiredLRP = model_helpers.NewValidDesiredLRP("super-lrp")
desireErr = client.DesireLRP(desiredLRP)
})
It("creates the desired LRP in the system", func() {
Expect(desireErr).NotTo(HaveOccurred())
persistedDesiredLRP, err := client.DesiredLRPByProcessGuid("super-lrp")
Expect(err).NotTo(HaveOccurred())
Expect(persistedDesiredLRP.DesiredLRPKey()).To(Equal(desiredLRP.DesiredLRPKey()))
Expect(persistedDesiredLRP.DesiredLRPResource()).To(Equal(desiredLRP.DesiredLRPResource()))
Expect(persistedDesiredLRP.Annotation).To(Equal(desiredLRP.Annotation))
Expect(persistedDesiredLRP.Instances).To(Equal(desiredLRP.Instances))
Expect(persistedDesiredLRP.DesiredLRPRunInfo()).To(Equal(desiredLRP.DesiredLRPRunInfo()))
})
})
Describe("RemoveDesiredLRP", func() {
var (
desiredLRP *models.DesiredLRP
removeErr error
)
JustBeforeEach(func() {
desiredLRP = model_helpers.NewValidDesiredLRP("super-lrp")
err := client.DesireLRP(desiredLRP)
Expect(err).NotTo(HaveOccurred())
removeErr = client.RemoveDesiredLRP("super-lrp")
示例3:
lrp.Instances = 5
})
Context("when the desired LRP does not yet exist", func() {
It("persists the scheduling info and run info", func() {
err := etcdDB.DesireLRP(logger, lrp)
Expect(err).NotTo(HaveOccurred())
persisted, err := etcdDB.DesiredLRPByProcessGuid(logger, "some-process-guid")
Expect(err).NotTo(HaveOccurred())
Expect(persisted.DesiredLRPKey()).To(Equal(lrp.DesiredLRPKey()))
Expect(persisted.DesiredLRPResource()).To(Equal(lrp.DesiredLRPResource()))
Expect(persisted.Annotation).To(Equal(lrp.Annotation))
Expect(persisted.Instances).To(Equal(lrp.Instances))
Expect(persisted.DesiredLRPRunInfo(clock.Now())).To(Equal(lrp.DesiredLRPRunInfo(clock.Now())))
})
It("sets the ModificationTag on the DesiredLRP", func() {
err := etcdDB.DesireLRP(logger, lrp)
Expect(err).NotTo(HaveOccurred())
lrp, err := etcdDB.DesiredLRPByProcessGuid(logger, "some-process-guid")
Expect(err).NotTo(HaveOccurred())
Expect(lrp.ModificationTag.Epoch).NotTo(BeEmpty())
Expect(lrp.ModificationTag.Index).To(BeEquivalentTo(0))
})
Context("An error occurs creating the scheduling info", func() {
BeforeEach(func() {