/// <summary> /// Initializes a new instance of the <see cref="GrainMethodInvoker"/> class. /// </summary> /// <param name="grain">The grain.</param> /// <param name="request">The request.</param> /// <param name="rootInvoker">The generated invoker.</param> /// <param name="filters">The invocation interceptors.</param> /// <param name="interfaceToImplementationMapping">The implementation map.</param> /// <param name="invokeInterceptor">The deprecated silo-wide interceptor.</param> public GrainMethodInvoker( IAddressable grain, InvokeMethodRequest request, IGrainMethodInvoker rootInvoker, List <IGrainCallFilter> filters, InterfaceToImplementationMappingCache interfaceToImplementationMapping, InvokeInterceptor invokeInterceptor) { this.request = request; this.rootInvoker = rootInvoker; this.Grain = grain; this.filters = filters; this.deprecatedInvokeInterceptor = invokeInterceptor; this.interfaceToImplementationMapping = interfaceToImplementationMapping; }
public MetricsTrackerTelemetryConsumer(IProviderRuntime runtime, TaskScheduler taskScheduler) { try { Runtime = runtime; TaskScheduler = taskScheduler; logger = Runtime.GetLogger(nameof(MetricsTrackerTelemetryConsumer)); Configuration = new MetricsConfiguration(); Counters = new ConcurrentDictionary <string, long>(); CounterHistory = new ConcurrentDictionary <string, ConcurrentQueue <long> >(); Metrics = new ConcurrentDictionary <string, double>(); MetricHistory = new ConcurrentDictionary <string, ConcurrentQueue <double> >(); TimeSpanMetrics = new ConcurrentDictionary <string, TimeSpan>(); TimeSpanMetricHistory = new ConcurrentDictionary <string, ConcurrentQueue <TimeSpan> >(); Requests = new ConcurrentDictionary <string, MeasuredRequest>(); RequestHistory = new ConcurrentDictionary <string, ConcurrentQueue <MeasuredRequest> >(); PreviousInterceptor = Runtime.GetInvokeInterceptor(); // start a message pump to give ourselves the right synchronization context // from which we can communicate with grains via normal grain references // TODO: don't start the pump until it's been requested //StartMessagePump().Ignore(); //Task.Factory.StartNew(() => StartMessagePump(), CancellationToken.None, TaskCreationOptions.None, TaskScheduler); var dispatchTask = Dispatch(() => StartMessagePump()); Management = Runtime.GrainFactory.GetGrain <IManagementGrain>(0); } catch (Exception ex) { logger.TrackException(ex); throw; } }
public void SetInvokeInterceptor(InvokeInterceptor interceptor) { #pragma warning disable 618 runtime.SetInvokeInterceptor(interceptor); #pragma warning restore 618 }
public void SetInvokeInterceptor(InvokeInterceptor interceptor) { providerRuntime.SetInvokeInterceptor(interceptor); }
public void SetInvokeInterceptor(InvokeInterceptor interceptor) { this.invokeInterceptor = interceptor; }
public void SetInvokeInterceptor(InvokeInterceptor interceptor) { runtime.SetInvokeInterceptor(interceptor); }
public void SetInvokeInterceptor(InvokeInterceptor interceptor) { throw new NotImplementedException(); }
private Task <object> InvokeWithInterceptors(IAddressable target, InvokeMethodRequest request, IGrainMethodInvoker invoker, bool hasSiloWideInterceptor, InvokeInterceptor siloWideInterceptor, bool hasGrainLevelInterceptor, IGrainInvokeInterceptor grainWithInterceptor) { // Get an invoker which delegates to the grain's IGrainInvocationInterceptor implementation. // If the grain does not implement IGrainInvocationInterceptor, then the invoker simply delegates // calls to the provided invoker. var interceptedMethodInvoker = interceptedMethodInvokerCache.GetOrCreate( target.GetType(), request.InterfaceId, invoker); var methodInfo = interceptedMethodInvoker.GetMethodInfo(request.MethodId); if (hasSiloWideInterceptor) { // There is a silo-level interceptor and possibly a grain-level interceptor. // As a minor optimization, only pass the intercepted invoker if there is a grain-level // interceptor. return(siloWideInterceptor( methodInfo, request, (IGrain)target, hasGrainLevelInterceptor ? interceptedMethodInvoker : invoker)); } // The grain has an invoke method, but there is no silo-wide interceptor. return(grainWithInterceptor.Invoke(methodInfo, request, invoker)); }