Ejemplo n.º 1
0
        public async Task Unregister(ActivationAddress address, bool force, int retries)
        {
            router.UnregistrationsRemoteReceived.Increment();
            // validate that this grain should be stored in our partition
            SiloAddress owner = router.CalculateTargetSilo(address.Grain);

            if (owner == null)
            {
                // We don't know about any other silos, and we're stopping, so throw
                throw new InvalidOperationException("Grain directory is stopping");
            }

            if (owner.Equals(router.MyAddress))
            {
                router.UnregistrationsLocal.Increment();
                partition.RemoveActivation(address.Grain, address.Activation, force);
                return;
            }

            if (retries > 0)
            {
                if (logger.IsVerbose2)
                {
                    logger.Verbose2("Retry " + retries + " RemoteGrainDirectory.Unregister for address=" + address + " at Owner=" + owner);
                }
                PrepareForRetry(retries);

                await Task.Delay(RETRY_DELAY);

                SiloAddress o = router.CalculateTargetSilo(address.Grain);
                if (o == null)
                {
                    // We don't know about any other silos, and we're stopping, so throw
                    throw new InvalidOperationException("Grain directory is stopping");
                }
                if (o.Equals(router.MyAddress))
                {
                    router.UnregistrationsLocal.Increment();
                    partition.RemoveActivation(address.Grain, address.Activation, force);
                    return;
                }
                router.UnregistrationsRemoteSent.Increment();
                await GetDirectoryReference(o).Unregister(address, force, retries - 1);
            }
            else
            {
                throw new OrleansException("Silo " + router.MyAddress + " is not the owner of the grain " + address.Grain + " Owner=" + owner);
            }
        }
Ejemplo n.º 2
0
 public void Unregister(ActivationAddress address, UnregistrationCause cause)
 {
     directoryPartition.RemoveActivation(address.Grain, address.Activation, cause);
 }
Ejemplo n.º 3
0
        public Task UnregisterAsync(List <ActivationAddress> addresses, UnregistrationCause cause)
        {
            List <ActivationAddress> formerActivationsInThisCluster = null;

            foreach (var address in addresses)
            {
                IActivationInfo existingAct;
                bool            wasRemoved;
                directoryPartition.RemoveActivation(address.Grain, address.Activation, cause, out existingAct, out wasRemoved);
                if (existingAct == null)
                {
                    logger.Verbose2("GSIP:Unr {0} {1} ignored", cause, address);
                }
                else if (!wasRemoved)
                {
                    logger.Verbose2("GSIP:Unr {0} {1} too fresh", cause, address);
                }
                else if (existingAct.RegistrationStatus == GrainDirectoryEntryStatus.Owned ||
                         existingAct.RegistrationStatus == GrainDirectoryEntryStatus.Doubtful)
                {
                    logger.Verbose2("GSIP:Unr {0} {1} broadcast ({2})", cause, address, existingAct.RegistrationStatus);
                    if (formerActivationsInThisCluster == null)
                    {
                        formerActivationsInThisCluster = new List <ActivationAddress>();
                    }
                    formerActivationsInThisCluster.Add(address);
                }
                else
                {
                    logger.Verbose2("GSIP:Unr {0} {1} removed ({2})", cause, address, existingAct.RegistrationStatus);
                }
            }

            if (formerActivationsInThisCluster == null)
            {
                return(TaskDone.Done);
            }

            // we must also remove cached references to former activations in this cluster
            // from remote clusters; thus, we broadcast the unregistration
            var myClusterId = Silo.CurrentSilo.ClusterId;

            if (myClusterId == null)
            {
                return(TaskDone.Done); // single cluster - no broadcast required
            }
            // target clusters in current configuration, other than this one
            var remoteClusters = Silo.CurrentSilo.LocalMultiClusterOracle.GetMultiClusterConfiguration().Clusters
                                 .Where(id => id != myClusterId).ToList();

            var tasks = new List <Task>();

            foreach (var remoteCluster in remoteClusters)
            {
                // find gateway
                var gossipOracle          = Silo.CurrentSilo.LocalMultiClusterOracle;
                var clusterGatewayAddress = gossipOracle.GetRandomClusterGateway(remoteCluster);
                if (clusterGatewayAddress != null)
                {
                    var clusterGrainDir = InsideRuntimeClient.Current.InternalGrainFactory.GetSystemTarget <IClusterGrainDirectory>(Constants.ClusterDirectoryServiceId, clusterGatewayAddress);

                    // try to send request

                    tasks.Add(clusterGrainDir.ProcessDeactivations(formerActivationsInThisCluster));
                }
            }
            return(Task.WhenAll(tasks));
        }
Ejemplo n.º 4
0
 public virtual void Unregister(ActivationAddress address, bool force)
 {
     DirectoryPartition.RemoveActivation(address.Grain, address.Activation, force);
 }