Ejemplo n.º 1
0
        // these are messages from some other node in the cluster
        public Task <IMessage> ReceiveMessage(ISubscriber sender, IMessage message, object?context, CancellationToken token)
        {
            if (message.Name == server.ShardAssignment.Name)
            {
                if (_cluster.Leader.IsRemote)
                {
                    // shard assignment requests should always be sent to the leader, so we if get one as
                    // a follower then something went wrong
                    _logger.LogWarning("Got shard assignment message as a follower");
                }

                // if we have a current shardAssignment, and one that was sent in that are different
                // we should check membership for new servers, or missing servers.



                // if we have new servers, ....


                // if we have missing servers ...


                // if we have same servers, but different assignments, then we will want to either keep it the same
                // or determine if we should balance some things around.

                var sa = new ShardAssignment(_cluster.Members.Count * 4, _cluster.Members);
                this._currentShardAssignment = sa;
                return(Task.FromResult(sa.ToBinaryMessage() as IMessage));
            }
            throw new NotImplementedException();
        }
Ejemplo n.º 2
0
        // these are signals from some other node in the cluster
        public Task ReceiveSignal(ISubscriber sender, IMessage signal, object?context, CancellationToken token)
        {
            switch (signal.Name)
            {
            case "": break;

            default: break;
            }
            throw new NotImplementedException();
        }
Ejemplo n.º 3
0
 public ShardAssignment(IMessage clusterMessage) : base()
 {
     if (clusterMessage.Name == "GetShardAssignment")
     {
         var respBytes = clusterMessage.ToByteArrayAsync().Result;
         var respSA    = new Ekati.Protocol.Grpc.ShardAssignment();
         respSA.MergeFrom(respBytes);
         InitFrom(respSA);
     }
 }