Beispiel #1
0
        public void receiveAliveMessage(MetaDataServerAliveMessage aliveMessage)
        {
            if (isFailing)
            {
                throw new Exception("MDS " + Id + " is failing");
            }
            if (isRecovering)
            {
                aliveMessage.Operations.Sort(new OperationComparer());
                foreach (MetaDataOperation op in aliveMessage.Operations)
                {
                    requestsQueue.Enqueue(op);
                }
                return;
            }

            try
            {
                replicationHandler.registerAliveMessage(aliveMessage.MetadataServerId);
            }
            catch (Exception)
            {
                throw;
            }

            if (aliveMessage.IsMaster && aliveMessage.Operations != null)
            {
                foreach (MetaDataOperation operation in aliveMessage.Operations)
                {
                    safeExecuteOperation(operation);
                }
            }
        }
        public void sendAliveMessage(MetaDataServerAliveMessage aliveMessage)
        {
            foreach (int slaveId in AliveServers)
            {
                int nodeId = slaveId;
                Task.Factory.StartNew(() =>
                {

                    if (nodeId != MetadataServerId)
                    {
                        MetaDataServer metadataServer = MetaInformationReader.Instance.MetaDataServers[nodeId].getObject<MetaDataServer>();
                        try
                        {
                            metadataServer.receiveAliveMessage(aliveMessage);
                        }

                        catch (Exception)
                        {

                        }
                    }
                });
            }
            resetMyTimer();
        }