Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void backupRenamesWork()
        public virtual void BackupRenamesWork()
        {
            // given a prexisting backup from a different store
            string backupName      = "preexistingBackup_" + RecordFormat;
            int    firstBackupPort = PortAuthority.allocatePort();

            StartDb(firstBackupPort);
            CreateSpecificNodePair(_db, "first");

            assertEquals(0, RunSameJvm(_backupDir, backupName, "--from", "127.0.0.1:" + firstBackupPort, "--cc-report-dir=" + _backupDir, "--protocol=common", "--backup-dir=" + _backupDir, "--name=" + backupName));
            DbRepresentation firstDatabaseRepresentation = DbRepresentation.of(_db);

            // and a different database
            int secondBackupPort     = PortAuthority.allocatePort();
            GraphDatabaseService db2 = CreateDb2(secondBackupPort);

            CreateSpecificNodePair(db2, "second");
            DbRepresentation secondDatabaseRepresentation = DbRepresentation.of(db2);

            // when backup is performed
            assertEquals(0, RunSameJvm(_backupDir, backupName, "--from", "127.0.0.1:" + secondBackupPort, "--cc-report-dir=" + _backupDir, "--backup-dir=" + _backupDir, "--protocol=common", "--name=" + backupName));

            // then the new backup has the correct name
            assertEquals(secondDatabaseRepresentation, GetBackupDbRepresentation(backupName));

            // and the old backup is in a renamed location
            assertEquals(firstDatabaseRepresentation, GetBackupDbRepresentation(backupName + ".err.0"));

            // and the data isn't equal (sanity check)
            assertNotEquals(firstDatabaseRepresentation, secondDatabaseRepresentation);
            db2.Shutdown();
        }
Пример #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public ClusterNetworkIT(int nrOfServers, ClusterTestScript script) throws java.net.URISyntaxException
        public ClusterNetworkIT(int nrOfServers, ClusterTestScript script)
        {
            this._script = script;

            @out.Clear();
            @in.Clear();

            for (int i = 0; i < nrOfServers; i++)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.net.URI uri = new java.net.URI("neo4j://localhost:" + org.neo4j.ports.allocation.PortAuthority.allocatePort());
                URI uri = new URI("neo4j://localhost:" + PortAuthority.allocatePort());

                Monitors monitors = new Monitors();
                NetworkedServerFactory factory = new NetworkedServerFactory(_life, new MultiPaxosServerFactory(new ClusterConfiguration("default", NullLogProvider.Instance), NullLogProvider.Instance, monitors.NewMonitor(typeof(StateMachines.Monitor))), new FixedTimeoutStrategy(1000), NullLogProvider.Instance, new ObjectStreamFactory(), new ObjectStreamFactory(), monitors.NewMonitor(typeof(NetworkReceiver.Monitor)), monitors.NewMonitor(typeof(NetworkSender.Monitor)), monitors.NewMonitor(typeof(NamedThreadFactory.Monitor)));

                ServerIdElectionCredentialsProvider electionCredentialsProvider = new ServerIdElectionCredentialsProvider();
                ProtocolServer server = factory.NewNetworkedServer(Config.defaults(MapUtil.stringMap(ClusterSettings.cluster_server.name(), uri.Host + ":" + uri.Port, ClusterSettings.server_id.name(), "" + i)), new InMemoryAcceptorInstanceStore(), electionCredentialsProvider);
                server.AddBindingListener(electionCredentialsProvider);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Cluster cluster2 = server.newClient(Cluster.class);
                Cluster cluster2 = server.NewClient(typeof(Cluster));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicReference<ClusterConfiguration> config2 = clusterStateListener(uri, cluster2);
                AtomicReference <ClusterConfiguration> config2 = ClusterStateListener(uri, cluster2);

                _servers.Add(cluster2);
                @out.Add(cluster2);
                _configurations.Add(config2);
            }

            _life.start();
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void incrementalBackupIsRecoveredAndConsistent() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void IncrementalBackupIsRecoveredAndConsistent()
        {
            // given database exists
            int backupPort = PortAuthority.allocatePort();

            StartDb(backupPort);
            string ip = ":" + backupPort;

            string         name           = System.Guid.randomUUID().ToString();
            File           backupLocation = new File(_backupDir, name);
            DatabaseLayout backupLayout   = DatabaseLayout.of(backupLocation);

            // when
            assertEquals(0, RunBackupTool(_testDirectory.absolutePath(), "--from", ip, "--cc-report-dir=" + _backupDir, "--backup-dir=" + _backupDir, "--name=" + name));

            // and
            CreateSomeData(_db);
            assertEquals(0, RunBackupTool(_testDirectory.absolutePath(), "--from", ip, "--cc-report-dir=" + _backupDir, "--backup-dir=" + _backupDir, "--name=" + name, arg(ARG_NAME_FALLBACK_FULL, false)));

            // then
            assertFalse("Store should not require recovery", (new RecoveryRequiredChecker(_fileSystemRule, _pageCacheRule.getPageCache(_fileSystemRule), Config.defaults(), new Monitors())).isRecoveryRequiredAt(backupLayout));
            ConsistencyFlags consistencyFlags = new ConsistencyFlags(true, true, true, true, true);

            assertTrue("Consistency check failed", new ConsistencyCheckService()
                       .runFullConsistencyCheck(backupLayout, Config.defaults(), ProgressMonitorFactory.NONE, NullLogProvider.Instance, false, consistencyFlags).Successful);
        }
Пример #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void reportsProgress() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ReportsProgress()
        {
            // given
            string backupName = "reportsProgress_" + RecordFormat;
            int    backupPort = PortAuthority.allocatePort();

            StartDb(backupPort);

            // when
            assertEquals(0, RunBackupTool(_backupDir, System.out, System.err, "--from", "127.0.0.1:" + backupPort, "--protocol=common", "--cc-report-dir=" + _backupDir, "--backup-dir=" + _backupDir, "--name=" + backupName));

            // then
            string output = _suppressOutput.OutputVoice.ToString();
            string legacyImplementationDetail = "temp-copy";
            string location = Paths.get(_backupDir.ToString(), backupName, legacyImplementationDetail).ToString();

            assertTrue(output.Contains("Start receiving store files"));
            assertTrue(output.Contains("Finish receiving store files"));
            string tested = Paths.get(location, "neostore.nodestore.db.labels").ToString();

            assertTrue(tested, output.Contains(format("Start receiving store file %s", tested)));
            assertTrue(tested, output.Contains(format("Finish receiving store file %s", tested)));
            assertFalse(output.Contains("Start receiving transactions from "));
            assertFalse(output.Contains("Finish receiving transactions at "));
            assertTrue(output.Contains("Start recovering store"));
            assertTrue(output.Contains("Finish recovering store"));
            assertFalse(output.Contains("Start receiving index snapshots"));
            assertFalse(output.Contains("Start receiving index snapshot id 1"));
            assertFalse(output.Contains("Finished receiving index snapshot id 1"));
            assertFalse(output.Contains("Finished receiving index snapshots"));
        }
Пример #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testAddressAlreadyBoundMessage() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestAddressAlreadyBoundMessage()
        {
            // given
            _testSocket = BindPort("localhost", PortAuthority.allocatePort());

            // when
            AssertableLogProvider logProvider         = new AssertableLogProvider();
            AssertableLogProvider userLogProvider     = new AssertableLogProvider();
            ListenSocketAddress   listenSocketAddress = new ListenSocketAddress("localhost", _testSocket.LocalPort);

            Server catchupServer = new Server(channel =>
            {
            }, logProvider, userLogProvider, listenSocketAddress, "server-name");

            //then
            try
            {
                catchupServer.Start();
            }
            catch (Exception)
            {
                //expected.
            }
            logProvider.FormattedMessageMatcher().assertContains("server-name: address is already bound: ");
            userLogProvider.FormattedMessageMatcher().assertContains("server-name: address is already bound: ");
        }
Пример #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSendAndReceive() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSendAndReceive()
        {
            // given: raft server handler
            int                   port            = PortAuthority.allocatePort();
            Semaphore             messageReceived = new Semaphore(0);
            ChannelInboundHandler nettyHandler    = new ChannelInboundHandlerAdapterAnonymousInnerClass(this, messageReceived);
            Server                raftServer      = raftServer(nettyHandler, port);

            raftServer.Start();

            // given: raft messaging service
            SenderService sender = RaftSender();

            sender.Start();

            // when
            AdvertisedSocketAddress to = new AdvertisedSocketAddress("localhost", port);
            MemberId  memberId         = new MemberId(System.Guid.randomUUID());
            ClusterId clusterId        = new ClusterId(System.Guid.randomUUID());

            Org.Neo4j.causalclustering.core.consensus.RaftMessages_NewEntry_Request newEntryMessage = new Org.Neo4j.causalclustering.core.consensus.RaftMessages_NewEntry_Request(memberId, new MemberIdSet(asSet(memberId)));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.causalclustering.core.consensus.RaftMessages_ClusterIdAwareMessage<?> message = org.neo4j.causalclustering.core.consensus.RaftMessages_ClusterIdAwareMessage.of(clusterId, newEntryMessage);
            Org.Neo4j.causalclustering.core.consensus.RaftMessages_ClusterIdAwareMessage <object> message = Org.Neo4j.causalclustering.core.consensus.RaftMessages_ClusterIdAwareMessage.of(clusterId, newEntryMessage);

            sender.Send(to, message, Blocking);

            // then
            assertTrue(messageReceived.tryAcquire(15, SECONDS));

            // cleanup
            sender.Stop();
            raftServer.Stop();
        }
Пример #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testInstancesWithConflictingClusterPorts()
        public virtual void TestInstancesWithConflictingClusterPorts()
        {
            HighlyAvailableGraphDatabase first = null;

            int clusterPort = PortAuthority.allocatePort();

            try
            {
                File masterStoreDir = TestDirectory.directory(TestName.MethodName + "Master");
                first = ( HighlyAvailableGraphDatabase )(new TestHighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(masterStoreDir).setConfig(ClusterSettings.initial_hosts, "127.0.0.1:" + clusterPort).setConfig(ClusterSettings.cluster_server, "127.0.0.1:" + clusterPort).setConfig(ClusterSettings.server_id, "1").setConfig(HaSettings.ha_server, "127.0.0.1:" + PortAuthority.allocatePort()).setConfig(OnlineBackupSettings.online_backup_enabled, false.ToString()).newGraphDatabase();

                try
                {
                    File slaveStoreDir = TestDirectory.directory(TestName.MethodName + "Slave");
                    HighlyAvailableGraphDatabase failed = ( HighlyAvailableGraphDatabase )(new TestHighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(slaveStoreDir).setConfig(ClusterSettings.initial_hosts, "127.0.0.1:" + clusterPort).setConfig(ClusterSettings.cluster_server, "127.0.0.1:" + clusterPort).setConfig(ClusterSettings.server_id, "2").setConfig(HaSettings.ha_server, "127.0.0.1:" + PortAuthority.allocatePort()).setConfig(OnlineBackupSettings.online_backup_enabled, false.ToString()).newGraphDatabase();
                    failed.Shutdown();
                    fail("Should not start when ports conflict");
                }
                catch (Exception)
                {
                    // good
                }
            }
            finally
            {
                if (first != null)
                {
                    first.Shutdown();
                }
            }
        }
Пример #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void backupDatabaseWithCustomTransactionLogsLocation() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void BackupDatabaseWithCustomTransactionLogsLocation()
        {
            int backupPort          = PortAuthority.allocatePort();
            GraphDatabaseService db = StartGraphDatabase(_serverStorePath, true, backupPort, "customLogLocation");

            try
            {
                CreateInitialDataSet(db);

                OnlineBackup backup      = OnlineBackup.From("127.0.0.1", backupPort);
                string       backupStore = _backupDatabasePath.Path;
                LogFiles     logFiles    = LogFilesBuilder.logFilesBasedOnlyBuilder(new File(backupStore), _fileSystemRule.get()).build();

                backup.Full(backupStore);
                assertThat(logFiles.LogFilesConflict(), Matchers.arrayWithSize(1));

                DbRepresentation representation = AddLotsOfData(db);
                backup.Incremental(backupStore);
                assertThat(logFiles.LogFilesConflict(), Matchers.arrayWithSize(1));

                assertEquals(representation, DbRepresentation);
            }
            finally
            {
                Db.shutdown();
            }
        }
Пример #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void backupIndexWithNoCommits()
        public virtual void BackupIndexWithNoCommits()
        {
            int backupPort          = PortAuthority.allocatePort();
            GraphDatabaseService db = null;

            try
            {
                db = GetEmbeddedTestDataBaseService(backupPort);

                using (Transaction transaction = Db.beginTx())
                {
                    Db.index().forNodes("created-no-commits");
                    transaction.Success();
                }

                OnlineBackup backup = OnlineBackup.From("127.0.0.1", backupPort);
                backup.Full(_backupDatabasePath.Path);
                assertTrue("Should be consistent", backup.Consistent);
                assertTrue(backup.Consistent);
            }
            finally
            {
                if (db != null)
                {
                    Db.shutdown();
                }
            }
        }
Пример #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void nonEmptyForeignDbShouldNotBeAbleToJoin()
        public virtual void NonEmptyForeignDbShouldNotBeAbleToJoin()
        {
            // GIVEN
            // -- one instance running
            int firstInstanceClusterPort = PortAuthority.allocatePort();

            _firstInstance = (new TestHighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(TestDirectory.directory("1")).setConfig(server_id, "1").setConfig(initial_hosts, "127.0.0.1:" + firstInstanceClusterPort).setConfig(cluster_server, "127.0.0.1:" + firstInstanceClusterPort).setConfig(ha_server, "127.0.0.1:" + PortAuthority.allocatePort()).setConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE).newGraphDatabase();
            CreateNodes(_firstInstance, 3, "first");
            // -- another instance preparing to join with a store with a different store ID
            File foreignDbStoreDir = CreateAnotherStore(TestDirectory.databaseDir("2"), 1);

            // WHEN
            // -- the other joins
            _foreignInstance = (new TestHighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(foreignDbStoreDir).setConfig(server_id, "2").setConfig(initial_hosts, "127.0.0.1:" + firstInstanceClusterPort).setConfig(cluster_server, "127.0.0.1:" + PortAuthority.allocatePort()).setConfig(ha_server, "127.0.0.1:" + PortAuthority.allocatePort()).setConfig(state_switch_timeout, "5s").setConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE).newGraphDatabase();

            try
            {
                // THEN
                // -- that node should arrive at the master
                CreateNode(_foreignInstance, "foreigner");
                fail("Shouldn't be able to create a node, since it shouldn't have joined");
            }
            catch (Exception)
            {
                // Good
            }
        }
Пример #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSendAMessageFromAClientWhichIsReceivedByAServer() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSendAMessageFromAClientWhichIsReceivedByAServer()
        {
            // given
            int port1 = PortAuthority.allocatePort();
            int port2 = PortAuthority.allocatePort();

            System.Threading.CountdownEvent latch = new System.Threading.CountdownEvent(1);

            LifeSupport life = new LifeSupport();

            Server server1 = new Server(latch, MapUtil.stringMap(ClusterSettings.cluster_server.name(), "localhost:" + port1, ClusterSettings.server_id.name(), "1", ClusterSettings.initial_hosts.name(), "localhost:" + port1 + ",localhost:" + port2));

            life.Add(server1);

            Server server2 = new Server(latch, MapUtil.stringMap(ClusterSettings.cluster_server.name(), "localhost:" + port2, ClusterSettings.server_id.name(), "2", ClusterSettings.initial_hosts.name(), "localhost:" + port1 + ",localhost:" + port2));

            life.Add(server2);

            life.Start();

            // when

            server1.Process(Message.To(TestMessage.HelloWorld, URI.create("cluster://127.0.0.1:" + port2), "Hello World"));

            // then

            assertTrue(latch.await(5, TimeUnit.SECONDS));

            assertTrue("server1 should have processed the message", server1.ProcessedMessage());
            assertTrue("server2 should have processed the message", server2.ProcessedMessage());

            life.Shutdown();
        }
Пример #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Setup()
        {
            _logProvider   = new DuplicatingLogProvider(_assertableLogProvider, FormattedLogProvider.withDefaultLogLevel(Level.DEBUG).toOutputStream(System.out));
            _serverHandler = new TestCatchupServerHandler(_logProvider, TestDirectory, _fsa);
            _serverHandler.addFile(_fileA);
            _serverHandler.addFile(_fileB);
            _serverHandler.addIndexFile(_indexFileA);
            WriteContents(_fsa, Relative(_fileA.Filename), _fileA.Content);
            WriteContents(_fsa, Relative(_fileB.Filename), _fileB.Content);
            WriteContents(_fsa, Relative(_indexFileA.Filename), _indexFileA.Content);

            ListenSocketAddress listenAddress = new ListenSocketAddress("localhost", PortAuthority.allocatePort());

            _catchupServer = (new CatchupServerBuilder(_serverHandler)).listenAddress(listenAddress).build();
            _catchupServer.start();

            CatchUpClient catchUpClient = (new CatchupClientBuilder()).build();

            catchUpClient.Start();

            ConstantTimeTimeoutStrategy storeCopyBackoffStrategy = new ConstantTimeTimeoutStrategy(1, TimeUnit.MILLISECONDS);

            Monitors monitors = new Monitors();

            _subject = new StoreCopyClient(catchUpClient, monitors, _logProvider, storeCopyBackoffStrategy);
        }
Пример #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testOnByDefault()
        public virtual void TestOnByDefault()
        {
            int port = PortAuthority.allocatePort();

            GraphDatabaseService db = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(_storeDir).setConfig(OnlineBackupSettings.online_backup_server, "localhost:" + port).newGraphDatabase();

            OnlineBackup.From(HOST_ADDRESS, port).full(_backupDir);
            Db.shutdown();
        }
Пример #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void backupFailsWithCatchupProtoOverride() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void BackupFailsWithCatchupProtoOverride()
        {
            string backupName = "portOverride" + RecordFormat;               // due to ClassRule not cleaning between tests

            int backupPort = PortAuthority.allocatePort();

            StartDb(backupPort);

            assertEquals(1, RunBackupTool(_testDirectory.absolutePath(), "--from", "127.0.0.1:" + backupPort, "--cc-report-dir=" + _backupDir, "--backup-dir=" + _backupDir, "--protocol=catchup", "--name=" + backupName));
        }
Пример #15
0
        protected internal override CoreClusterMember CreateCoreClusterMember(int serverId, int discoveryPort, int clusterSize, IList <AdvertisedSocketAddress> initialHosts, string recordFormat, IDictionary <string, string> extraParams, IDictionary <string, System.Func <int, string> > instanceExtraParams)
        {
            int txPort     = PortAuthority.allocatePort();
            int raftPort   = PortAuthority.allocatePort();
            int boltPort   = PortAuthority.allocatePort();
            int httpPort   = PortAuthority.allocatePort();
            int backupPort = PortAuthority.allocatePort();

            return(new CoreClusterMember(serverId, discoveryPort, txPort, raftPort, boltPort, httpPort, backupPort, clusterSize, initialHosts, DiscoveryServiceFactory, recordFormat, ParentDir, extraParams, instanceExtraParams, ListenAddress, AdvertisedAddress));
        }
Пример #16
0
        // @Test
        // TODO: Update this for causal clustering testing.
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void shouldBeAbleToStartInHAMode() throws Exception
        public virtual void ShouldBeAbleToStartInHAMode()
        {
            // When
            int clusterPort = PortAuthority.allocatePort();
            int resultCode  = ServerBootstrapper.start(Bootstrapper, "--home-dir", TempDir.newFolder("home-dir").AbsolutePath, "-c", ConfigOption(EnterpriseEditionSettings.mode, "CORE"), "-c", ConfigOption(ClusterSettings.server_id, "1"), "-c", ConfigOption(ClusterSettings.initial_hosts, "127.0.0.1:" + clusterPort), "-c", ConfigOption(ClusterSettings.cluster_server, "127.0.0.1:" + clusterPort), "-c", ConfigOption(GraphDatabaseSettings.data_directory, getRelativePath(_folder.Root, GraphDatabaseSettings.data_directory)), "-c", ConfigOption(logs_directory, TempDir.Root.AbsolutePath), "-c", ConfigOption(certificates_directory, getRelativePath(_folder.Root, certificates_directory)), "-c", (new BoltConnector("BOLT")).listen_address.name() + "=localhost:0", "-c", "dbms.connector.https.listen_address=localhost:0", "-c", "dbms.connector.1.type=HTTP", "-c", "dbms.connector.1.encryption=NONE", "-c", "dbms.connector.1.listen_address=localhost:0", "-c", "dbms.connector.1.enabled=true", "-c", "causal_clustering.initial_discovery_members=localhost:5000");

            // Then
            assertEquals(ServerBootstrapper.OK, resultCode);
            assertEventually("Server was not started", Bootstrapper.isRunning, @is(true), 1, TimeUnit.MINUTES);
        }
Пример #17
0
        protected internal override ReadReplica CreateReadReplica(int serverId, IList <AdvertisedSocketAddress> initialHosts, IDictionary <string, string> extraParams, IDictionary <string, System.Func <int, string> > instanceExtraParams, string recordFormat, Monitors monitors)
        {
            int boltPort      = PortAuthority.allocatePort();
            int httpPort      = PortAuthority.allocatePort();
            int txPort        = PortAuthority.allocatePort();
            int backupPort    = PortAuthority.allocatePort();
            int discoveryPort = PortAuthority.allocatePort();

            return(new ReadReplica(ParentDir, serverId, boltPort, httpPort, txPort, backupPort, discoveryPort, DiscoveryServiceFactory, initialHosts, extraParams, instanceExtraParams, recordFormat, monitors, AdvertisedAddress, ListenAddress));
        }
Пример #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUpPorts()
        public virtual void SetUpPorts()
        {
            _backupPort = PortAuthority.allocatePort();
            GraphDatabaseFactory factory = new EnterpriseGraphDatabaseFactory();
            GraphDatabaseBuilder builder = factory.NewEmbeddedDatabaseBuilder(_dir.storeDir());

            builder.setConfig(online_backup_enabled, "true");
            builder.setConfig(online_backup_server, "127.0.0.1:" + _backupPort);
            _db = ( GraphDatabaseAPI )builder.NewGraphDatabase();
            _cleanup.add(_db);
        }
Пример #19
0
        public override int Port(int offset, int id)
        {
            int key = offset + id;

            if (!Cache.ContainsKey(key))
            {
                Cache[key] = PortAuthority.allocatePort();
            }

            return(Cache[key]);
        }
Пример #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testConflictingIdDoesNotSilentlyFail()
        public virtual void TestConflictingIdDoesNotSilentlyFail()
        {
            HighlyAvailableGraphDatabase master     = null;
            HighlyAvailableGraphDatabase dbWithId21 = null;
            HighlyAvailableGraphDatabase dbWithId22 = null;

            try
            {
                int masterClusterPort = PortAuthority.allocatePort();

                GraphDatabaseBuilder masterBuilder = (new TestHighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(Path(1)).setConfig(ClusterSettings.initial_hosts, "127.0.0.1:" + masterClusterPort).setConfig(ClusterSettings.cluster_server, "127.0.0.1:" + masterClusterPort).setConfig(ClusterSettings.server_id, "" + 1).setConfig(HaSettings.HaServer, ":" + PortAuthority.allocatePort()).setConfig(HaSettings.TxPushFactor, "0").setConfig(OnlineBackupSettings.online_backup_enabled, false.ToString());
                master = ( HighlyAvailableGraphDatabase )masterBuilder.NewGraphDatabase();

                GraphDatabaseBuilder db21Builder = (new TestHighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(Path(2)).setConfig(ClusterSettings.initial_hosts, "127.0.0.1:" + masterClusterPort).setConfig(ClusterSettings.cluster_server, "127.0.0.1:" + PortAuthority.allocatePort()).setConfig(ClusterSettings.server_id, "" + 2).setConfig(HaSettings.HaServer, ":" + PortAuthority.allocatePort()).setConfig(HaSettings.TxPushFactor, "0").setConfig(OnlineBackupSettings.online_backup_enabled, false.ToString());
                dbWithId21 = ( HighlyAvailableGraphDatabase )db21Builder.NewGraphDatabase();

                GraphDatabaseBuilder db22Builder = (new TestHighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(Path(3)).setConfig(ClusterSettings.initial_hosts, "127.0.0.1:" + masterClusterPort).setConfig(ClusterSettings.cluster_server, "127.0.0.1:" + PortAuthority.allocatePort()).setConfig(ClusterSettings.server_id, "" + 2).setConfig(HaSettings.HaServer, ":" + PortAuthority.allocatePort()).setConfig(HaSettings.TxPushFactor, "0").setConfig(OnlineBackupSettings.online_backup_enabled, false.ToString());

                try
                {
                    dbWithId22 = ( HighlyAvailableGraphDatabase )db22Builder.NewGraphDatabase();
                    fail("Should not be able to startup when a cluster already has my id");
                }
                catch (Exception)
                {
                    // awesome
                }

                assertTrue(master.Master);
                assertTrue(!dbWithId21.Master);

                using (Transaction transaction = dbWithId21.BeginTx())
                {
                    transaction.Success();
                }
            }
            finally
            {
                if (dbWithId21 != null)
                {
                    dbWithId21.Shutdown();
                }
                if (dbWithId22 != null)
                {
                    dbWithId22.Shutdown();
                }
                if (master != null)
                {
                    master.Shutdown();
                }
            }
        }
Пример #21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void secondaryTransactionProtocolIsSwitchedOffCorrespondingBackupSetting() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SecondaryTransactionProtocolIsSwitchedOffCorrespondingBackupSetting()
        {
            // given a cluster with backup switched off
            int[]  backupPorts = new int[] { PortAuthority.allocatePort(), PortAuthority.allocatePort(), PortAuthority.allocatePort() };
            string value       = "localhost:%d";

            _clusterRule = _clusterRule.withSharedCoreParam(OnlineBackupSettings.online_backup_enabled, "false").withInstanceCoreParam(online_backup_server, i => format(value, backupPorts[i]));
            StartCluster(RecordFormat);
            string customAddress = "localhost:" + backupPorts[0];

            // then a full backup is impossible from the backup port
            assertEquals(1, RunBackupOtherJvm(customAddress, DATABASE_NAME));
        }
Пример #22
0
        private void TestWithAddress(InetAddress inetAddress)
        {
            int clusterPort         = PortAuthority.allocatePort();
            GraphDatabaseService db = (new HighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(Dir.storeDir()).setConfig(ClusterSettings.cluster_server, Ipv6HostPortSetting(inetAddress.HostAddress, clusterPort)).setConfig(ClusterSettings.initial_hosts, Ipv6HostPortSetting(inetAddress.HostAddress, clusterPort)).setConfig(HaSettings.HaServer, Ipv6HostPortSetting("::", PortAuthority.allocatePort())).setConfig(ClusterSettings.server_id, "1").setConfig(OnlineBackupSettings.online_backup_enabled, false.ToString()).newGraphDatabase();

            using (Transaction tx = Db.beginTx())
            {
                Db.createNode();
                tx.Success();
            }

            Db.shutdown();
        }
Пример #23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void makeSureBackupCanBePerformedWithCustomPort() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MakeSureBackupCanBePerformedWithCustomPort()
        {
            assumeFalse(SystemUtils.IS_OS_WINDOWS);
            string backupName = "customport" + RecordFormat;               // due to ClassRule not cleaning between tests

            int backupPort = PortAuthority.allocatePort();

            StartDb(backupPort);
            assertEquals("should not be able to do backup when noone is listening", 1, RunBackupTool(_testDirectory.absolutePath(), "--from", "127.0.0.1:" + PortAuthority.allocatePort(), "--cc-report-dir=" + _backupDir, "--backup-dir=" + _backupDir, "--name=" + backupName));
            assertEquals(0, RunBackupTool(_testDirectory.absolutePath(), "--from", "127.0.0.1:" + backupPort, "--cc-report-dir=" + _backupDir, "--backup-dir=" + _backupDir, "--name=" + backupName));
            assertEquals(DbRepresentation.of(_db), GetBackupDbRepresentation(backupName));
            CreateSomeData(_db);
            assertEquals(0, RunBackupTool(_testDirectory.absolutePath(), "--from", "127.0.0.1:" + backupPort, "--cc-report-dir=" + _backupDir, "--backup-dir=" + _backupDir, "--name=" + backupName));
            assertEquals(DbRepresentation.of(_db), GetBackupDbRepresentation(backupName));
        }
Пример #24
0
        private SortedDictionary <int, Configuration> CreateConfigurations()
        {
            SortedDictionary <int, Configuration> configurations = new SortedDictionary <int, Configuration>();

            IntStream.range(0, 3).forEach(serverId =>
            {
                int clusterPort = PortAuthority.allocatePort();
                int haPort      = PortAuthority.allocatePort();
                File directory  = TestDirectory.databaseDir(Convert.ToString(serverId)).AbsoluteFile;

                configurations[serverId] = new Configuration(this, serverId, clusterPort, haPort, directory);
            });

            return(configurations);
        }
Пример #25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testOffByConfig()
        public virtual void TestOffByConfig()
        {
            int port = PortAuthority.allocatePort();

            GraphDatabaseService db = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(_storeDir).setConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE).setConfig(OnlineBackupSettings.online_backup_server, "localhost:" + port).newGraphDatabase();

            try
            {
                OnlineBackup.From(HOST_ADDRESS, port).full(_backupDir);
                fail("Shouldn't be possible");
            }
            catch (Exception)
            {               // Good
            }
            Db.shutdown();
        }
Пример #26
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogConnetionRefusedMessage()
        public virtual void ShouldLogConnetionRefusedMessage()
        {
            InMemoryStoreStreamProvider clientStoreFileStream = new InMemoryStoreStreamProvider();
            int port = PortAuthority.allocatePort();

            try
            {
                _subject.copyStoreFiles(new CatchupAddressProviderAnonymousInnerClass(this, port)
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                                        , _serverHandler.StoreId, clientStoreFileStream, Once::new, _targetLocation);
                fail();
            }
            catch (StoreCopyFailedException)
            {
                _assertableLogProvider.rawMessageMatcher().assertContainsSingle(Matchers.allOf(Matchers.containsString("Connection refused: localhost/127.0.0.1:" + port)));
            }
        }
Пример #27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void multipleIncrementals() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MultipleIncrementals()
        {
            int backupPort          = PortAuthority.allocatePort();
            GraphDatabaseService db = null;

            try
            {
                db = GetEmbeddedTestDataBaseService(backupPort);

                Index <Node> index;
                using (Transaction tx = Db.beginTx())
                {
                    index = Db.index().forNodes("yo");
                    index.Add(Db.createNode(), "justTo", "commitATx");
                    Db.createNode();
                    tx.Success();
                }

                OnlineBackup backup = OnlineBackup.From("127.0.0.1", backupPort);
                backup.Full(_backupDatabasePath.Path);
                assertTrue("Should be consistent", backup.Consistent);
                PageCache pageCache       = _pageCacheRule.getPageCache(_fileSystemRule.get());
                long      lastCommittedTx = GetLastCommittedTx(_backupDatabaseLayout, pageCache);

                for (int i = 0; i < 5; i++)
                {
                    using (Transaction tx = Db.beginTx())
                    {
                        Node node = Db.createNode();
                        index.Add(node, "key", "value" + i);
                        tx.Success();
                    }
                    backup = backup.incremental(_backupDatabasePath.Path);
                    assertTrue("Should be consistent", backup.Consistent);
                    assertEquals(lastCommittedTx + i + 1, GetLastCommittedTx(_backupDatabaseLayout, pageCache));
                }
            }
            finally
            {
                if (db != null)
                {
                    Db.shutdown();
                }
            }
        }
Пример #28
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRetainFileLocksAfterFullBackupOnLiveDatabase()
        public virtual void ShouldRetainFileLocksAfterFullBackupOnLiveDatabase()
        {
            int  backupPort = PortAuthority.allocatePort();
            File sourcePath = _testDir.directory("serverdb-lock");

            GraphDatabaseService db = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(sourcePath).setConfig(OnlineBackupSettings.online_backup_enabled, Settings.TRUE).setConfig(OnlineBackupSettings.online_backup_server, "127.0.0.1:" + backupPort).setConfig(GraphDatabaseSettings.record_format, RecordFormatName).newGraphDatabase();

            try
            {
                AssertStoreIsLocked(sourcePath);
                OnlineBackup.From("127.0.0.1", backupPort).full(_backupDatabasePath.Path);
                AssertStoreIsLocked(sourcePath);
            }
            finally
            {
                Db.shutdown();
            }
        }
Пример #29
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void backupDatabaseTransactionLogsStoredWithDatabase() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void BackupDatabaseTransactionLogsStoredWithDatabase()
        {
            int backupPort = PortAuthority.allocatePort();

            StartDb(backupPort);
            string ip   = ":" + backupPort;
            string name = "backupWithTxLogs" + RecordFormat;

            assertEquals(0, RunBackupTool(_testDirectory.absolutePath(), "--from", ip, "--cc-report-dir=" + _backupDir, "--backup-dir=" + _backupDir, "--name=" + name));
            _db.shutdown();

            using (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction())
            {
                LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(new File(_backupDir, name), fileSystem).build();
                assertTrue(logFiles.VersionExists(0));
                assertThat(logFiles.GetLogFileForVersion(0).length(), greaterThan(50L));
            }
        }
Пример #30
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void makeSureIncrementalFailsWhenNoDb()
        public virtual void MakeSureIncrementalFailsWhenNoDb()
        {
            int backupPort = PortAuthority.allocatePort();

            CreateInitialDataSet(_serverStorePath);
            ServerInterface server = StartServer(_serverStorePath, backupPort);
            OnlineBackup    backup = OnlineBackup.From("127.0.0.1", backupPort);

            try
            {
                backup.incremental(_backupDatabasePath.Path);
                fail("Shouldn't be able to do incremental backup into non-existing db");
            }
            catch (Exception)
            {
                // Good
            }
            ShutdownServer(server);
        }