Exemple #1
0
 private ClusterQuery(IInsightRuntime runtime)
 {
     this.fabricClient = runtime.GetService(typeof(FabricClient)) as FabricClient;
     Assert.IsNotNull(this.fabricClient, "Runtime needs to supply non-null Fabric client");
     this.logger      = runtime.GetLogProvider().CreateLoggerInstance("ClusterQuery.log");
     this.logProvider = runtime.GetLogProvider();
 }
 public HttpServiceClientHandler(IInsightRuntime runtime, IResolveServiceEndpoint serviceEndpointResolver)
 {
     Assert.IsNotNull(runtime, "Runtime can't be null");
     Assert.IsNotNull(serviceEndpointResolver, "Service Endpoint resolver can't be null");
     this.serviceResolver = serviceEndpointResolver;
     this.logger          = runtime.GetLogProvider().CreateLoggerInstance("HttpServiceClientHandler");
 }
        public async Task StartAnalysisEngineAsync(IList <InsightType> insightTypes, IInsightRuntime runtime, CancellationToken token)
        {
            await this.singleAccess.WaitAsync(token).ConfigureAwait(false);

            try
            {
                if (this.isRunning)
                {
                    throw new ClusterAnalysisAlreadyStartedException();
                }

                var connectionInfo       = (TraceStoreConnectionInformation)runtime.GetService(typeof(TraceStoreConnectionInformation));
                var traceStoreConnection = new TraceStoreConnection(connectionInfo, runtime.GetLogProvider());

                // Add the connection to Runtime. TODO Get rid of this and pass this explicitly.
                runtime.AddService(typeof(TraceStoreConnection), traceStoreConnection);

                var analysisScheduler = new AnalysisScheduler(
                    runtime.GetLogProvider(),
                    runtime.GetStoreProvider(),
                    runtime.TaskRunner,
                    traceStoreConnection,
                    token);

                runtime.AddService(typeof(AnalysisScheduler), analysisScheduler);

                Assert.IsNotNull(connectionInfo, "connectionInfo != null");

                this.callBackStore = new SimpleCallbackStore(
                    runtime.GetStoreProvider(),
                    runtime.TaskRunner,
                    runtime.GetLogProvider(),
                    traceStoreConnection.EventStoreReader,
                    token);

                AgentDirectory.InitializeSingleInstance(
                    runtime.GetCurrentConfig(),
                    runtime.GetLogProvider(),
                    runtime.GetStoreProvider(),
                    runtime.TaskRunner,
                    traceStoreConnection,
                    (IClusterQuery)runtime.GetService(typeof(IClusterQuery)),
                    token);

                foreach (var oneInsightType in insightTypes)
                {
                    switch (oneInsightType)
                    {
                    case InsightType.PartitionInsight:
                        this.partitionInsightGenerator = new PartitionInsightGenerator(runtime, this.callBackStore, token);
                        await this.partitionInsightGenerator.StartGeneratingAsync().ConfigureAwait(false);

                        break;

                    case InsightType.ReplicaInsight:
                        break;

                    case InsightType.CodePackageInsight:
                        break;

                    case InsightType.NodeInsight:
                        break;

                    case InsightType.ClusterInsight:
                        break;

                    default:
                        throw new NotSupportedException(
                                  string.Format(CultureInfo.InvariantCulture, "Insight Type '{0}' is currently not supported", oneInsightType));
                    }
                }

                this.isRunning = true;
            }
            catch
            {
                AgentDirectory.ReleaseInstance();
                throw;
            }
            finally
            {
                this.singleAccess.Release();
            }
        }