Example #1
0
        // 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);
        }
Example #2
0
        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 AzureTableEventStoreReader(ILogProvider logProvider, AzureTableStoreStorageAccessInformation connectionInformation) : base(
         logProvider,
         connectionInformation)
 {
 }
Example #4
0
 protected AzureStoreReader(ILogProvider logProvider, AzureTableStoreStorageAccessInformation azureTableStorageAccessInfo) : base(logProvider)
 {
     Assert.IsNotNull(azureTableStorageAccessInfo, "azureTableStorageAccessInfo != null");
     this.azureTableAccessInfo = azureTableStorageAccessInfo;
 }