//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSuppressFailureToCloseChannelInFailedAttemptToReadHeaderAfterOpen() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSuppressFailureToCloseChannelInFailedAttemptToReadHeaderAfterOpen() { // GIVEN a file which returns 1/2 log header size worth of bytes FileSystemAbstraction fs = mock(typeof(FileSystemAbstraction)); LogFiles logFiles = LogFilesBuilder.builder(_directory.databaseLayout(), fs).withTransactionIdStore(_transactionIdStore).withLogVersionRepository(_logVersionRepository).build(); int logVersion = 0; File logFile = logFiles.GetLogFileForVersion(logVersion); StoreChannel channel = mock(typeof(StoreChannel)); when(channel.read(any(typeof(ByteBuffer)))).thenReturn(LogHeader.LOG_HEADER_SIZE / 2); when(fs.FileExists(logFile)).thenReturn(true); when(fs.Open(eq(logFile), any(typeof(OpenMode)))).thenReturn(channel); doThrow(typeof(IOException)).when(channel).close(); // WHEN try { logFiles.OpenForVersion(logVersion); fail("Should have failed"); } catch (IncompleteLogHeaderException e) { // THEN good verify(channel).close(); assertEquals(1, e.Suppressed.length); assertTrue(e.Suppressed[0] is IOException); } }
internal static LuceneIndexProvider LuceneProvider(FileSystemAbstraction fs, IndexDirectoryStructure.Factory directoryStructure, IndexProvider.Monitor monitor, Config config, OperationalMode operationalMode) { bool ephemeral = config.Get(GraphDatabaseSettings.ephemeral); DirectoryFactory directoryFactory = directoryFactory(ephemeral); return(new LuceneIndexProvider(fs, directoryFactory, directoryStructure, monitor, config, operationalMode)); }
//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."); } }
public Builder(RecordStorageEngineRule outerInstance, FileSystemAbstraction fs, PageCache pageCache, DatabaseLayout databaseLayout) { this._outerInstance = outerInstance; this.Fs = fs; this.PageCache = pageCache; this.DatabaseLayout = databaseLayout; }
private static ChildInitializer ChildInitializer(FileSystemAbstraction fileSystem, GraphDatabaseAPI graphDb) { ApplicationSupportedProtocols catchupProtocols = new ApplicationSupportedProtocols(CATCHUP, emptyList()); ModifierSupportedProtocols modifierProtocols = new ModifierSupportedProtocols(COMPRESSION, emptyList()); ApplicationProtocolRepository catchupRepository = new ApplicationProtocolRepository(Protocol_ApplicationProtocols.values(), catchupProtocols); ModifierProtocolRepository modifierRepository = new ModifierProtocolRepository(Protocol_ModifierProtocols.values(), singletonList(modifierProtocols)); System.Func <CheckPointer> checkPointer = () => graphDb.DependencyResolver.resolveDependency(typeof(CheckPointer)); System.Func <bool> availability = () => graphDb.DependencyResolver.resolveDependency(typeof(DatabaseAvailabilityGuard)).Available; System.Func <NeoStoreDataSource> dataSource = () => graphDb.DependencyResolver.resolveDependency(typeof(NeoStoreDataSource)); LogProvider logProvider = NullLogProvider.Instance; Org.Neo4j.Storageengine.Api.StoreId kernelStoreId = dataSource().StoreId; StoreId storeId = new StoreId(kernelStoreId.CreationTime, kernelStoreId.RandomId, kernelStoreId.UpgradeTime, kernelStoreId.UpgradeId); CheckPointerService checkPointerService = new CheckPointerService(checkPointer, createInitialisedScheduler(), Group.CHECKPOINT); RegularCatchupServerHandler catchupServerHandler = new RegularCatchupServerHandler(new Monitors(), logProvider, () => storeId, dataSource, availability, fileSystem, null, checkPointerService); NettyPipelineBuilderFactory pipelineBuilder = new NettyPipelineBuilderFactory(VoidPipelineWrapperFactory.VOID_WRAPPER); CatchupProtocolServerInstaller.Factory catchupProtocolServerInstaller = new CatchupProtocolServerInstaller.Factory(pipelineBuilder, logProvider, catchupServerHandler); ProtocolInstallerRepository <Org.Neo4j.causalclustering.protocol.ProtocolInstaller_Orientation_Server> protocolInstallerRepository = new ProtocolInstallerRepository <Org.Neo4j.causalclustering.protocol.ProtocolInstaller_Orientation_Server>(singletonList(catchupProtocolServerInstaller), Org.Neo4j.causalclustering.protocol.ModifierProtocolInstaller_Fields.AllServerInstallers); return(new HandshakeServerInitializer(catchupRepository, modifierRepository, protocolInstallerRepository, pipelineBuilder, logProvider)); }
/// <summary> /// Creates a new id file. /// </summary> /// <param name="file"> The name of the id generator </param> /// <param name="throwIfFileExists"> if {@code true} will cause an <seealso cref="System.InvalidOperationException"/> to be thrown if /// the file already exists. if {@code false} will truncate the file writing the header in it. </param> public static void CreateEmptyIdFile(FileSystemAbstraction fs, File file, long highId, bool throwIfFileExists) { // sanity checks if (fs == null) { throw new System.ArgumentException("Null filesystem"); } if (file == null) { throw new System.ArgumentException("Null filename"); } if (throwIfFileExists && fs.FileExists(file)) { throw new System.InvalidOperationException("Can't create id file [" + file + "], file already exists"); } try { using (StoreChannel channel = fs.Create(file)) { // write the header channel.Truncate(0); ByteBuffer buffer = ByteBuffer.allocate(HeaderSize); buffer.put(_cleanGenerator).putLong(highId).flip(); channel.WriteAll(buffer); channel.Force(false); } } catch (IOException e) { throw new UnderlyingStorageException("Unable to create id file " + file, e); } }
//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() { FileSystemAbstraction fs = _fsRule.get(); _pageCache = _pageCacheRule.getPageCache(fs); _idGeneratorFactory = new DefaultIdGeneratorFactory(fs); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static java.io.File createNeoStoreFile(org.neo4j.io.fs.FileSystemAbstraction fileSystem, org.neo4j.io.layout.DatabaseLayout databaseLayout) throws java.io.IOException private static File CreateNeoStoreFile(FileSystemAbstraction fileSystem, DatabaseLayout databaseLayout) { File neoStoreFile = databaseLayout.MetadataStore(); fileSystem.Create(neoStoreFile).close(); return(neoStoreFile); }
public virtual PageCache GetPageCache(FileSystemAbstraction fs, PageCacheConfig pageCacheConfig, Config config) { CloseExistingPageCache(); PageCache = CreatePageCache(fs, pageCacheConfig, config); PageCachePostConstruct(pageCacheConfig); return(PageCache); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static LogHeader readLogHeader(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File file, boolean strict) throws java.io.IOException public static LogHeader ReadLogHeader(FileSystemAbstraction fileSystem, File file, bool strict) { using (StoreChannel channel = fileSystem.Open(file, OpenMode.READ)) { return(ReadLogHeader(ByteBuffer.allocate(LOG_HEADER_SIZE), channel, strict, file)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void prepareNeoStoreFile(org.neo4j.io.fs.FileSystemAbstraction fileSystem, org.neo4j.io.layout.DatabaseLayout databaseLayout, String storeVersion, org.neo4j.io.pagecache.PageCache pageCache) throws java.io.IOException private static void PrepareNeoStoreFile(FileSystemAbstraction fileSystem, DatabaseLayout databaseLayout, string storeVersion, PageCache pageCache) { File neoStoreFile = CreateNeoStoreFile(fileSystem, databaseLayout); long value = MetaDataStore.versionStringToLong(storeVersion); MetaDataStore.setRecord(pageCache, neoStoreFile, STORE_VERSION, value); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: IndexUpdateStorage(org.neo4j.io.fs.FileSystemAbstraction fs, java.io.File file, ByteBufferFactory.Allocator byteBufferFactory, int blockSize, org.neo4j.index.internal.gbptree.Layout<KEY,VALUE> layout) throws java.io.IOException internal IndexUpdateStorage(FileSystemAbstraction fs, File file, ByteBufferFactory.Allocator byteBufferFactory, int blockSize, Layout <KEY, VALUE> layout) : base(fs, file, byteBufferFactory, blockSize) { this._layout = layout; this._key1 = layout.NewKey(); this._key2 = layout.NewKey(); this._value = layout.NewValue(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: BlockReader(org.neo4j.io.fs.FileSystemAbstraction fs, java.io.File file, org.neo4j.index.internal.gbptree.Layout<KEY,VALUE> layout) throws java.io.IOException internal BlockReader(FileSystemAbstraction fs, File file, Layout <KEY, VALUE> layout) { this._fs = fs; this._file = file; this._layout = layout; this._channel = fs.Open(file, OpenMode.READ); }
internal StoreResource(File file, string relativePath, int recordSize, FileSystemAbstraction fs) { this._file = file; this._path = relativePath; this._recordSize = recordSize; this._fs = fs; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: static long readHighId(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File file) throws java.io.IOException internal static long ReadHighId(FileSystemAbstraction fileSystem, File file) { using (StoreChannel channel = fileSystem.Open(file, OpenMode.READ)) { return(ReadAndValidate(channel, file)); } }
public RecoveryRequiredChecker(FileSystemAbstraction fs, PageCache pageCache, Config config, Monitors monitors) { this._fs = fs; this._pageCache = pageCache; this._config = config; this._monitors = monitors; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: static long readDefragCount(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File file) throws java.io.IOException internal static long ReadDefragCount(FileSystemAbstraction fileSystem, File file) { using (StoreChannel channel = fileSystem.Open(file, OpenMode.READ)) { return(FreeIdKeeper.CountFreeIds(new OffsetChannel(channel, HeaderSize))); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static void assertRecoveryIsNotRequired(org.neo4j.io.fs.FileSystemAbstraction fs, org.neo4j.io.pagecache.PageCache pageCache, org.neo4j.kernel.configuration.Config config, org.neo4j.io.layout.DatabaseLayout databaseLayout, org.neo4j.kernel.monitoring.Monitors monitors) throws RecoveryRequiredException, java.io.IOException public static void AssertRecoveryIsNotRequired(FileSystemAbstraction fs, PageCache pageCache, Config config, DatabaseLayout databaseLayout, Monitors monitors) { if ((new RecoveryRequiredChecker(fs, pageCache, config, monitors)).IsRecoveryRequiredAt(databaseLayout)) { throw new RecoveryRequiredException(); } }
public SimpleFileStorage(FileSystemAbstraction fileSystem, File directory, string name, ChannelMarshal <T> marshal, LogProvider logProvider) { this._fileSystem = fileSystem; this._log = logProvider.getLog(this.GetType()); this._file = new File(DurableStateStorage.StateDir(directory, name), name); this._marshal = marshal; }
internal CausalClusteringBeanImpl(ManagementData management, bool isMXBean) : base(management, isMXBean) { ClusterStateDirectory = management.ResolveDependency(typeof(ClusterStateDirectory)); RaftMachine = management.ResolveDependency(typeof(RaftMachine)); Fs = management.KernelData.FilesystemAbstraction; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static void restoreFromBackup(java.io.File backup, org.neo4j.io.fs.FileSystemAbstraction fsa, org.neo4j.causalclustering.discovery.ClusterMember clusterMember) throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed public static void RestoreFromBackup(File backup, FileSystemAbstraction fsa, ClusterMember clusterMember) { Config config = clusterMember.config(); RestoreDatabaseCommand restoreDatabaseCommand = new RestoreDatabaseCommand(fsa, backup, config, GraphDatabaseSettings.DEFAULT_DATABASE_NAME, true); restoreDatabaseCommand.Execute(); }
public void SetMigrationStatus(Org.Neo4j.Io.fs.FileSystemAbstraction fs, java.io.File stateFile, string info) { if (fs.FileExists(stateFile)) { try { fs.Truncate(stateFile, 0); } catch (IOException e) { throw new Exception(e); } } try { using (Writer writer = fs.OpenAsWriter(stateFile, StandardCharsets.UTF_8, false)) { writer.write(name()); writer.write('\n'); writer.write(info); writer.flush(); } } catch (IOException e) { throw new Exception(e); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void before() public virtual void Before() { FileSystemAbstraction fs = this._fs.get(); StoreFactory storeFactory = new StoreFactory(_testDirectory.databaseLayout(), Config.defaults(), new DefaultIdGeneratorFactory(fs), _pageCacheRule.getPageCache(fs), fs, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY); _neoStores = storeFactory.OpenAllNeoStores(true); }
internal ThresholdBasedPruneStrategy(FileSystemAbstraction fileSystem, LogFiles logFiles, Threshold threshold) { this._fileSystem = fileSystem; this._files = logFiles; this._logFileInformation = _files.LogFileInformation; this._threshold = threshold; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void dropShouldDeleteEntireIndexFolder() public virtual void DropShouldDeleteEntireIndexFolder() { // given File root = Storage.directory().directory("root"); IndexDirectoryStructure directoryStructure = IndexDirectoryStructure.directoriesByProvider(root).forProvider(GenericNativeIndexProvider.Descriptor); long indexId = 8; File indexDirectory = directoryStructure.DirectoryForIndex(indexId); StoreIndexDescriptor descriptor = IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forLabel(1, 1)).withId(indexId); IndexSpecificSpaceFillingCurveSettingsCache spatialSettings = mock(typeof(IndexSpecificSpaceFillingCurveSettingsCache)); PageCache pageCache = Storage.pageCache(); FileSystemAbstraction fs = Storage.fileSystem(); File indexFile = new File(indexDirectory, "my-index"); GenericLayout layout = new GenericLayout(1, spatialSettings); RecoveryCleanupWorkCollector immediate = immediate(); IndexDropAction dropAction = new FileSystemIndexDropAction(fs, directoryStructure); GenericNativeIndexPopulator populator = new GenericNativeIndexPopulator(pageCache, fs, indexFile, layout, EMPTY, descriptor, spatialSettings, directoryStructure, mock(typeof(SpaceFillingCurveConfiguration)), dropAction, false); populator.Create(); // when assertTrue(fs.ListFiles(indexDirectory).Length > 0); populator.Drop(); // then assertFalse(fs.FileExists(indexDirectory)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void createStore() public virtual void CreateStore() { _file = new File("target/test-data/index-provider-store"); _fileSystem = new DefaultFileSystemAbstraction(); _file.mkdirs(); _fileSystem.deleteFile(_file); }
public ClusteringModule(DiscoveryServiceFactory discoveryServiceFactory, MemberId myself, PlatformModule platformModule, File clusterStateDirectory, DatabaseLayout databaseLayout) { LifeSupport life = platformModule.Life; Config config = platformModule.Config; LogProvider logProvider = platformModule.Logging.InternalLogProvider; LogProvider userLogProvider = platformModule.Logging.UserLogProvider; Dependencies dependencies = platformModule.Dependencies; Monitors monitors = platformModule.Monitors; FileSystemAbstraction fileSystem = platformModule.FileSystem; RemoteMembersResolver remoteMembersResolver = chooseResolver(config, platformModule.Logging); _topologyService = discoveryServiceFactory.CoreTopologyService(config, myself, platformModule.JobScheduler, logProvider, userLogProvider, remoteMembersResolver, ResolveStrategy(config, logProvider), monitors); life.Add(_topologyService); dependencies.SatisfyDependency(_topologyService); // for tests CoreBootstrapper coreBootstrapper = new CoreBootstrapper(databaseLayout, platformModule.PageCache, fileSystem, config, logProvider, platformModule.Monitors); SimpleStorage <ClusterId> clusterIdStorage = new SimpleFileStorage <ClusterId>(fileSystem, clusterStateDirectory, CLUSTER_ID_NAME, new ClusterId.Marshal(), logProvider); SimpleStorage <DatabaseName> dbNameStorage = new SimpleFileStorage <DatabaseName>(fileSystem, clusterStateDirectory, DB_NAME, new DatabaseName.Marshal(), logProvider); string dbName = config.Get(CausalClusteringSettings.database); int minimumCoreHosts = config.Get(CausalClusteringSettings.minimum_core_cluster_size_at_formation); Duration clusterBindingTimeout = config.Get(CausalClusteringSettings.cluster_binding_timeout); _clusterBinder = new ClusterBinder(clusterIdStorage, dbNameStorage, _topologyService, Clocks.systemClock(), () => sleep(100), clusterBindingTimeout, coreBootstrapper, dbName, minimumCoreHosts, platformModule.Monitors); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.kernel.impl.transaction.log.ReadableLogChannel openLogFile(org.neo4j.io.fs.FileSystemAbstraction fs, int version) throws java.io.IOException internal virtual ReadableLogChannel OpenLogFile(FileSystemAbstraction fs, int version) { LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(WorkingDirectory, fs).build(); PhysicalLogVersionedStoreChannel channel = logFiles.OpenForVersion(version); return(new ReadAheadLogChannel(channel, new ReaderLogVersionBridge(logFiles))); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private boolean isUnclean(org.neo4j.io.fs.FileSystemAbstraction fileSystem) throws java.io.IOException private bool IsUnclean(FileSystemAbstraction fileSystem) { PageCache pageCache = PageCacheRule.getPageCache(fileSystem); RecoveryRequiredChecker requiredChecker = new RecoveryRequiredChecker(fileSystem, pageCache, Config.defaults(), _monitors); return(requiredChecker.IsRecoveryRequiredAt(TestDirectory.databaseLayout())); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldWriteSomeDataIntoTheLog() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldWriteSomeDataIntoTheLog() { // GIVEN string name = "log"; FileSystemAbstraction fs = _fileSystemRule.get(); LogFiles logFiles = LogFilesBuilder.builder(_directory.databaseLayout(), fs).withTransactionIdStore(_transactionIdStore).withLogVersionRepository(_logVersionRepository).build(); _life.start(); _life.add(logFiles); // WHEN FlushablePositionAwareChannel writer = logFiles.LogFile.Writer; LogPositionMarker positionMarker = new LogPositionMarker(); writer.GetCurrentPosition(positionMarker); int intValue = 45; long longValue = 4854587; writer.PutInt(intValue); writer.PutLong(longValue); writer.PrepareForFlush().flush(); // THEN using (ReadableClosableChannel reader = logFiles.LogFile.getReader(positionMarker.NewPosition())) { assertEquals(intValue, reader.Int); assertEquals(longValue, reader.Long); } }