private IPerSiloGrain GetGrainServiceForSilo(SiloAddress address) { // This slightly misuses a public interface intended for // serialization support, but is cleaner than private reflection. var keyinfo = ((GrainReference)GrainService).ToKeyInfo(); var targetKeyInfo = new GrainReferenceKeyInfo(keyinfo.Key, (address.Endpoint, address.Generation)); var targetRef = GrainReferenceConverter.GetGrainFromKeyInfo(targetKeyInfo); return(targetRef.Cast <IPerSiloGrain>()); }
public GrainReferenceKeyInfo ToKeyInfo() { if (IsObserverReference) { return(new GrainReferenceKeyInfo(GrainId.ToKeyInfo(), observerId.Guid)); } if (IsSystemTarget) { return(new GrainReferenceKeyInfo(GrainId.ToKeyInfo(), (SystemTargetSilo.Endpoint, SystemTargetSilo.Generation))); } if (HasGenericArgument) { return(new GrainReferenceKeyInfo(GrainId.ToKeyInfo(), genericArguments)); } return(new GrainReferenceKeyInfo(GrainId.ToKeyInfo())); }
internal static GrainReference FromKeyInfo(GrainReferenceKeyInfo keyInfo, IGrainReferenceRuntime runtime) { if (keyInfo.HasGenericArgument) { return(FromGrainId(GrainId.FromKeyInfo(keyInfo.Key), runtime, keyInfo.GenericArgument)); } else if (keyInfo.HasObserverId) { return(NewObserverGrainReference(GrainId.FromKeyInfo(keyInfo.Key), GuidId.GetGuidId(keyInfo.ObserverId), runtime)); } else if (keyInfo.HasTargetSilo) { return(FromGrainId(GrainId.FromKeyInfo(keyInfo.Key), runtime, null, SiloAddress.New(keyInfo.TargetSilo.endpoint, keyInfo.TargetSilo.generation))); } else { return(FromGrainId(GrainId.FromKeyInfo(keyInfo.Key), runtime)); } }
/// <inheritdoc /> public GrainReference GetGrainFromKeyInfo(GrainReferenceKeyInfo keyInfo) => GrainReference.FromKeyInfo(keyInfo, this.GrainReferenceRuntime);