/// <summary> /// Takes a raw address that can have a single port or 2 ports (lower and upper bounds of port range) and /// processes it to a clean separation of host and ports. When only one port is specified, it is in the lower bound. /// The presence of an upper bound implies a range. /// </summary> /// <param name="rawAddress"> the raw address that a user can provide via config or command line </param> /// <returns> the host, lower bound port, and upper bound port </returns> public static OptionalHostnamePort ToOptionalHostnamePortFromRawAddress(string rawAddress) { HostnamePort hostnamePort = new HostnamePort(rawAddress); Optional <string> processedHost = Optional.ofNullable(hostnamePort.Host).map(str => str.replaceAll("\\[", "")).map(str => str.replaceAll("]", "")); return(new OptionalHostnamePort(processedHost, OptionalFromZeroable(hostnamePort.Ports[0]), OptionalFromZeroable(hostnamePort.Ports[1]))); }
public HighAvailabilitySlaves(ClusterMembers clusterMembers, Cluster cluster, SlaveFactory slaveFactory, HostnamePort me) { this._clusterMembers = clusterMembers; this._cluster = cluster; this._slaveFactory = slaveFactory; this._me = me; }
private URI BoltURI() { ConnectorPortRegister connectorPortRegister = (( GraphDatabaseAPI )_db).DependencyResolver.resolveDependency(typeof(ConnectorPortRegister)); HostnamePort boltHostNamePort = connectorPortRegister.GetLocalAddress("bolt"); return(URI.create("bolt://" + boltHostNamePort.Host + ":" + boltHostNamePort.Port)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: org.neo4j.backup.impl.BackupOutcome executeBackup(org.neo4j.helpers.HostnamePort hostnamePort, java.nio.file.Path to, org.neo4j.backup.impl.ConsistencyCheck consistencyCheck, org.neo4j.kernel.configuration.Config config, long timeout, boolean forensics) throws ToolFailureException internal virtual BackupOutcome ExecuteBackup(HostnamePort hostnamePort, Path to, ConsistencyCheck consistencyCheck, Config config, long timeout, bool forensics) { try { _systemOut.println("Performing backup from '" + hostnamePort + "'"); string host = hostnamePort.Host; int port = hostnamePort.Port; BackupOutcome outcome = _backupProtocolService.doIncrementalBackupOrFallbackToFull(host, port, DatabaseLayout.of(to.toFile()), consistencyCheck, config, timeout, forensics); _systemOut.println("Done"); return(outcome); } catch (Exception e) when(e is UnexpectedStoreVersionException || e is IncrementalBackupNotPossibleException) { throw new ToolFailureException(e.Message, e); } catch (MismatchingStoreIdException e) { throw new ToolFailureException(string.format(MISMATCHED_STORE_ID, e.Expected, e.Encountered)); } catch (ComException e) { throw new ToolFailureException("Couldn't connect to '" + hostnamePort + "'", e); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.backup.impl.BackupOutcome runBackup(org.neo4j.helpers.Args args) throws ToolFailureException private BackupOutcome RunBackup(Args args) { string host = args.Get(HOST).Trim(); int port = args.GetNumber(PORT, BackupServer.DEFAULT_PORT).intValue(); Path to = Paths.get(args.Get(TO).Trim()); Config tuningConfiguration = ReadConfiguration(args); bool forensics = args.GetBoolean(FORENSICS, false, true).Value; ConsistencyCheck consistencyCheck = ParseConsistencyChecker(args); if (host.Contains(":")) { if (!host.StartsWith("[", StringComparison.Ordinal)) { host = "[" + host; } if (!host.EndsWith("]", StringComparison.Ordinal)) { host += "]"; } } long timeout = args.GetDuration(TIMEOUT, BackupClient.BIG_READ_TIMEOUT); URI backupURI = NewURI(DEFAULT_SCHEME + "://" + host + ":" + port); // a bit of validation HostnamePort hostnamePort = NewHostnamePort(backupURI); return(ExecuteBackup(hostnamePort, to, consistencyCheck, tuningConfiguration, timeout, forensics)); }
public GraphiteOutput(HostnamePort hostnamePort, long period, MetricRegistry registry, Log logger, string prefix) { this._hostnamePort = hostnamePort; this._period = period; this._registry = registry; this._logger = logger; this._prefix = prefix; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void Setup() { InstallSleepProcedure(_server.graphDatabaseService()); _address = _server.lookupDefaultConnector(); _connection = new SocketConnection(); _util = new TransportTestUtil(new Neo4jPackV1()); }
internal PrometheusOutput(HostnamePort hostnamePort, MetricRegistry registry, Log logger, ConnectorPortRegister portRegister) { this._hostnamePort = hostnamePort; this._registry = registry; this._logger = logger; this._portRegister = portRegister; this._eventRegistry = new MetricRegistry(); }
public UdcTimerTask(HostnamePort hostAddress, UdcInformationCollector collector) { this._storeId = collector.StoreId; SuccessCounts[_storeId] = 0; FailureCounts[_storeId] = 0; _pinger = new Pinger(hostAddress, collector); }
private string ResolvePortOnlyHost(HostnamePort host) { try { return(host.ToString(InetAddress.LocalHost.HostAddress)); } catch (UnknownHostException e) { throw new Exception(e); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") org.neo4j.bolt.v1.transport.socket.client.TransportConnection startBoltSession(String username, String password) throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual TransportConnection StartBoltSession(string username, string password) { TransportConnection connection = new SocketConnection(); HostnamePort address = Neo.lookupConnector(DEFAULT_CONNECTOR_KEY); IDictionary <string, object> authToken = map("principal", username, "credentials", password, "scheme", "basic"); connection.Connect(address).send(Util.acceptedVersions(1, 0, 0, 0)).send(Util.chunk(new InitMessage("TestClient/1.1", authToken))); assertThat(connection, eventuallyReceives(new sbyte[] { 0, 0, 0, 1 })); assertThat(connection, Util.eventuallyReceives(msgSuccess())); return(connection); }
public static void VerifyConnector(GraphDatabaseService db, string name, bool enabled) { HostnamePort address = ConnectorAddress(db, name); if (enabled) { assertNotNull(address); assertTrue(CanConnectToSocket(address.Host, address.Port)); } else { assertNull(address); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.backup.impl.BackupOutcome runBackupWithLegacyArgs(org.neo4j.helpers.Args args) throws ToolFailureException private BackupOutcome RunBackupWithLegacyArgs(Args args) { string from = args.Get(FROM).Trim(); Path to = Paths.get(args.Get(TO).Trim()); Config tuningConfiguration = ReadConfiguration(args); bool forensics = args.GetBoolean(FORENSICS, false, true).Value; ConsistencyCheck consistencyCheck = ParseConsistencyChecker(args); long timeout = args.GetDuration(TIMEOUT, BackupClient.BIG_READ_TIMEOUT); URI backupURI = ResolveBackupUri(from, args, tuningConfiguration); HostnamePort hostnamePort = NewHostnamePort(backupURI); return(ExecuteBackup(hostnamePort, to, consistencyCheck, tuningConfiguration, timeout, forensics)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReturnBoltUriWhenDefaultBoltConnectorOffAndOtherConnectorConfigured() public virtual void ShouldReturnBoltUriWhenDefaultBoltConnectorOffAndOtherConnectorConfigured() { TestServerBuilder serverBuilder = newInProcessBuilder(TestDir.directory()).withConfig("dbms.connector.bolt.enabled", "false").withConfig("dbms.connector.another_bolt.type", "BOLT").withConfig("dbms.connector.another_bolt.enabled", "true").withConfig("dbms.connector.another_bolt.listen_address", ":0"); using (ServerControls server = serverBuilder.NewServer()) { HostnamePort boltHostPort = connectorAddress(server.Graph(), "bolt"); HostnamePort anotherBoltHostPort = connectorAddress(server.Graph(), "another_bolt"); assertNull(boltHostPort); assertNotNull(anotherBoltHostPort); URI boltUri = server.BoltURI(); assertEquals("bolt", boltUri.Scheme); assertEquals(anotherBoltHostPort.Host, boltUri.Host); assertEquals(anotherBoltHostPort.Port, boltUri.Port); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void normalPingSequenceShouldBeOneThenTwoThenThreeEtc() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void NormalPingSequenceShouldBeOneThenTwoThenThreeEtc() { int[] expectedSequence = new int[] { 1, 2, 3, 4 }; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.helpers.HostnamePort hostURL = new org.neo4j.helpers.HostnamePort(hostname, server.getLocalPort()); HostnamePort hostURL = new HostnamePort(_hostname, server.LocalPort); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.Map<String,String> udcFields = new java.util.HashMap<>(); IDictionary <string, string> udcFields = new Dictionary <string, string>(); Pinger p = new Pinger(hostURL, new TestUdcCollector(udcFields)); foreach (int s in expectedSequence) { p.Ping(); int count = int.Parse(Handler.QueryMap[UdcConstants.PING]); assertEquals(s, count); } }
public override Fallible <BackupStageOutcome> PerformFullBackup(DatabaseLayout targetDatabaseLayout, Config config, OptionalHostnamePort userProvidedAddress) { HostnamePort fromAddress = _addressResolver.resolveCorrectHAAddress(config, userProvidedAddress); _log.info("Resolved address for backup protocol is " + fromAddress); ConsistencyCheck consistencyCheck = ConsistencyCheck.NONE; bool forensics = false; try { string host = fromAddress.Host; int port = fromAddress.Port; _backupProtocolService.doFullBackup(host, port, targetDatabaseLayout, consistencyCheck, config, _timeout, forensics); return(new Fallible <BackupStageOutcome>(BackupStageOutcome.Success, null)); } catch (ComException e) { return(new Fallible <BackupStageOutcome>(BackupStageOutcome.WrongProtocol, e)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPingServer() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldPingServer() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.helpers.HostnamePort hostURL = new org.neo4j.helpers.HostnamePort(hostname, server.getLocalPort()); HostnamePort hostURL = new HostnamePort(_hostname, server.LocalPort); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.Map<String,String> udcFields = new java.util.HashMap<>(); IDictionary <string, string> udcFields = new Dictionary <string, string>(); udcFields[ID] = _expectedStoreId; udcFields[UdcConstants.VERSION] = _expectedKernelVersion; Pinger p = new Pinger(hostURL, new TestUdcCollector(udcFields)); p.Ping(); IDictionary <string, string> actualQueryMap = Handler.QueryMap; assertThat(actualQueryMap, notNullValue()); assertThat(actualQueryMap[ID], @is(_expectedStoreId)); }
public override Fallible <BackupStageOutcome> PerformIncrementalBackup(DatabaseLayout targetDatabaseLayout, Config config, OptionalHostnamePort fromAddress) { HostnamePort resolvedAddress = _addressResolver.resolveCorrectHAAddress(config, fromAddress); _log.info("Resolved address for backup protocol is " + resolvedAddress); try { string host = resolvedAddress.Host; int port = resolvedAddress.Port; _backupProtocolService.doIncrementalBackup(host, port, targetDatabaseLayout, ConsistencyCheck.NONE, _timeout, config); return(new Fallible <BackupStageOutcome>(BackupStageOutcome.Success, null)); } catch (MismatchingStoreIdException e) { return(new Fallible <BackupStageOutcome>(BackupStageOutcome.UnrecoverableFailure, e)); } catch (Exception e) { return(new Fallible <BackupStageOutcome>(BackupStageOutcome.Failure, e)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldIncludePingCountInURI() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldIncludePingCountInURI() { const int expectedPingCount = 16; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.helpers.HostnamePort hostURL = new org.neo4j.helpers.HostnamePort(hostname, server.getLocalPort()); HostnamePort hostURL = new HostnamePort(_hostname, server.LocalPort); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.Map<String,String> udcFields = new java.util.HashMap<>(); IDictionary <string, string> udcFields = new Dictionary <string, string>(); Pinger p = new Pinger(hostURL, new TestUdcCollector(udcFields)); for (int i = 0; i < expectedPingCount; i++) { p.Ping(); } assertThat(p.PingCount, @is(equalTo(expectedPingCount))); IDictionary <string, string> actualQueryMap = Handler.QueryMap; assertThat(actualQueryMap[UdcConstants.PING], @is(Convert.ToString(expectedPingCount))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void makeSureBackupCanBePerformed() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void MakeSureBackupCanBePerformed() { // Run backup ManagedCluster cluster = ClusterRule.startCluster(); DbRepresentation beforeChange = DbRepresentation.of(cluster.Master); HighlyAvailableGraphDatabase hagdb = cluster.AllMembers.GetEnumerator().next(); HostnamePort address = cluster.GetBackupAddress(hagdb); string databaseName = "basic"; assertEquals(0, runBackupToolFromOtherJvmToGetExitCode(_backupPath, BackupArguments(address.ToString(), _backupPath, databaseName))); // Add some new data DbRepresentation afterChange = createSomeData(cluster.Master); cluster.Sync(); // Verify that backed up database can be started and compare representation Config config = Config.builder().withSetting(OnlineBackupSettings.online_backup_enabled, Settings.FALSE).withSetting(GraphDatabaseSettings.active_database, databaseName).build(); DbRepresentation backupRepresentation = DbRepresentation.of(DatabaseLayout.of(_backupPath, databaseName).databaseDirectory(), config); assertEquals(beforeChange, backupRepresentation); assertNotEquals(backupRepresentation, afterChange); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setUp() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SetUp() { Address = Server.lookupDefaultConnector(); Connection = System.Activator.CreateInstance(ConnectionClass); Util = new TransportTestUtil(newNeo4jPack(), newMessageEncoder()); }
private URI ConnectorUri(string scheme, Connector connector) { HostnamePort hostPort = _connectorPortRegister.getLocalAddress(connector.Key()); return(URI.create(scheme + "://" + hostPort + "/")); }
internal Pinger(HostnamePort address, UdcInformationCollector collector) { this._address = address; this._collector = collector; }
public virtual void Register(string connectorKey, InetSocketAddress localAddress) { HostnamePort hostnamePort = new HostnamePort(localAddress.HostString, localAddress.Port); _connectorsInfo[connectorKey] = hostnamePort; }
public static string BackupAddress(GraphDatabaseFacade graphDatabaseFacade) { HostnamePort backupAddress = graphDatabaseFacade.DependencyResolver.resolveDependency(typeof(Config)).get(OnlineBackupSettings.online_backup_server); return(string.Format("{0}:{1}", backupAddress.Host, backupAddress.Port)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setUp() public virtual void SetUp() { _address = Server.lookupDefaultConnector(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void Setup() { _address = Server.lookupDefaultConnector(); _connection = System.Activator.CreateInstance(ConnectionClass); _util = new TransportTestUtil(new Neo4jPackV2()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() public virtual void Setup() { this._client = Cf.newInstance(); this._address = Server.lookupDefaultConnector(); this._util = new TransportTestUtil(new Neo4jPackV1()); }