In response to a successful Store request the peer MUST return a StoreAns message containing a series of StoreKindResponse elements containing the current value of the generation counter for each Kind-ID, as well as a list of the peers where the data will be replicated by the node processing the request. see RELOAD base -12 p.90
Esempio n. 1
0
        public override RELOAD_MessageBody FromReader(ReloadMessage rm, BinaryReader reader, long reload_msg_size)
        {
            /* try to read the packet as a StoreAns packet */
            try
            {
                long postBeforeMsg = reader.BaseStream.Position;
                RELOAD_MsgCode = (RELOAD_MessageCode)(UInt16)IPAddress.NetworkToHostOrder(
                  reader.ReadInt16());
                long posBeforeRead = reader.BaseStream.Position;
                UInt32 message_len = (UInt32)(IPAddress.HostToNetworkOrder(
                  (int)reader.ReadInt32()));

                if (RELOAD_MsgCode == RELOAD_MessageCode.Store_Answer)
                {
                    while (StreamUtil.ReadBytes(posBeforeRead, reader) < message_len)
                    {
                        /* Read kind id */
                        UInt32 kindId = (UInt32)(IPAddress.NetworkToHostOrder(reader.ReadInt32()));
                        /* Read generation */
                        UInt64 generation_counter = (UInt64)(IPAddress.NetworkToHostOrder(reader.ReadInt64()));
                        /* read length of replicas */
                        long posBeforeReplicas = reader.BaseStream.Position;
                        UInt16 replicas_lenght = (UInt16)(IPAddress.NetworkToHostOrder(reader.ReadInt16()));
                        List<NodeId> replicas = new List<NodeId>();

                        /* Read replicas */
                        while (StreamUtil.ReadBytes(posBeforeReplicas, reader) < replicas_lenght)
                        {
                            NodeId replica = new NodeId(reader.ReadBytes(ReloadGlobals.NODE_ID_DIGITS));
                            replicas.Add(replica);
                        }
                        StoreKindResponse store_kind_response = new StoreKindResponse();
                        store_kind_response.kind = kindId;
                        store_kind_response.generation_counter = generation_counter;
                        store_kind_response.replicas = new List<NodeId>();
                        store_kind_response.replicas.AddRange(replicas);

                        kind_responses.Add(store_kind_response);
                    }
                }
                UInt32 totalRead = StreamUtil.ReadBytes(postBeforeMsg, reader);
                reload_msg_size = reload_msg_size - (totalRead + 1); // TODO check whether true
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return this;
        }
Esempio n. 2
0
 public StoreAns(List<StoreKindData> store_kind_data, List<NodeId> replicas)
 {
     this.RELOAD_MsgCode = RELOAD_MessageCode.Store_Answer;
     kind_responses = new List<StoreKindResponse>();
     foreach (StoreKindData stored_kind in store_kind_data)
     {
         StoreKindResponse store_kind_response = new StoreKindResponse();
         store_kind_response.kind = stored_kind.Kind;
         store_kind_response.generation_counter = stored_kind.Generation_counter;
         store_kind_response.replicas = new List<NodeId>();
         foreach (NodeId nodeid in replicas)
         {
             store_kind_response.replicas.Add(nodeid);
         }
         kind_responses.Add(store_kind_response);
     }
 }