コード例 #1
0
ファイル: Header.cs プロジェクト: rigazilla/glassRod
        public static SegmentBasedTopologyInfo fromBytes(List <Byte> bytes, ref ulong pos)
        {
            SegmentBasedTopologyInfo resp = new SegmentBasedTopologyInfo();
            ulong numNodes;

            resp.topologyId = HotRodUtils.bytesToVLong(bytes, ref pos);
            numNodes        = HotRodUtils.bytesToVLong(bytes, ref pos);
            resp.nodes      = new NodeAddress[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);
                resp.nodes[i] = new NodeAddress(address, port);
            }
            resp.hashFuncVersion  = bytes[(int)pos++];
            resp.numSegments      = HotRodUtils.bytesToVLong(bytes, ref pos);
            resp.segmentSize      = (ulong)0x7FFFFFFF / resp.numSegments;
            resp.segmentsToOwners = new List <int> [resp.numSegments];
            for (uint i = 0; i < resp.numSegments; i++)
            {
                resp.segmentsToOwners[i] = new List <int>();
                int numOwner = bytes[(int)pos++];
                for (uint j = 0; j < numOwner; j++)
                {
                    ulong idx = HotRodUtils.bytesToVLong(bytes, ref pos);
                    resp.segmentsToOwners[i].Add((int)idx);
                }
            }
            return(resp);
        }
コード例 #2
0
ファイル: Header.cs プロジェクト: rigazilla/glassRod
        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);
        }