本文整理汇总了Golang中github.com/cloudfoundry-incubator/bbs/models.NewActualLRPKey函数的典型用法代码示例。如果您正苦于以下问题:Golang NewActualLRPKey函数的具体用法?Golang NewActualLRPKey怎么用?Golang NewActualLRPKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewActualLRPKey函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: createActualLRP
func (db *ETCDDB) createActualLRP(logger lager.Logger, desiredLRP *models.DesiredLRP, index int32) error {
logger = logger.Session("create-actual-lrp")
var err error
if index >= desiredLRP.Instances {
err = models.NewError(models.Error_InvalidRecord, "Index too large")
logger.Error("actual-lrp-index-too-large", err, lager.Data{"actual_index": index, "desired_instances": desiredLRP.Instances})
return err
}
guid, err := uuid.NewV4()
if err != nil {
return err
}
actualLRP := &models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey(
desiredLRP.ProcessGuid,
index,
desiredLRP.Domain,
),
State: models.ActualLRPStateUnclaimed,
Since: db.clock.Now().UnixNano(),
ModificationTag: models.ModificationTag{
Epoch: guid.String(),
Index: 0,
},
}
err = db.createRawActualLRP(logger, actualLRP)
if err != nil {
return err
}
return nil
}
示例2: defaultCrashedActual
func defaultCrashedActual(crashCount int32, lastCrashed int64) *models.ActualLRP {
return &models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey("p-guid", 0, "domain"),
State: models.ActualLRPStateCrashed,
CrashCount: crashCount,
Since: lastCrashed,
}
}
示例3: BuildLRPAuctions
func BuildLRPAuctions(start auctioneer.LRPStartRequest, queueTime time.Time) []auctiontypes.LRPAuction {
auctions := make([]auctiontypes.LRPAuction, 0, len(start.Indices))
for _, index := range start.Indices {
lrpKey := models.NewActualLRPKey(start.ProcessGuid, int32(index), start.Domain)
auctions = append(auctions, auctiontypes.NewLRPAuction(rep.NewLRP(lrpKey, start.Resource), queueTime))
}
return auctions
}
示例4: ScheduleLRPsForAuctions
func (a *AuctionRunner) ScheduleLRPsForAuctions(lrpStarts []auctioneer.LRPStartRequest) {
a.lock.Lock()
defer a.lock.Unlock()
now := a.clock.Now()
for _, start := range lrpStarts {
log.Infof("+lrp auction posted: %v: %v\n", start.ProcessGuid, start.Indices)
for _, i := range start.Indices {
lrpKey := models.NewActualLRPKey(start.ProcessGuid, int32(i), start.Domain)
auction := auctiontypes.NewLRPAuction(rep.NewLRP(lrpKey, start.Resource), now)
a.lrpAuctions = append(a.lrpAuctions, auction)
}
}
a.claimToHaveWork()
}
示例5: AddLRPStarts
func (b *Batch) AddLRPStarts(starts []auctioneer.LRPStartRequest) {
auctions := make([]auctiontypes.LRPAuction, 0, len(starts))
now := b.clock.Now()
for i := range starts {
start := &starts[i]
for _, index := range start.Indices {
lrpKey := models.NewActualLRPKey(start.ProcessGuid, int32(index), start.Domain)
auction := auctiontypes.NewLRPAuction(rep.NewLRP(lrpKey, start.Resource), now)
auctions = append(auctions, auction)
}
}
b.lock.Lock()
b.lrpAuctions = append(b.lrpAuctions, auctions...)
b.claimToHaveWork()
b.lock.Unlock()
}
示例6: NewValidActualLRP
func NewValidActualLRP(guid string, index int32) *models.ActualLRP {
actualLRP := &models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey(guid, index, "some-domain"),
ActualLRPInstanceKey: models.NewActualLRPInstanceKey("some-guid", "some-cell"),
ActualLRPNetInfo: models.NewActualLRPNetInfo("some-address", models.NewPortMapping(2222, 4444)),
CrashCount: 33,
CrashReason: "badness",
State: models.ActualLRPStateRunning,
Since: 1138,
ModificationTag: models.ModificationTag{
Epoch: "some-epoch",
Index: 999,
},
}
err := actualLRP.Validate()
Expect(err).NotTo(HaveOccurred())
return actualLRP
}
示例7: Execute
func (o *ResidualJointLRPOperation) Execute() {
logger := o.logger.Session("executing-residual-joint-lrp-operation", lager.Data{
"lrp-key": o.ActualLRPKey,
"lrp-instance-key": o.ActualLRPInstanceKey,
})
logger.Info("starting")
defer logger.Info("finished")
_, exists := o.containerDelegate.GetContainer(logger, rep.LRPContainerGuid(o.GetProcessGuid(), o.GetInstanceGuid()))
if exists {
logger.Info("skipped-because-container-exists")
return
}
actualLRPKey := models.NewActualLRPKey(o.ProcessGuid, int32(o.Index), o.Domain)
actualLRPInstanceKey := models.NewActualLRPInstanceKey(o.InstanceGuid, o.CellId)
o.bbsClient.RemoveActualLRP(o.ProcessGuid, int(o.Index))
o.bbsClient.RemoveEvacuatingActualLRP(&actualLRPKey, &actualLRPInstanceKey)
}
示例8: startInstanceRange
func (db *ETCDDB) startInstanceRange(logger lager.Logger, lower, upper int32, schedulingInfo *models.DesiredLRPSchedulingInfo) {
logger = logger.Session("start-instance-range", lager.Data{"lower": lower, "upper": upper})
logger.Info("starting")
defer logger.Info("complete")
keys := make([]*models.ActualLRPKey, upper-lower)
i := 0
for actualIndex := lower; actualIndex < upper; actualIndex++ {
key := models.NewActualLRPKey(schedulingInfo.ProcessGuid, int32(actualIndex), schedulingInfo.Domain)
keys[i] = &key
i++
}
createdIndices := db.createUnclaimedActualLRPs(logger, keys)
start := auctioneer.NewLRPStartRequestFromSchedulingInfo(schedulingInfo, createdIndices...)
err := db.auctioneerClient.RequestLRPAuctions([]*auctioneer.LRPStartRequest{&start})
if err != nil {
logger.Error("failed-to-request-auction", err)
}
}
示例9: itValidatesPresenceOfTheLRPKey
func itValidatesPresenceOfTheLRPKey(lrp *models.ActualLRP) {
Context("when the lrp key is set", func() {
BeforeEach(func() {
lrp.ActualLRPKey = models.NewActualLRPKey("some-guid", 1, "domain")
})
It("validate does not return an error", func() {
Expect(lrp.Validate()).NotTo(HaveOccurred())
})
})
Context("when the lrp key is not set", func() {
BeforeEach(func() {
lrp.ActualLRPKey = models.ActualLRPKey{}
})
It("validate returns an error", func() {
err := lrp.Validate()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("process_guid"))
})
})
}
示例10: lrpForState
func lrpForState(state string, timeInState time.Duration) models.ActualLRP {
var actualLRPKey = models.NewActualLRPKey("some-process-guid", 1, "tests")
var instanceKey = models.NewActualLRPInstanceKey("some-instance-guid", "some-cell")
lrp := models.ActualLRP{
ActualLRPKey: actualLRPKey,
State: state,
Since: clock.Now().Add(-timeInState).UnixNano(),
}
switch state {
case models.ActualLRPStateUnclaimed:
case models.ActualLRPStateCrashed:
lrp.CrashReason = "crashed"
case models.ActualLRPStateClaimed:
lrp.ActualLRPInstanceKey = instanceKey
case models.ActualLRPStateRunning:
lrp.ActualLRPInstanceKey = instanceKey
lrp.ActualLRPNetInfo = models.NewActualLRPNetInfo("1.2.3.4", &models.PortMapping{ContainerPort: 1234, HostPort: 5678})
}
return lrp
}
示例11: ActualLRPKeyFromTags
func ActualLRPKeyFromTags(tags executor.Tags) (*models.ActualLRPKey, error) {
if tags == nil {
return &models.ActualLRPKey{}, ErrContainerMissingTags
}
processIndex, err := strconv.Atoi(tags[ProcessIndexTag])
if err != nil {
return &models.ActualLRPKey{}, ErrInvalidProcessIndex
}
actualLRPKey := models.NewActualLRPKey(
tags[ProcessGuidTag],
int32(processIndex),
tags[DomainTag],
)
err = actualLRPKey.Validate()
if err != nil {
return &models.ActualLRPKey{}, err
}
return &actualLRPKey, nil
}
示例12:
logger = lager.NewLogger("test")
logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.DEBUG))
responseRecorder = httptest.NewRecorder()
handler = handlers.NewActualLRPHandler(logger, fakeActualLRPDB)
})
Describe("ActualLRPGroups", func() {
var request *http.Request
BeforeEach(func() {
request = newTestRequest("")
actualLRP1 = models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey(
"process-guid-0",
1,
"domain-0",
),
ActualLRPInstanceKey: models.NewActualLRPInstanceKey(
"instance-guid-0",
"cell-id-0",
),
State: models.ActualLRPStateRunning,
Since: 1138,
}
actualLRP2 = models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey(
"process-guid-1",
2,
"domain-1",
示例13:
Describe("RemoveEvacuatingActualLRP", func() {
var (
processGuid = "process-guid"
index = int32(1)
key models.ActualLRPKey
instanceKey models.ActualLRPInstanceKey
requestBody interface{}
)
BeforeEach(func() {
key = models.NewActualLRPKey(
processGuid,
index,
"domain-0",
)
instanceKey = models.NewActualLRPInstanceKey("instance-guid", "cell-id")
requestBody = &models.RemoveEvacuatingActualLRPRequest{
ActualLrpKey: &key,
ActualLrpInstanceKey: &instanceKey,
}
})
JustBeforeEach(func() {
request := newTestRequest(requestBody)
handler.RemoveEvacuatingActualLRP(responseRecorder, request)
})
Context("when removeEvacuatinging the actual lrp in the DB succeeds", func() {
示例14:
uaaUsername = "amandaplease"
allowedCiphers = ""
allowedMACs = ""
allowedKeyExchanges = ""
expectedGetActualLRPRequest = &models.ActualLRPGroupByProcessGuidAndIndexRequest{
ProcessGuid: processGuid,
Index: 99,
}
actualLRPGroupResponse = &models.ActualLRPGroupResponse{
Error: nil,
ActualLrpGroup: &models.ActualLRPGroup{
Instance: &models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey(processGuid, 99, "some-domain"),
ActualLRPInstanceKey: models.NewActualLRPInstanceKey("some-instance-guid", "some-cell-id"),
ActualLRPNetInfo: models.NewActualLRPNetInfo("127.0.0.1", models.NewPortMapping(uint32(sshdPort), 9999)),
},
},
}
getDesiredLRPRequest = &models.DesiredLRPByProcessGuidRequest{
ProcessGuid: processGuid,
}
sshRoute, err := json.Marshal(routes.SSHRoute{
ContainerPort: 9999,
PrivateKey: privateKeyPem,
HostFingerprint: hostKeyFingerprint,
})
示例15:
var client rep.Client
BeforeEach(func() {
fakeServer = ghttp.NewServer()
client = rep.NewClient(cf_http.NewClient(), fakeServer.URL())
})
AfterEach(func() {
fakeServer.Close()
})
Describe("StopLRPInstance", func() {
const cellAddr = "cell.example.com"
var stopErr error
var actualLRP = models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey("some-process-guid", 2, "test-domain"),
ActualLRPInstanceKey: models.NewActualLRPInstanceKey("some-instance-guid", "some-cell-id"),
}
JustBeforeEach(func() {
stopErr = client.StopLRPInstance(actualLRP.ActualLRPKey, actualLRP.ActualLRPInstanceKey)
})
Context("when the request is successful", func() {
BeforeEach(func() {
fakeServer.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", "/v1/lrps/some-process-guid/instances/some-instance-guid/stop"),
ghttp.RespondWith(http.StatusAccepted, ""),
),
)