public ClusterAnalysisApiHandler(IReliableStateManager reliableStateManager, FabricClient client, CancellationToken token)
        {
            this.stateManager          = reliableStateManager;
            this.fabricClient          = client;
            this.serializationSettings = new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.All
            };
            this.originalCancellationToken    = token;
            this.startStopApiSingleAccessLock = new SemaphoreSlim(1);
            this.clusterAnalyzerApiStateStore = PersistentStoreProvider.GetStateProvider(this.stateManager)
                                                .CreatePersistentStoreForStringsAsync(ClusterAnalysisApiStateStoreIdentifier, AgeBasedRetentionPolicy.Forever, token).GetAwaiter().GetResult();

            this.logger = ClusterAnalysisLogProvider.LogProvider.CreateLoggerInstance(ClusterAnalysisTraceIdentifier);
        }
        private async Task <IInsightRuntime> CreateRunTimeAsync(ClusterAnalysisConfiguration configuration, CancellationToken token)
        {
            this.logger.LogMessage("CreateRunTimeAsync:: Entering");

            IInsightRuntime runtime;
            var             isOneBox = await this.IsCurrentDeploymentOneboxAsync(token).ConfigureAwait(false);

            if (isOneBox)
            {
                var config = this.CreateOneBoxConfig(configuration);
                this.logger.LogMessage("OneBoxConfig: {0}", config);

                runtime = DefaultInsightRuntime.GetInstance(
                    ClusterAnalysisLogProvider.LogProvider,
                    PersistentStoreProvider.GetStateProvider(this.stateManager),
                    config,
                    new PerformanceSessionManager(ClusterAnalysisLogProvider.LogProvider, token),
                    new TaskRunner(ClusterAnalysisLogProvider.LogProvider, this.OnUnhandledExceptionInAnalysisAsync),
                    token);

                this.AddServiceToRuntime(runtime, typeof(FabricClient), this.fabricClient);
                this.AddServiceToRuntime(runtime, typeof(IClusterQuery), ClusterQuery.CreateClusterQueryInstance(runtime));
                this.AddServiceToRuntime(runtime, typeof(IResolveServiceEndpoint), new ResolveServiceEndpoint(ServicePartitionResolver.GetDefault()));

                var localStoreConnection = new LocalTraceStoreConnectionInformation(
                    runtime.GetCurrentConfig().RuntimeContext.FabricDataRoot,
                    runtime.GetCurrentConfig().RuntimeContext.FabricLogRoot,
                    runtime.GetCurrentConfig().RuntimeContext.FabricCodePath);

                this.AddServiceToRuntime(
                    runtime,
                    typeof(TraceStoreConnectionInformation),
                    localStoreConnection);
            }
            else
            {
                this.logger.LogMessage("CreateRunTimeAsync:: Only One-Box deployment supported currently");
                throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, "Cluster Analysis is only supported on One-Box deployment for Preview."));
            }

            return(runtime);
        }