/// <summary> /// Takes action to process a logset based on the current status of the Logset. /// </summary> protected void ProcessLogset(LogsharkRequest request, IArtifactProcessor artifactProcessor) { LogsetStatus existingProcessedLogsetStatus = LogsharkController.GetExistingLogsetStatus(request); if (request.ForceParse && !request.Target.IsHashId) { // If we are forcing a reparsing of this logset, first drop any existing logset in our MongoCluster which matches this hash-id. if (existingProcessedLogsetStatus != LogsetStatus.NonExistent) { Log.InfoFormat("'Force Parse' request issued, dropping existing Mongo database '{0}'..", request.RunContext.MongoDatabaseName); MongoAdminUtil.DropDatabase(request.Configuration.MongoConnectionInfo.GetClient(), request.RunContext.MongoDatabaseName); } ParseLogset(request, artifactProcessor); return; } switch (existingProcessedLogsetStatus) { case LogsetStatus.NonExistent: if (request.Target.IsHashId) { request.RunContext.IsValidLogset = false; throw new InvalidTargetHashException(String.Format("No logset exists that matches logset hash '{0}'. Aborting..", request.RunContext.LogsetHash)); } ParseLogset(request, artifactProcessor); break; case LogsetStatus.Corrupt: if (request.Target.IsHashId) { request.RunContext.IsValidLogset = false; throw new InvalidTargetHashException(String.Format("Mongo database matching logset hash '{0}' exists but is corrupted. Aborting..", request.RunContext.LogsetHash)); } Log.InfoFormat("Logset matching hash '{0}' exists but is corrupted. Dropping it and reprocessing..", request.RunContext.MongoDatabaseName); MongoAdminUtil.DropDatabase(request.Configuration.MongoConnectionInfo.GetClient(), request.RunContext.MongoDatabaseName); ParseLogset(request, artifactProcessor); break; case LogsetStatus.InFlight: string collisionErrorMessage = String.Format("Logset matching hash '{0}' exists but is currently being processed by another user. Aborting..", request.RunContext.MongoDatabaseName); Log.InfoFormat(collisionErrorMessage); throw new ProcessingUserCollisionException(collisionErrorMessage); case LogsetStatus.Incomplete: if (request.Target.IsHashId) { throw new InvalidTargetHashException("Found existing logset matching hash, but it is a partial logset that does not contain all of the data required to run specified plugins. Aborting.."); } MongoAdminUtil.DropDatabase(request.Configuration.MongoConnectionInfo.GetClient(), request.RunContext.MongoDatabaseName); Log.Info("Found existing logset matching hash, but it is a partial logset that does not contain all of the data required to run specified plugins. Dropping it and reprocessing.."); ParseLogset(request, artifactProcessor); break; case LogsetStatus.Indeterminable: throw new IndeterminableLogsetStatusException("Unable to determine status of logset. Aborting.."); case LogsetStatus.Valid: request.RunContext.UtilizedExistingProcessedLogset = true; request.RunContext.IsValidLogset = true; Log.Info("Found existing logset matching hash, skipping extraction and parsing."); LogsetMetadataReader.SetLogsetType(request); LogsetMetadataReader.SetLogsetSize(request); break; default: throw new ArgumentOutOfRangeException(String.Format("'{0}' is not a valid LogsetStatus!", existingProcessedLogsetStatus)); } LogsharkController.ValidateMongoDatabaseContainsData(request); }