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);
        }