public static HashAwareTopologyInfo fromBytes(List <Byte> bytes, ref ulong pos) { HashAwareTopologyInfo resp = new HashAwareTopologyInfo(); ulong numNodes; resp.topologyId = HotRodUtils.bytesToVLong(bytes, ref pos); numNodes = HotRodUtils.bytesToVLong(bytes, ref pos); resp.nodes = new List <HashAwareNodeAddress>((int)numNodes); for (uint i = 0; i < numNodes; i++) { ulong addressLength = HotRodUtils.bytesToVLong(bytes, ref pos); string address = Encoding.UTF8.GetString(bytes.GetRange((int)pos, (int)addressLength).ToArray()); pos += addressLength; ushort port = HotRodUtils.bytesToUShort(bytes, ref pos); ulong hashcode = HotRodUtils.bytesToULong(bytes, ref pos); resp.nodes.Add(new HashAwareNodeAddress(address, port, hashcode)); } return(resp); }
public static HeaderResponse fromBytes(List <Byte> bytes, ref ulong pos) { HeaderResponse resp = new HeaderResponse(); if (bytes[0] != 0xA1) { throw new Exception("Bad magic number received: " + bytes[0]); } resp.magic = bytes[(int)pos++]; resp.messageId = HotRodUtils.bytesToVLong(bytes, ref pos); resp.opcode = bytes[(int)pos++]; resp.status = bytes[(int)pos++]; resp.topologyChangeMarker = bytes[(int)pos++]; if (resp.topologyChangeMarker != 0) { HashAwareTopologyInfo.fromBytes(bytes, ref pos); } return(resp); }