Example #1
0
 public GrainFactory(
     IRuntimeClient runtimeClient,
     TypeMetadataCache typeCache)
 {
     this.runtimeClient = runtimeClient;
     this.typeCache     = typeCache;
 }
Example #2
0
        public PersistentStreamProvider(string name, PersistentStreamOptions options, IProviderRuntime runtime, SerializationManager serializationManager, ILogger <PersistentStreamProvider> logger)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (runtime == null)
            {
                throw new ArgumentNullException(nameof(runtime));
            }
            if (serializationManager == null)
            {
                throw new ArgumentNullException(nameof(serializationManager));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            this.Name                 = name;
            this.options              = options;
            this.runtime              = runtime.ServiceProvider.GetRequiredService <IStreamProviderRuntime>();
            this.runtimeClient        = runtime.ServiceProvider.GetRequiredService <IRuntimeClient>();
            this.serializationManager = serializationManager;
            this.logger               = logger;
        }
        public async Task Init(string name, IProviderRuntime providerUtilitiesManager, IProviderConfiguration config)
        {
            if (!stateManager.PresetState(ProviderState.Initialized))
            {
                return;
            }
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }
            if (providerUtilitiesManager == null)
            {
                throw new ArgumentNullException("providerUtilitiesManager");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            Name            = name;
            providerRuntime = (IStreamProviderRuntime)providerUtilitiesManager;
            logger          = providerRuntime.GetLogger(this.GetType().Name);
            adapterFactory  = new TAdapterFactory();
            // Temporary change, but we need GrainFactory inside ServiceProvider for now,
            // so will change it back as soon as we have an action item to add GrainFactory to ServiceProvider.
            adapterFactory.Init(config, Name, logger, new GrainFactoryServiceProvider(providerRuntime));
            queueAdapter = await adapterFactory.CreateAdapter();

            myConfig                  = new PersistentStreamProviderConfig(config);
            this.providerConfig       = config;
            this.serializationManager = this.providerRuntime.ServiceProvider.GetRequiredService <SerializationManager>();
            this.runtimeClient        = this.providerRuntime.ServiceProvider.GetRequiredService <IRuntimeClient>();
            if (this.myConfig.PubSubType == StreamPubSubType.ExplicitGrainBasedAndImplicit ||
                this.myConfig.PubSubType == StreamPubSubType.ExplicitGrainBasedOnly)
            {
                this.streamSubscriptionManager = this.providerRuntime.ServiceProvider
                                                 .GetService <IStreamSubscriptionManagerAdmin>().GetStreamSubscriptionManager(StreamSubscriptionManagerType.ExplicitSubscribeOnly);
            }
            string startup;

            if (config.Properties.TryGetValue(StartupStatePropertyName, out startup))
            {
                if (!Enum.TryParse(startup, true, out startupState))
                {
                    throw new ArgumentException(
                              String.Format("Unsupported value '{0}' for configuration parameter {1} of stream provider {2}.", startup, StartupStatePropertyName, config.Name));
                }
            }
            else
            {
                startupState = StartupStateDefaultValue;
            }
            logger.Info("Initialized PersistentStreamProvider<{0}> with name {1}, Adapter {2} and config {3}, {4} = {5}.",
                        typeof(TAdapterFactory).Name,
                        Name,
                        queueAdapter.Name,
                        myConfig,
                        StartupStatePropertyName, startupState);
            stateManager.CommitState();
        }
 public SimpleMessageStreamProvider(
     string name,
     SimpleMessageStreamProviderOptions options,
     IStreamFilter streamFilter,
     ILoggerFactory loggerFactory,
     IServiceProvider services)
 {
     this.loggerFactory   = loggerFactory;
     this.Name            = name;
     this.logger          = loggerFactory.CreateLogger <SimpleMessageStreamProvider>();
     this.options         = options;
     this.streamFilter    = streamFilter;
     this.providerRuntime = services.GetRequiredService <IStreamProviderRuntime>();
     this.runtimeClient   = providerRuntime.ServiceProvider.GetService <IRuntimeClient>();
     if (this.options.PubSubType == StreamPubSubType.ExplicitGrainBasedAndImplicit ||
         this.options.PubSubType == StreamPubSubType.ExplicitGrainBasedOnly)
     {
         this.streamSubscriptionManager = this.providerRuntime.ServiceProvider
                                          .GetService <IStreamSubscriptionManagerAdmin>()
                                          .GetStreamSubscriptionManager(StreamSubscriptionManagerType.ExplicitSubscribeOnly);
     }
     logger.Info(
         "Initialized SimpleMessageStreamProvider with name {0} and with property FireAndForgetDelivery: {1}, OptimizeForImmutableData: {2} " +
         "and PubSubType: {3}", Name, this.options.FireAndForgetDelivery, this.options.OptimizeForImmutableData,
         this.options.PubSubType);
 }
Example #5
0
 StreamPubSubWrapper(IRuntimeClient client, string[] providers, IStreamPubSub registry, Func <StreamIdentity, StreamPubSubMatch[]> matcher)
 {
     this.client    = client;
     this.providers = providers;
     this.registry  = registry;
     this.matcher   = matcher;
 }
Example #6
0
        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, GrainId.NewClientId());
        }
Example #7
0
        public Task Init(string name, IProviderRuntime providerUtilitiesManager, IProviderConfiguration config)
        {
            if (!stateManager.PresetState(ProviderState.Initialized))
            {
                return(TaskDone.Done);
            }
            this.Name                = name;
            providerRuntime          = (IStreamProviderRuntime)providerUtilitiesManager;
            this.runtimeClient       = this.providerRuntime.ServiceProvider.GetRequiredService <IRuntimeClient>();
            fireAndForgetDelivery    = config.GetBoolProperty(FIRE_AND_FORGET_DELIVERY, DEFAULT_VALUE_FIRE_AND_FORGET_DELIVERY);
            optimizeForImmutableData = config.GetBoolProperty(OPTIMIZE_FOR_IMMUTABLE_DATA, DEFAULT_VALUE_OPTIMIZE_FOR_IMMUTABLE_DATA);

            string pubSubTypeString;

            pubSubType = !config.Properties.TryGetValue(STREAM_PUBSUB_TYPE, out pubSubTypeString)
                ? DEFAULT_STREAM_PUBSUB_TYPE
                : (StreamPubSubType)Enum.Parse(typeof(StreamPubSubType), pubSubTypeString);
            if (pubSubType == StreamPubSubType.ExplicitGrainBasedAndImplicit ||
                pubSubType == StreamPubSubType.ExplicitGrainBasedOnly)
            {
                this.streamSubscriptionManager = this.providerRuntime.ServiceProvider
                                                 .GetService <IStreamSubscriptionManagerAdmin>().GetStreamSubscriptionManager(StreamSubscriptionManagerType.ExplicitSubscribeOnly);
            }

            logger = providerRuntime.GetLogger(this.GetType().Name);
            logger.Info("Initialized SimpleMessageStreamProvider with name {0} and with property FireAndForgetDelivery: {1}, OptimizeForImmutableData: {2} " +
                        "and PubSubType: {3}", Name, fireAndForgetDelivery, optimizeForImmutableData, pubSubType);
            stateManager.CommitState();
            return(TaskDone.Done);
        }
Example #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClusterClient"/> class.
        /// </summary>
        /// <param name="runtimeClient">The runtime client.</param>
        /// <param name="loggerFactory">Logger factory used to create loggers</param>
        /// <param name="clientMessagingOptions">Messaging parameters</param>
        public ClusterClient(IRuntimeClient runtimeClient, ILoggerFactory loggerFactory, IOptions <ClientMessagingOptions> clientMessagingOptions)
        {
            this.runtimeClient          = runtimeClient;
            this.clusterClientLifecycle = new ClusterClientLifecycle(loggerFactory.CreateLogger <LifecycleSubject>());

            //set PropagateActivityId flag from node cofnig
            RequestContext.PropagateActivityId |= clientMessagingOptions.Value.PropagateActivityId;

            // register all lifecycle participants
            IEnumerable <ILifecycleParticipant <IClusterClientLifecycle> > lifecycleParticipants = this.ServiceProvider.GetServices <ILifecycleParticipant <IClusterClientLifecycle> >();

            foreach (ILifecycleParticipant <IClusterClientLifecycle> participant in lifecycleParticipants)
            {
                participant?.Participate(clusterClientLifecycle);
            }

            // register all named lifecycle participants
            IKeyedServiceCollection <string, ILifecycleParticipant <IClusterClientLifecycle> > namedLifecycleParticipantCollections = this.ServiceProvider.GetService <IKeyedServiceCollection <string, ILifecycleParticipant <IClusterClientLifecycle> > >();

            foreach (ILifecycleParticipant <IClusterClientLifecycle> participant in namedLifecycleParticipantCollections
                     ?.GetServices(this.ServiceProvider)
                     ?.Select(s => s?.GetService(this.ServiceProvider)))
            {
                participant?.Participate(clusterClientLifecycle);
            }

            // It is fine for this field to be null in the case that the client is not the host.
            this.applicationLifetime = runtimeClient.ServiceProvider.GetService <IHostApplicationLifetime>() as ClientApplicationLifetime;
        }
Example #9
0
        public HostedClient(
            IRuntimeClient runtimeClient,
            ClientObserverRegistrar clientObserverRegistrar,
            ILocalSiloDetails siloDetails,
            ILogger <HostedClient> logger,
            IGrainReferenceRuntime grainReferenceRuntime,
            IInternalGrainFactory grainFactory,
            InvokableObjectManager invokableObjectManager,
            ISiloMessageCenter messageCenter)
        {
            this.runtimeClient           = runtimeClient;
            this.clientObserverRegistrar = clientObserverRegistrar;
            this.grainReferenceRuntime   = grainReferenceRuntime;
            this.grainFactory            = grainFactory;
            this.invokableObjects        = invokableObjectManager;
            this.siloMessageCenter       = messageCenter;
            this.logger = logger;

            this.ClientAddress = ActivationAddress.NewActivationAddress(siloDetails.SiloAddress, GrainId.NewClientId());

            // Register with the directory and message center so that we can receive messages.
            this.clientObserverRegistrar.SetHostedClient(this);
            this.clientObserverRegistrar.ClientAdded(this.ClientId);
            this.siloMessageCenter.SetHostedClient(this);

            // Start pumping messages.
            this.Start();
        }
Example #10
0
 public ClientProviderRuntime(IGrainFactory grainFactory, IServiceProvider serviceProvider)
 {
     this.runtimeClient = RuntimeClient.Current;
     caoTable           = new Dictionary <Type, Tuple <IGrainExtension, IAddressable> >();
     lockable           = new AsyncLock();
     GrainFactory       = grainFactory;
     ServiceProvider    = serviceProvider;
 }
Example #11
0
 public ClientProviderRuntime(IInternalGrainFactory grainFactory, IServiceProvider serviceProvider)
 {
     this.grainFactory    = grainFactory;
     this.ServiceProvider = serviceProvider;
     this.runtimeClient   = serviceProvider.GetService <IRuntimeClient>();
     caoTable             = new Dictionary <Type, Tuple <IGrainExtension, IAddressable> >();
     lockable             = new AsyncLock();
 }
Example #12
0
        public InvokableObjectManager(IRuntimeClient runtimeClient, SerializationManager serializationManager, ILogger <InvokableObjectManager> logger)
        {
            this.runtimeClient        = runtimeClient;
            this.serializationManager = serializationManager;
            this.logger = logger;

            this.dispatchFunc = o =>
                                this.LocalObjectMessagePumpAsync((LocalObjectData)o);
        }
Example #13
0
 internal StreamImpl(InternalStreamId streamId, IInternalStreamProvider provider, bool isRewindable, IRuntimeClient runtimeClient)
 {
     this.streamId      = streamId;
     this.provider      = provider ?? throw new ArgumentNullException(nameof(provider));
     this.runtimeClient = runtimeClient ?? throw new ArgumentNullException(nameof(runtimeClient));
     producerInterface  = null;
     consumerInterface  = null;
     initLock           = new object();
     this.isRewindable  = isRewindable;
 }
Example #14
0
 public ClientProviderRuntime(IInternalGrainFactory grainFactory, IServiceProvider serviceProvider, ILoggerFactory loggerFactory)
 {
     this.grainFactory    = grainFactory;
     this.ServiceProvider = serviceProvider;
     this.runtimeClient   = serviceProvider.GetService <IRuntimeClient>();
     this.loggerFactory   = loggerFactory;
     caoTable             = new Dictionary <Type, Tuple <IGrainExtension, IAddressable> >();
     lockable             = new AsyncLock();
     //all async timer created through current class all share this logger for perf reasons
     this.timerLogger = loggerFactory.CreateLogger <AsyncTaskSafeTimer>();
 }
Example #15
0
 public GrainReferenceRuntime(
     Factory <string, Logger> loggerFactory,
     IRuntimeClient runtimeClient,
     IInternalGrainFactory internalGrainFactory,
     SerializationManager serializationManager)
 {
     this.responseCallbackDelegate = this.ResponseCallback;
     this.logger               = loggerFactory.Invoke(nameof(GrainReferenceRuntime));
     this.RuntimeClient        = runtimeClient;
     this.internalGrainFactory = internalGrainFactory;
     this.serializationManager = serializationManager;
 }
 public GrainReferenceRuntime(
     ILogger <GrainReferenceRuntime> logger,
     IRuntimeClient runtimeClient,
     IInternalGrainFactory internalGrainFactory,
     SerializationManager serializationManager)
 {
     this.responseCallbackDelegate = this.ResponseCallback;
     this.logger               = logger;
     this.RuntimeClient        = runtimeClient;
     this.internalGrainFactory = internalGrainFactory;
     this.serializationManager = serializationManager;
 }
Example #17
0
 public ClientMessageCenter(
     IOptions <GatewayOptions> gatewayOptions,
     IOptions <ClientMessagingOptions> clientMessagingOptions,
     IPAddress localAddress,
     int gen,
     GrainId clientId,
     IGatewayListProvider gatewayListProvider,
     SerializationManager serializationManager,
     IRuntimeClient runtimeClient,
     MessageFactory messageFactory,
     IClusterConnectionStatusListener connectionStatusListener,
     ExecutorService executorService,
     ILoggerFactory loggerFactory,
     IOptions <NetworkingOptions> networkingOptions,
     IOptions <StatisticsOptions> statisticsOptions)
 {
     this.loggerFactory         = loggerFactory;
     this.openConnectionTimeout = networkingOptions.Value.OpenConnectionTimeout;
     this.SerializationManager  = serializationManager;
     this.executorService       = executorService;
     lockable                      = new object();
     MyAddress                     = SiloAddress.New(new IPEndPoint(localAddress, 0), gen);
     ClientId                      = clientId;
     this.RuntimeClient            = runtimeClient;
     this.messageFactory           = messageFactory;
     this.connectionStatusListener = connectionStatusListener;
     Running                = false;
     GatewayManager         = new GatewayManager(gatewayOptions.Value, gatewayListProvider, loggerFactory);
     PendingInboundMessages = new BlockingCollection <Message>();
     gatewayConnections     = new Dictionary <Uri, GatewayConnection>();
     numMessages            = 0;
     grainBuckets           = new WeakReference[clientMessagingOptions.Value.ClientSenderBuckets];
     logger = loggerFactory.CreateLogger <ClientMessageCenter>();
     if (logger.IsEnabled(LogLevel.Debug))
     {
         logger.Debug("Proxy grain client constructed");
     }
     IntValueStatistic.FindOrCreate(
         StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT,
         () =>
     {
         lock (gatewayConnections)
         {
             return(gatewayConnections.Values.Count(conn => conn.IsLive));
         }
     });
     statisticsLevel = statisticsOptions.Value.CollectionLevel;
     if (statisticsLevel.CollectQueueStats())
     {
         queueTracking = new QueueTrackingStatistic("ClientReceiver", statisticsOptions);
     }
 }
Example #18
0
 public InvokableObjectManager(
     IGrainContext rootGrainContext,
     IRuntimeClient runtimeClient,
     SerializationManager serializationManager,
     MessagingTrace messagingTrace,
     ILogger logger)
 {
     this.rootGrainContext     = rootGrainContext;
     this.runtimeClient        = runtimeClient;
     this.serializationManager = serializationManager;
     this.messagingTrace       = messagingTrace;
     this.logger = logger;
 }
Example #19
0
 public InvokableObjectManager(
     IGrainContext rootGrainContext,
     IRuntimeClient runtimeClient,
     DeepCopier deepCopier,
     MessagingTrace messagingTrace,
     ILogger logger)
 {
     this.rootGrainContext = rootGrainContext;
     this.runtimeClient    = runtimeClient;
     this.deepCopier       = deepCopier;
     this.messagingTrace   = messagingTrace;
     this.logger           = logger;
 }
Example #20
0
        /// <summary>Constructs a reference to the grain with the specified Id.</summary>
        /// <param name="grainId">The Id of the grain to refer to.</param>
        /// <param name="genericArgument">Type arguments in case of a generic grain.</param>
        /// <param name="systemTargetSilo">Target silo in case of a system target reference.</param>
        /// <param name="observerId">Observer ID in case of an observer reference.</param>
        /// <param name="runtimeClient">The runtime which this grain reference is bound to.</param>
        private GrainReference(GrainId grainId, string genericArgument, SiloAddress systemTargetSilo, GuidId observerId, IRuntimeClient runtimeClient)
        {
            GrainId = grainId;
            this.responseCallbackDelegate = this.ResponseCallback;
            genericArguments   = genericArgument;
            SystemTargetSilo   = systemTargetSilo;
            this.observerId    = observerId;
            this.runtimeClient = runtimeClient;
            if (String.IsNullOrEmpty(genericArgument))
            {
                genericArguments = null; // always keep it null instead of empty.
            }

            // SystemTarget checks
            if (grainId.IsSystemTarget && systemTargetSilo == null)
            {
                throw new ArgumentNullException("systemTargetSilo", String.Format("Trying to create a GrainReference for SystemTarget grain id {0}, but passing null systemTargetSilo.", grainId));
            }
            if (grainId.IsSystemTarget && genericArguments != null)
            {
                throw new ArgumentException(String.Format("Trying to create a GrainReference for SystemTarget grain id {0}, and also passing non-null genericArguments {1}.", grainId, genericArguments), "genericArgument");
            }
            if (grainId.IsSystemTarget && observerId != null)
            {
                throw new ArgumentException(String.Format("Trying to create a GrainReference for SystemTarget grain id {0}, and also passing non-null observerId {1}.", grainId, observerId), "genericArgument");
            }
            if (!grainId.IsSystemTarget && systemTargetSilo != null)
            {
                throw new ArgumentException(String.Format("Trying to create a GrainReference for non-SystemTarget grain id {0}, but passing a non-null systemTargetSilo {1}.", grainId, systemTargetSilo), "systemTargetSilo");
            }

            // ObserverId checks
            if (grainId.IsClient && observerId == null)
            {
                throw new ArgumentNullException("observerId", String.Format("Trying to create a GrainReference for Observer with Client grain id {0}, but passing null observerId.", grainId));
            }
            if (grainId.IsClient && genericArguments != null)
            {
                throw new ArgumentException(String.Format("Trying to create a GrainReference for Client grain id {0}, and also passing non-null genericArguments {1}.", grainId, genericArguments), "genericArgument");
            }
            if (grainId.IsClient && systemTargetSilo != null)
            {
                throw new ArgumentException(String.Format("Trying to create a GrainReference for Client grain id {0}, and also passing non-null systemTargetSilo {1}.", grainId, systemTargetSilo), "genericArgument");
            }
            if (!grainId.IsClient && observerId != null)
            {
                throw new ArgumentException(String.Format("Trying to create a GrainReference with non null Observer {0}, but non Client grain id {1}.", observerId, grainId), "observerId");
            }

            isUnordered = GetUnordered();
        }
Example #21
0
 public GrainReferenceRuntime(
     IRuntimeClient runtimeClient,
     IGrainCancellationTokenRuntime cancellationTokenRuntime,
     IEnumerable <IOutgoingGrainCallFilter> outgoingCallFilters,
     GrainReferenceActivator referenceActivator,
     GrainInterfaceTypeResolver interfaceTypeResolver)
 {
     this.RuntimeClient            = runtimeClient;
     this.cancellationTokenRuntime = cancellationTokenRuntime;
     this.referenceActivator       = referenceActivator;
     this.interfaceTypeResolver    = interfaceTypeResolver;
     this.filters     = outgoingCallFilters.ToArray();
     this.sendRequest = (GrainReference reference, IResponseCompletionSource callback, IInvokable body, InvokeMethodOptions options) => RuntimeClient.SendRequest(reference, body, callback, options);
 }
Example #22
0
        public Activation(ActivationId id, object activation, IRuntimeClient runtimeClient)
        {
            this.activation    = activation;
            this.ActivationId  = id;
            this.runtimeClient = runtimeClient;
            var channel = Channel.CreateUnbounded <Message>(
                new UnboundedChannelOptions
            {
                SingleWriter = false, SingleReader = true, AllowSynchronousContinuations = false
            });

            this.pending  = channel.Reader;
            this.incoming = channel.Writer;
        }
Example #23
0
 public ClientMessageCenter(
     IOptions <ClientMessagingOptions> clientMessagingOptions,
     IPAddress localAddress,
     int gen,
     GrainId clientId,
     SerializationManager serializationManager,
     IRuntimeClient runtimeClient,
     MessageFactory messageFactory,
     IClusterConnectionStatusListener connectionStatusListener,
     ILoggerFactory loggerFactory,
     IOptions <StatisticsOptions> statisticsOptions,
     ConnectionManager connectionManager,
     GatewayManager gatewayManager)
 {
     this.messageHandlers      = new Action <Message> [Enum.GetValues(typeof(Message.Categories)).Length];
     this.connectionManager    = connectionManager;
     this.SerializationManager = serializationManager;
     MyAddress                     = SiloAddress.New(new IPEndPoint(localAddress, 0), gen);
     ClientId                      = clientId;
     this.RuntimeClient            = runtimeClient;
     this.messageFactory           = messageFactory;
     this.connectionStatusListener = connectionStatusListener;
     Running                = false;
     this.gatewayManager    = gatewayManager;
     PendingInboundMessages = Channel.CreateUnbounded <Message>(new UnboundedChannelOptions
     {
         SingleReader = true,
         SingleWriter = false,
         AllowSynchronousContinuations = false
     });
     numMessages       = 0;
     this.grainBuckets = new WeakReference <Connection> [clientMessagingOptions.Value.ClientSenderBuckets];
     logger            = loggerFactory.CreateLogger <ClientMessageCenter>();
     if (logger.IsEnabled(LogLevel.Debug))
     {
         logger.Debug("Proxy grain client constructed");
     }
     IntValueStatistic.FindOrCreate(
         StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT,
         () =>
     {
         return(connectionManager.ConnectionCount);
     });
     statisticsLevel = statisticsOptions.Value.CollectionLevel;
     if (statisticsLevel.CollectQueueStats())
     {
         queueTracking = new QueueTrackingStatistic("ClientReceiver", statisticsOptions);
     }
 }
 public ClientProviderRuntime(
     IInternalGrainFactory grainFactory,
     IServiceProvider serviceProvider,
     ILoggerFactory loggerFactory,
     ImplicitStreamSubscriberTable implicitSubscriberTable,
     ClientGrainContext clientContext)
 {
     this.grainFactory            = grainFactory;
     this.ServiceProvider         = serviceProvider;
     this.implicitSubscriberTable = implicitSubscriberTable;
     this.clientContext           = clientContext;
     this.runtimeClient           = serviceProvider.GetService <IRuntimeClient>();
     //all async timer created through current class all share this logger for perf reasons
     this.timerLogger = loggerFactory.CreateLogger <AsyncTaskSafeTimer>();
 }
 public GrainReferenceRuntime(
     IRuntimeClient runtimeClient,
     IGrainCancellationTokenRuntime cancellationTokenRuntime,
     SerializationManager serializationManager,
     IEnumerable <IOutgoingGrainCallFilter> outgoingCallFilters,
     TypeMetadataCache typeMetadataCache)
 {
     this.grainReferenceMethodCache = new InterfaceToImplementationMappingCache();
     this.sendRequestDelegate       = SendRequest;
     this.RuntimeClient             = runtimeClient;
     this.cancellationTokenRuntime  = cancellationTokenRuntime;
     this.GrainReferenceFactory     = new GrainReferenceFactory(typeMetadataCache, this);
     this.serializationManager      = serializationManager;
     this.filters = outgoingCallFilters.ToArray();
 }
 public GrainReferenceRuntime(
     IRuntimeClient runtimeClient,
     IGrainCancellationTokenRuntime cancellationTokenRuntime,
     IEnumerable <IOutgoingGrainCallFilter> outgoingCallFilters,
     GrainReferenceActivator referenceActivator,
     GrainInterfaceTypeResolver interfaceTypeResolver,
     DeepCopier deepCopier)
 {
     this.RuntimeClient            = runtimeClient;
     this.cancellationTokenRuntime = cancellationTokenRuntime;
     this.referenceActivator       = referenceActivator;
     this.interfaceTypeResolver    = interfaceTypeResolver;
     this.filters     = outgoingCallFilters.ToArray();
     this.sendRequest = this.SendRequest;
     this.deepCopier  = deepCopier;
 }
        public InvokableObjectManager(
            IGrainContext rootGrainContext,
            IRuntimeClient runtimeClient,
            SerializationManager serializationManager,
            MessagingTrace messagingTrace,
            ILogger logger)
        {
            this.rootGrainContext     = rootGrainContext;
            this.runtimeClient        = runtimeClient;
            this.serializationManager = serializationManager;
            this.messagingTrace       = messagingTrace;
            this.logger = logger;

            this.dispatchFunc = o =>
                                this.LocalObjectMessagePumpAsync((LocalObjectData)o);
        }
Example #28
0
 public ProxiedMessageCenter(
     ClientConfiguration config,
     IPAddress localAddress,
     int gen,
     GrainId clientId,
     IGatewayListProvider gatewayListProvider,
     SerializationManager serializationManager,
     IRuntimeClient runtimeClient,
     MessageFactory messageFactory,
     IClusterConnectionStatusListener connectionStatusListener,
     ILoggerFactory loggerFactory,
     IOptions <ClientMessagingOptions> messagingOptions)
 {
     this.loggerFactory         = loggerFactory;
     this.openConnectionTimeout = messagingOptions.Value.OpenConnectionTimeout;
     this.SerializationManager  = serializationManager;
     lockable                      = new object();
     MyAddress                     = SiloAddress.New(new IPEndPoint(localAddress, 0), gen);
     ClientId                      = clientId;
     this.RuntimeClient            = runtimeClient;
     this.messageFactory           = messageFactory;
     this.connectionStatusListener = connectionStatusListener;
     Running                = false;
     GatewayManager         = new GatewayManager(config, gatewayListProvider, loggerFactory);
     PendingInboundMessages = new BlockingCollection <Message>();
     gatewayConnections     = new Dictionary <Uri, GatewayConnection>();
     numMessages            = 0;
     grainBuckets           = new WeakReference[config.ClientSenderBuckets];
     logger = new LoggerWrapper <ProxiedMessageCenter>(loggerFactory);
     if (logger.IsVerbose)
     {
         logger.Verbose("Proxy grain client constructed");
     }
     IntValueStatistic.FindOrCreate(
         StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT,
         () =>
     {
         lock (gatewayConnections)
         {
             return(gatewayConnections.Values.Count(conn => conn.IsLive));
         }
     });
     if (StatisticsCollector.CollectQueueStats)
     {
         queueTracking = new QueueTrackingStatistic("ClientReceiver");
     }
 }
 public GrainReferenceRuntime(
     ILogger <GrainReferenceRuntime> logger,
     IRuntimeClient runtimeClient,
     IGrainCancellationTokenRuntime cancellationTokenRuntime,
     IInternalGrainFactory internalGrainFactory,
     SerializationManager serializationManager,
     IEnumerable <IOutgoingGrainCallFilter> outgoingCallFilters)
 {
     this.grainReferenceMethodCache = new InterfaceToImplementationMappingCache();
     this.sendRequestDelegate       = SendRequest;
     this.logger                   = logger;
     this.RuntimeClient            = runtimeClient;
     this.cancellationTokenRuntime = cancellationTokenRuntime;
     this.internalGrainFactory     = internalGrainFactory;
     this.serializationManager     = serializationManager;
     this.filters                  = outgoingCallFilters.ToArray();
 }
Example #30
0
        public ActivationData(
            ActivationAddress addr,
            string genericArguments,
            PlacementStrategy placedUsing,
            IMultiClusterRegistrationStrategy registrationStrategy,
            IActivationCollector collector,
            TimeSpan ageLimit,
            IOptions <SiloMessagingOptions> messagingOptions,
            TimeSpan maxWarningRequestProcessingTime,
            TimeSpan maxRequestProcessingTime,
            IRuntimeClient runtimeClient,
            ILoggerFactory loggerFactory)
        {
            if (null == addr)
            {
                throw new ArgumentNullException(nameof(addr));
            }
            if (null == placedUsing)
            {
                throw new ArgumentNullException(nameof(placedUsing));
            }
            if (null == collector)
            {
                throw new ArgumentNullException(nameof(collector));
            }

            logger         = loggerFactory.CreateLogger <ActivationData>();
            this.lifecycle = new GrainLifecycle(loggerFactory.CreateLogger <LifecycleSubject>());
            this.maxRequestProcessingTime        = maxRequestProcessingTime;
            this.maxWarningRequestProcessingTime = maxWarningRequestProcessingTime;
            this.messagingOptions = messagingOptions.Value;
            ResetKeepAliveRequest();
            Address              = addr;
            State                = ActivationState.Create;
            PlacedUsing          = placedUsing;
            RegistrationStrategy = registrationStrategy;
            if (!Grain.IsSystemTarget)
            {
                this.collector = collector;
            }

            CollectionAgeLimit = ageLimit;

            GrainReference         = GrainReference.FromGrainId(addr.Grain, runtimeClient.GrainReferenceRuntime, genericArguments, Grain.IsSystemTarget ? addr.Silo : null);
            this.SchedulingContext = new SchedulingContext(this);
        }
Example #31
0
 public GrainRuntime(
     GlobalConfiguration globalConfig,
     ILocalSiloDetails localSiloDetails,
     IGrainFactory grainFactory,
     ITimerRegistry timerRegistry,
     IReminderRegistry reminderRegistry,
     IStreamProviderManager streamProviderManager,
     IServiceProvider serviceProvider,
     IRuntimeClient runtimeClient)
 {
     this.runtimeClient = runtimeClient;
     ServiceId = globalConfig.ServiceId;
     SiloIdentity = localSiloDetails.SiloAddress.ToLongString();
     GrainFactory = grainFactory;
     TimerRegistry = timerRegistry;
     ReminderRegistry = reminderRegistry;
     StreamProviderManager = streamProviderManager;
     ServiceProvider = serviceProvider;
 }