Exemplo n.º 1
0
 public LogsScanner(
     [NotNull] LogSearchParameters logSearchParameters, 
     [NotNull] JobCancellationManager cancellationManager,
     [NotNull] IWurmLogFiles wurmLogFiles,
     [NotNull] MonthlyLogFilesHeuristics monthlyHeuristics,
     [NotNull] LogFileStreamReaderFactory streamReaderFactory,
     [NotNull] ILogger logger,
     [NotNull] LogFileParserFactory logFileParserFactory, 
     [NotNull] IWurmApiConfig wurmApiConfig)
 {
     if (logSearchParameters == null) throw new ArgumentNullException("logSearchParameters");
     if (cancellationManager == null) throw new ArgumentNullException("cancellationManager");
     if (wurmLogFiles == null) throw new ArgumentNullException("wurmLogFiles");
     if (monthlyHeuristics == null) throw new ArgumentNullException("monthlyHeuristics");
     if (streamReaderFactory == null) throw new ArgumentNullException("streamReaderFactory");
     if (logger == null) throw new ArgumentNullException("logger");
     if (logFileParserFactory == null) throw new ArgumentNullException("logFileParserFactory");
     if (wurmApiConfig == null) throw new ArgumentNullException("wurmApiConfig");
     this.logSearchParameters = logSearchParameters;
     this.cancellationManager = cancellationManager;
     this.wurmLogFiles = wurmLogFiles;
     this.monthlyHeuristics = monthlyHeuristics;
     this.streamReaderFactory = streamReaderFactory;
     this.logger = logger;
     this.logFileParserFactory = logFileParserFactory;
     this.wurmApiConfig = wurmApiConfig;
 }
Exemplo n.º 2
0
 public LogsScannerFactory(
     LogFileParserFactory logFileParserFactory,
     LogFileStreamReaderFactory streamReaderFactory,
     MonthlyLogFilesHeuristics heuristics,
     IWurmLogFiles wurmLogFiles,
     ILogger logger, [NotNull] IWurmApiConfig wurmApiConfig)
 {
     if (logFileParserFactory == null)
         throw new ArgumentNullException("logFileParserFactory");
     if (streamReaderFactory == null)
         throw new ArgumentNullException("streamReaderFactory");
     if (heuristics == null)
         throw new ArgumentNullException("heuristics");
     if (wurmLogFiles == null)
         throw new ArgumentNullException("wurmLogFiles");
     if (logger == null)
         throw new ArgumentNullException("logger");
     if (wurmApiConfig == null) throw new ArgumentNullException("wurmApiConfig");
     this.logFileParserFactory = logFileParserFactory;
     this.streamReaderFactory = streamReaderFactory;
     this.heuristics = heuristics;
     this.wurmLogFiles = wurmLogFiles;
     this.logger = logger;
     this.wurmApiConfig = wurmApiConfig;
 }
 public MonthlyHeuristicsExtractor(
     LogFileInfo logFileInfo,
     LogFileStreamReaderFactory logFileStreamReaderFactory,
     IWurmApiLogger logger, [NotNull] IWurmApiConfig wurmApiConfig)
 {
     if (logFileInfo == null)
     {
         throw new ArgumentNullException(nameof(logFileInfo));
     }
     if (logFileStreamReaderFactory == null)
     {
         throw new ArgumentNullException(nameof(logFileStreamReaderFactory));
     }
     if (logger == null)
     {
         throw new ArgumentNullException(nameof(logger));
     }
     if (wurmApiConfig == null)
     {
         throw new ArgumentNullException(nameof(wurmApiConfig));
     }
     this.logFileInfo = logFileInfo;
     this.logFileStreamReaderFactory = logFileStreamReaderFactory;
     this.logger        = logger;
     this.wurmApiConfig = wurmApiConfig;
 }
 public LogFileStreamReaderFactory([NotNull] IWurmApiConfig wurmApiConfig)
 {
     if (wurmApiConfig == null)
     {
         throw new ArgumentNullException(nameof(wurmApiConfig));
     }
     this.wurmApiConfig = wurmApiConfig;
 }
Exemplo n.º 5
0
 public WurmPaths(IWurmClientInstallDirectory wurmInstallDirectory, [NotNull] IWurmApiConfig wurmApiConfig)
 {
     if (wurmApiConfig == null)
     {
         throw new ArgumentNullException(nameof(wurmApiConfig));
     }
     this.wurmApiConfig = wurmApiConfig;
     ConfigsDirFullPath = Path.Combine(wurmInstallDirectory.FullPath, "configs");
     playersDirPath     = Path.Combine(wurmInstallDirectory.FullPath, "players");
 }
 public MonthlyHeuristicsExtractorFactory(
     LogFileStreamReaderFactory logFileStreamReaderFactory,
     ILogger logger, [NotNull] IWurmApiConfig wurmApiConfig)
 {
     if (logFileStreamReaderFactory == null) throw new ArgumentNullException("logFileStreamReaderFactory");
     if (logger == null) throw new ArgumentNullException("logger");
     if (wurmApiConfig == null) throw new ArgumentNullException("wurmApiConfig");
     this.logFileStreamReaderFactory = logFileStreamReaderFactory;
     this.logger = logger;
     this.wurmApiConfig = wurmApiConfig;
 }
Exemplo n.º 7
0
        public WurmServerHistory(
            [NotNull] string dataDirectoryFullPath,
            [NotNull] IWurmLogsHistory wurmLogsHistory,
            IWurmServerList wurmServerList,
            IWurmApiLogger logger,
            IWurmLogsMonitorInternal wurmLogsMonitor,
            IWurmLogFiles wurmLogFiles,
            IInternalEventAggregator internalEventAggregator,
            [NotNull] IWurmServerGroups wurmServerGroups,
            [NotNull] IWurmApiConfig wurmApiConfig)
        {
            if (dataDirectoryFullPath == null)
            {
                throw new ArgumentNullException(nameof(dataDirectoryFullPath));
            }
            if (wurmLogsHistory == null)
            {
                throw new ArgumentNullException(nameof(wurmLogsHistory));
            }
            if (wurmServerGroups == null)
            {
                throw new ArgumentNullException(nameof(wurmServerGroups));
            }
            if (wurmApiConfig == null)
            {
                throw new ArgumentNullException(nameof(wurmApiConfig));
            }
            this.wurmLogsHistory  = wurmLogsHistory;
            this.wurmServerGroups = wurmServerGroups;
            this.wurmApiConfig    = wurmApiConfig;

            IPersistenceStrategy persistenceStrategy = new FlatFilesPersistenceStrategy(dataDirectoryFullPath);

            var persistentLibrary =
                new PersistentCollectionsLibrary(persistenceStrategy,
                                                 new PersObjErrorHandlingStrategy(logger));
            var collection = persistentLibrary.GetCollection("serverhistory");

            var providerFactory = new ServerHistoryProviderFactory(
                collection,
                wurmLogsHistory,
                wurmServerList,
                logger,
                wurmLogsMonitor,
                wurmLogFiles,
                internalEventAggregator);


            jobExecutor = new JobExecutor(providerFactory, persistentLibrary);
            runner      = new QueuedJobsSyncRunner <object, ServerName>(jobExecutor, logger);
        }
Exemplo n.º 8
0
 public LogsScanner(
     [NotNull] LogSearchParameters logSearchParameters,
     [NotNull] JobCancellationManager cancellationManager,
     [NotNull] IWurmLogFiles wurmLogFiles,
     [NotNull] MonthlyLogFilesHeuristics monthlyHeuristics,
     [NotNull] LogFileStreamReaderFactory streamReaderFactory,
     [NotNull] IWurmApiLogger logger,
     [NotNull] LogFileParserFactory logFileParserFactory,
     [NotNull] IWurmApiConfig wurmApiConfig)
 {
     if (logSearchParameters == null)
     {
         throw new ArgumentNullException(nameof(logSearchParameters));
     }
     if (cancellationManager == null)
     {
         throw new ArgumentNullException(nameof(cancellationManager));
     }
     if (wurmLogFiles == null)
     {
         throw new ArgumentNullException(nameof(wurmLogFiles));
     }
     if (monthlyHeuristics == null)
     {
         throw new ArgumentNullException(nameof(monthlyHeuristics));
     }
     if (streamReaderFactory == null)
     {
         throw new ArgumentNullException(nameof(streamReaderFactory));
     }
     if (logger == null)
     {
         throw new ArgumentNullException(nameof(logger));
     }
     if (logFileParserFactory == null)
     {
         throw new ArgumentNullException(nameof(logFileParserFactory));
     }
     if (wurmApiConfig == null)
     {
         throw new ArgumentNullException(nameof(wurmApiConfig));
     }
     this.logSearchParameters = logSearchParameters;
     this.cancellationManager = cancellationManager;
     this.wurmLogFiles        = wurmLogFiles;
     this.monthlyHeuristics   = monthlyHeuristics;
     this.streamReaderFactory = streamReaderFactory;
     this.logger = logger;
     this.logFileParserFactory = logFileParserFactory;
     this.wurmApiConfig        = wurmApiConfig;
 }
Exemplo n.º 9
0
        public WurmLogsHistory([NotNull] IWurmLogFiles wurmLogFiles, [NotNull] IWurmApiLogger logger,
                               [NotNull] string heuristicsDataDirectory, [NotNull] LogFileStreamReaderFactory logFileStreamReaderFactory,
                               [NotNull] IWurmApiConfig wurmApiConfig)
        {
            if (wurmLogFiles == null)
            {
                throw new ArgumentNullException(nameof(wurmLogFiles));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (heuristicsDataDirectory == null)
            {
                throw new ArgumentNullException(nameof(heuristicsDataDirectory));
            }
            if (logFileStreamReaderFactory == null)
            {
                throw new ArgumentNullException(nameof(logFileStreamReaderFactory));
            }
            if (wurmApiConfig == null)
            {
                throw new ArgumentNullException(nameof(wurmApiConfig));
            }

            IPersistenceStrategy persistenceStrategy = new FlatFilesPersistenceStrategy(heuristicsDataDirectory);

            var persistentLibrary =
                new PersistentCollectionsLibrary(persistenceStrategy,
                                                 new PersObjErrorHandlingStrategy(logger));
            var heuristicsCollection = persistentLibrary.GetCollection("heuristics");

            var logsScannerFactory = new LogsScannerFactory(
                new LogFileParserFactory(logger),
                logFileStreamReaderFactory,
                new MonthlyLogFilesHeuristics(
                    heuristicsCollection,
                    wurmLogFiles,
                    new MonthlyHeuristicsExtractorFactory(logFileStreamReaderFactory, logger, wurmApiConfig)),
                wurmLogFiles,
                logger,
                wurmApiConfig);

            runner =
                new QueuedJobsSyncRunner <LogSearchParameters, ScanResult>(
                    new ScanJobExecutor(logsScannerFactory, persistentLibrary, logger),
                    logger);
        }
Exemplo n.º 10
0
 public LogsScannerFactory(
     LogFileParserFactory logFileParserFactory,
     LogFileStreamReaderFactory streamReaderFactory,
     MonthlyLogFilesHeuristics heuristics,
     IWurmLogFiles wurmLogFiles,
     IWurmApiLogger logger, [NotNull] IWurmApiConfig wurmApiConfig)
 {
     if (logFileParserFactory == null)
     {
         throw new ArgumentNullException(nameof(logFileParserFactory));
     }
     if (streamReaderFactory == null)
     {
         throw new ArgumentNullException(nameof(streamReaderFactory));
     }
     if (heuristics == null)
     {
         throw new ArgumentNullException(nameof(heuristics));
     }
     if (wurmLogFiles == null)
     {
         throw new ArgumentNullException(nameof(wurmLogFiles));
     }
     if (logger == null)
     {
         throw new ArgumentNullException(nameof(logger));
     }
     if (wurmApiConfig == null)
     {
         throw new ArgumentNullException(nameof(wurmApiConfig));
     }
     this.logFileParserFactory = logFileParserFactory;
     this.streamReaderFactory  = streamReaderFactory;
     this.heuristics           = heuristics;
     this.wurmLogFiles         = wurmLogFiles;
     this.logger        = logger;
     this.wurmApiConfig = wurmApiConfig;
 }
Exemplo n.º 11
0
        public WurmServers(
            [NotNull] IWurmLogsHistory wurmLogsHistory,
            [NotNull] IWurmLogsMonitorInternal wurmLogsMonitor,
            [NotNull] IWurmServerList wurmServerList,
            [NotNull] IHttpWebRequests httpWebRequests,
            [NotNull] string dataDirectory,
            [NotNull] IWurmCharacterDirectories wurmCharacterDirectories,
            [NotNull] IWurmServerHistory wurmServerHistory,
            [NotNull] IWurmApiLogger logger,
            [NotNull] IWurmServerGroups wurmServerGroups,
            [NotNull] IWurmApiConfig wurmApiConfig)
        {
            if (wurmLogsHistory == null)
            {
                throw new ArgumentNullException(nameof(wurmLogsHistory));
            }
            if (wurmLogsMonitor == null)
            {
                throw new ArgumentNullException(nameof(wurmLogsMonitor));
            }
            if (wurmServerList == null)
            {
                throw new ArgumentNullException(nameof(wurmServerList));
            }
            if (httpWebRequests == null)
            {
                throw new ArgumentNullException(nameof(httpWebRequests));
            }
            if (dataDirectory == null)
            {
                throw new ArgumentNullException(nameof(dataDirectory));
            }
            if (wurmCharacterDirectories == null)
            {
                throw new ArgumentNullException(nameof(wurmCharacterDirectories));
            }
            if (wurmServerHistory == null)
            {
                throw new ArgumentNullException(nameof(wurmServerHistory));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (wurmServerGroups == null)
            {
                throw new ArgumentNullException(nameof(wurmServerGroups));
            }
            if (wurmApiConfig == null)
            {
                throw new ArgumentNullException(nameof(wurmApiConfig));
            }

            this.wurmServerGroups = wurmServerGroups;
            this.wurmApiConfig    = wurmApiConfig;

            liveLogsDataQueue = new LiveLogsDataQueue(wurmLogsMonitor);
            LiveLogs liveLogs = new LiveLogs(liveLogsDataQueue, wurmServerHistory);

            IPersistenceStrategy persistenceStrategy = new FlatFilesPersistenceStrategy(dataDirectory);

            persistentCollectionsLibrary =
                new PersistentCollectionsLibrary(persistenceStrategy,
                                                 new PersObjErrorHandlingStrategy(logger));
            var             persistent      = persistentCollectionsLibrary.DefaultCollection.GetObject <ServersData>("WurmServers");
            LogHistorySaved logHistorySaved = new LogHistorySaved(persistent);
            LogHistory      logHistory      = new LogHistory(wurmLogsHistory,
                                                             wurmCharacterDirectories,
                                                             wurmServerHistory,
                                                             logHistorySaved,
                                                             new LogEntriesParser(),
                                                             logger);

            WebFeeds webFeeds = new WebFeeds(httpWebRequests, wurmServerList, logger);

            runner = new QueuedJobsSyncRunner <Job, JobResult>(new JobRunner(liveLogs, logHistory, webFeeds, persistentCollectionsLibrary), logger);

            wurmServerFactory = new WurmServerFactory(runner);

            var descriptions = wurmServerList.All;

            foreach (var serverDescription in descriptions)
            {
                RegisterServer(serverDescription);
            }
        }
Exemplo n.º 12
0
 public LogFileStreamReaderFactory([NotNull] IWurmApiConfig wurmApiConfig)
 {
     if (wurmApiConfig == null) throw new ArgumentNullException("wurmApiConfig");
     this.wurmApiConfig = wurmApiConfig;
 }
Exemplo n.º 13
0
        void ConstructSystems(string wurmApiDataDirectoryFullPath, IWurmClientInstallDirectory installDirectory,
                              IHttpWebRequests httpWebRequests, IWurmApiLogger logger, IWurmApiEventMarshaller publicEventMarshaller,
                              IWurmApiEventMarshaller internalEventMarshaller, WurmApiConfig wurmApiConfig)
        {
            IWurmApiConfig internalWurmApiConfig = wurmApiConfig.CreateCopy();

            LogFileStreamReaderFactory logFileStreamReaderFactory = Wire(new LogFileStreamReaderFactory(internalWurmApiConfig));

            Wire(installDirectory);
            Wire(httpWebRequests);

            if (logger == null)
            {
                logger = new WurmApiLoggerStub();
            }

            PublicEventInvoker publicEventInvoker = Wire(new PublicEventInvoker(publicEventMarshaller, logger));

            TaskManager taskManager = Wire(new TaskManager(logger));

            InternalEventAggregator internalEventAggregator = Wire(new InternalEventAggregator());

            InternalEventInvoker internalEventInvoker =
                Wire(new InternalEventInvoker(internalEventAggregator, logger, internalEventMarshaller));

            WurmPaths        paths        = Wire(new WurmPaths(installDirectory, wurmApiConfig));
            WurmServerGroups serverGroups = Wire(new WurmServerGroups(internalWurmApiConfig.ServerInfoMap));

            WurmServerList serverList = Wire(new WurmServerList(internalWurmApiConfig.ServerInfoMap));

            WurmLogDefinitions logDefinitions = Wire(new WurmLogDefinitions());

            WurmConfigDirectories configDirectories =
                Wire(new WurmConfigDirectories(paths, internalEventAggregator, taskManager, logger));
            WurmCharacterDirectories characterDirectories =
                Wire(new WurmCharacterDirectories(paths, internalEventAggregator, taskManager, logger));
            WurmLogFiles logFiles =
                Wire(new WurmLogFiles(characterDirectories,
                                      logger,
                                      logDefinitions,
                                      internalEventAggregator,
                                      internalEventInvoker,
                                      taskManager,
                                      paths));

            WurmLogsMonitor logsMonitor =
                Wire(new WurmLogsMonitor(logFiles,
                                         logger,
                                         publicEventInvoker,
                                         internalEventAggregator,
                                         characterDirectories,
                                         internalEventInvoker,
                                         taskManager,
                                         logFileStreamReaderFactory));
            var heuristicsDataDirectory = Path.Combine(wurmApiDataDirectoryFullPath, "WurmLogsHistory");

            if (internalWurmApiConfig.ClearAllCaches)
            {
                ClearDir(heuristicsDataDirectory, logger);
            }

            WurmLogsHistory logsHistory =
                Wire(new WurmLogsHistory(logFiles,
                                         logger,
                                         heuristicsDataDirectory,
                                         logFileStreamReaderFactory,
                                         wurmApiConfig));

            WurmConfigs wurmConfigs =
                Wire(new WurmConfigs(configDirectories,
                                     logger,
                                     publicEventInvoker,
                                     internalEventAggregator,
                                     taskManager));
            WurmAutoruns autoruns = Wire(new WurmAutoruns(wurmConfigs, characterDirectories, logger));

            var wurmServerHistoryDataDirectory = Path.Combine(wurmApiDataDirectoryFullPath, "WurmServerHistory");

            if (internalWurmApiConfig.ClearAllCaches)
            {
                ClearDir(wurmServerHistoryDataDirectory, logger);
            }
            WurmServerHistory wurmServerHistory =
                Wire(new WurmServerHistory(wurmServerHistoryDataDirectory,
                                           logsHistory,
                                           serverList,
                                           logger,
                                           logsMonitor,
                                           logFiles,
                                           internalEventAggregator,
                                           serverGroups,
                                           wurmApiConfig));

            var wurmServersDataDirectory = Path.Combine(wurmApiDataDirectoryFullPath, "WurmServers");

            if (internalWurmApiConfig.ClearAllCaches)
            {
                ClearDir(wurmServersDataDirectory, logger);
            }
            WurmServers wurmServers =
                Wire(new WurmServers(logsHistory,
                                     logsMonitor,
                                     serverList,
                                     httpWebRequests,
                                     wurmServersDataDirectory,
                                     characterDirectories,
                                     wurmServerHistory,
                                     logger,
                                     serverGroups,
                                     wurmApiConfig));

            WurmCharacters characters =
                Wire(new WurmCharacters(characterDirectories,
                                        wurmConfigs,
                                        wurmServers,
                                        wurmServerHistory,
                                        logger,
                                        taskManager,
                                        logsMonitor,
                                        publicEventInvoker,
                                        internalEventAggregator,
                                        paths,
                                        logsHistory,
                                        serverGroups));

            HttpWebRequests          = httpWebRequests;
            Autoruns                 = autoruns;
            Characters               = characters;
            Configs                  = wurmConfigs;
            LogDefinitions           = logDefinitions;
            LogsHistory              = logsHistory;
            LogsMonitor              = logsMonitor;
            Servers                  = wurmServers;
            WurmLogFiles             = logFiles;
            WurmServerHistory        = wurmServerHistory;
            WurmCharacterDirectories = characterDirectories;
            WurmConfigDirectories    = configDirectories;
            InternalEventAggregator  = internalEventAggregator;
            Paths        = paths;
            ServerGroups = serverGroups;
            Logger       = logger;
            ServersList  = serverList;
        }