예제 #1
0
        private ActivationAddress GetClientActivationAddress(GrainId clientId)
        {
            // Need to pick a unique deterministic ActivationId for this client.
            // We store it in the grain directory and there for every GrainId we use ActivationId as a key
            // so every GW needs to behave as a different "activation" with a different ActivationId (its not enough that they have different SiloAddress)
            string    stringToHash = clientId.ToParsableString() + myAddress.Endpoint + myAddress.Generation.ToString(System.Globalization.CultureInfo.InvariantCulture);
            Guid      hash         = Utils.CalculateGuidHash(stringToHash);
            UniqueKey key          = UniqueKey.NewKey(hash);

            return(ActivationAddress.GetAddress(myAddress, clientId, ActivationId.GetActivationId(key)));
        }
예제 #2
0
        public static ActivationId GetClientGWActivation(GrainId grain, SiloAddress location)
        {
            if (!grain.IsClient)
            {
                throw new ArgumentException("ClientGW activation IDs can only be created for client grains");
            }

            // Construct a unique and deterministic ActivationId based on GrainId and SiloAddress.
            string    stringToHash = grain.ToParsableString() + location.Endpoint + location.Generation.ToString(System.Globalization.CultureInfo.InvariantCulture);
            Guid      hash         = Utils.CalculateGuidHash(stringToHash);
            UniqueKey key          = UniqueKey.NewKey(hash);

            return(FindOrCreate(key));
        }