public override void SetContract(PreemptionContract c) { lock (this) { MaybeInitBuilder(); if (null == c) { builder.ClearContract(); } this.contract = c; } }
private PreemptionMessage GeneratePreemptionMessage(Allocation allocation) { PreemptionMessage pMsg = null; // assemble strict preemption request if (allocation.GetStrictContainerPreemptions() != null) { pMsg = recordFactory.NewRecordInstance <PreemptionMessage>(); StrictPreemptionContract pStrict = recordFactory.NewRecordInstance <StrictPreemptionContract >(); ICollection <PreemptionContainer> pCont = new HashSet <PreemptionContainer>(); foreach (ContainerId cId in allocation.GetStrictContainerPreemptions()) { PreemptionContainer pc = recordFactory.NewRecordInstance <PreemptionContainer>(); pc.SetId(cId); pCont.AddItem(pc); } pStrict.SetContainers(pCont); pMsg.SetStrictContract(pStrict); } // assemble negotiable preemption request if (allocation.GetResourcePreemptions() != null && allocation.GetResourcePreemptions ().Count > 0 && allocation.GetContainerPreemptions() != null && allocation.GetContainerPreemptions ().Count > 0) { if (pMsg == null) { pMsg = recordFactory.NewRecordInstance <PreemptionMessage>(); } PreemptionContract contract = recordFactory.NewRecordInstance <PreemptionContract> (); ICollection <PreemptionContainer> pCont = new HashSet <PreemptionContainer>(); foreach (ContainerId cId in allocation.GetContainerPreemptions()) { PreemptionContainer pc = recordFactory.NewRecordInstance <PreemptionContainer>(); pc.SetId(cId); pCont.AddItem(pc); } IList <PreemptionResourceRequest> pRes = new AList <PreemptionResourceRequest>(); foreach (ResourceRequest crr in allocation.GetResourcePreemptions()) { PreemptionResourceRequest prr = recordFactory.NewRecordInstance <PreemptionResourceRequest >(); prr.SetResourceRequest(crr); pRes.AddItem(prr); } contract.SetContainers(pCont); contract.SetResourceRequest(pRes); pMsg.SetContract(contract); } return(pMsg); }
public override PreemptionContract GetContract() { lock (this) { YarnProtos.PreemptionMessageProtoOrBuilder p = viaProto ? proto : builder; if (contract != null) { return(contract); } if (!p.HasContract()) { return(null); } contract = ConvertFromProtoFormat(p.GetContract()); return(contract); } }
private YarnProtos.PreemptionContractProto ConvertToProtoFormat(PreemptionContract t) { return(((PreemptionContractPBImpl)t).GetProto()); }