Пример #1
0
        public static Arguments Arguments()
        {
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            string argExampleProtoOverride = ( string )Stream.of(SelectedBackupProtocol.values()).map(SelectedBackupProtocol::getName).sorted().collect(Collectors.joining("|"));

            return((new Arguments()).withArgument(new MandatoryCanonicalPath(ARG_NAME_BACKUP_DIRECTORY, "backup-path", ARG_DESC_BACKUP_DIRECTORY)).withArgument(new MandatoryNamedArg(ARG_NAME_BACKUP_NAME, "graph.db-backup", ARG_DESC_BACKUP_NAME)).withArgument(new OptionalNamedArg(ARG_NAME_BACKUP_SOURCE, "address", ARG_DFLT_BACKUP_SOURCE, ARG_DESC_BACKUP_SOURCE)).withArgument(new OptionalNamedArg(ARG_NAME_PROTO_OVERRIDE, argExampleProtoOverride, ARG_DFLT_PROTO_OVERRIDE, ARG_DESC_PROTO_OVERRIDE)).withArgument(new OptionalBooleanArg(ARG_NAME_FALLBACK_FULL, true, ARG_DESC_FALLBACK_FULL)).withArgument(new OptionalNamedArg(ARG_NAME_TIMEOUT, "timeout", ARG_DFLT_TIMEOUT, ARG_DESC_TIMEOUT)).withArgument(new OptionalNamedArg(ARG_NAME_PAGECACHE, "8m", ARG_DFLT_PAGECACHE, ARG_DESC_PAGECACHE)).withArgument(new OptionalBooleanArg(ARG_NAME_CHECK_CONSISTENCY, true, ARG_DESC_CHECK_CONSISTENCY)).withArgument(new OptionalCanonicalPath(ARG_NAME_REPORT_DIRECTORY, "directory", ".", ARG_DESC_REPORT_DIRECTORY)).withArgument(new OptionalCanonicalPath(ARG_NAME_ADDITIONAL_CONFIG_DIR, "config-file-path", "", ARG_DESC_ADDITIONAL_CONFIG_DIR)).withArgument(new OptionalBooleanArg(ARG_NAME_CHECK_GRAPH, true, ARG_DESC_CHECK_GRAPH)).withArgument(new OptionalBooleanArg(ARG_NAME_CHECK_INDEXES, true, ARG_DESC_CHECK_INDEXES)).withArgument(new OptionalBooleanArg(ARG_NAME_CHECK_LABELS, true, ARG_DESC_CHECK_LABELS)).withArgument(new OptionalBooleanArg(ARG_NAME_CHECK_OWNERS, false, ARG_DESC_CHECK_OWNERS)));
        }
Пример #2
0
        private void ProtocolWarn(OnlineBackupContext onlineBackupContext)
        {
            SelectedBackupProtocol selectedBackupProtocol = onlineBackupContext.RequiredArguments.SelectedBackupProtocol;

            if (!SelectedBackupProtocol.Any.Equals(selectedBackupProtocol))
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String compatibleProducts;
                string compatibleProducts;
                switch (selectedBackupProtocol.innerEnumValue)
                {
                case Org.Neo4j.backup.impl.SelectedBackupProtocol.InnerEnum.CATCHUP:
                    compatibleProducts = "causal clustering";
                    break;

                case Org.Neo4j.backup.impl.SelectedBackupProtocol.InnerEnum.COMMON:
                    compatibleProducts = "HA and single";
                    break;

                default:
                    throw new System.ArgumentException("Unhandled protocol " + selectedBackupProtocol);
                }
                _outsideWorld.stdOutLine(format("The selected protocol `%s` means that it is only compatible with %s instances", selectedBackupProtocol.Name, compatibleProducts));
            }
        }
Пример #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public OnlineBackupContext createContext(String... args) throws org.neo4j.commandline.admin.IncorrectUsage, org.neo4j.commandline.admin.CommandFailed
        public virtual OnlineBackupContext CreateContext(params string[] args)
        {
            try
            {
                Arguments arguments = arguments();
                arguments.Parse(args);

                OptionalHostnamePort address = Converters.toOptionalHostnamePortFromRawAddress(arguments.Get(ARG_NAME_BACKUP_SOURCE));
                Path   folder             = this.GetBackupDirectory(arguments);
                string name               = arguments.Get(ARG_NAME_BACKUP_NAME);
                bool   fallbackToFull     = arguments.GetBoolean(ARG_NAME_FALLBACK_FULL);
                bool   doConsistencyCheck = arguments.GetBoolean(ARG_NAME_CHECK_CONSISTENCY);
                long   timeout            = ( long? )arguments.Get(ARG_NAME_TIMEOUT, TimeUtil.parseTimeMillis).Value;
                SelectedBackupProtocol selectedBackupProtocol = SelectedBackupProtocol.fromUserInput(arguments.Get(ARG_NAME_PROTO_OVERRIDE));
                string          pagecacheMemory  = arguments.Get(ARG_NAME_PAGECACHE);
                Optional <Path> additionalConfig = arguments.GetOptionalPath(ARG_NAME_ADDITIONAL_CONFIG_DIR);
                Path            reportDir        = ( Path )arguments.GetOptionalPath(ARG_NAME_REPORT_DIRECTORY).orElseThrow(() =>
                {
                    return(new System.ArgumentException(ARG_NAME_REPORT_DIRECTORY + " must be a path"));
                });
                OnlineBackupRequiredArguments requiredArguments = new OnlineBackupRequiredArguments(address, folder, name, selectedBackupProtocol, fallbackToFull, doConsistencyCheck, timeout, reportDir);

                Path           configFile = _configDir.resolve(Config.DEFAULT_CONFIG_FILE_NAME);
                Config.Builder builder    = Config.fromFile(configFile);
                Path           logPath    = requiredArguments.ResolvedLocationFromName;

                Config config = builder.WithHome(this._homeDir).withSetting(GraphDatabaseSettings.logical_logs_location, logPath.ToString()).withConnectorsDisabled().withNoThrowOnFileLoadFailure().build();

                additionalConfig.map(this.loadAdditionalConfigFile).ifPresent(config.augment);

                // We only replace the page cache memory setting.
                // Any other custom page swapper, etc. settings are preserved and used.
                config.Augment(GraphDatabaseSettings.pagecache_memory, pagecacheMemory);

                // Disable prometheus to avoid binding exceptions
                config.Augment("metrics.prometheus.enabled", Settings.FALSE);

                // Build consistency-checker configuration.
                // Note: We can remove the loading from config file in 4.0.
                System.Func <string, Setting <bool>, bool> oneOf = (a, s) => arguments.Has(a) ? arguments.GetBoolean(a) : config.Get(s);

                ConsistencyFlags consistencyFlags = new ConsistencyFlags(config);

                return(new OnlineBackupContext(requiredArguments, config, consistencyFlags));
            }
            catch (System.ArgumentException e)
            {
                throw new IncorrectUsage(e.Message);
            }
            catch (UncheckedIOException e)
            {
                throw new CommandFailed(e.Message, e);
            }
        }
Пример #4
0
 internal OnlineBackupRequiredArguments(OptionalHostnamePort address, Path directory, string name, SelectedBackupProtocol selectedBackupProtocol, bool fallbackToFull, bool doConsistencyCheck, long timeout, Path reportDir)
 {
     this._address                = address;
     this._directory              = directory;
     this._name                   = name;
     this._fallbackToFull         = fallbackToFull;
     this._doConsistencyCheck     = doConsistencyCheck;
     this._timeout                = timeout;
     this._reportDir              = reportDir;
     this._selectedBackupProtocol = selectedBackupProtocol;
 }
Пример #5
0
        internal virtual IList <BackupStrategyWrapper> GetStrategies(SelectedBackupProtocol selectedBackupProtocol)
        {
            switch (selectedBackupProtocol.innerEnumValue)
            {
            case Org.Neo4j.backup.impl.SelectedBackupProtocol.InnerEnum.ANY:
                return(Arrays.asList(_ccBackupStrategy, _haBackupStrategy));

            case Org.Neo4j.backup.impl.SelectedBackupProtocol.InnerEnum.COMMON:
                return(Collections.singletonList(_haBackupStrategy));

            case Org.Neo4j.backup.impl.SelectedBackupProtocol.InnerEnum.CATCHUP:
                return(Collections.singletonList(_ccBackupStrategy));

            default:
                throw new System.ArgumentException("Unhandled protocol choice: " + selectedBackupProtocol);
            }
        }
Пример #6
0
 public virtual OnlineBackupCommandBuilder WithSelectedBackupStrategy(SelectedBackupProtocol selectedBackupStrategy)
 {
     this._selectedBackupProtocol = selectedBackupStrategy;
     return(this);
 }