示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canBeEnabledAndDisabledAtRuntime() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CanBeEnabledAndDisabledAtRuntime()
        {
            _database = _databaseBuilder.setConfig(log_queries, Settings.FALSE).setConfig(GraphDatabaseSettings.log_queries_filename, _logFilename.Path).newGraphDatabase();
            IList <string> strings;

            try
            {
                _database.execute(QUERY).close();

                // File will not be created until query logging is enabled.
                assertFalse(FileSystem.fileExists(_logFilename));

                _database.execute("CALL dbms.setConfigValue('" + log_queries.name() + "', 'true')").close();
                _database.execute(QUERY).close();

                // Both config change and query should exist
                strings = ReadAllLines(_logFilename);
                assertEquals(2, strings.Count);

                _database.execute("CALL dbms.setConfigValue('" + log_queries.name() + "', 'false')").close();
                _database.execute(QUERY).close();
            }
            finally
            {
                _database.shutdown();
            }

            // Value should not change when disabled
            strings = ReadAllLines(_logFilename);
            assertEquals(2, strings.Count);
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void disabledQueryLogRotation() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void DisabledQueryLogRotation()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.File logsDirectory = new java.io.File(testDirectory.storeDir(), "logs");
            File logsDirectory = new File(TestDirectory.storeDir(), "logs");
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.File logFilename = new java.io.File(logsDirectory, "query.log");
            File logFilename = new File(logsDirectory, "query.log");
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.File shiftedLogFilename1 = new java.io.File(logsDirectory, "query.log.1");
            File shiftedLogFilename1 = new File(logsDirectory, "query.log.1");

            _database = _databaseBuilder.setConfig(log_queries, Settings.TRUE).setConfig(logs_directory, logsDirectory.Path).setConfig(log_queries_rotation_threshold, "0").newGraphDatabase();

            // Logging is done asynchronously, so write many times to make sure we would have rotated something
            for (int i = 0; i < 100; i++)
            {
                _database.execute(QUERY);
            }

            _database.shutdown();

            assertFalse("There should not exist a shifted log file because rotation is disabled", shiftedLogFilename1.exists());

            IList <string> lines = ReadAllLines(logFilename);

            assertEquals(100, lines.Count);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void addConcurrentlySameLabelToANode() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void AddConcurrentlySameLabelToANode()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long nodeId = initWithNode(db);
            long nodeId = InitWithNode(_db);

            Thread t1 = NewThreadForNodeAction(nodeId, node => node.addLabel(Label.label("A")));

            Thread t2 = NewThreadForNodeAction(nodeId, node => node.addLabel(Label.label("A")));

            StartAndWait(t1, t2);

            _db.shutdown();

            AssertDatabaseConsistent();
        }
示例#4
0
        private DbRepresentation CreateTransactionWithWeirdRelationshipGroupRecord(File path)
        {
            _db = StartGraphDatabase(path);
            int              i = 0;
            Node             node;
            RelationshipType typeToDelete = RelationshipType.withName("A");
            RelationshipType theOtherType = RelationshipType.withName("B");
            int              defaultDenseNodeThreshold = int.Parse(GraphDatabaseSettings.dense_node_threshold.DefaultValue);

            using (Transaction tx = _db.beginTx())
            {
                node = _db.createNode();
                for ( ; i < defaultDenseNodeThreshold - 1; i++)
                {
                    node.CreateRelationshipTo(_db.createNode(), theOtherType);
                }
                node.CreateRelationshipTo(_db.createNode(), typeToDelete);
                tx.Success();
            }
            using (Transaction tx = _db.beginTx())
            {
                node.CreateRelationshipTo(_db.createNode(), theOtherType);
                foreach (Relationship relationship in node.GetRelationships(Direction.BOTH, typeToDelete))
                {
                    relationship.Delete();
                }
                tx.Success();
            }
            DbRepresentation result = DbRepresentation.of(_db);

            _db.shutdown();
            return(result);
        }
示例#5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void tearDown()
        public virtual void TearDown()
        {
            if (_db != null)
            {
                _db.shutdown();
            }
            IOUtils.closeAllSilently(_driver);
        }
示例#6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @AfterClass public static void stopDb()
        public static void StopDb()
        {
            if (_graphdb != null)
            {
                _graphdb.shutdown();
            }
            _graphdb = null;
        }
示例#7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void tearDown()
        public virtual void TearDown()
        {
            if (_db != null)
            {
                _db.tearDown();
            }
            if (_database != null)
            {
                _database.shutdown();
            }
        }
示例#8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void after()
        public virtual void After()
        {
            if (_foreignInstance != null)
            {
                _foreignInstance.shutdown();
            }
            if (_firstInstance != null)
            {
                _firstInstance.shutdown();
            }
        }
示例#9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void tearDown()
        public virtual void TearDown()
        {
            try
            {
                _database.shutdown();
            }
            catch (Exception)
            {
                //ignore
            }
        }
示例#10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void shutItDown() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShutItDown()
        {
            if (_server != null)
            {
                ShutdownServer(_server);
                _server = null;
            }
            if (_db != null)
            {
                _db.shutdown();
                _db = null;
            }
        }
示例#11
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void dirtyDatabase() throws java.io.IOException
        private void DirtyDatabase()
        {
            _db = StartDatabase();

            DatabaseHealth databaseHealth = databaseHealth(_db);

            Index(_db);
            SomeData(_db);
            Checkpoint(_db);
            SomeData(_db);
            databaseHealth.Panic(new Exception("Trigger recovery on next startup"));
            _db.shutdown();
            _db = null;
        }
示例#12
0
        private DbRepresentation AddMoreData2(File path)
        {
            _db = StartGraphDatabase(path);
            using (Transaction tx = _db.beginTx())
            {
                Node donald    = _db.getNodeById(2);
                Node gladstone = _db.createNode();
                gladstone.SetProperty("name", "Gladstone");
                Relationship hates = donald.CreateRelationshipTo(gladstone, RelationshipType.withName("HATES"));
                hates.SetProperty("since", 1948);
                tx.Success();
            }
            DbRepresentation result = DbRepresentation.of(_db);

            _db.shutdown();
            return(result);
        }
示例#13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void queryLogRotation()
        public virtual void QueryLogRotation()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.File logsDirectory = new java.io.File(testDirectory.storeDir(), "logs");
            File logsDirectory = new File(TestDirectory.storeDir(), "logs");

            _databaseBuilder.setConfig(log_queries, Settings.TRUE).setConfig(logs_directory, logsDirectory.Path).setConfig(log_queries_max_archives, "100").setConfig(log_queries_rotation_threshold, "1");
            _database = _databaseBuilder.newGraphDatabase();

            // Logging is done asynchronously, and it turns out it's really hard to make it all work the same on Linux
            // and on Windows, so just write many times to make sure we rotate several times.

            for (int i = 0; i < 100; i++)
            {
                _database.execute(QUERY);
            }

            _database.shutdown();

            File[] queryLogs = FileSystem.get().listFiles(logsDirectory, (dir, name) => name.StartsWith("query.log"));
            assertThat("Expect to have more then one query log file.", queryLogs.Length, greaterThanOrEqualTo(2));

            IList <string> loggedQueries = java.util.queryLogs.Select(this.readAllLinesSilent).flatMap(System.Collections.ICollection.stream).ToList();

            assertThat("Expected log file to have at least one log entry", loggedQueries, hasSize(100));

            _database = _databaseBuilder.newGraphDatabase();
            // Now modify max_archives and rotation_threshold at runtime, and observe that we end up with fewer larger files
            _database.execute("CALL dbms.setConfigValue('" + log_queries_max_archives.name() + "','1')");
            _database.execute("CALL dbms.setConfigValue('" + log_queries_rotation_threshold.name() + "','20m')");
            for (int i = 0; i < 100; i++)
            {
                _database.execute(QUERY);
            }

            _database.shutdown();

            queryLogs = FileSystem.get().listFiles(logsDirectory, (dir, name) => name.StartsWith("query.log"));
            assertThat("Expect to have more then one query log file.", queryLogs.Length, lessThan(100));

            loggedQueries = java.util.queryLogs.Select(this.readAllLinesSilent).flatMap(System.Collections.ICollection.stream).ToList();
            assertThat("Expected log file to have at least one log entry", loggedQueries.Count, lessThanOrEqualTo(202));
        }
示例#14
0
        private DbRepresentation CreateInitialDataSet(File path)
        {
            _db = StartGraphDatabase(path);
            using (Transaction tx = _db.beginTx())
            {
                _db.createNode().setProperty("name", "Goofy");
                Node donald = _db.createNode();
                donald.SetProperty("name", "Donald");
                Node daisy = _db.createNode();
                daisy.SetProperty("name", "Daisy");
                Relationship knows = donald.CreateRelationshipTo(daisy, RelationshipType.withName("LOVES"));
                knows.SetProperty("since", 1940);
                tx.Success();
            }
            DbRepresentation result = DbRepresentation.of(_db);

            _db.shutdown();
            return(result);
        }
示例#15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @AfterClass public static void tearDownDb()
        public static void TearDownDb()
        {
            _graphDb.shutdown();
        }
示例#16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void tearDown()
        public virtual void TearDown()
        {
            _db.shutdown();
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void tearDown()
        public virtual void TearDown()
        {
            _database.shutdown();
        }
示例#18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @AfterEach void shutdownDb()
        internal virtual void ShutdownDb()
        {
            _db.shutdown();
        }
示例#19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void tearDown()
        public virtual void TearDown()
        {
            _graphDatabaseService.shutdown();
        }
示例#20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void tearDown()
        public virtual void TearDown()
        {
            _tx.close();
            _gdb.shutdown();
        }
示例#21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void shutdown()
        public virtual void Shutdown()
        {
            _graphDb.shutdown();
        }
示例#22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @AfterClass public static void tearDownStuff()
        public static void TearDownStuff()
        {
            _graphDb.shutdown();
        }
示例#23
0
 public override void TearDown()
 {
     _db.shutdown();
     _db = null;
 }
示例#24
0
 private void ExecuteSingleQueryWithTimeZoneLog()
 {
     _database = _databaseBuilder.setConfig(log_queries, Settings.TRUE).setConfig(GraphDatabaseSettings.db_timezone, LogTimeZone.SYSTEM.name()).setConfig(logs_directory, _logsDirectory.Path).newGraphDatabase();
     _database.execute(QUERY).close();
     _database.shutdown();
 }
示例#25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void after()
        public virtual void After()
        {
            _db.shutdown();
        }
示例#26
0
 public virtual void Shutdown()
 {
     _gds.shutdown();
 }
示例#27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @AfterClass public static void tearDown()
        public static void TearDown()
        {
            _executorService.shutdown();
            _database.shutdown();
        }
示例#28
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @AfterClass public static void tearDownGraphDb()
        public static void TearDownGraphDb()
        {
            GraphDb.shutdown();
        }