Exemplo n.º 1
0
        private bool ProcessEvents <T>(FilterDefinition <T> filter) where T : BaseHyperEvent, new()
        {
            var collection = MongoDatabase.GetCollection <T>(ParserConstants.HyperCollectionName);

            using (var persister = ExtractFactory.CreateExtract <T>())
                using (var processor = new SimpleModelProcessor <T, T>(persister, Log))
                {
                    processor.Process(collection, new QueryDefinition <T>(filter), item => item, filter);
                    return(persister.ItemsPersisted > 0);
                }
        }
Exemplo n.º 2
0
        public override IPluginResponse Execute()
        {
            var pluginResponse = CreatePluginResponse();

            IMongoCollection <BsonDocument> collection = MongoDatabase.GetCollection <BsonDocument>(ParserConstants.TabAdminCollectionName);

            Log.Info("Processing Tableau Server version data from tabadmin logs...");
            var versions = TabadminVersionProcessor.BuildVersionTimeline(collection).ToList();

            bool persistedData;

            using (var persister = ExtractFactory.CreateExtract <TableauServerVersion>())
                using (GetPersisterStatusWriter(persister, versions.Count))
                {
                    persister.Enqueue(versions);
                    persistedData = persister.ItemsPersisted > 0;
                }

            using (var persister = ExtractFactory.CreateExtract <TabadminError>())
                using (var processor = new SimpleModelProcessor <BsonDocument, TabadminError>(persister, Log))
                {
                    var filter = BuildTabadminErrorFilter();
                    processor.Process(collection, new QueryDefinition <BsonDocument>(filter), document => new TabadminError(document, versions), filter);

                    persistedData = persistedData || persister.ItemsPersisted > 0;
                }

            using (var persister = ExtractFactory.CreateExtract <TabadminAction>())
                using (var processor = new SimpleModelProcessor <BsonDocument, TabadminAction>(persister, Log))
                {
                    var filter = BuildTabadminActionFilter();
                    processor.Process(collection, new QueryDefinition <BsonDocument>(filter), document => new TabadminAction(document, versions), filter);

                    persistedData = persistedData || persister.ItemsPersisted > 0;
                }

            if (!persistedData)
            {
                Log.Info("Failed to persist any data from Tabadmin logs!");
                pluginResponse.GeneratedNoData = true;
            }

            return(pluginResponse);
        }
Exemplo n.º 3
0
        private bool ProcessDocuments <T>(IDictionary <string, ISet <string> > collectionWorkerMap, Func <string, IMongoCollection <BsonDocument>, IEnumerable <T> > selector) where T : new()
        {
            Log.InfoFormat("Processing {0} events..", typeof(T).Name);

            using (var persister = ExtractFactory.CreateExtract <T>())
                using (GetPersisterStatusWriter(persister))
                {
                    foreach (var collectionWorkerMapping in collectionWorkerMap)
                    {
                        var collection = MongoDatabase.GetCollection <BsonDocument>(collectionWorkerMapping.Key);

                        foreach (var worker in collectionWorkerMapping.Value)
                        {
                            var records = selector(worker, collection);
                            persister.Enqueue(records);
                        }
                    }

                    return(persister.ItemsPersisted > 0);
                }
        }
Exemplo n.º 4
0
        public override IPluginResponse Execute()
        {
            // The PluginResponse contains state about whether this plugin ran successfully, as well as any errors encountered.  Append any non-fatal errors to this.
            var pluginResponse = CreatePluginResponse();

            var collection = MongoDatabase.GetCollection <FlattenedArtEvent>(ParserConstants.VizqlServerCppCollectionName);
            var filter     = Builders <FlattenedArtEvent> .Filter.Where(line => line.ArtData != null);

            using (var persister = ExtractFactory.CreateExtract <FlattenedArtEvent>("Art.hyper"))
                using (var processor = new SimpleModelProcessor <FlattenedArtEvent, FlattenedArtEvent>(persister, Log))
                {
                    processor.Process(collection, new QueryDefinition <FlattenedArtEvent>(filter), item => item, filter);

                    if (persister.ItemsPersisted == 0)
                    {
                        Log.Info("Failed to persist any ART events!");
                        pluginResponse.GeneratedNoData = true;
                    }
                }

            return(pluginResponse);
        }
Exemplo n.º 5
0
        private void Loading_Load(object sender, EventArgs e)
        {
            if (InstallPathExists() && !IsNewVersionAvailable())
            {
                ExecuteApplication();
            }
            else if (IsNewVersionAvailable())
            {
                NotifyNewVersionIsAvailable();
            }

            statusLabelMessage.Text    = "";
            fileDataReceivedLabel.Text = "";

            var fileProcess       = new FileProcess();
            var botDirectories    = new CreateBotDirectoriesCommand();
            var downloadFactory   = new DownloadFactory(_webClient, fileProcess);
            var downloadService   = new DownloadService(downloadFactory);
            var extractFactory    = new ExtractFactory();
            var extractService    = new ExtractService(extractFactory);
            var removeFactory     = new RemoveFactory();
            var removeService     = new RemoveService(removeFactory);
            var tesseractDownload = downloadService.Create(FileType.Tesseract, _binDirectory);
            var clientDownload    = downloadService.Create(FileType.Client, _installPath);
            var tesseractExtract  = extractService.Create(FileType.Tesseract, _binDirectory);
            var clientExtract     = extractService.Create(FileType.Client, _installPath);
            var tesseractRemove   = removeService.Create(FileType.Tesseract, _binDirectory);
            var clientRemove      = removeService.Create(FileType.Client, _installPath);

            _commandList.Add(botDirectories);
            _commandList.Add(tesseractDownload);
            _commandList.Add(clientDownload);
            _commandList.Add(tesseractExtract);
            _commandList.Add(clientExtract);
            _commandList.Add(tesseractRemove);
            _commandList.Add(clientRemove);

            Run();
        }
Exemplo n.º 6
0
        public override IPluginResponse Execute()
        {
            var pluginResponse = CreatePluginResponse();

            IMongoCollection <HttpdRequest> collection = MongoDatabase.GetCollection <HttpdRequest>(ParserConstants.HttpdCollectionName);

            using (var persister = ExtractFactory.CreateExtract <HttpdRequest>("ApacheRequests.hyper"))
                using (var processor = new SimpleModelProcessor <HttpdRequest, HttpdRequest>(persister, Log))
                {
                    var apacheRequestFilter = BuildApacheRequestFilter(includeGatewayHealthCheckRequests);

                    processor.Process(collection, new QueryDefinition <HttpdRequest>(apacheRequestFilter), item => item, apacheRequestFilter);

                    if (persister.ItemsPersisted <= 0)
                    {
                        Log.Warn("Failed to persist any data from Apache logs!");
                        pluginResponse.GeneratedNoData = true;
                    }

                    return(pluginResponse);
                }
        }
Exemplo n.º 7
0
        private static List <INode> Extract()
        {
            var framework = _testFramework.ToLower();

            if (!framework.Equals("nunit"))
            {
                Console.Write("Unsupported Test Framework.");
            }

            var nodes     = new List <INode>();
            var extractor = ExtractFactory.Extractor <Extractors.NUnit.Extractor.NUnit>();

            if (_extractSuits)
            {
                nodes.AddRange(extractor.ExtractTimed <ISuiteNode>(_assemblies).Item1);
            }
            else
            {
                nodes.AddRange(extractor.ExtractTimed <IStubNode>(_assemblies).Item1);
            }
            return(nodes);
        }
Exemplo n.º 8
0
        public override IPluginResponse Execute()
        {
            var pluginResponse = CreatePluginResponse();

            IMongoCollection <FilestoreEvent> collection = MongoDatabase.GetCollection <FilestoreEvent>(ParserConstants.FilestoreCollectionName);

            using (var persister = ExtractFactory.CreateExtract <FilestoreEvent>("FilestoreEvents.hyper"))
                using (var processor = new SimpleModelProcessor <FilestoreEvent, FilestoreEvent>(persister, Log))
                {
                    var filestoreEventFilter = Builders <FilestoreEvent> .Filter.Regex("file", new BsonRegularExpression("filestore.*"));

                    processor.Process(collection, new QueryDefinition <FilestoreEvent>(filestoreEventFilter), item => item, filestoreEventFilter);

                    if (persister.ItemsPersisted <= 0)
                    {
                        Log.Warn("Failed to persist any data from Filestore logs!");
                        pluginResponse.GeneratedNoData = true;
                    }

                    return(pluginResponse);
                }
        }
Exemplo n.º 9
0
        protected bool PersistConfigData(ICollection <ConfigEntry> configEntries, ICollection <ConfigProcessInfo> workerDetails)
        {
            Log.InfoFormat($"Persisting configuration data for {configEntries.Count} config key entries and {workerDetails.Count} worker processes..");

            var persistedData = false;

            using (var extract = ExtractFactory.CreateExtract <ConfigEntry>("ConfigEntries.hyper"))
                using (GetPersisterStatusWriter(extract, configEntries.Count))
                {
                    extract.Enqueue(configEntries);
                    persistedData = persistedData || extract.ItemsPersisted > 0;
                }

            using (var extract = ExtractFactory.CreateExtract <ConfigProcessInfo>("ProcessTopology.hyper"))
                using (GetPersisterStatusWriter(extract, workerDetails.Count))
                {
                    extract.Enqueue(workerDetails);
                    persistedData = persistedData || extract.ItemsPersisted > 0;
                }

            return(persistedData);
        }
Exemplo n.º 10
0
        private bool ProcessDocuments <T>(string collectionName, FilterDefinition <BsonDocument> query, Func <BsonDocument, T> transform) where T : new()
        {
            bool persistedData;

            Log.InfoFormat("Processing {0} events..", typeof(T).Name);

            using (var persister = ExtractFactory.CreateExtract <T>())
                using (GetPersisterStatusWriter(persister))
                {
                    var collection = MongoDatabase.GetCollection <BsonDocument>(collectionName);
                    var documents  = collection.Find(query).ToEnumerable();

                    foreach (var document in documents)
                    {
                        var instance = TransformDocument(document, transform);
                        persister.Enqueue(instance);
                    }

                    persistedData = persister.ItemsPersisted > 0;
                }

            Log.InfoFormat("Finished processing {0} events!", typeof(T).Name);
            return(persistedData);
        }
Exemplo n.º 11
0
        public override IPluginResponse Execute()
        {
            IPluginResponse pluginResponse = CreatePluginResponse();

            var collection = MongoDatabase.GetCollection <NetstatDocument>(ParserConstants.NetstatCollectionName);

            using (var persister = ExtractFactory.CreateExtract <NetstatActiveConnection>("NetstatEntries.hyper"))
                using (GetPersisterStatusWriter(persister))
                {
                    foreach (var worker in NetstatQueries.GetDistinctWorkers(collection))
                    {
                        var activeConnectionsForWorker = GetActiveConnectionsForWorker(worker, collection);
                        persister.Enqueue(activeConnectionsForWorker);
                    }

                    if (persister.ItemsPersisted <= 0)
                    {
                        Log.Warn("Failed to persist any Netstat data!");
                        pluginResponse.GeneratedNoData = true;
                    }

                    return(pluginResponse);
                }
        }
 public ExtractService(ExtractFactory extractFactory)
 {
     _extractFactory = extractFactory;
 }
 /// <summary>
 ///     Created a new instance of <see cref="ExtractCommand" />
 /// </summary>
 /// <param name="mainWindowViewModel"><see cref="MainWindowViewModel"/> to work on</param>
 internal ExtractCommand(MainWindowViewModel mainWindowViewModel)
 {
     _mainWindowViewModel = mainWindowViewModel;
     _extractor           = ExtractFactory.Extractor <NUnit>();
 }