internal SystemTarget(LegacyGrainId grainId, SiloAddress silo, bool lowPriority, ILoggerFactory loggerFactory) { this.grainId = grainId; Silo = silo; this.ActivationAddress = ActivationAddress.GetAddress(this.Silo, this.grainId, this.ActivationId); this.IsLowPriority = lowPriority; ActivationId = ActivationId.GetDeterministic(grainId); this.timerLogger = loggerFactory.CreateLogger <GrainTimer>(); }
internal static GrainReference FromKeyInfo(GrainReferenceKeyInfo keyInfo, IGrainReferenceRuntime runtime) { if (keyInfo.HasGenericArgument) { return(FromGrainId(LegacyGrainId.FromKeyInfo(keyInfo.Key), runtime, keyInfo.GenericArgument)); } else if (keyInfo.HasObserverId) { return(NewObserverGrainReference(LegacyGrainId.FromKeyInfo(keyInfo.Key), GuidId.GetGuidId(keyInfo.ObserverId), runtime)); } else if (keyInfo.HasTargetSilo) { return(FromGrainId(LegacyGrainId.FromKeyInfo(keyInfo.Key), runtime, null, SiloAddress.New(keyInfo.TargetSilo.endpoint, keyInfo.TargetSilo.generation))); } else { return(FromGrainId(LegacyGrainId.FromKeyInfo(keyInfo.Key), runtime)); } }
internal static GrainReference FromKeyString(string key, IGrainReferenceRuntime runtime) { if (string.IsNullOrWhiteSpace(key)) { throw new ArgumentNullException(nameof(key), "GrainReference.FromKeyString cannot parse null key"); } ReadOnlySpan <char> trimmed = key.AsSpan().Trim(); ReadOnlySpan <char> grainIdStr; int grainIdIndex = (GRAIN_REFERENCE_STR + "=").Length; int genericIndex = trimmed.IndexOf(GENERIC_ARGUMENTS_STR_WITH_EQUAL_SIGN.AsSpan(), StringComparison.Ordinal); int observerIndex = trimmed.IndexOf(OBSERVER_ID_STR_WITH_EQUAL_SIGN.AsSpan(), StringComparison.Ordinal); int systemTargetIndex = trimmed.IndexOf(SYSTEM_TARGET_STR_WITH_EQUAL_SIGN.AsSpan(), StringComparison.Ordinal); if (genericIndex >= 0) { grainIdStr = trimmed.Slice(grainIdIndex, genericIndex - grainIdIndex).Trim(); ReadOnlySpan <char> genericStr = trimmed.Slice(genericIndex + GENERIC_ARGUMENTS_STR_WITH_EQUAL_SIGN.Length); return(FromGrainId(LegacyGrainId.FromParsableString(grainIdStr), runtime, genericStr.ToString())); } else if (observerIndex >= 0) { grainIdStr = trimmed.Slice(grainIdIndex, observerIndex - grainIdIndex).Trim(); ReadOnlySpan <char> observerIdStr = trimmed.Slice(observerIndex + OBSERVER_ID_STR_WITH_EQUAL_SIGN.Length); GuidId observerId = GuidId.FromParsableString(observerIdStr.ToString()); return(NewObserverGrainReference(LegacyGrainId.FromParsableString(grainIdStr), observerId, runtime)); } else if (systemTargetIndex >= 0) { grainIdStr = trimmed.Slice(grainIdIndex, systemTargetIndex - grainIdIndex).Trim(); ReadOnlySpan <char> systemTargetStr = trimmed.Slice(systemTargetIndex + SYSTEM_TARGET_STR_WITH_EQUAL_SIGN.Length); SiloAddress siloAddress = SiloAddress.FromParsableString(systemTargetStr.ToString()); return(FromGrainId(LegacyGrainId.FromParsableString(grainIdStr), runtime, null, siloAddress)); } else { grainIdStr = trimmed.Slice(grainIdIndex); return(FromGrainId(LegacyGrainId.FromParsableString(grainIdStr), runtime)); } }
public static bool IsLegacyGrain(this in GrainId id) => id.Type.IsLegacyGrain() || (LegacyGrainId.TryConvertFromGrainId(id, out var legacyId) && legacyId.IsGrain);
public static bool IsSystemTarget(this in GrainId id) => id.Type.IsSystemTarget() || LegacyGrainId.TryConvertFromGrainId(id, out var legacyId) && legacyId.IsSystemTarget;
internal SystemTarget(LegacyGrainId grainId, SiloAddress silo, ILoggerFactory loggerFactory) : this(grainId, silo, false, loggerFactory) { }
private bool IsUnordered(GrainReference reference) { return(LegacyGrainId.TryConvertFromGrainId(reference.GrainId, out var legacyId) && this.RuntimeClient.GrainTypeResolver is IGrainTypeResolver resolver && resolver.IsUnordered(legacyId.TypeCode)); }
public GrainReference MakeGrainServiceReference(int typeData, string systemGrainId, SiloAddress siloAddress) => GrainReference.FromGrainId(LegacyGrainId.GetGrainServiceGrainId(typeData, systemGrainId), this.runtimeClient.GrainReferenceRuntime, systemTargetSilo: siloAddress);
public HostedClient( IRuntimeClient runtimeClient, ClientObserverRegistrar clientObserverRegistrar, ILocalSiloDetails siloDetails, ILogger <HostedClient> logger, IGrainReferenceRuntime grainReferenceRuntime, IInternalGrainFactory grainFactory, InvokableObjectManager invokableObjectManager, MessageCenter messageCenter, MessagingTrace messagingTrace) { this.incomingMessages = Channel.CreateUnbounded <Message>(new UnboundedChannelOptions { SingleReader = true, SingleWriter = false, AllowSynchronousContinuations = false, }); this.runtimeClient = runtimeClient; this.clientObserverRegistrar = clientObserverRegistrar; this.grainReferenceRuntime = grainReferenceRuntime; this.grainFactory = grainFactory; this.invokableObjects = invokableObjectManager; this.siloMessageCenter = messageCenter; this.messagingTrace = messagingTrace; this.logger = logger; this.ClientAddress = ActivationAddress.NewActivationAddress(siloDetails.SiloAddress, LegacyGrainId.NewClientId()); }