Example #1
0
 public static RegionTable decodeRegionTable(KVMemoryStream stream)
 {
     RegionTable table =new RegionTable();
     int size = stream.ReadInt();
     for (int i = 0; i < size; i++)
     {
         Region region = decodeRegion(stream);
         Address addr = decodeAddress(stream);
         table.addRegion(region, addr);
     }
     return table;
 }
Example #2
0
        public static RegionTable decodeRegionTable(KVMemoryStream stream)
        {
            RegionTable table = new RegionTable();
            int         size  = stream.ReadInt();

            for (int i = 0; i < size; i++)
            {
                Region  region = decodeRegion(stream);
                Address addr   = decodeAddress(stream);
                table.addRegion(region, addr);
            }
            return(table);
        }
Example #3
0
        public void UpdateRegionTable()
        {
            Socket socket = getMasterConnection();

            SocketUtil.WriteUpdateRegionTableRequest(socket);
            RegionTable newTable = null;
            int         ret      = SocketUtil.ReadRegionTableResponse(socket, out newTable);

            if (ret != ProtocolCode.Success)
            {
                throw new KVException(ProtocolCode.getMessage(ret));
            }
            this.table = newTable;
        }
Example #4
0
 internal static int ReadRegionTableResponse(Socket socket, out RegionTable table)
 {
     using (KVMemoryStream stream = ReadResponse(socket))
     {
         int len     = stream.ReadInt();
         int type    = stream.ReadInt();
         int retCode = stream.ReadInt();
         if (retCode == ProtocolCode.Success)
         {
             table = DecoderUtil.decodeRegionTable(stream);
         }
         else
         {
             table = null;
         }
         return(retCode);
     }
 }
Example #5
0
 internal static int ReadRegionTableResponse(Socket socket,out RegionTable table)
 {
     using (KVMemoryStream stream = ReadResponse(socket))
     {
         int len = stream.ReadInt();
         int type = stream.ReadInt();
         int retCode = stream.ReadInt();
         if (retCode == ProtocolCode.Success)
         {
             table = DecoderUtil.decodeRegionTable(stream);
         }
         else
         {
             table = null;
         }
         return retCode;
     }
 }
Example #6
0
        public void UpdateRegionTable()
        {
            Socket socket = getMasterConnection();

            SocketUtil.WriteUpdateRegionTableRequest(socket);
            RegionTable newTable = null;
            int ret = SocketUtil.ReadRegionTableResponse(socket, out newTable);
            if (ret != ProtocolCode.Success)
            {
                throw new KVException(ProtocolCode.getMessage(ret));
            }
            this.table = newTable;
        }