Ejemplo n.º 1
0
        public static void ClearCache(this ProcedureContext procedureContext)
        {
            #region Argument exceptions

            if (procedureContext == null)
            {
                throw new ArgumentNullException(nameof(procedureContext));
            }

            if (procedureContext.ClearCacheMode == ClearCacheMode.Default)
            {
                throw new ArgumentException("Invalid ClearCacheMode[ClearCacheMode.Default]");
            }

            #endregion

            if (procedureContext.IsCancellationRequested)
            {
                return;
            }

            if (procedureContext.ClearCacheMode != ClearCacheMode.Nothing)
            {
                EventsNotifier.Instance.Notify(ProcedureEvents.ProcedureAnalyzeStepClearCache);
            }

            if (procedureContext.ClearCacheMode == ClearCacheMode.CurrentCube ||
                procedureContext.ClearCacheMode == ClearCacheMode.CurrentCubeAndFileSystem ||
                procedureContext.ClearCacheMode == ClearCacheMode.CurrentDatabase ||
                procedureContext.ClearCacheMode == ClearCacheMode.CurrentDatabaseAndFileSystem ||
                procedureContext.ClearCacheMode == ClearCacheMode.AllDatabases ||
                procedureContext.ClearCacheMode == ClearCacheMode.AllDatabasesAndFileSystem)
            {
                XmlaHelper.ClearCache(procedureContext);
            }

            if (procedureContext.ClearCacheMode == ClearCacheMode.FileSystemOnly ||
                procedureContext.ClearCacheMode == ClearCacheMode.CurrentCubeAndFileSystem ||
                procedureContext.ClearCacheMode == ClearCacheMode.CurrentDatabaseAndFileSystem ||
                procedureContext.ClearCacheMode == ClearCacheMode.AllDatabasesAndFileSystem)
            {
                FileSystemHelper.ClearFileSystemCache(clearStandbyCache: true);
            }
        }
Ejemplo n.º 2
0
        private ProcedureContext(ProcedureExecutionMode executionMode, string statement, ClearCacheMode clearCacheMode, int queryResultRowLimit = 0, string clientVersion = null, string clientType = null, string batchID = null, string batchConnectionString = null, string batchName = null)
        {
            #region Argument exception

            if (statement == null)
            {
                throw new ArgumentNullException("statement");
            }

            if (executionMode == ProcedureExecutionMode.Batch ^ batchID != null)
            {
                throw new ArgumentException("ExecutionMode XOR batchID");
            }

            if (executionMode == ProcedureExecutionMode.Batch ^ batchConnectionString != null)
            {
                throw new ArgumentException("ExecutionMode XOR BatchConnectionString");
            }

            #endregion

            _batchConnectionString = batchConnectionString;
            _cancellationSource    = new CancellationTokenSource();

            Statement                 = statement;
            ExecutionMode             = executionMode;
            BatchID                   = Guid.Parse(batchID ?? Guid.Empty.ToString());
            ExecutionID               = Guid.NewGuid();
            BatchName                 = batchName;
            CubeName                  = statement.GetCubeName();
            QueryResultRowLimit       = queryResultRowLimit;
            DatabaseName              = AdomdServer.Context.CurrentDatabaseName;
            ConnectionUserName        = AdomdServer.Context.CurrentConnection.User.Name;
            ImpersonationIdentity     = WindowsIdentity.GetCurrent();
            ExecuteForPrepare         = AdomdServer.Context.ExecuteForPrepare;
            CurrentTraceEvents        = ProfilerCollector.CurrentTraceEvents();
            ASQAServerVersion         = GetAsqaServerVersion().ToString();
            ASQAServerConfig          = GetRawConfiguration();
            ClientVersion             = clientVersion;
            ClientType                = clientType;
            SystemPhysicalMemory      = PInvokeHelper.GetPhysicalSystemMemory();
            SystemOperativeSystemName = PInvokeHelper.GetOperatingSystemName();
            SystemLogicalCpuCore      = Environment.ProcessorCount;

            GetConfigurationDetails(out int configuredTraceEventsThreshold, out ClearCacheMode configuredClearCacheMode);
            TraceEventsThreshold = configuredTraceEventsThreshold;
            ClearCacheMode       = clearCacheMode == ClearCacheMode.Default ? configuredClearCacheMode : clearCacheMode;

            var ssasInfo = GetServerInfo();
            SSASInstanceName    = AdomdServer.Context.CurrentServerID;
            SSASInstanceVersion = ssasInfo.Item1;
            SSASInstanceEdition = ssasInfo.Item2;
            SSASInstanceConfig  = ssasInfo.Item3;

            if (executionMode == ProcedureExecutionMode.Batch)
            {
                var sqlInfo = BatchHelper.GetServerInfo(this);
                SQLInstanceName    = sqlInfo.Item1;
                SQLInstanceVersion = sqlInfo.Item2;
                SQLInstanceEdition = sqlInfo.Item3;

                CheckBatchVersionCompatibility(version: sqlInfo.Item4);
            }

            CubeMetadata = XmlaHelper.RetrieveCubeMetadata(this);
            ProcedureContext.CheckVersionCompatibility(SSASInstanceVersion);
        }