public MongoProcessingHeartbeatTimer(LogsharkRequest logsharkRequest) { metadataWriter = new LogsetMetadataWriter(logsharkRequest); long heartbeatDelayMs = 1000 * CoreConstants.MONGO_PROCESSING_HEARTBEAT_INTERVAL; timer = new Timer(WriteHeartbeat, null, 0, heartbeatDelayMs); }
/// <summary> /// Processes an entire directory of log files. /// </summary> public void ProcessLogset() { Log.InfoFormat("Processing log directory '{0}'..", logsharkRequest.RunContext.RootLogDirectory); var parseTimer = logsharkRequest.RunContext.CreateTimer("Parsed Files"); Queue <LogFileContext> logFiles = logsetPreprocessor.Preprocess(); var metadataWriter = new LogsetMetadataWriter(logsharkRequest); metadataWriter.WritePreProcessingMetadata(); using (new MongoProcessingHeartbeatTimer(logsharkRequest)) { ProcessFiles(logFiles); } metadataWriter.WritePostProcessingMetadata(processedSuccessfully: true); metadataWriter.WriteMasterMetadataRecord(); parseTimer.Stop(); Log.InfoFormat("Finished processing log directory {0}! [{1}]", logsharkRequest.RunContext.RootLogDirectory, parseTimer.Elapsed.Print()); }
/// <summary> /// Performs any teardown tasks. /// </summary> public static void TearDown(LogsharkRequest request) { // Drop logset if user didn't want to retain it, assuming they didn't piggyback on an existing processed logset. if (request.DropMongoDBPostRun && !request.RunContext.UtilizedExistingProcessedLogset) { try { Log.InfoFormat("Dropping Mongo database {0}..", request.RunContext.MongoDatabaseName); MongoAdminUtil.DropDatabase(request.Configuration.MongoConnectionInfo.GetClient(), request.RunContext.MongoDatabaseName); // Remove metadata record for this run from master metadata DB. LogsetMetadataWriter metadataWriter = new LogsetMetadataWriter(request); metadataWriter.DeleteMasterMetadataRecord(); } catch (Exception ex) { Log.ErrorFormat("Failed to clean up DB {0}: {1}", request.RunContext.MongoDatabaseName, ex.Message); } } LogsetExtractor.CleanUpRun(request.RunId); }