Esempio n. 1
0
        public static List <byte[]> ParallelFetchValuesHTTP(List <ConfigState.ShardServer> shardServers, Int64 tableID, byte[] key)
        {
            var threads    = new GetterThreadState[shardServers.Count];
            var doneEvents = new ManualResetEvent[shardServers.Count];
            var serverKeys = new List <byte[]>();

            var i = 0;

            foreach (var shardServer in shardServers)
            {
                var url = Utils.HTTP.BuildUri(GetShardServerURL(shardServer),
                                              "raw/get?tableID=" + tableID,
                                              "&key=", key);

                doneEvents[i] = new ManualResetEvent(false);

                threads[i]             = new GetterThreadState();
                threads[i].shardServer = shardServer;
                threads[i].url         = url;
                threads[i].doneEvent   = doneEvents[i];
                ThreadPool.QueueUserWorkItem(threads[i].GetterThreadFunc, null);

                i += 1;
            }

            WaitHandle.WaitAll(doneEvents);

            foreach (var thread in threads)
            {
                serverKeys.Add(thread.value);
            }

            return(serverKeys);
        }
Esempio n. 2
0
        public static List<byte[]> ParallelFetchValuesHTTP(List<ConfigState.ShardServer> shardServers, Int64 tableID, byte[] key)
        {
            var threads = new GetterThreadState[shardServers.Count];
            var doneEvents = new ManualResetEvent[shardServers.Count];
            var serverKeys = new List<byte[]>();

            var i = 0;
            foreach (var shardServer in shardServers)
            {
                var url = Utils.HTTP.BuildUri(GetShardServerURL(shardServer),
                            "raw/get?tableID=" + tableID,
                            "&key=", key);

                doneEvents[i] = new ManualResetEvent(false);

                threads[i] = new GetterThreadState();
                threads[i].shardServer = shardServer;
                threads[i].url = url;
                threads[i].doneEvent = doneEvents[i];
                ThreadPool.QueueUserWorkItem(threads[i].GetterThreadFunc, null);

                i += 1;
            }

            WaitHandle.WaitAll(doneEvents);

            foreach (var thread in threads)
            {
                serverKeys.Add(thread.value);
            }

            return serverKeys;
        }