コード例 #1
0
        /// <summary>
        /// Takes action to process a logset based on the current status of the Logset.
        /// </summary>
        private LogsetParsingResult ProcessLogset(LogsharkRequest request, RunInitializationResult runInitializationResult)
        {
            var statusChecker = new LogsetProcessingStatusChecker(request.Configuration.MongoConnectionInfo);
            LogsetProcessingStatus existingProcessedLogsetStatus = statusChecker.GetStatus(runInitializationResult.LogsetHash, runInitializationResult.CollectionsRequested);

            Func <LogsetParsingRequest, LogsetParsingResult> parseLogset = logsetParsingRequest => ParseLogset(logsetParsingRequest, request.Configuration);
            Action <string> dropLogset = logsetHash => MongoAdminHelper.DropDatabase(request.Configuration.MongoConnectionInfo.GetClient(), logsetHash);

            var parsingRequest = new LogsetParsingRequest(runInitializationResult, request.ForceParse);
            ILogsetProcessingStrategy processingStrategy = LogsetProcessingStrategyFactory.GetLogsetProcessingStrategy(request.Target, parseLogset, dropLogset, request.Configuration);

            return(processingStrategy.ProcessLogset(parsingRequest, existingProcessedLogsetStatus));
        }
コード例 #2
0
        /// <summary>
        /// Performs any teardown tasks.
        /// </summary>
        private void TearDown(LogsharkRunContext context)
        {
            // Purge application temp directory to free up disk space for the user.
            PurgeTempDirectory(context.Request.Configuration);

            // Drop logset if user didn't want to retain it, assuming they didn't piggyback on an existing processed logset.
            bool utilizedExistingLogset = context.ParsingResult != null && context.ParsingResult.UtilizedExistingProcessedLogset;

            if (context.Request.DropMongoDBPostRun && utilizedExistingLogset)
            {
                Log.InfoFormat("Dropping Mongo database {0}..", context.InitializationResult);
                try
                {
                    MongoAdminHelper.DropDatabase(context.Request.Configuration.MongoConnectionInfo.GetClient(), context.InitializationResult.LogsetHash);
                }
                catch (Exception ex)
                {
                    Log.ErrorFormat("Failed to clean up Mongo database '{0}': {1}", context.InitializationResult.LogsetHash, ex.Message);
                }
            }
        }