예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void delete(java.io.File storeDir, org.neo4j.kernel.impl.transaction.log.files.LogFiles logFiles) throws java.io.IOException
        public virtual void Delete(File storeDir, LogFiles logFiles)
        {
            // 'files' can be null if the directory doesn't exist. This is fine, we just ignore it then.
            File[] files = _fs.listFiles(storeDir, _fileFilter);
            if (files != null)
            {
                foreach (File file in files)
                {
                    _fs.deleteRecursively(file);
                }
            }

            File[] txLogs = _fs.listFiles(logFiles.LogFilesDirectory());
            if (txLogs != null)
            {
                foreach (File txLog in txLogs)
                {
                    _fs.deleteFile(txLog);
                }
            }

            IEnumerable <FileHandle> iterator = AcceptedPageCachedFiles(storeDir).iterator;

            foreach (FileHandle fh in iterator)
            {
                fh.Delete();
            }
        }
예제 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void moveTo(java.io.File source, java.io.File target, org.neo4j.kernel.impl.transaction.log.files.LogFiles logFiles) throws java.io.IOException
        public virtual void MoveTo(File source, File target, LogFiles logFiles)
        {
            _fs.mkdirs(logFiles.LogFilesDirectory());
            foreach (File candidate in _fs.listFiles(source, _fileFilter))
            {
                File destination = logFiles.IsLogFile(candidate) ? logFiles.LogFilesDirectory() : target;
                _fs.moveToDirectory(candidate, destination);
            }

            IEnumerable <FileHandle> fileHandles = AcceptedPageCachedFiles(source).iterator;

            foreach (FileHandle fh in fileHandles)
            {
                fh.Rename(new File(target, fh.RelativeFile.Path), StandardCopyOption.REPLACE_EXISTING);
            }
        }
예제 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void verifyLogFilesWithCustomPathListing(String path) throws java.io.IOException
        private void VerifyLogFilesWithCustomPathListing(string path)
        {
            GraphDatabaseAPI   graphDatabase = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(TestDirectory.databaseDir("customDb")).setConfig(GraphDatabaseSettings.logical_logs_location, path).newGraphDatabase();
            NeoStoreDataSource dataSource    = graphDatabase.DependencyResolver.resolveDependency(typeof(NeoStoreDataSource));
            LogFiles           logFiles      = graphDatabase.DependencyResolver.resolveDependency(typeof(LogFiles));

            assertTrue(dataSource.ListStoreFiles(true).Any(metadata => metadata.LogFile && logFiles.IsLogFile(metadata.file())));
            assertEquals(Paths.get(path).FileName.ToString(), logFiles.LogFilesDirectory().Name);
            graphDatabase.Shutdown();
        }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void clusterWithCustomTransactionLogLocation() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ClusterWithCustomTransactionLogLocation()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.causalclustering.discovery.Cluster<?> cluster = clusterRule.startCluster();
            Cluster <object> cluster = ClusterRule.startCluster();

            for (int i = 0; i < 10; i++)
            {
                cluster.CoreTx((db, tx) =>
                {
                    Db.createNode();
                    tx.success();
                });
            }

            ICollection <CoreClusterMember> coreClusterMembers = cluster.CoreMembers();

            foreach (CoreClusterMember coreClusterMember in coreClusterMembers)
            {
                DependencyResolver dependencyResolver = coreClusterMember.Database().DependencyResolver;
                LogFiles           logFiles           = dependencyResolver.ResolveDependency(typeof(LogFiles));
                assertEquals(logFiles.LogFilesDirectory().Name, "core-tx-logs-" + coreClusterMember.ServerId());
                assertTrue(logFiles.HasAnyEntries(0));
                File[] coreLogDirectories = coreClusterMember.DatabaseDirectory().listFiles(file => file.Name.StartsWith("core"));
                assertThat(coreLogDirectories, Matchers.arrayWithSize(1));

                LogFileInStoreDirectoryDoesNotExist(coreClusterMember.DatabaseDirectory(), dependencyResolver);
            }

            ICollection <ReadReplica> readReplicas = cluster.ReadReplicas();

            foreach (ReadReplica readReplica in readReplicas)
            {
                readReplica.TxPollingClient().upToDateFuture().get();
                DependencyResolver dependencyResolver = readReplica.Database().DependencyResolver;
                LogFiles           logFiles           = dependencyResolver.ResolveDependency(typeof(LogFiles));
                assertEquals(logFiles.LogFilesDirectory().Name, "replica-tx-logs-" + readReplica.ServerId());
                assertTrue(logFiles.HasAnyEntries(0));
                File[] replicaLogDirectories = readReplica.DatabaseDirectory().listFiles(file => file.Name.StartsWith("replica"));
                assertThat(replicaLogDirectories, Matchers.arrayWithSize(1));

                LogFileInStoreDirectoryDoesNotExist(readReplica.DatabaseDirectory(), dependencyResolver);
            }
        }