Пример #1
0
        /// <summary>
        /// Parses a configuration value for log specifying log pruning. It has one of these forms:
        /// <ul>
        ///   <li>all</li>
        ///   <li>[number][unit] [type]</li>
        /// </ul>
        /// For example:
        /// <ul>
        ///   <li>100M size - For keeping last 100 megabytes of log data</li>
        ///   <li>20 pcs - For keeping last 20 non-empty log files</li>
        ///   <li>7 days - For keeping last 7 days worth of log data</li>
        ///   <li>1k hours - For keeping last 1000 hours worth of log data</li>
        /// </ul>
        /// </summary>
        internal virtual LogPruneStrategy StrategyFromConfigValue(FileSystemAbstraction fileSystem, LogFiles logFiles, Clock clock, string configValue)
        {
            ThresholdConfigValue value = parse(configValue);

            if (value == ThresholdConfigValue.NO_PRUNING)
            {
                return(NO_PRUNING);
            }

            Threshold thresholdToUse = GetThresholdByType(fileSystem, clock, value, configValue);

            return(new ThresholdBasedPruneStrategy(fileSystem, logFiles, thresholdToUse));
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @VisibleForTesting static Threshold getThresholdByType(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.time.Clock clock, org.neo4j.kernel.impl.transaction.log.pruning.ThresholdConfigParser.ThresholdConfigValue value, String originalConfigValue)
        internal static Threshold GetThresholdByType(FileSystemAbstraction fileSystem, Clock clock, ThresholdConfigValue value, string originalConfigValue)
        {
            long thresholdValue = value.Value;

            switch (value.Type)
            {
            case "files":
                return(new FileCountThreshold(thresholdValue));

            case "size":
                return(new FileSizeThreshold(fileSystem, thresholdValue));

            case "txs":
            case "entries":                             // txs and entries are synonyms
                return(new EntryCountThreshold(thresholdValue));

            case "hours":
                return(new EntryTimespanThreshold(clock, HOURS, thresholdValue));

            case "days":
                return(new EntryTimespanThreshold(clock, DAYS, thresholdValue));

            default:
                throw new System.ArgumentException("Invalid log pruning configuration value '" + originalConfigValue + "'. Invalid type '" + value.Type + "', valid are files, size, txs, entries, hours, days.");
            }
        }