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; }
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(); } }