本文整理汇总了Golang中github.com/cloudfoundry-incubator/bbs/models.NewActualLRPKey函数的典型用法代码示例。如果您正苦于以下问题:Golang NewActualLRPKey函数的具体用法?Golang NewActualLRPKey怎么用?Golang NewActualLRPKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewActualLRPKey函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:timani,项目名称:bbs,代码行数:35,代码来源:actual_lrp_db.go
示例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,
}
}
开发者ID:rowhit,项目名称:lattice,代码行数:8,代码来源:actual_lrp_test.go
示例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
}
开发者ID:ihocho,项目名称:auction,代码行数:9,代码来源:test_helpers_test.go
示例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()
}
开发者ID:LaynePeng,项目名称:cloudfoundry-mesos,代码行数:15,代码来源:auction_runner.go
示例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()
}
开发者ID:layer-x,项目名称:pluggable-auction,代码行数:17,代码来源:batch.go
示例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
}
开发者ID:emc-xchallenge,项目名称:bbs,代码行数:19,代码来源:constructors.go
示例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)
}
开发者ID:jiangytcn,项目名称:rep,代码行数:19,代码来源:operation.go
示例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)
}
}
开发者ID:emc-xchallenge,项目名称:bbs,代码行数:21,代码来源:desired_lrp_db.go
示例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"))
})
})
}
开发者ID:rowhit,项目名称:lattice,代码行数:23,代码来源:actual_lrp_test.go
示例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
}
开发者ID:emc-xchallenge,项目名称:bbs,代码行数:23,代码来源:actual_lrp_crashing_test.go
示例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
}
开发者ID:jianhuiz,项目名称:rep,代码行数:23,代码来源:conversion_helpers.go
示例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",
开发者ID:Gerg,项目名称:bbs,代码行数:31,代码来源:actual_lrp_handlers_test.go
示例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() {
开发者ID:emc-xchallenge,项目名称:bbs,代码行数:30,代码来源:evacuation_handler_test.go
示例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,
})
开发者ID:swisscom,项目名称:diego-ssh,代码行数:31,代码来源:main_test.go
示例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, ""),
),
)
开发者ID:jianhuiz,项目名称:rep,代码行数:31,代码来源:client_test.go
示例16:
Expect(err).NotTo(HaveOccurred())
desiredLRPRemovedEvent, ok := event.(receptor.DesiredLRPRemovedEvent)
Expect(ok).To(BeTrue())
Expect(desiredLRPRemovedEvent).To(Equal(expectedEvent))
})
})
})
Describe("Actual LRP Events", func() {
var actualLRPResponse receptor.ActualLRPResponse
BeforeEach(func() {
actualLRPResponse = serialization.ActualLRPProtoToResponse(
&models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey("some-guid", 0, "some-domain"),
State: models.ActualLRPStateUnclaimed,
Since: 1,
},
false,
)
})
Context("when receiving a ActualLRPCreatedEvent", func() {
var expectedEvent receptor.ActualLRPCreatedEvent
BeforeEach(func() {
expectedEvent = receptor.NewActualLRPCreatedEvent(actualLRPResponse)
payload, err := json.Marshal(expectedEvent)
Expect(err).NotTo(HaveOccurred())
开发者ID:davidwadden,项目名称:lattice-release,代码行数:30,代码来源:event_source_test.go
示例17:
event, err := eventSource.Next()
Expect(err).NotTo(HaveOccurred())
desiredLRPRemovedEvent, ok := event.(*models.DesiredLRPRemovedEvent)
Expect(ok).To(BeTrue())
Expect(desiredLRPRemovedEvent).To(Equal(expectedEvent))
})
})
})
Describe("Actual LRP Events", func() {
var actualLRPGroup *models.ActualLRPGroup
var actualLRP *models.ActualLRP
BeforeEach(func() {
actualLRP = models.NewUnclaimedActualLRP(models.NewActualLRPKey("some-guid", 0, "some-domain"), 1)
actualLRPGroup = models.NewRunningActualLRPGroup(actualLRP)
})
Context("when receiving a ActualLRPCreatedEvent", func() {
var expectedEvent *models.ActualLRPCreatedEvent
BeforeEach(func() {
expectedEvent = models.NewActualLRPCreatedEvent(actualLRPGroup)
payload, err := proto.Marshal(expectedEvent)
Expect(err).NotTo(HaveOccurred())
payload = []byte(base64.StdEncoding.EncodeToString(payload))
fakeRawEventSource.NextReturns(
sse.Event{
ID: "sup",
开发者ID:timani,项目名称:bbs,代码行数:31,代码来源:event_source_test.go
示例18: BuildLRP
func BuildLRP(guid, domain string, index int, rootFS string, memoryMB, diskMB int32) *rep.LRP {
lrpKey := models.NewActualLRPKey(guid, int32(index), domain)
lrp := rep.NewLRP(lrpKey, rep.NewResource(memoryMB, diskMB, rootFS))
return &lrp
}
开发者ID:ihocho,项目名称:auction,代码行数:5,代码来源:test_helpers_test.go
示例19: CalculateConvergence
func CalculateConvergence(
logger lager.Logger,
clock clock.Clock,
restartCalculator models.RestartCalculator,
input *models.ConvergenceInput,
) *models.ConvergenceChanges {
sess := logger.Session("calculate-convergence")
var extraLRPCount, missingLRPCount int
sess.Info("start")
defer sess.Info("done")
changes := &models.ConvergenceChanges{}
now := clock.Now()
for processGuid, _ := range input.AllProcessGuids {
pLog := sess.WithData(lager.Data{
"process_guid": processGuid,
})
desired, hasDesired := input.DesiredLRPs[processGuid]
actualsByIndex := input.ActualLRPs[processGuid]
if hasDesired {
for i := int32(0); i < desired.Instances; i++ {
if _, hasIndex := actualsByIndex[i]; !hasIndex {
pLog.Info("missing", lager.Data{"index": i})
missingLRPCount++
lrpKey := models.NewActualLRPKey(desired.ProcessGuid, i, desired.Domain)
changes.ActualLRPKeysForMissingIndices = append(
changes.ActualLRPKeysForMissingIndices,
&lrpKey,
)
}
}
for i, actual := range actualsByIndex {
if actual.CellIsMissing(input.Cells) {
pLog.Info("missing-cell", lager.Data{"index": i, "cell_id": actual.CellId})
changes.ActualLRPsWithMissingCells = append(changes.ActualLRPsWithMissingCells, actual)
continue
}
if actual.Index >= desired.Instances && input.Domains.Contains(desired.Domain) {
pLog.Info("extra", lager.Data{"index": i})
extraLRPCount++
changes.ActualLRPsForExtraIndices = append(changes.ActualLRPsForExtraIndices, actual)
continue
}
if actual.ShouldRestartCrash(now, restartCalculator) {
pLog.Info("restart-crash", lager.Data{"index": i})
changes.RestartableCrashedActualLRPs = append(changes.RestartableCrashedActualLRPs, actual)
continue
}
if actual.ShouldStartUnclaimed(now) {
pLog.Info("stale-unclaimed", lager.Data{"index": i})
changes.StaleUnclaimedActualLRPs = append(changes.StaleUnclaimedActualLRPs, actual)
continue
}
}
} else {
for i, actual := range actualsByIndex {
if !input.Domains.Contains(actual.Domain) {
pLog.Info("skipping-unfresh-domain")
continue
}
pLog.Info("no-longer-desired", lager.Data{"index": i})
extraLRPCount++
changes.ActualLRPsForExtraIndices = append(changes.ActualLRPsForExtraIndices, actual)
}
}
}
missingLRPs.Send(missingLRPCount)
extraLRPs.Send(extraLRPCount)
return changes
}
开发者ID:timani,项目名称:bbs,代码行数:84,代码来源:lrp_convergence.go
示例20:
. "github.com/onsi/gomega/gbytes"
)
var _ = Describe("Operation", func() {
Describe("ResidualInstanceLRPOperation", func() {
var (
containerDelegate *fake_internal.FakeContainerDelegate
residualLRPOperation *generator.ResidualInstanceLRPOperation
lrpKey models.ActualLRPKey
instanceKey models.ActualLRPInstanceKey
expectedContainerGuid string
)
BeforeEach(func() {
lrpKey = models.NewActualLRPKey("the-process-guid", 0, "the-domain")
instanceKey = models.NewActualLRPInstanceKey("the-instance-guid", "the-cell-id")
containerDelegate = new(fake_internal.FakeContainerDelegate)
residualLRPOperation = generator.NewResidualInstanceLRPOperation(logger, fakeBBS, containerDelegate, lrpKey, instanceKey)
expectedContainerGuid = rep.LRPContainerGuid(lrpKey.GetProcessGuid(), instanceKey.GetInstanceGuid())
})
Describe("Key", func() {
It("returns the InstanceGuid", func() {
Expect(residualLRPOperation.Key()).To(Equal("the-instance-guid"))
})
})
Describe("Execute", func() {
const sessionName = "test.executing-residual-instance-lrp-operation"
开发者ID:jiangytcn,项目名称:rep,代码行数:31,代码来源:operation_test.go
注:本文中的github.com/cloudfoundry-incubator/bbs/models.NewActualLRPKey函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论