Пример #1
0
        public override async Task <JoinPartitionResponse> JoinPartition(
            JoinPartitionRequest request,
            ServerCallContext context)
        {
            await dispatcher.OnJoinPartition(ParseJoinPartition(request));

            Console.WriteLine(
                "[{0}] Received Partition {1}",
                DateTime.Now.ToString("HH:mm:ss"),
                request.PartitionId);

            return(new JoinPartitionResponse());
        }
Пример #2
0
        private JoinPartitionArguments ParseJoinPartition(
            JoinPartitionRequest request)
        {
            string partitionName = request.PartitionId;
            string masterId      = request.MasterId;

            List <Tuple <string, string> > servers = new List <Tuple <string, string> >();

            foreach (Server server in request.Servers)
            {
                servers.Add(new Tuple <string, string>(server.Id, server.Url));
            }

            return(new JoinPartitionArguments {
                PartitionId = partitionName,
                Members = servers,
                MasterId = masterId
            });
        }
Пример #3
0
        public async Task <bool> JoinPartitionAsync(
            string partitionName,
            IEnumerable <Tuple <string, string> > servers,
            string masterId)
        {
            JoinPartitionRequest request =
                ServerConfigurationMessageFactory.BuildJoinPartitionRequest(
                    partitionName,
                    servers,
                    masterId);

            try {
                await client.JoinPartitionAsync(request);

                return(true);
            }
            catch (RpcException e) {
                Console.WriteLine(
                    "Error: {0} when joining partition at server {1}",
                    e.StatusCode,
                    target);
                return(false);
            }
        }