// 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 TraceStoreConnection(TraceStoreConnectionInformation traceConnectionInformation, ILogProvider logProvider) { Assert.IsNotNull(traceConnectionInformation, "Trace connection information can't be null"); Assert.IsNotNull(logProvider, "Log Provider can't be null"); this.logger = logProvider.CreateLoggerInstance("TraceStoreConnection"); this.InitializeStore(traceConnectionInformation, logProvider); }
private void InitializeStore(TraceStoreConnectionInformation connInfo, ILogProvider logProvider) { if (connInfo is LocalTraceStoreConnectionInformation) { this.InitializeLocalStore((LocalTraceStoreConnectionInformation)connInfo, logProvider); return; } if (connInfo is AzureTraceStoreConnectionInformation) { this.InitializeAzureStore((AzureTraceStoreConnectionInformation)connInfo, logProvider); return; } if (connInfo is AzureTableStoreStorageAccessInformation) { this.InitializeAzureStore((AzureTableStoreStorageAccessInformation)connInfo, logProvider); return; } throw new NotSupportedException( string.Format(CultureInfo.InvariantCulture, "Connection Information of Type '{0}' is Not supported", connInfo.GetType())); }
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(); } }