コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void allClusterNodesShouldSupportTheBuiltInProcedures() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void AllClusterNodesShouldSupportTheBuiltInProcedures()
            {
                ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();
                try
                {
                    foreach (HighlyAvailableGraphDatabase gdb in cluster.AllMembers)
                    {
                        {
                            // (1) BuiltInProcedures from community
                            Result result = gdb.Execute("CALL dbms.procedures()");
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                            assertTrue(result.HasNext());
                            result.Close();
                        }

                        // (2) BuiltInProcedures from enterprise
                        using (InternalTransaction tx = gdb.BeginTransaction(KernelTransaction.Type.@explicit, EnterpriseLoginContext.AUTH_DISABLED))
                        {
                            Result result = gdb.execute(tx, "CALL dbms.listQueries()", EMPTY_MAP);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                            assertTrue(result.HasNext());
                            result.Close();

                            tx.Success();
                        }
                    }
                }
                finally
                {
                    cluster.Shutdown();
                }
            }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleSlaveWritingFirstAfterStoryCopy() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHandleSlaveWritingFirstAfterStoryCopy()
        {
            // Given
            ISet <long> expected = new HashSet <object>();

            ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();
            HighlyAvailableGraphDatabase  master  = cluster.Master;
            HighlyAvailableGraphDatabase  slave   = cluster.AnySlave;

            // When
            expected.Add(CreateOneNode(master));
            cluster.Sync();

            // ... crash the slave
            File slaveStoreDirectory = cluster.GetDatabaseDir(slave);

            ClusterManager.RepairKit shutdownSlave = cluster.Shutdown(slave);
            deleteRecursively(slaveStoreDirectory);

            // ... and slave copy store from master
            slave = shutdownSlave.Repair();
            // ... and first write after crash occurs on salve
            expected.Add(CreateOneNode(slave));
            cluster.Sync();

            // Then
            assertEquals(expected, CollectIds(master));
            assertEquals(expected, CollectIds(slave));
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void given4instanceClusterWhenMasterGoesDownThenElectNewMaster() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Given4instanceClusterWhenMasterGoesDownThenElectNewMaster()
        {
            ClusterManager clusterManager = (new ClusterManager.Builder(TestDirectory.directory(TestName.MethodName))).withCluster(ClusterManager.clusterOfSize(4)).build();

            try
            {
                clusterManager.Start();
                ClusterManager.ManagedCluster cluster = clusterManager.Cluster;
                cluster.Await(allSeesAllAsAvailable());

                Logging.Logger.info("STOPPING MASTER");
                cluster.Shutdown(cluster.Master);
                Logging.Logger.info("STOPPED MASTER");

                cluster.Await(ClusterManager.masterAvailable());

                GraphDatabaseService master = cluster.Master;
                Logging.Logger.info("CREATE NODE");
                using (Transaction tx = master.BeginTx())
                {
                    master.CreateNode();
                    Logging.Logger.info("CREATED NODE");
                    tx.Success();
                }

                Logging.Logger.info("STOPPING CLUSTER");
            }
            finally
            {
                clusterManager.SafeShutdown();
            }
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCopyStoreFromMasterIfBranched() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCopyStoreFromMasterIfBranched()
        {
            // GIVEN
            File           dir            = _directory.directory();
            ClusterManager clusterManager = _life.add(new ClusterManager.Builder(dir)
                                                      .withCluster(clusterOfSize(2)).build());

            ClusterManager.ManagedCluster cluster = clusterManager.Cluster;
            cluster.Await(allSeesAllAsAvailable());
            CreateNode(cluster.Master, "A");
            cluster.Sync();

            // WHEN
            HighlyAvailableGraphDatabase slave = cluster.AnySlave;
            File databaseDir = slave.DatabaseLayout().databaseDirectory();

            ClusterManager.RepairKit     starter = cluster.Shutdown(slave);
            HighlyAvailableGraphDatabase master  = cluster.Master;

            CreateNode(master, "B1");
            CreateNode(master, "C");
            CreateNodeOffline(databaseDir, "B2");
            slave = starter.Repair();

            // THEN
            cluster.Await(allSeesAllAsAvailable());
            slave.BeginTx().close();
        }
コード例 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void newSlaveJoiningClusterShouldNotAcceptOperationsUntilConstraintIsOnline() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void NewSlaveJoiningClusterShouldNotAcceptOperationsUntilConstraintIsOnline()
            {
                // Given
                ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();
                string type = type(4);
                string key  = key(4);

                HighlyAvailableGraphDatabase master = cluster.Master;

                HighlyAvailableGraphDatabase slave = cluster.AnySlave;
                File slaveStoreDirectory           = cluster.GetDatabaseDir(slave);

                // Crash the slave
                ClusterManager.RepairKit shutdownSlave = cluster.Shutdown(slave);
                deleteRecursively(slaveStoreDirectory);

                using (Transaction tx = master.BeginTx())
                {
                    CreateConstraint(master, type, key);
                    tx.Success();
                }

                // When
                slave = shutdownSlave.Repair();

                // Then
                using (Transaction ignored = slave.BeginTx())
                {
                    ConstraintDefinition definition = GetConstraint(slave, type, key);
                    assertThat(definition, instanceOf(ConstraintDefinitionClass()));
                    assertThat(single(definition.PropertyKeys), equalTo(key));
                    ValidateLabelOrRelationshipType(definition, type);
                }
            }
コード例 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateConstraintOnMaster()
            public virtual void ShouldCreateConstraintOnMaster()
            {
                // given
                ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();
                HighlyAvailableGraphDatabase  master  = cluster.Master;
                string type = type(0);
                string key  = key(0);

                // when
                using (Transaction tx = master.BeginTx())
                {
                    CreateConstraint(master, type, key);
                    tx.Success();
                }

                cluster.Sync();

                // then
                foreach (HighlyAvailableGraphDatabase clusterMember in cluster.AllMembers)
                {
                    using (Transaction tx = clusterMember.BeginTx())
                    {
                        ConstraintDefinition constraint = GetConstraint(clusterMember, type, key);
                        ValidateLabelOrRelationshipType(constraint, type);
                        assertEquals(key, single(constraint.PropertyKeys));
                        tx.Success();
                    }
                }
            }
コード例 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void updatePullerSwitchOnNodeModeSwitch() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UpdatePullerSwitchOnNodeModeSwitch()
        {
            ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();

            Label firstLabel = Label.label("firstLabel");

            CreateLabeledNodeOnMaster(cluster, firstLabel);
            // force update puller to work
            PullUpdatesOnSlave(cluster);
            // node should exist on slave now
            CheckLabeledNodeExistenceOnSlave(cluster, firstLabel);
            // verify that puller working on slave and not working on master
            VerifyUpdatePullerThreads(cluster);

            for (int i = 1; i <= 2; i++)
            {
                // switch roles in cluster - now update puller should be stopped on old slave and start on old master.
                ClusterManager.RepairKit repairKit = cluster.Shutdown(cluster.Master);
                cluster.Await(masterAvailable());

                Label currentLabel = Label.label("label_" + i);

                CreateLabeledNodeOnMaster(cluster, currentLabel);

                repairKit.Repair();
                cluster.Await(allSeesAllAsAvailable(), 120);

                // forcing updates pulling
                PullUpdatesOnSlave(cluster);
                CheckLabeledNodeExistenceOnSlave(cluster, currentLabel);
                // checking pulling threads
                VerifyUpdatePullerThreads(cluster);
            }
        }
コード例 #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void lastTxCommitTimestampShouldBeUnknownAfterStartIfNoFiledOrLogsPresent() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void LastTxCommitTimestampShouldBeUnknownAfterStartIfNoFiledOrLogsPresent()
        {
            ClusterManager clusterManager = (new ClusterManager.Builder(TestDirectory.directory(TestName.MethodName))).withCluster(ClusterManager.clusterOfSize(3)).build();

            try
            {
                clusterManager.Start();
                ClusterManager.ManagedCluster cluster = clusterManager.Cluster;
                cluster.Await(allSeesAllAsAvailable());

                RunSomeTransactions(cluster.Master);
                cluster.Sync();

                HighlyAvailableGraphDatabase slave      = cluster.AnySlave;
                DatabaseLayout           databaseLayout = slave.DatabaseLayout();
                ClusterManager.RepairKit slaveRepairKit = cluster.Shutdown(slave);

                ClearLastTransactionCommitTimestampField(databaseLayout);
                DeleteLogs(databaseLayout);

                HighlyAvailableGraphDatabase repairedSlave = slaveRepairKit.Repair();
                cluster.Await(allSeesAllAsAvailable());

                assertEquals(Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.UNKNOWN_TX_COMMIT_TIMESTAMP, LastCommittedTxTimestamp(repairedSlave));
            }
            finally
            {
                clusterManager.Stop();
            }
        }
コード例 #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void terminatedTransactionDoesNotForceUpdatePulling()
        public virtual void TerminatedTransactionDoesNotForceUpdatePulling()
        {
            int testTxsOnMaster = 42;

            ClusterManager.ManagedCluster cluster = ClusterRule.withSharedSetting(HaSettings.pull_interval, "0s").withSharedSetting(HaSettings.tx_push_factor, "0").startCluster();

            HighlyAvailableGraphDatabase master = cluster.Master;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.ha.HighlyAvailableGraphDatabase slave = cluster.getAnySlave();
            HighlyAvailableGraphDatabase slave = cluster.AnySlave;

            CreateNodeOn(master);
            cluster.Sync();

            long lastClosedTxIdOnMaster = LastClosedTxIdOn(master);
            long lastClosedTxIdOnSlave  = LastClosedTxIdOn(slave);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.CountDownLatch slaveTxStarted = new java.util.concurrent.CountDownLatch(1);
            System.Threading.CountdownEvent slaveTxStarted = new System.Threading.CountdownEvent(1);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.CountDownLatch slaveShouldCommit = new java.util.concurrent.CountDownLatch(1);
            System.Threading.CountdownEvent slaveShouldCommit = new System.Threading.CountdownEvent(1);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicReference<org.neo4j.graphdb.Transaction> slaveTx = new java.util.concurrent.atomic.AtomicReference<>();
            AtomicReference <Transaction> slaveTx = new AtomicReference <Transaction>();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.concurrent.Future<?> slaveCommit = java.util.concurrent.Executors.newSingleThreadExecutor().submit(() ->
            Future <object> slaveCommit = Executors.newSingleThreadExecutor().submit(() =>
            {
                using (Transaction tx = slave.BeginTx())
                {
                    slaveTx.set(tx);
                    slaveTxStarted.Signal();
                    Await(slaveShouldCommit);
                    tx.success();
                }
            });

            Await(slaveTxStarted);
            CreateNodesOn(master, testTxsOnMaster);

            assertNotNull(slaveTx.get());
            slaveTx.get().terminate();
            slaveShouldCommit.Signal();

            try
            {
                slaveCommit.get();
                fail("Exception expected");
            }
            catch (Exception e)
            {
                assertThat(e, instanceOf(typeof(ExecutionException)));
                assertThat(e.InnerException, instanceOf(typeof(TransientTransactionFailureException)));
            }

            assertEquals(lastClosedTxIdOnMaster + testTxsOnMaster, LastClosedTxIdOn(master));
            assertEquals(lastClosedTxIdOnSlave, LastClosedTxIdOn(slave));
        }
コード例 #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void makeSureUpdatePullerGetsGoingAfterMasterSwitch() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MakeSureUpdatePullerGetsGoingAfterMasterSwitch()
        {
            ClusterManager.ManagedCluster cluster = ClusterRule.withSharedSetting(HaSettings.pull_interval, PULL_INTERVAL + "ms").startCluster();

            cluster.Info("### Creating initial dataset");
            long commonNodeId = CreateNodeOnMaster(cluster);

            HighlyAvailableGraphDatabase master = cluster.Master;

            SetProperty(master, commonNodeId, 1);
            cluster.Info("### Initial dataset created");
            AwaitPropagation(1, commonNodeId, cluster);

            cluster.Info("### Shutting down master");
            ClusterManager.RepairKit masterShutdownRK = cluster.Shutdown(master);

            cluster.Info("### Awaiting new master");
            cluster.Await(masterAvailable(master));
            cluster.Await(masterSeesSlavesAsAvailable(1));

            cluster.Info("### Doing a write to master");
            SetProperty(cluster.Master, commonNodeId, 2);
            AwaitPropagation(2, commonNodeId, cluster, master);

            cluster.Info("### Repairing cluster");
            masterShutdownRK.Repair();
            cluster.Await(masterAvailable());
            cluster.Await(masterSeesSlavesAsAvailable(2));
            cluster.Await(allSeesAllAsAvailable());

            cluster.Info("### Awaiting change propagation");
            AwaitPropagation(2, commonNodeId, cluster);
        }
コード例 #11
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void assertAllStoreConsistent(org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster cluster) throws org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException
        private static void AssertAllStoreConsistent(ClusterManager.ManagedCluster cluster)
        {
            foreach (HighlyAvailableGraphDatabase slave in cluster.AllMembers)
            {
                assertConsistentStore(slave.DatabaseLayout());
            }
        }
コード例 #12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void testFailOver(int clusterSize) throws Throwable
        private void TestFailOver(int clusterSize)
        {
            // given
            ClusterManager clusterManager = (new ClusterManager.Builder()).withRootDirectory(Dir.cleanDirectory("failover")).withCluster(ClusterManager.clusterOfSize(clusterSize)).build();

            clusterManager.Start();
            ClusterManager.ManagedCluster cluster = clusterManager.Cluster;

            cluster.Await(ClusterManager.allSeesAllAsAvailable());
            HighlyAvailableGraphDatabase oldMaster = cluster.Master;

            // When
            long start = System.nanoTime();

            ClusterManager.RepairKit repairKit = cluster.Fail(oldMaster);
            Logger.Logger.warning("Shut down master");

            // Then
            cluster.Await(ClusterManager.masterAvailable(oldMaster));
            long end = System.nanoTime();

            Logger.Logger.warning("Failover took:" + (end - start) / 1000000 + "ms");

            repairKit.Repair();
            Thread.Sleep(3000);                 // give repaired instance chance to cleanly rejoin and exit faster

            clusterManager.SafeShutdown();
        }
コード例 #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void lastTxCommitTimestampShouldGetInitializedOnSlaveIfNotPresent() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void LastTxCommitTimestampShouldGetInitializedOnSlaveIfNotPresent()
        {
            ClusterManager clusterManager = (new ClusterManager.Builder(TestDirectory.directory(TestName.MethodName))).withCluster(ClusterManager.clusterOfSize(3)).build();

            try
            {
                clusterManager.Start();
                ClusterManager.ManagedCluster cluster = clusterManager.Cluster;
                cluster.Await(allSeesAllAsAvailable());

                RunSomeTransactions(cluster.Master);
                cluster.Sync();

                HighlyAvailableGraphDatabase slave      = cluster.AnySlave;
                DatabaseLayout           databaseLayout = slave.DatabaseLayout();
                ClusterManager.RepairKit slaveRepairKit = cluster.Shutdown(slave);

                ClearLastTransactionCommitTimestampField(databaseLayout);

                HighlyAvailableGraphDatabase repairedSlave = slaveRepairKit.Repair();
                cluster.Await(allSeesAllAsAvailable());

                assertEquals(LastCommittedTxTimestamp(cluster.Master), LastCommittedTxTimestamp(repairedSlave));
            }
            finally
            {
                clusterManager.Stop();
            }
        }
コード例 #14
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void awaitIndexOnline(org.neo4j.graphdb.schema.IndexDefinition index, org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster cluster, java.util.Map<Object,org.neo4j.graphdb.Node> expectedDdata) throws InterruptedException
        private static void AwaitIndexOnline(IndexDefinition index, ClusterManager.ManagedCluster cluster, IDictionary <object, Node> expectedDdata)
        {
            foreach (GraphDatabaseService db in cluster.AllMembers)
            {
                AwaitIndexOnline(index, db, expectedDdata);
            }
        }
コード例 #15
0
 public virtual void ShutdownCluster()
 {
     if (_clusterManager != null)
     {
         _clusterManager.safeShutdown();
         _cluster = null;
     }
 }
コード例 #16
0
        private ClusterManager.ManagedCluster StartCluster()
        {
            _clusterRule.withSharedSetting(GraphDatabaseSettings.lock_manager, LockManagerName);

            ClusterManager.ManagedCluster cluster = _clusterRule.startCluster();
            cluster.Await(ClusterManager.allSeesAllAsAvailable());
            return(cluster);
        }
コード例 #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("ResultOfMethodCallIgnored") private org.neo4j.kernel.impl.ha.ClusterManager.RepairKit bringSlaveOfflineAndRemoveStoreFiles(org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster cluster, org.neo4j.kernel.ha.HighlyAvailableGraphDatabase slave) throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        private ClusterManager.RepairKit BringSlaveOfflineAndRemoveStoreFiles(ClusterManager.ManagedCluster cluster, HighlyAvailableGraphDatabase slave)
        {
            ClusterManager.RepairKit slaveDown = cluster.Shutdown(slave);

            File databaseDir = slave.DatabaseLayout().databaseDirectory();

            deleteRecursively(databaseDir);
            databaseDir.mkdir();
            return(slaveDown);
        }
コード例 #18
0
        private void CreateLabeledNodeOnMaster(ClusterManager.ManagedCluster cluster, Label label)
        {
            HighlyAvailableGraphDatabase master = cluster.Master;

            using (Transaction transaction = master.BeginTx())
            {
                Node masterNode = master.CreateNode();
                masterNode.AddLabel(label);
                transaction.Success();
            }
        }
コード例 #19
0
        private void CheckLabeledNodeExistenceOnSlave(ClusterManager.ManagedCluster cluster, Label label)
        {
            HighlyAvailableGraphDatabase slave = cluster.AnySlave;

            using (Transaction transaction = slave.BeginTx())
            {
                ResourceIterator <Node> slaveNodes = slave.FindNodes(label);
                assertEquals(1, Iterators.asList(slaveNodes).Count);
                transaction.Success();
            }
        }
コード例 #20
0
        private void VerifyUpdatePullerThreads(ClusterManager.ManagedCluster cluster)
        {
            IDictionary <Thread, StackTraceElement[]> threads = Thread.AllStackTraces;
            Optional <KeyValuePair <Thread, StackTraceElement[]> > masterEntry = FindThreadWithPrefix(threads, UPDATE_PULLER_THREAD_PREFIX + ServerId(cluster.Master));

            assertFalse(format("Found an update puller on master.%s", masterEntry.map(this.prettyPrint).orElse("")), masterEntry.Present);

            Optional <KeyValuePair <Thread, StackTraceElement[]> > slaveEntry = FindThreadWithPrefix(threads, UPDATE_PULLER_THREAD_PREFIX + ServerId(cluster.AnySlave));

            assertTrue("Found no update puller on slave", slaveEntry.Present);
        }
コード例 #21
0
        private ClusterManager.RepairKit KillIncrementally(ClusterManager.ManagedCluster cluster, HighlyAvailableGraphDatabase failed1, HighlyAvailableGraphDatabase failed2, HighlyAvailableGraphDatabase failed3)
        {
            ClusterManager.RepairKit firstFailure = cluster.Fail(failed1);
            cluster.Await(instanceEvicted(failed1));
            cluster.Fail(failed2);
            cluster.Await(instanceEvicted(failed2));
            cluster.Fail(failed3);
            cluster.Await(instanceEvicted(failed3));

            return(firstFailure);
        }
コード例 #22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void migratingOlderDataAndThanStartAClusterUsingTheNewerDataShouldWork() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void MigratingOlderDataAndThanStartAClusterUsingTheNewerDataShouldWork()
            {
                // migrate the store using a single instance
                File storeDir                = TestDir.storeDir("initialData");
                File databaseDirectory       = Store.prepareDirectory(TestDir.databaseDir(storeDir));
                GraphDatabaseFactory factory = new TestGraphDatabaseFactory();
                GraphDatabaseBuilder builder = factory.NewEmbeddedDatabaseBuilder(databaseDirectory);

                builder.SetConfig(GraphDatabaseSettings.allow_upgrade, "true");
                builder.SetConfig(GraphDatabaseSettings.pagecache_memory, "8m");
                builder.setConfig(GraphDatabaseSettings.logs_directory, TestDir.directory("logs").AbsolutePath);
                builder.SetConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE);
                GraphDatabaseService db = builder.NewGraphDatabase();

                try
                {
                    CheckInstance(Store, ( GraphDatabaseAPI )db);
                }
                finally
                {
                    Db.shutdown();
                }

                assertConsistentStore(DatabaseLayout.of(databaseDirectory));

                // start the cluster with the db migrated from the old instance
                File           haDir          = TestDir.storeDir("ha-stuff");
                ClusterManager clusterManager = (new ClusterManager.Builder(haDir)).withSeedDir(databaseDirectory).withCluster(clusterOfSize(2)).build();

                HighlyAvailableGraphDatabase master;
                HighlyAvailableGraphDatabase slave;

                try
                {
                    clusterManager.Start();
                    ClusterManager.ManagedCluster cluster = clusterManager.Cluster;

                    cluster.Await(allSeesAllAsAvailable());

                    master = cluster.Master;
                    CheckInstance(Store, master);
                    slave = cluster.AnySlave;
                    CheckInstance(Store, slave);
                    clusterManager.SafeShutdown();

                    assertConsistentStore(master.DatabaseLayout());
                    assertConsistentStore(slave.DatabaseLayout());
                }
                finally
                {
                    clusterManager.SafeShutdown();
                }
            }
コード例 #23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldContinueServingBoltRequestsBetweenInternalRestarts() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldContinueServingBoltRequestsBetweenInternalRestarts()
        {
            // given

            /*
             * Interestingly, it is enough to simply start a slave and then direct sessions to it. The problem seems
             * to arise immediately, since simply from startup to being into SLAVE at least one internal restart happens
             * and that seems sufficient to break the bolt server.
             * However, that would make the test really weird, so we'll start the cluster, make sure we can connect and
             * then isolate the slave, make it shutdown internally, then have it rejoin and it will switch to slave.
             * At the end of this process, it must still be possible to open and execute transactions against the instance.
             */
            ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();
            HighlyAvailableGraphDatabase  slave1  = cluster.AnySlave;

            Driver driver = GraphDatabase.driver(cluster.GetBoltAddress(slave1), AuthTokens.basic("neo4j", "neo4j"));

            /*
             * We'll use a bookmark to enforce use of kernel internals by the bolt server, to make sure that parts that are
             * switched during an internal restart are actually refreshed. Technically, this is not necessary, since the
             * bolt server makes such use for every request. But this puts a nice bow on top of it.
             */
            string lastBookmark = InExpirableSession(driver, Driver.session, s =>
            {
                using (Transaction tx = s.beginTransaction())
                {
                    tx.run("CREATE (person:Person {name: {name}, title: {title}})", parameters("name", "Webber", "title", "Mr"));
                    tx.success();
                }
                return(s.lastBookmark());
            });

            // when
            ClusterManager.RepairKit slaveFailRK = cluster.Fail(slave1);

            cluster.Await(entireClusterSeesMemberAsNotAvailable(slave1));
            slaveFailRK.Repair();
            cluster.Await(masterSeesMembers(3));

            // then
            int?count = InExpirableSession(driver, Driver.session, s =>
            {
                Record record;
                using (Transaction tx = s.beginTransaction(lastBookmark))
                {
                    record = tx.run("MATCH (n:Person) RETURN COUNT(*) AS count").next();
                    tx.success();
                }
                return(record.get("count").asInt());
            });

            assertEquals(1, count.Value);
        }
コード例 #24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void onlineSchemaIndicesOnMasterShouldBeBroughtOnlineOnSlavesAfterStoreCopy() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void OnlineSchemaIndicesOnMasterShouldBeBroughtOnlineOnSlavesAfterStoreCopy()
        {
            /*
             * The master has an index that is online.
             * Then a slave comes online and contacts the master to get copies of the store files.
             * Because the index is online, it should be copied, and the slave should successfully bring the index online.
             */

            // GIVEN
            ControlledGraphDatabaseFactory dbFactory = new ControlledGraphDatabaseFactory();

            ClusterManager.ManagedCluster cluster = ClusterRule.withDbFactory(dbFactory).withSharedSetting(GraphDatabaseSettings.default_schema_provider, _controlledProviderDescriptor.name()).startCluster();
            cluster.Await(allSeesAllAsAvailable(), 120);

            HighlyAvailableGraphDatabase slave = cluster.AnySlave;

            // All slaves in the cluster, except the one I care about, proceed as normal
            ProceedAsNormalWithIndexPopulationOnAllSlavesExcept(dbFactory, cluster, slave);

            // A slave is offline, and has no store files
            ClusterManager.RepairKit slaveDown = BringSlaveOfflineAndRemoveStoreFiles(cluster, slave);

            // And I create an index on the master, and wait for population to start
            HighlyAvailableGraphDatabase master = cluster.Master;
            IDictionary <object, Node>   data   = CreateSomeData(master);

            CreateIndex(master);
            dbFactory.AwaitPopulationStarted(master);

            // And the population finishes
            dbFactory.TriggerFinish(master);
            IndexDefinition index;

            using (Transaction tx = master.BeginTx())
            {
                index = single(master.Schema().Indexes);
                AwaitIndexOnline(index, master, data);
                tx.Success();
            }

            // WHEN the slave comes online after population has finished on the master
            slave = slaveDown.Repair();
            cluster.Await(allSeesAllAsAvailable());
            cluster.Sync();

            // THEN the index should work on the slave
            dbFactory.TriggerFinish(slave);
            using (Transaction tx = slave.BeginTx())
            {
                AwaitIndexOnline(index, slave, data);
                tx.Success();
            }
        }
コード例 #25
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void restartingTheClusterShouldWork(org.neo4j.test.ha.ClusterRule clusterRule) throws Exception
        private static void RestartingTheClusterShouldWork(ClusterRule clusterRule)
        {
            ClusterManager.ManagedCluster cluster = clusterRule.StartCluster();
            try
            {
                cluster.Await(allSeesAllAsAvailable(), 180);
            }
            finally
            {
                clusterRule.ShutdownCluster();
            }

            AssertAllStoreConsistent(cluster);
        }
コード例 #26
0
		 private HighlyAvailableGraphDatabase GetNthSlave( ClusterManager.ManagedCluster cluster, int slaveOrder )
		 {
			  Debug.Assert( slaveOrder > 0 );
			  HighlyAvailableGraphDatabase slave = null;

			  IList<HighlyAvailableGraphDatabase> excluded = new List<HighlyAvailableGraphDatabase>();
			  while ( slaveOrder-- > 0 )
			  {
					slave = cluster.GetAnySlave( ToArray( excluded ) );
					excluded.Add( slave );
			  }

			  return slave;
		 }
コード例 #27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void creatingIndexOnMasterShouldHaveSlavesBuildItAsWell() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CreatingIndexOnMasterShouldHaveSlavesBuildItAsWell()
        {
            // GIVEN
            ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();
            HighlyAvailableGraphDatabase  master  = cluster.Master;
            IDictionary <object, Node>    data    = CreateSomeData(master);

            // WHEN
            IndexDefinition index = CreateIndex(master);

            cluster.Sync();

            // THEN
            AwaitIndexOnline(index, cluster, data);
        }
コード例 #28
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void reelectTheSameMasterMakingItGoToPendingAndBack(org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster cluster) throws Throwable
        private void ReelectTheSameMasterMakingItGoToPendingAndBack(ClusterManager.ManagedCluster cluster)
        {
            HighlyAvailableGraphDatabase master = cluster.Master;

            // Fail master and wait for master to go to pending, since it detects it's partitioned away
            ClusterManager.RepairKit masterRepair = cluster.Fail(master, false, ClusterManager.NetworkFlag.IN, ClusterManager.NetworkFlag.OUT);
            cluster.Await(memberThinksItIsRole(master, UNKNOWN));

            // Then Immediately repair
            masterRepair.Repair();

            // Wait for this instance to go to master again, since the other instances are slave only
            cluster.Await(memberThinksItIsRole(master, MASTER));
            cluster.Await(ClusterManager.masterAvailable());
            assertEquals(master, cluster.Master);
        }
コード例 #29
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void creatingIndexOnSlaveIsNotAllowed()
        public virtual void CreatingIndexOnSlaveIsNotAllowed()
        {
            // GIVEN
            ClusterManager.ManagedCluster cluster = ClusterRule.startCluster();
            HighlyAvailableGraphDatabase  slave   = cluster.AnySlave;

            // WHEN
            try
            {
                CreateIndex(slave);
                fail("should have thrown exception");
            }
            catch (ConstraintViolationException)
            {
                // expected
            }
        }
コード例 #30
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void indexPopulationJobsShouldContinueThroughRoleSwitch() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void IndexPopulationJobsShouldContinueThroughRoleSwitch()
        {
            // GIVEN a cluster of 3
            ControlledGraphDatabaseFactory dbFactory = new ControlledGraphDatabaseFactory();

            ClusterManager.ManagedCluster cluster     = ClusterRule.withDbFactory(dbFactory).withSharedSetting(GraphDatabaseSettings.default_schema_provider, _controlledProviderDescriptor.name()).startCluster();
            HighlyAvailableGraphDatabase  firstMaster = cluster.Master;

            // where the master gets some data created as well as an index
            IDictionary <object, Node> data = CreateSomeData(firstMaster);

            CreateIndex(firstMaster);
            //dbFactory.awaitPopulationStarted( firstMaster );
            dbFactory.TriggerFinish(firstMaster);

            // Pick a slave, pull the data and the index
            HighlyAvailableGraphDatabase aSlave = cluster.AnySlave;

            aSlave.DependencyResolver.resolveDependency(typeof(UpdatePuller)).pullUpdates();

            // and await the index population to start. It will actually block as long as we want it to
            dbFactory.AwaitPopulationStarted(aSlave);

            // WHEN we shut down the master
            cluster.Shutdown(firstMaster);

            dbFactory.TriggerFinish(aSlave);
            cluster.Await(masterAvailable(firstMaster));
            // get the new master, which should be the slave we pulled from above
            HighlyAvailableGraphDatabase newMaster = cluster.Master;

            // THEN
            assertEquals("Unexpected new master", aSlave, newMaster);
            using (Transaction tx = newMaster.BeginTx())
            {
                IndexDefinition index = single(newMaster.Schema().Indexes);
                AwaitIndexOnline(index, newMaster, data);
                tx.Success();
            }
            // FINALLY: let all db's finish
            foreach (HighlyAvailableGraphDatabase db in cluster.AllMembers)
            {
                dbFactory.TriggerFinish(db);
            }
        }