示例#1
0
        public async Task <int> Register(ActivationAddress address, int retries)
        {
            router.RegistrationsRemoteReceived.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 (router.MyAddress.Equals(owner))
            {
                router.RegistrationsLocal.Increment();
                return(partition.AddActivation(address.Grain, address.Activation, address.Silo));
            }

            if (retries > 0)
            {
                if (logger.IsVerbose2)
                {
                    logger.Verbose2("Retry " + retries + " RemoteGrainDirectory.Register 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 (router.MyAddress.Equals(o))
                {
                    router.RegistrationsLocal.Increment();
                    return(partition.AddActivation(address.Grain, address.Activation, address.Silo));
                }
                router.RegistrationsRemoteSent.Increment();
                return(await GetDirectoryReference(o).Register(address, retries - 1));
            }

            throw new OrleansException("Silo " + router.MyAddress + " is not the owner of the grain " + address.Grain + " Owner=" + owner);
        }
示例#2
0
 public AddressAndTag Register(ActivationAddress address, bool singleActivation)
 {
     if (singleActivation)
     {
         var result = directoryPartition.AddSingleActivation(address.Grain, address.Activation, address.Silo, GrainDirectoryEntryStatus.ClusterLocal);
         return(result);
     }
     else
     {
         var tag = directoryPartition.AddActivation(address.Grain, address.Activation, address.Silo);
         return(new AddressAndTag()
         {
             Address = address, VersionTag = tag
         });
     }
 }
示例#3
0
 public virtual AddressAndTag Register(ActivationAddress address, bool singleActivation)
 {
     if (singleActivation)
     {
         var result = DirectoryPartition.AddSingleActivation(address.Grain, address.Activation, address.Silo);
         return(result);
     }
     else
     {
         var tag = DirectoryPartition.AddActivation(address.Grain, address.Activation, address.Silo);
         return(new AddressAndTag()
         {
             Address = address, VersionTag = tag
         });
     }
 }