Exemplo n.º 1
0
        public void ListGlobal()
        {
            foreach (var serverId in ServerUrls.Keys)
            {
                TryChangeCommunicationChannel(serverId);

                try
                {
                    ListGlobalRequest request = new ListGlobalRequest();
                    var reply = Client.ListGlobal(request);
                    Console.WriteLine("Received from " + serverId);
                    foreach (var key in reply.Keys)
                    {
                        Console.WriteLine($"object <{key.PartitionId}, {key.ObjectId}>");
                    }
                }
                catch (RpcException e)
                {
                    if (e.Status.StatusCode == StatusCode.Unavailable || e.Status.StatusCode == StatusCode.DeadlineExceeded || e.Status.StatusCode == StatusCode.Internal)
                    {
                        UpdateCrashedServersList();
                    }
                    else
                    {
                        throw e;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public ListGlobalReply ListMeGlobal(ListGlobalRequest request)
        {
            Console.WriteLine("Received ListGlobal");
            List <Key> lst = new List <Key>();

            LocalReadWriteLock.AcquireReaderLock(-1);
            foreach (var key in KeyValuePairs.Keys)
            {
                KeyValuePairs[key].LockRead();
                lst.Add(new Key
                {
                    PartitionId = key.Partition_id,
                    ObjectId    = key.Object_id
                });
                KeyValuePairs[key].UnlockRead();
            }
            LocalReadWriteLock.ReleaseReaderLock();

            return(new ListGlobalReply
            {
                Keys = { lst }
            });
        }
Exemplo n.º 3
0
 // Call to List Global
 public override Task <ListGlobalReply> ListGlobal(ListGlobalRequest request, ServerCallContext context)
 {
     return(Task.FromResult(ListMeGlobal(request)));
 }