Exemplo n.º 1
0
        public override IPluginResponse Execute(IPluginRequest pluginRequest)
        {
            pluginResponse = CreatePluginResponse();
            logsetHash     = pluginRequest.LogsetHash;

            GetOutputDatabaseConnection().CreateOrMigrateTable <DataengineEvent>();

            dataenginePersister = GetConcurrentBatchPersister <DataengineEvent>(pluginRequest);

            dataengineCollection = MongoDatabase.GetCollection <BsonDocument>(dataengineCollectionName);

            using (GetPersisterStatusWriter <DataengineEvent>(dataenginePersister))
            {
                ProcessDataEngineLogs(dataengineCollection);
                dataenginePersister.Shutdown();
            }
            Log.Info("Finished processing Data Engine events!");

            // Check if we persisted any data.
            if (!PersistedData())
            {
                Log.Info("Failed to persist any data from Data Engine logs!");
                pluginResponse.GeneratedNoData = true;
            }

            return(pluginResponse);
        }
Exemplo n.º 2
0
        public override IPluginResponse Execute(IPluginRequest pluginRequest)
        {
            Setup(pluginRequest);

            pluginResponse = CreatePluginResponse();

            using (GetPersisterStatusWriter(resourceManagerPersister))
            {
                try
                {
                    ProcessSrmEvents();
                }
                finally
                {
                    resourceManagerPersister.Shutdown();
                }
            }

            // Check if we persisted any data.
            if (!PersistedData())
            {
                Log.Info("Failed to persist any Server Resource Manager data!");
                pluginResponse.GeneratedNoData = true;
            }

            return(pluginResponse);
        }
Exemplo n.º 3
0
        public override IPluginResponse Execute(IPluginRequest pluginRequest)
        {
            //Set member variables for execution.
            this.pluginRequest     = pluginRequest;
            this.logsetHash        = pluginRequest.LogsetHash;
            this.pluginResponse    = CreatePluginResponse();
            this.workerHostnameMap = ConfigDataHelper.GetWorkerHostnameMap(MongoDatabase);

            // Create output database.
            using (var outputDatabase = GetOutputDatabaseConnection())
            {
                CreateTables(outputDatabase);
            }

            //Process collections.
            ProcessCollections(GetMongoCollections());

            // Check if we persisted any data.
            if (!PersistedData())
            {
                Log.Info("Failed to persist any data from Vizqlserver logs!");
                pluginResponse.GeneratedNoData = true;
            }

            return(pluginResponse);
        }
Exemplo n.º 4
0
        public override IPluginResponse Execute(IPluginRequest pluginRequest)
        {
            pluginResponse = CreatePluginResponse();

            if (PluginResponses.All(response => response.GeneratedNoData))
            {
                Log.WarnFormat("No plugins associated with this run generated any data; skipping execution of this plugin.");
                pluginResponse.GeneratedNoData = true;
            }
            else
            {
                try
                {
                    var dependencyManager = new WorkbookDependencyManager(PluginResponses, WorkbookDirectory, WorkbookConfigFilename);
                    workbookNames = dependencyManager.GetValidWorkbooks();
                }
                catch (Exception ex)
                {
                    string errorMessage = String.Format("Failed to generate custom workbooks: {0}", ex.Message);
                    Log.Error(errorMessage);
                    pluginResponse.SetExecutionOutcome(false, errorMessage);
                }
            }

            return(pluginResponse);
        }
Exemplo n.º 5
0
        public override IPluginResponse Execute(IPluginRequest pluginRequest)
        {
            pluginResponse = CreatePluginResponse();

            CreateTables();

            Log.Info("Processing Backgrounder job events..");

            IPersister <BackgrounderJob> backgrounderPersister = GetConcurrentCustomPersister <BackgrounderJob>(pluginRequest, BackgrounderPersistenceHelper.PersistBackgrounderJob);

            using (GetPersisterStatusWriter(backgrounderPersister))
            {
                BackgrounderJobProcessor backgrounderJobProcessor = new BackgrounderJobProcessor(MongoDatabase, backgrounderPersister, pluginRequest.LogsetHash);
                backgrounderJobProcessor.ProcessJobs();
                backgrounderPersister.Shutdown();
            }

            Log.Info("Finished processing Backgrounder job events!");

            // Check if we persisted any data.
            if (!PersistedData())
            {
                Log.Info("Failed to persist any data from Backgrounder logs!");
                pluginResponse.GeneratedNoData = true;
            }

            return(pluginResponse);
        }
Exemplo n.º 6
0
        private void ProcessEvents <T>(IPluginRequest pluginRequest, Func <IMongoCollection <T>, IAsyncCursor <T> > query) where T : BaseHyperEvent, new()
        {
            Log.InfoFormat("Processing {0} events..", typeof(T).Name);

            var collection = MongoDatabase.GetCollection <T>(ParserConstants.HyperCollectionName);

            GetOutputDatabaseConnection().CreateOrMigrateTable <T>();

            IPersister <T> persister = GetConcurrentBatchPersister <T>(pluginRequest);

            using (GetPersisterStatusWriter(persister))
            {
                IAsyncCursor <T> cursor = query(collection);
                while (cursor.MoveNext())
                {
                    cursor.Current.ForEach(document =>
                    {
                        document.LogsetHash = pluginRequest.LogsetHash;
                        persister.Enqueue(document);
                    });
                }

                persister.Shutdown();
            }

            Log.InfoFormat("Finished processing {0} events!", typeof(T).Name);
        }
Exemplo n.º 7
0
        public override IPluginResponse Execute(IPluginRequest pluginRequest)
        {
            pluginResponse = CreatePluginResponse();
            logsetHash     = pluginRequest.LogsetHash;

            HandlePluginRequestArguments(pluginRequest);

            // Process Apache requests.
            IMongoCollection <BsonDocument> apacheCollection = MongoDatabase.GetCollection <BsonDocument>("httpd");

            apachePersister = GetConcurrentBatchPersister <HttpdRequest>(pluginRequest);

            long totalApacheRequests = CountApacheRequests(apacheCollection);

            using (GetPersisterStatusWriter(apachePersister, totalApacheRequests))
            {
                ProcessApacheLogs(apacheCollection);
                apachePersister.Shutdown();
            }

            Log.Info("Finished processing Apache requests!");

            // Check if we persisted any data.
            if (!PersistedData())
            {
                Log.Info("Failed to persist any data from Apache logs!");
                pluginResponse.GeneratedNoData = true;
            }

            return(pluginResponse);
        }
Exemplo n.º 8
0
        private bool ParseIncludeGatewayHealthCheck(IPluginRequest request)
        {
            bool includeGatewayHealthChecksValue = false;

            if (request.ContainsRequestArgument(IncludeGatewayHealthChecksPluginArgumentKey))
            {
                try
                {
                    includeGatewayHealthChecksValue = PluginArgumentHelper.GetAsBoolean(IncludeGatewayHealthChecksPluginArgumentKey, request);
                }
                catch (FormatException)
                {
                    Log.WarnFormat("Invalid value was specified for plugin argument key '{0}': valid values are either 'true' or 'false'.  Proceeding with default value of '{1}'..", IncludeGatewayHealthChecksPluginArgumentKey, includeGatewayHealthChecksValue);
                }
            }

            // Log results.
            if (includeGatewayHealthChecksValue)
            {
                Log.Info("Including gateway health check requests due to user request.");
            }
            else
            {
                Log.InfoFormat("Excluding gateway health check requests from plugin output.  Use the plugin argument '{0}:true' if you wish to include them.", IncludeGatewayHealthChecksPluginArgumentKey);
            }

            return(includeGatewayHealthChecksValue);
        }
Exemplo n.º 9
0
        protected void HandlePluginRequestArguments(IPluginRequest pluginRequest)
        {
            if (pluginRequest.ContainsRequestArgument(IncludeGatewayHealthChecksPluginArgumentKey))
            {
                try
                {
                    includeGatewayHealthCheckRequests = PluginArgumentHelper.GetAsBoolean(IncludeGatewayHealthChecksPluginArgumentKey, pluginRequest);
                }
                catch (FormatException)
                {
                    Log.WarnFormat("Invalid value was specified for plugin argument key '{0}': valid values are either 'true' or 'false'.  Proceeding with default value of '{1}'..",
                                   IncludeGatewayHealthChecksPluginArgumentKey, includeGatewayHealthCheckRequests.ToString().ToLowerInvariant());
                }
            }

            // Log results.
            if (includeGatewayHealthCheckRequests)
            {
                Log.Info("Including gateway health check requests due to user request.");
            }
            else
            {
                Log.InfoFormat("Excluding gateway health check requests from plugin output.  Use the plugin argument '{0}:true' if you wish to include them.", IncludeGatewayHealthChecksPluginArgumentKey);
            }
        }
        public static InsertionResult PersistResourceManagerInfo(IPluginRequest pluginRequest, IDbConnection dbConnection, ResourceManagerEvent resourceManagerInfo)
        {
            try
            {
                if (resourceManagerInfo is ResourceManagerCpuInfo)
                {
                    ResourceManagerCpuInfo cpuInfo = resourceManagerInfo as ResourceManagerCpuInfo;
                    cpuInfo.EventHash = GenerateCpuInfoEventHash(cpuInfo);
                    dbConnection.Insert(cpuInfo);
                }
                else if (resourceManagerInfo is ResourceManagerMemoryInfo)
                {
                    ResourceManagerMemoryInfo memoryInfo = resourceManagerInfo as ResourceManagerMemoryInfo;
                    memoryInfo.EventHash = GenerateMemoryInfoEventHash(memoryInfo);
                    dbConnection.Insert(memoryInfo);
                }
                else if (resourceManagerInfo is ResourceManagerAction)
                {
                    ResourceManagerAction actionEvent = resourceManagerInfo as ResourceManagerAction;
                    actionEvent.EventHash = GenerateActionEventHash(actionEvent);
                    dbConnection.Insert(actionEvent);
                }
                else if (resourceManagerInfo is ResourceManagerThreshold)
                {
                    ResourceManagerThreshold threshold = resourceManagerInfo as ResourceManagerThreshold;
                    threshold.EventHash = GenerateThresholdEventHash(threshold);
                    dbConnection.Insert(threshold);
                }

                return(new InsertionResult
                {
                    SuccessfulInserts = 1,
                    FailedInserts = 0
                });
            }
            catch (PostgresException ex)
            {
                // Log an error only if this isn't a duplicate key exception.
                if (!ex.SqlState.Equals(PluginLibConstants.POSTGRES_ERROR_CODE_UNIQUE_VIOLATION))
                {
                    Log.ErrorFormat("Failed to persist ResourceManagerInfo event '{0}': {1}", resourceManagerInfo.EventHash, ex.Message);
                }

                return(new InsertionResult
                {
                    SuccessfulInserts = 0,
                    FailedInserts = 1
                });
            }
            catch (NpgsqlException ex)
            {
                Log.ErrorFormat("Failed to persist ResourceManagerInfo event '{0}': {1}", resourceManagerInfo.EventHash, ex.Message);

                return(new InsertionResult
                {
                    SuccessfulInserts = 0,
                    FailedInserts = 1
                });
            }
        }
Exemplo n.º 11
0
        public override IPluginResponse Execute(IPluginRequest pluginRequest)
        {
            pluginResponse = CreatePluginResponse();
            logsetHash     = pluginRequest.LogsetHash;

            // Your plugin logic goes here.
            IMongoCollection <BsonDocument> postgresCollection = MongoDatabase.GetCollection <BsonDocument>("pgsql");

            postgresPersister = GetConcurrentBatchPersister <PostgresEvent>(pluginRequest);

            long totalPostgresLines = CountPostgresLines(postgresCollection);

            using (GetPersisterStatusWriter <PostgresEvent>(postgresPersister, totalPostgresLines))
            {
                ProcessPostgresLogs(postgresCollection);
                postgresPersister.Shutdown();
            }

            Log.Info("Finished processing Postgres Logs!");

            // Check if we persisted any data.
            if (!PersistedData())
            {
                Log.Info("Failed to persist any data from Postgres logs!");
                pluginResponse.GeneratedNoData = true;
            }

            return(pluginResponse);
        }
Exemplo n.º 12
0
        public override IPluginResponse Execute(IPluginRequest pluginRequest)
        {
            pluginResponse = CreatePluginResponse();
            logsetHash     = pluginRequest.LogsetHash;

            // Process Searchserver events.
            IMongoCollection <BsonDocument> searchserverCollection = MongoDatabase.GetCollection <BsonDocument>("searchserver");

            searchserverPersister = GetConcurrentBatchPersister <SearchserverEvent>(pluginRequest);
            long totalSearchserverEvents = CountSearchserverEvents(searchserverCollection);

            using (GetPersisterStatusWriter <SearchserverEvent>(searchserverPersister, totalSearchserverEvents))
            {
                ProcessSearchserverLogs(searchserverCollection);
            }
            Log.Info("Finished processing Search Server events!");

            // Check if we persisted any data.
            if (!PersistedData())
            {
                Log.Info("Failed to persist any data from Search Server logs!");
                pluginResponse.GeneratedNoData = true;
            }

            return(pluginResponse);
        }
Exemplo n.º 13
0
        public override IPluginResponse Execute(IPluginRequest pluginRequest)
        {
            IPluginResponse response = CreatePluginResponse();

            logsetHash = pluginRequest.LogsetHash;

            InitializeDatabaseTables();
            IPersister <NetstatActiveConnection> activeConnectionsPersister = GetConcurrentBatchPersister <NetstatActiveConnection>(pluginRequest);

            // Process netstat entries for all available workers.
            var netstatCollection = MongoDatabase.GetCollection <BsonDocument>(ParserConstants.NetstatCollectionName);

            foreach (string workerId in MongoQueryHelper.GetDistinctWorkers(netstatCollection))
            {
                Log.InfoFormat("Retrieving netstat information for worker '{0}'..", workerId);
                IEnumerable <NetstatActiveConnection> activeConnectionsForWorker = GetActiveConnectionEntriesForWorker(workerId, netstatCollection);
                activeConnectionsPersister.Enqueue(activeConnectionsForWorker);
            }

            // Shutdown persister and wait for data to flush.
            activeConnectionsPersister.Shutdown();
            Log.Info("Finished processing netstat data!");

            // Check if we persisted any data.
            if (!PersistedData())
            {
                Log.Info("Failed to persist any netstat data!");
                response.GeneratedNoData = true;
            }

            return(response);
        }
Exemplo n.º 14
0
        public override IPluginResponse Execute(IPluginRequest pluginRequest)
        {
            pluginResponse = CreatePluginResponse();

            logsetHash = pluginRequest.LogsetHash;

            // Process Vizportal events.
            IMongoCollection <BsonDocument> vizportalCollection = MongoDatabase.GetCollection <BsonDocument>("vizportal_java");

            vizportalPersister = GetConcurrentBatchPersister <VizportalEvent>(pluginRequest);

            long totalVizportalRequests = CountVizportalRequests(vizportalCollection);

            using (GetPersisterStatusWriter(vizportalPersister, totalVizportalRequests))
            {
                ProcessVizportalLogs(vizportalCollection);
                vizportalPersister.Shutdown();
            }

            Log.Info("Finished processing Vizportal events!");

            // Check if we persisted any data.
            if (!PersistedData())
            {
                Log.Info("Failed to persist any data from Vizportal logs!");
                pluginResponse.GeneratedNoData = true;
            }

            return(pluginResponse);
        }
Exemplo n.º 15
0
        public override IPluginResponse Execute(IPluginRequest pluginRequest)
        {
            pluginResponse = CreatePluginResponse();
            logsetHash     = pluginRequest.LogsetHash;

            // Process Filestore events.
            IMongoCollection <BsonDocument> filestoreCollection = MongoDatabase.GetCollection <BsonDocument>(ParserConstants.FilestoreCollectionName);

            filestorePersister = GetConcurrentBatchPersister <FilestoreEvent>(pluginRequest);
            long totalFilestoreEvents = CountFilestoreEvents(filestoreCollection);

            using (GetPersisterStatusWriter <FilestoreEvent>(filestorePersister, totalFilestoreEvents))
            {
                ProcessFilestoreLogs(filestoreCollection);
            }
            Log.Info("Finished processing Filestore events!");

            // Check if we persisted any data.
            if (!PersistedData())
            {
                Log.Info("Failed to persist any data from Filestore logs!");
                pluginResponse.GeneratedNoData = true;
            }

            return(pluginResponse);
        }
Exemplo n.º 16
0
        public override IPluginResponse Execute(IPluginRequest pluginRequest)
        {
            pluginResponse = CreatePluginResponse();

            Log.Info("Retrieving configuration information for workers..");
            workerHostnameMap = ConfigDataHelper.GetWorkerHostnameMap(MongoDatabase);

            netstatCollection = MongoDatabase.GetCollection <BsonDocument>(NetstatCollectionName);

            logsetHash = pluginRequest.LogsetHash;

            List <NetstatEntry> netstatEntries = new List <NetstatEntry>();

            foreach (int workerIndex in workerHostnameMap.Keys)
            {
                Log.InfoFormat("Retrieving netstat information for worker {0}..", workerIndex);
                IEnumerable <NetstatEntry> entriesForWorker = GetNetstatEntriesForWorker(workerIndex);
                netstatEntries.AddRange(entriesForWorker);
            }

            Log.InfoFormat("Writing netstat information to database..");
            CreateTables();
            PersistNetstatEntries(netstatEntries);

            Log.Info("Finished processing netstat data!");

            // Check if we persisted any data.
            if (!PersistedData())
            {
                Log.Info("Failed to persist any netstat data!");
                pluginResponse.GeneratedNoData = true;
            }

            return(pluginResponse);
        }
Exemplo n.º 17
0
        public override IPluginResponse Execute(IPluginRequest pluginRequest)
        {
            pluginResponse = CreatePluginResponse();
            logsetHash     = pluginRequest.LogsetHash;
            IMongoCollection <BsonDocument> tabadminCollection = MongoDatabase.GetCollection <BsonDocument>(collectionToQuery);

            persistenceHelper = GetConcurrentBatchPersister <TabadminModelBase>(pluginRequest);

            using (IDbConnection dbConnection = GetOutputDatabaseConnection())
            {
                Log.Info("Processing Tableau Server version data from tabadmin logs...");
                dbConnection.CreateOrMigrateTable <TSVersion>();
                TabadminVersionProcessor.Execute(tabadminCollection, persistenceHelper, pluginResponse, logsetHash);

                // TODO: Create one class for processing Action and Error objects, as they are nearly identical.
                Log.Info("Processing tabadmin error data...");
                dbConnection.CreateOrMigrateTable <TabadminError>();
                TabadminErrorProcessor.Execute(tabadminCollection, persistenceHelper, pluginResponse, logsetHash);

                Log.Info("Processing tabadmin admin action data...");
                dbConnection.CreateOrMigrateTable <TabadminAction>();
                TabadminActionProcessor.Execute(tabadminCollection, persistenceHelper, pluginResponse, logsetHash);

                // Shutdown the persistenceHelper to force a flush to the database, then re-initialize it for future use.
                persistenceHelper.Shutdown();
                persistenceHelper = GetConcurrentBatchPersister <TabadminModelBase>(pluginRequest);

                IList <TSVersion> allTsVersions = dbConnection.Query <TSVersion>("select * from tabadmin_ts_version");

                // TODO: Figure out how to do a lazy query of Error and Action objects, and update them one at a time, rather than loading
                // the entire table into memory. I ran into issues updating the objects while holding the SELECT query connection open with Each().
                // The driver doesn't seem to be able to handle two connections at once.
                Log.Info("Updating version_id foreign keys for TabadminError objects...");
                foreach (var tabadminError in dbConnection.Query <TabadminError>("select * from tabadmin_error"))
                {
                    tabadminError.VersionId = TSVersionHelper.GetTSVersionIdByDate(allTsVersions, tabadminError);
                    dbConnection.Update(tabadminError);
                }

                Log.Info("Updating version_id foreign keys for TabadminAction objects...");
                foreach (var tabadminAction in dbConnection.Query <TabadminAction>("select * from tabadmin_action"))
                {
                    tabadminAction.VersionId = TSVersionHelper.GetTSVersionIdByDate(allTsVersions, tabadminAction);
                    dbConnection.Update(tabadminAction);
                }
            }
            persistenceHelper.Shutdown();

            // Check if we persisted any data.
            if (!PostgresHelper.ContainsRecord <TSVersion>(OutputDatabaseConnectionFactory) &&
                !PostgresHelper.ContainsRecord <TabadminError>(OutputDatabaseConnectionFactory) &&
                !PostgresHelper.ContainsRecord <TabadminAction>(OutputDatabaseConnectionFactory))
            {
                Log.Info("Failed to persist any data from Tabadmin logs!");
                pluginResponse.GeneratedNoData = true;
            }

            return(pluginResponse);
        }
Exemplo n.º 18
0
        public override IPluginResponse Execute(IPluginRequest pluginRequest)
        {
            pluginResponse = CreatePluginResponse();

            // TODO: Your plugin logic goes here.

            return(pluginResponse);
        }
 public ConcurrentCustomDbPersister(IDbConnectionFactory connectionFactory, IPluginRequest pluginRequest, InsertionMethod customInsertionMethod, int persisterPoolSize = PluginLibConstants.DEFAULT_PERSISTER_POOL_SIZE)
     : base(persisterPoolSize)
 {
     while (insertionThreadPool.Count < persisterPoolSize)
     {
         insertionThreadPool.Add(new CustomDbInsertionThread <T>(pluginRequest, connectionFactory.OpenDbConnection(), customInsertionMethod));
     }
 }
 public ConcurrentCustomPersisterFactory(IDbConnectionFactory dbConnectionFactory,
                                         IPluginRequest pluginRequest,
                                         ConcurrentCustomPersister <T> .InsertionMethod insertionMethod,
                                         IDictionary <Type, long> persistedRecordJournal = null)
     : base(dbConnectionFactory, pluginRequest, persistedRecordJournal)
 {
     this.insertionMethod = insertionMethod;
 }
Exemplo n.º 21
0
        public DesktopSessionPersister(IPluginRequest pluginRequest, IExtractPersisterFactory extractFactory)
        {
            maxQueryLength = VizqlPluginArgumentHelper.GetMaxQueryLength(pluginRequest, MaxQueryLengthArgumentKey, MaxQueryLengthDefault);

            sessionPersister          = extractFactory.CreateExtract <VizqlDesktopSession>("VizqlDesktopSessions.hyper");
            errorPersister            = extractFactory.CreateExtract <VizqlErrorEvent>("VizqlDesktopErrorEvents.hyper");
            performanceEventPersister = extractFactory.CreateExtract <VizqlPerformanceEvent>("VizqlDesktopPerformanceEvents.hyper");
            endQueryPersister         = extractFactory.CreateExtract <VizqlEndQuery>("VizqlDesktopEndQueryEvents.hyper");
        }
Exemplo n.º 22
0
        /// <summary>
        /// Executes a single plugin.
        /// </summary>
        /// <param name="pluginType">The type of the plugin to execute.</param>
        /// <returns>Response containing state about the success/failure of the plugin's execution.</returns>
        protected IPluginResponse ExecutePlugin(Type pluginType)
        {
            string pluginName = pluginType.Name;

            // Setup plugin for execution.
            IPluginRequest request     = CreatePluginRequest(pluginType);
            var            pluginTimer = logsharkRequest.RunContext.CreateTimer("Executed Plugin", pluginName);

            // Execute plugin.
            IPluginResponse pluginResponse = new PluginResponse(pluginName);

            try
            {
                IPlugin plugin = InitializePlugin(pluginType);

                Log.InfoFormat("Execution of {0} plugin started at {1}..", pluginName, DateTime.Now.ToString("h:mm tt", CultureInfo.InvariantCulture));
                pluginResponse = plugin.Execute(request);

                // Flush any workbooks, if this was a workbook creation plugin.
                if (plugin is IWorkbookCreationPlugin)
                {
                    WriteWorkbooksToDisk(plugin as IWorkbookCreationPlugin, pluginResponse);
                }

                // Publish any associated workbooks, if requested.
                if (logsharkRequest.PublishWorkbooks)
                {
                    workbookPublisher.PublishWorkbooks(pluginResponse);
                }
            }
            catch (PluginInitializationException ex)
            {
                string errorMessage = String.Format("Failed to initialize {0} plugin: {1}", pluginName, ex.Message);
                HandlePluginExecutionFailure(pluginResponse, errorMessage, ex);
            }
            catch (PublishingException ex)
            {
                string errorMessage = String.Format("Failed to publish workbooks: {0}", ex.Message);
                HandlePluginExecutionFailure(pluginResponse, errorMessage, ex);
            }
            catch (Exception ex)
            {
                string errorMessage = String.Format("Encountered uncaught exception while executing plugin '{0}': {1}", pluginName, ex.GetFlattenedMessage());
                HandlePluginExecutionFailure(pluginResponse, errorMessage, ex);
            }
            finally
            {
                pluginTimer.Stop();
                pluginResponse.PluginRunTime = pluginTimer.Elapsed;

                logsharkRequest.RunContext.RegisterPluginResponse(pluginResponse);
                PrintExecutionOutcome(pluginResponse);
            }

            return(pluginResponse);
        }
Exemplo n.º 23
0
        public static InsertionResult PersistBackgrounderJob(IPluginRequest pluginRequest, IDbConnection dbConnection, BackgrounderJob backgrounderJob)
        {
            try
            {
                dbConnection.Insert(backgrounderJob);

                if (backgrounderJob.Errors != null && backgrounderJob.Errors.Count > 0)
                {
                    dbConnection.InsertAll(backgrounderJob.Errors);
                }

                if (backgrounderJob.BackgrounderJobDetail != null)
                {
                    if (backgrounderJob.BackgrounderJobDetail is BackgrounderExtractJobDetail)
                    {
                        dbConnection.Insert(backgrounderJob.BackgrounderJobDetail as BackgrounderExtractJobDetail);
                    }

                    if (backgrounderJob.BackgrounderJobDetail is BackgrounderSubscriptionJobDetail)
                    {
                        dbConnection.Insert(backgrounderJob.BackgrounderJobDetail as BackgrounderSubscriptionJobDetail);
                    }
                }

                Log.DebugFormat("Persisted Backgrounder Job '{0}' ({1}).", backgrounderJob.JobId, backgrounderJob.JobType);
                return(new InsertionResult
                {
                    SuccessfulInserts = 1,
                    FailedInserts = 0
                });
            }
            catch (PostgresException ex)
            {
                // Log an error only if this isn't a duplicate key exception.
                if (!ex.SqlState.Equals(PluginLibConstants.POSTGRES_ERROR_CODE_UNIQUE_VIOLATION))
                {
                    Log.ErrorFormat("Failed to persist Backgrounder Job '{0}' ({1}): {2}", backgrounderJob.JobId, backgrounderJob.JobType, ex.Message);
                }

                return(new InsertionResult
                {
                    SuccessfulInserts = 0,
                    FailedInserts = 1
                });
            }
            catch (NpgsqlException ex)
            {
                Log.ErrorFormat("Failed to persist Backgrounder Job '{0}' ({1}): {2}", backgrounderJob.JobId, backgrounderJob.JobType, ex.Message);

                return(new InsertionResult
                {
                    SuccessfulInserts = 0,
                    FailedInserts = 1
                });
            }
        }
        public ConcurrentCustomPersister(IPluginRequest pluginRequest, IDbConnectionFactory connectionFactory, InsertionMethod customInsertionMethod, IDictionary <Type, long> recordsPersisted = null)
            : base(recordsPersisted)
        {
            int poolSize = GlobalPluginArgumentHelper.GetPersisterPoolSize(pluginRequest);

            while (insertionThreadPool.Count < poolSize)
            {
                insertionThreadPool.Add(new CustomInsertionThread <T>(pluginRequest, connectionFactory.OpenDbConnection(), customInsertionMethod));
            }
        }
Exemplo n.º 25
0
 protected SingleModelAggregationProcessor(IPluginRequest pluginRequest,
                                           IMongoDatabase mongoDatabase,
                                           IDbConnectionFactory outputConnectionFactory,
                                           IPersisterFactory <TModel> persisterFactory)
 {
     this.pluginRequest           = pluginRequest;
     this.mongoDatabase           = mongoDatabase;
     this.outputConnectionFactory = outputConnectionFactory;
     this.persisterFactory        = persisterFactory;
 }
Exemplo n.º 26
0
 protected SingleModelAggregationProcessor(IPluginRequest pluginRequest,
                                           IMongoDatabase mongoDatabase,
                                           IPersister <TModel> persister,
                                           ILog log)
 {
     this.pluginRequest = pluginRequest;
     this.mongoDatabase = mongoDatabase;
     this.persister     = persister;
     Log = log;
 }
Exemplo n.º 27
0
        protected BasePlugin(IPluginRequest pluginRequest)
        {
            this.pluginRequest = pluginRequest;

            MongoDatabase = pluginRequest.MongoDatabase;

            Type pluginType = GetType();

            Log            = PluginLogFactory.GetLogger(pluginType);
            ExtractFactory = new ExtractPersisterFactory(pluginRequest.OutputDirectory, Log, pluginRequest.TempDirectory, pluginRequest.LogDirectory);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Looks up a custom plugin argument and returns its value, cast as a boolean. Throws FormatException if cast fails.
        /// </summary>
        /// <param name="key">Key to lookup in pluginRequest.</param>
        /// <param name="pluginRequest">IPluginRequest object.</param>
        /// <returns>Custom plugin argument specified by key, cast as a boolean.</returns>
        public static bool GetAsBoolean(string key, IPluginRequest pluginRequest)
        {
            string value = GetRequestArgument(key, pluginRequest).ToLowerInvariant();

            try
            {
                return(Boolean.Parse(value));
            }
            catch
            {
                throw new FormatException(String.Format("Unable to parse value {0} for key {1} as bool.", value, key));
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Looks up a custom plugin argument and returns its value, cast as an integer. Throws FormatException if cast fails.
        /// </summary>
        /// <param name="key">Key to lookup in pluginRequest.</param>
        /// <param name="pluginRequest">IPluginRequest object.</param>
        /// <returns>Custom plugin argument specified by key, cast as an integer.</returns>
        public static double GetAsDouble(string key, IPluginRequest pluginRequest)
        {
            string value = GetRequestArgument(key, pluginRequest);

            try
            {
                return(Double.Parse(value));
            }
            catch
            {
                throw new FormatException(String.Format("Unable to parse value {0} for key {1} as double.", value, key));
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// Looks up a custom plugin argument and returns its value, cast as an integer. Throws FormatException if cast fails.
        /// </summary>
        /// <param name="key">Key to lookup in pluginRequest.</param>
        /// <param name="pluginRequest">IPluginRequest object.</param>
        /// <returns>Custom plugin argument specified by key, cast as an integer.</returns>
        public static int GetAsInt(string key, IPluginRequest pluginRequest)
        {
            string value = GetRequestArgument(key, pluginRequest);

            try
            {
                return(Int32.Parse(value));
            }
            catch
            {
                throw new FormatException(String.Format("Unable to parse value {0} for key {1} as integer.", value, key));
            }
        }