Beispiel #1
0
        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;
        }
        // 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 PrimaryMoveAnalysisQueryStoreReaderWrapper(
     ILogger logger,
     ITraceStoreReader queryStoreReader,
     CancellationToken cancellationToken)
 {
     this.queryStoreReader  = queryStoreReader;
     this.cancellationToken = cancellationToken;
     this.logger            = logger;
 }
Beispiel #4
0
 public PrimaryMoveAnalysisEventStoreReaderWrapper(
     ILogger logger,
     ITraceStoreReader eventStoreReader,
     CancellationToken cancellationToken)
 {
     this.eventStoreReader  = eventStoreReader;
     this.cancellationToken = cancellationToken;
     this.logger            = logger;
 }
Beispiel #5
0
 /// <inheritdoc />
 protected TimeTriggeredAgent(
     ITaskRunner taskRunner,
     ILogger logger,
     IStoreProvider storeProvider,
     ITraceStoreReader eventStoreReader,
     ITraceStoreReader queryStoreReader,
     IClusterQuery clusterQuery,
     CancellationToken token) : base(taskRunner, logger, storeProvider, eventStoreReader, queryStoreReader, clusterQuery, token)
 {
 }
Beispiel #6
0
 /// <summary>
 /// Create an instance of <see cref="SimpleCallbackStore"/>
 /// </summary>
 /// <param name="logProvider"></param>
 /// <param name="traceStoreReader"></param>
 /// <param name="token"></param>
 /// <param name="storeProvider"></param>
 /// <param name="taskRunner"></param>
 /// <remarks>
 /// Keeping private to control who can create an instance.
 /// </remarks>
 internal SimpleCallbackStore(
     IStoreProvider storeProvider,
     ITaskRunner taskRunner,
     ILogProvider logProvider,
     ITraceStoreReader traceStoreReader,
     CancellationToken token) : base(storeProvider, taskRunner, logProvider, token)
 {
     Assert.IsNotNull(traceStoreReader, "Trace Store Reader can't be null");
     this.traceStoreReader = traceStoreReader;
 }
Beispiel #7
0
        public static ReadFilter CreateTypeAndIdFilter(ITraceStoreReader traceStoreReader, Type type, Guid eventInstanceId)
        {
            var filter = ReadFilter.CreateReadFilter(type);

            if (eventInstanceId != Guid.Empty && traceStoreReader.IsPropertyLevelFilteringSupported())
            {
                filter.AddFilter(type, EventInstanceFilterName, eventInstanceId);
            }

            return(filter);
        }
 /// <inheritdoc />
 internal ReconfigAnalysisAgent(
     Config config,
     ITaskRunner taskRunner,
     ILogger logger,
     IStoreProvider storeProvider,
     ITraceStoreReader eventStoreReader,
     ITraceStoreReader queryStoreReader,
     IClusterQuery clusterQuery,
     CancellationToken token) : base(taskRunner, logger, storeProvider, eventStoreReader, queryStoreReader, clusterQuery, token)
 {
     Assert.IsNotNull(config, "Config can't be null");
     this.currentConfig = config.NamedConfigManager.GetConfiguration <ReconfigAnalysisAgentConfig>();
     this.Logger.LogMessage("Init with Config: {0}", this.currentConfig);
 }
Beispiel #9
0
        public static ReadFilter CreatePartitionFilter(ITraceStoreReader traceStoreReader, IList <Type> types, Guid partitionId)
        {
            var filter = ReadFilter.CreateReadFilter(types);

            if (partitionId != Guid.Empty && traceStoreReader.IsPropertyLevelFilteringSupported())
            {
                foreach (var oneType in types)
                {
                    filter.AddFilter(oneType, PartitionFilterName, partitionId);
                }
            }

            return(filter);
        }
Beispiel #10
0
        public static ReadFilter CreateNodeFilter(ITraceStoreReader traceStoreReader, IList <Type> types, string nodeName)
        {
            var filter = ReadFilter.CreateReadFilter(types);

            if (!string.IsNullOrEmpty(nodeName) && traceStoreReader.IsPropertyLevelFilteringSupported())
            {
                foreach (var oneType in types)
                {
                    filter.AddFilter(oneType, NodeFilterName, nodeName);
                }
            }

            return(filter);
        }
Beispiel #11
0
 /// <inheritdoc />
 internal PrimaryMoveAnalysisAgent(
     Config config,
     ITaskRunner taskRunner,
     ILogger logger,
     IStoreProvider storeProvider,
     ITraceStoreReader eventStoreReader,
     ITraceStoreReader queryStoreReader,
     IClusterQuery clusterQuery,
     CancellationToken token) : base(taskRunner, logger, storeProvider, eventStoreReader, queryStoreReader, clusterQuery, token)
 {
     // This is to keep track of the previous location of the primary
     this.primaryReplicaContextStore          = new PrimaryReplicaContextPersistentStoreWrapper(this.Logger, storeProvider, this.CancelToken);
     this.primaryMoveAnalysisQueryStoreReader = new PrimaryMoveAnalysisQueryStoreReaderWrapper(this.Logger, this.QueryStoreReader, this.CancelToken);
     this.primaryMoveAnalysisEventStoreReader = new PrimaryMoveAnalysisEventStoreReaderWrapper(this.Logger, this.EventStoreReader, this.CancelToken);
 }
Beispiel #12
0
        public static ReadFilter CreateCorrelationEventFilter(ITraceStoreReader reader, IList <Guid> eventInstances)
        {
            var type   = typeof(CorrelationTraceRecord);
            var filter = ReadFilter.CreateReadFilter(type);

            if (!reader.IsPropertyLevelFilteringSupported())
            {
                return(filter);
            }

            foreach (var oneInstance in eventInstances)
            {
                filter.AddFilter(type, CorrelationTraceRecord.RelatedFromIdPropertyName, oneInstance);
                filter.AddFilter(type, CorrelationTraceRecord.RelatedToIdPropertyName, oneInstance);
            }

            return(filter);
        }
Beispiel #13
0
        internal BoundedTraceStoreReader(ITraceStoreReader reader, DateTime lowerBound, DateTime upperBound)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            if (upperBound <= lowerBound)
            {
                throw new ArgumentException(string.Format("Bound Start : {0} >= Bound End: {1}", lowerBound, upperBound));
            }

            if (upperBound - lowerBound > MaxBoundInterval)
            {
                throw new ArgumentOutOfRangeException(string.Format("Max Bound supported: {0}, Requested: {1}", MaxBoundInterval, upperBound - lowerBound));
            }

            this.traceStoreReader = reader;
            this.boundStart       = lowerBound;
            this.boundEnd         = upperBound;
        }
Beispiel #14
0
        protected Agent(
            ITaskRunner taskRunner,
            ILogger logger,
            IStoreProvider storeProvider,
            ITraceStoreReader eventStoreReader,
            ITraceStoreReader queryStoreReader,
            IClusterQuery clusterQuery,
            CancellationToken token)
        {
            Common.Util.Assert.IsNotNull(storeProvider, "Store Provider can't be null");
            Common.Util.Assert.IsNotNull(logger, "Loger can't be null");
            Common.Util.Assert.IsNotNull(eventStoreReader, "Query Store reader can't be null");
            Common.Util.Assert.IsNotNull(taskRunner, "Task Runner can't be null");
            Common.Util.Assert.IsNotNull(queryStoreReader, "Query Store reader can't be null");
            Common.Util.Assert.IsNotNull(clusterQuery, "Cluster Query can't be null");

            this.TaskRunner           = taskRunner;
            this.Logger               = logger;
            this.StoreProvider        = storeProvider;
            this.EventStoreReader     = eventStoreReader;
            this.QueryStoreReader     = queryStoreReader;
            this.ClusterQueryInstance = clusterQuery;
            this.CancelToken          = token;
        }
        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();
            }
        }
Beispiel #16
0
 private void InitializeLocalStore(LocalTraceStoreConnectionInformation localEventStoreConnectionInformation, ILogProvider logProvider)
 {
     this.QueryStoreReader = new LocalQueryStoreReader(logProvider, localEventStoreConnectionInformation);
     this.EventStoreReader = new LocalEventStoreReader(logProvider, localEventStoreConnectionInformation);
 }
Beispiel #17
0
 private void InitializeAzureStore(AzureTableStoreStorageAccessInformation azureStorageAccessInfo, ILogProvider logProvider)
 {
     this.QueryStoreReader = new AzureTableQueryStoreReader(logProvider, azureStorageAccessInfo);
     this.EventStoreReader = new AzureTableEventStoreReader(logProvider, azureStorageAccessInfo);
 }