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()); }
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 }); }
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); } }