static void Main(string[] args) { //TraceStoreConnectionInformation info = new LocalTraceStoreConnectionInformation( // @"D:\Repos\WindowsFabric\out\debug-amd64\bin\WinFabricTest\test\FabActFiveNodelCluster.test\TC", // @"E:\crm_duplicate", // @"D:\Repos\WindowsFabric\out\debug-amd64\bin\WinFabricTest\test\FabActFiveNodelCluster.test\TC"); TraceStoreConnectionInformation info = new AzureTraceStoreConnectionInformation( "winfablrc", HandyUtil.SecureStringFromCharArray("<Insert key Here>"), "vipinrtobitlogsqt", "blobContainerRandmom", "e98a88aa63aa42b4", LocalDiskLogger.LogProvider); TraceStoreConnection connection = new TraceStoreConnection(info, LocalDiskLogger.LogProvider); ReadFilter filter = ReadFilter.CreateReadFilter(typeof(NodeOpeningTraceRecord)); // SET your Duration. var duration = new Duration( DateTime.SpecifyKind(DateTime.Parse("2018-04-10 01:01:19.155"), DateTimeKind.Utc), DateTime.SpecifyKind(DateTime.UtcNow, DateTimeKind.Utc)); var results = connection.EventStoreReader.WithinBound(duration).ReadBackwardAsync(filter, 500, CancellationToken.None).GetAwaiter().GetResult(); Console.WriteLine("Count {0}", results.Count()); foreach (var one in results) { Console.WriteLine(one.TimeStamp.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture) + " " + one); Console.WriteLine(); } Console.Read(); }
// Used for console driven testing. internal EventStoreReader(string accountName, string accountKey, string tablePrefix, string deploymentId) { TraceStoreConnectionInformation connectionInfo = null; EventStoreLogger.Logger.LogMessage("Cloud Environment. Configuring Test Reader"); var azureTableStorageAccess = new AzureTableCachedStorageAccess( new CachePolicy(MaxDaysToMaintainCache, MaxItemsToCache, TimeSpan.FromHours(8)), accountName, accountKey, true, tablePrefix, deploymentId); // Kick-off the Cache Update Task. This task is launched in a separate Task // which is monitored by the TaskRunner and therefore doesn't need to be monitored here. azureTableStorageAccess.KickOffUpdaterAsync(CancellationToken.None); connectionInfo = new AzureTableStoreStorageAccessInformation(azureTableStorageAccess, tablePrefix, deploymentId); var connection = new TraceStoreConnection(connectionInfo, EventStoreLogProvider.LogProvider); traceStoreReader = connection.EventStoreReader; this.initialized = true; this.singleAccess = new SemaphoreSlim(1); }
public EventStoreReader() { TraceStoreConnectionInformation connectionInfo = null; if (ClusterSettingsReader.IsOneBoxEnvironment()) { EventStoreLogger.Logger.LogMessage("One Box Environment. Configuring local Reader"); connectionInfo = new LocalTraceStoreConnectionInformation( FabricEnvironment.GetDataRoot(), FabricEnvironment.GetLogRoot(), FabricEnvironment.GetCodePath()); } else { EventStoreLogger.Logger.LogMessage("Cloud Environment. Configuring Cloud Reader"); var operationalConsumer = ClusterSettingsReader.OperationalConsumer; if (operationalConsumer == null) { throw new ConnectionParsingException(ErrorCodes.AzureConnectionInformationMissing, "Config is Missing Operational Store Connection information"); } connectionInfo = new AzureTraceStoreConnectionInformation( operationalConsumer.Connection.AccountName, operationalConsumer.Connection.AccountKey, operationalConsumer.TablesPrefix, null, operationalConsumer.DeploymentId, EventStoreLogProvider.LogProvider); } var connection = new TraceStoreConnection(connectionInfo, EventStoreLogProvider.LogProvider); traceStoreReader = connection.EventStoreReader; }
public AnalysisScheduler( ILogProvider logProvider, IStoreProvider storeProvider, ITaskRunner taskRunner, TraceStoreConnection traceStoreConnection, CancellationToken token) { Assert.IsNotNull(logProvider, "Log Provider can't be null"); Assert.IsNotNull(storeProvider, "Store Provider can't be null"); Assert.IsNotNull(taskRunner, "Task Runner can't be null"); Assert.IsNotNull(traceStoreConnection, "Trace store connection can't be null"); this.Logger = logProvider.CreateLoggerInstance(TracePrefix); this.TaskRunner = taskRunner; this.consumerMap = new Dictionary <AgentIdentifier, IDictionary <IAnalysisConsumer, ConsumeOptions> >(); this.CancelToken = token; // The in memory Caches for typed objects this.signalWaitingToBeProcessedMap = new ConcurrentDictionary <Guid, ConcurrentQueue <ScenarioData> >(); this.analysisMetadataObjectStore = new TypedObjectStore <AnalysisMetadata>( this.Logger, storeProvider, AgentConstants.AnalysisMetadataStoreId, AgentConstants.AnalysisMetadataStoreRetentionPolicy, token); this.analysisContainerObjectStore = new TypedObjectStore <AnalysisContainer>( this.Logger, storeProvider, AgentConstants.AnalysisContainerStoreId, AgentConstants.AnalysisContainerStoreRetentionPolicy, token); this.signalWaitingToBeProcessedStoreInstance = storeProvider.CreatePersistentStoreKeyGuidValueStringAsync( AgentConstants.AnalysisUnprocessedSignalStoreId, AgentConstants.AnalysisUnprocessedSignalStoreRetentionPolicy, this.CancelToken).GetAwaiter().GetResult(); Assert.IsNotNull(this.signalWaitingToBeProcessedStoreInstance, "signalWaitingToBeProcessedStoreInstance"); // Restore state from any of the previous Runs. this.RestoreStateFromPreviousRunsAsync().GetAwaiter().GetResult(); this.Logger.LogMessage("kicking off Activation Task"); var activationTask = this.TaskRunner.Run("AgentActivationTask", this.ActivateAnalysisAsync, this.CancelToken); this.InitializeDataFlowPipeline(); }
public static void InitializeSingleInstance( Config config, ILogProvider logProvider, IStoreProvider storeProvider, ITaskRunner taskRunner, TraceStoreConnection traceStoreConnection, IClusterQuery clusterQuery, CancellationToken token) { if (SingleInstance != null) { return; } lock (singleAccessLock) { if (SingleInstance == null) { SingleInstance = new AgentDirectory(config, logProvider, storeProvider, taskRunner, traceStoreConnection, clusterQuery, token); } } }
private AgentDirectory( Config configuration, ILogProvider logProvider, IStoreProvider storeProvider, ITaskRunner taskRunner, TraceStoreConnection traceStoreConnection, IClusterQuery clusterQuery, CancellationToken token) { Assert.IsNotNull(configuration, "Config can't be null"); Assert.IsNotNull(logProvider, "Log Provider can't be null"); Assert.IsNotNull(storeProvider, "Store Provider can't be null"); Assert.IsNotNull(taskRunner, "Task Runner can't be null"); Assert.IsNotNull(traceStoreConnection, "Trace store connection can't be null"); Assert.IsNotNull(clusterQuery, "Cluster Query can't be null"); this.taskRunner = taskRunner; this.logProvider = logProvider; this.clusterQuery = clusterQuery; this.storeConnection = traceStoreConnection; this.storeProvider = storeProvider; this.token = token; this.configuration = configuration; this.agentMap = new ConcurrentDictionary <AgentIdentifier, Agent>(); }
private async Task InitIfRequiredAsync(CancellationToken token) { if (this.initialized) { return; } await this.singleAccess.WaitAsync(token).ConfigureAwait(false); if (this.initialized) { return; } EventStoreLogger.Logger.LogMessage("Doing Reader Initialization"); try { TraceStoreConnectionInformation connectionInfo = null; if (ClusterSettingsReader.IsOneBoxEnvironment()) { EventStoreLogger.Logger.LogMessage("One Box Environment. Configuring local Reader"); connectionInfo = new LocalTraceStoreConnectionInformation( FabricEnvironment.GetDataRoot(), FabricEnvironment.GetLogRoot(), FabricEnvironment.GetCodePath()); } else { EventStoreLogger.Logger.LogMessage("Cloud Environment. Configuring Cloud Reader. Mode : {0}", this.dataReaderMode); var operationalConsumer = ClusterSettingsReader.OperationalConsumer; if (operationalConsumer == null) { throw new ConnectionParsingException(ErrorCodes.AzureConnectionInformationMissing, "Config is Missing Operational Store Connection information"); } if (this.dataReaderMode == DataReaderMode.CacheMode) { EventStoreLogger.Logger.LogMessage("Caching is Enabled."); this.azureAccessObject = new AzureTableCachedStorageAccess( new CachePolicy(MaxDaysToMaintainCache, MaxItemsToCache, TimeSpan.FromHours(8)), operationalConsumer.Connection.AccountName, HandyUtil.ConvertToUnsecureString(operationalConsumer.Connection.AccountKey), true, operationalConsumer.TablesPrefix, operationalConsumer.DeploymentId); // Kick-off the Cache Update Task. This task is launched in a separate Task // which is monitored by the TaskRunner and therefore doesn't need to be monitored here. var task = ((AzureTableCachedStorageAccess)azureAccessObject).KickOffUpdaterAsync(token); } else { EventStoreLogger.Logger.LogMessage("Caching is Disabled"); this.azureAccessObject = new AccountAndKeyTableStorageAccess( operationalConsumer.Connection.AccountName, HandyUtil.ConvertToUnsecureString(operationalConsumer.Connection.AccountKey), true); } connectionInfo = new AzureTableStoreStorageAccessInformation(azureAccessObject, operationalConsumer.TablesPrefix, operationalConsumer.DeploymentId); } var connection = new TraceStoreConnection(connectionInfo, EventStoreLogProvider.LogProvider); traceStoreReader = connection.EventStoreReader; this.initialized = true; } finally { this.singleAccess.Release(); } }
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(); } }