예제 #1
0
        public Task DeleteAsync(GrainId gid)
        {
            directoryPartition.RemoveGrain(gid);

            // broadcast deletion to all other clusters
            var myClusterId = Silo.CurrentSilo.ClusterId;

            if (myClusterId == null)
            {
                return(TaskDone.Done); // single cluster - no broadcast required
            }
            // target ALL clusters, not just clusters in current configuration
            var remoteClusters = Silo.CurrentSilo.LocalMultiClusterOracle.GetActiveClusters()
                                 .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.ProcessDeletion(gid));
                }
            }
            return(Task.WhenAll(tasks));
        }
예제 #2
0
        public async Task DeleteGrain(GrainId grain, int retries)
        {
            // validate that this grain should be stored in our partition
            SiloAddress owner = router.CalculateTargetSilo(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))
            {
                partition.RemoveGrain(grain);
                return;
            }

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

                await Task.Delay(RETRY_DELAY);

                SiloAddress o = router.CalculateTargetSilo(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))
                {
                    partition.RemoveGrain(grain);
                    return;
                }
                await GetDirectoryReference(o).DeleteGrain(grain, retries - 1);
            }
            else
            {
                throw new OrleansException("Silo " + router.MyAddress + " is not the owner of the grain " + grain + " Owner=" + owner);
            }
        }
예제 #3
0
 public void Delete(GrainId gid)
 {
     directoryPartition.RemoveGrain(gid);
 }
예제 #4
0
 public virtual void Delete(GrainId gid)
 {
     DirectoryPartition.RemoveGrain(gid);
 }