private bool RealUsersExist(Config config) { bool result = false; File authFile = CommunitySecurityModule.getUserRepositoryFile(config); if (_outsideWorld.fileSystem().fileExists(authFile)) { result = true; // Check if it only contains the default neo4j user FileUserRepository userRepository = new FileUserRepository(_outsideWorld.fileSystem(), authFile, NullLogProvider.Instance); try { using (Lifespan life = new Lifespan(userRepository)) { ListSnapshot <User> users = userRepository.PersistedSnapshot; if (users.Values().Count == 1) { User user = users.Values()[0]; if (INITIAL_USER_NAME.Equals(user.Name()) && user.Credentials().matchesPassword(INITIAL_PASSWORD)) { // We allow overwriting an unmodified default neo4j user result = false; } } } } catch (IOException) { // Do not allow overwriting if we had a problem reading the file } } return(result); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() public virtual void Setup() { when(_reportDir.toFile()).thenReturn(TestDirectory.databaseLayout().databaseDirectory()); when(_outsideWorld.fileSystem()).thenReturn(_fileSystem); when(_onlineBackupContext.RequiredArguments).thenReturn(_requiredArguments); when(_onlineBackupContext.ResolvedLocationFromName).thenReturn(_reportDir); when(_requiredArguments.ReportDir).thenReturn(_reportDir); _subject = new BackupStrategyCoordinator(_consistencyCheckService, _outsideWorld, _logProvider, _progressMonitorFactory, Arrays.asList(_firstStrategy, _secondStrategy)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() public virtual void Setup() { _desiredBackupLayout = TestDirectory.databaseLayout("desiredBackupLayout"); _reportDir = TestDirectory.directory("reportDir").toPath(); _availableFreshBackupLocation = TestDirectory.directory("availableFreshBackupLocation").toPath(); Path availableOldBackupLocation = TestDirectory.directory("availableOldBackupLocation").toPath(); when(_outsideWorld.fileSystem()).thenReturn(_fileSystemAbstraction); when(_backupCopyService.findAnAvailableLocationForNewFullBackup(any())).thenReturn(_availableFreshBackupLocation); when(_backupCopyService.findNewBackupLocationForBrokenExisting(any())).thenReturn(availableOldBackupLocation); when(_backupStrategyImplementation.performFullBackup(any(), any(), any())).thenReturn(_success); when(_logProvider.getLog(( Type )any())).thenReturn(_log); _subject = new BackupStrategyWrapper(_backupStrategyImplementation, _backupCopyService, _pageCache, _config, _backupRecoveryService, _logProvider); }
/// <summary> /// Construct a wrapper of supported backup strategies /// </summary> /// <param name="onlineBackupContext"> the input of the backup tool, such as CLI arguments, config etc. </param> /// <param name="backupProtocolService"> the underlying backup implementation for HA and single node instances </param> /// <param name="backupDelegator"> the backup implementation used for CC backups </param> /// <param name="pageCache"> the page cache used moving files </param> /// <returns> strategy coordinator that handles the which backup strategies are tried and establishes if a backup was successful or not </returns> internal virtual BackupStrategyCoordinator BackupStrategyCoordinator(OnlineBackupContext onlineBackupContext, BackupProtocolService backupProtocolService, BackupDelegator backupDelegator, PageCache pageCache) { FileSystemAbstraction fs = _outsideWorld.fileSystem(); BackupCopyService copyService = new BackupCopyService(fs, new FileMoveProvider(fs)); ProgressMonitorFactory progressMonitorFactory = ProgressMonitorFactory.textual(_outsideWorld.errorStream()); BackupRecoveryService recoveryService = new BackupRecoveryService(); long timeout = onlineBackupContext.RequiredArguments.Timeout; Config config = onlineBackupContext.Config; StoreFiles storeFiles = new StoreFiles(fs, pageCache); BackupStrategy ccStrategy = new CausalClusteringBackupStrategy(backupDelegator, _addressResolver, _logProvider, storeFiles); BackupStrategy haStrategy = new HaBackupStrategy(backupProtocolService, _addressResolver, _logProvider, timeout); BackupStrategyWrapper ccStrategyWrapper = Wrap(ccStrategy, copyService, pageCache, config, recoveryService); BackupStrategyWrapper haStrategyWrapper = Wrap(haStrategy, copyService, pageCache, config, recoveryService); StrategyResolverService strategyResolverService = new StrategyResolverService(haStrategyWrapper, ccStrategyWrapper); IList <BackupStrategyWrapper> strategies = strategyResolverService.GetStrategies(onlineBackupContext.RequiredArguments.SelectedBackupProtocol); return(new BackupStrategyCoordinator(_consistencyCheckService, _outsideWorld, _logProvider, progressMonitorFactory, strategies)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void doImport() throws java.io.IOException public override void DoImport() { FileSystemAbstraction fs = _outsideWorld.fileSystem(); File storeDir = _databaseConfig.get(GraphDatabaseSettings.database_path); File reportFile = new File(_reportFileName); Stream badOutput = new BufferedOutputStream(fs.OpenAsOutputStream(reportFile, false)); Collector badCollector = badCollector(badOutput, IgnoringSomething ? BadCollector.UNLIMITED_TOLERANCE : 0, collect(_ignoreBadRelationships, _ignoreDuplicateNodes, _ignoreExtraColumns)); Configuration configuration = new WrappedBatchImporterConfigurationForNeo4jAdmin(importConfiguration(null, false, _databaseConfig, storeDir, _highIO)); // Extract the default time zone from the database configuration ZoneId dbTimeZone = _databaseConfig.get(GraphDatabaseSettings.db_temporal_timezone); System.Func <ZoneId> defaultTimeZone = () => dbTimeZone; CsvInput input = new CsvInput(nodeData(_inputEncoding, _nodesFiles), defaultFormatNodeFileHeader(defaultTimeZone), relationshipData(_inputEncoding, _relationshipsFiles), defaultFormatRelationshipFileHeader(defaultTimeZone), _idType, new WrappedCsvInputConfigurationForNeo4jAdmin(csvConfiguration(_args, false)), badCollector, new CsvInput.PrintingMonitor(_outsideWorld.outStream())); ImportTool.doImport(_outsideWorld.errorStream(), _outsideWorld.errorStream(), _outsideWorld.inStream(), DatabaseLayout.of(storeDir), reportFile, fs, _nodesFiles, _relationshipsFiles, false, input, this._databaseConfig, badOutput, configuration, false); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void performConsistencyCheck(org.neo4j.kernel.configuration.Config config, OnlineBackupRequiredArguments requiredArgs, org.neo4j.consistency.checking.full.ConsistencyFlags consistencyFlags, org.neo4j.io.layout.DatabaseLayout layout) throws org.neo4j.commandline.admin.CommandFailed private void PerformConsistencyCheck(Config config, OnlineBackupRequiredArguments requiredArgs, ConsistencyFlags consistencyFlags, DatabaseLayout layout) { try { bool verbose = false; File reportDir = requiredArgs.ReportDir.toFile(); ConsistencyCheckService.Result ccResult = _consistencyCheckService.runFullConsistencyCheck(layout, config, _progressMonitorFactory, _logProvider, _outsideWorld.fileSystem(), verbose, reportDir, consistencyFlags); if (!ccResult.Successful) { throw new CommandFailed(format("Inconsistencies found. See '%s' for details.", ccResult.ReportFile()), STATUS_CC_INCONSISTENT); } } catch (Exception e) { if (e is CommandFailed) { throw ( CommandFailed )e; } throw new CommandFailed("Failed to do consistency check on backup: " + e.Message, e, STATUS_CC_ERROR); } }