private void HandleGaveUp(MasterMessageUnion wrapper,
                           MessageStreamWriter <MasterMessageUnion> writer)
 {
     master.GaveUp(new NodeEndpoint
     {
         Async = new Uri(wrapper.GaveUp.Endpoint.Async),
         Sync  = new Uri(wrapper.GaveUp.Endpoint.Sync)
     },
                   wrapper.GaveUp.Type == ReplicationType.Backup ? Internal.ReplicationType.Backup : Internal.ReplicationType.Ownership,
                   wrapper.GaveUp.GaveUpSegmentsList.ToArray());
     writer.Write(new MasterMessageUnion.Builder
     {
         Type = MasterMessageType.GaveUpResponse
     }.Build());
 }
        private void HandleJoin(MasterMessageUnion wrapper,
                                MessageStreamWriter <MasterMessageUnion> writer)
        {
            var endpoint = wrapper.JoinRequest.EndpointJoining;
            var segments = master.Join(new NodeEndpoint
            {
                Async = new Uri(endpoint.Async),
                Sync  = new Uri(endpoint.Sync)
            });
            var joinResponse = new JoinResponseMessage.Builder
            {
                SegmentsList = { segments.Select(x => x.GetSegment()) }
            };

            writer.Write(new MasterMessageUnion.Builder
            {
                Type         = MasterMessageType.JoinResult,
                JoinResponse = joinResponse.Build()
            }.Build());
        }
 private void HandleCatchUp(MasterMessageUnion wrapper,
     MessageStreamWriter<MasterMessageUnion> writer)
 {
     master.CaughtUp(new NodeEndpoint
     {
         Async = new Uri(wrapper.CaughtUp.Endpoint.Async),
         Sync = new Uri(wrapper.CaughtUp.Endpoint.Sync)
     },
     wrapper.CaughtUp.Type == ReplicationType.Backup ? Internal.ReplicationType.Backup : Internal.ReplicationType.Ownership,
     wrapper.CaughtUp.CaughtUpSegmentsList.ToArray());
     writer.Write(new MasterMessageUnion.Builder
     {
         Type = MasterMessageType.CaughtUpResponse
     }.Build());
 }
 private void HandleJoin(MasterMessageUnion wrapper,
     MessageStreamWriter<MasterMessageUnion> writer)
 {
     var endpoint = wrapper.JoinRequest.EndpointJoining;
     var segments = master.Join(new NodeEndpoint
     {
         Async = new Uri(endpoint.Async),
         Sync = new Uri(endpoint.Sync)
     });
     var joinResponse = new JoinResponseMessage.Builder
     {
         SegmentsList = { segments.Select(x => x.GetSegment()) }
     };
     writer.Write(new MasterMessageUnion.Builder
     {
         Type = MasterMessageType.JoinResult,
         JoinResponse = joinResponse.Build()
     }.Build());
 }