//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldParseExplicitSettingValueWhenProvided() public virtual void ShouldParseExplicitSettingValueWhenProvided() { // given IDictionary <string, string> config = stringMap(GraphDatabaseSettings.default_listen_address.name(), "server1.example.com", _listenAddressSetting.name(), "server1.internal:4000"); // when ListenSocketAddress listenSocketAddress = _listenAddressSetting.apply(config.get); // then assertEquals("server1.internal", listenSocketAddress.Hostname); assertEquals(4000, listenSocketAddress.Port); }
private Server RaftServer(ChannelInboundHandler nettyHandler, int port) { NettyPipelineBuilderFactory pipelineFactory = new NettyPipelineBuilderFactory(VOID_WRAPPER); RaftProtocolServerInstallerV1.Factory factoryV1 = new RaftProtocolServerInstallerV1.Factory(nettyHandler, pipelineFactory, _logProvider); RaftProtocolServerInstallerV2.Factory factoryV2 = new RaftProtocolServerInstallerV2.Factory(nettyHandler, pipelineFactory, _logProvider); ProtocolInstallerRepository <Org.Neo4j.causalclustering.protocol.ProtocolInstaller_Orientation_Server> installer = new ProtocolInstallerRepository <Org.Neo4j.causalclustering.protocol.ProtocolInstaller_Orientation_Server>(Arrays.asList(factoryV1, factoryV2), Org.Neo4j.causalclustering.protocol.ModifierProtocolInstaller_Fields.AllServerInstallers); HandshakeServerInitializer channelInitializer = new HandshakeServerInitializer(_applicationProtocolRepository, _modifierProtocolRepository, installer, pipelineFactory, _logProvider); ListenSocketAddress listenAddress = new ListenSocketAddress("localhost", port); return(new Server(channelInitializer, null, _logProvider, _logProvider, listenAddress, "raft-server")); }
public virtual Optional <Server> ResolveIfBackupEnabled(Config config) { if (config.Get(OnlineBackupSettings.online_backup_enabled)) { ListenSocketAddress backupAddress = HostnamePortAsListenAddress.Resolve(config, OnlineBackupSettings.online_backup_server); _logProvider.getLog(typeof(TransactionBackupServiceProvider)).info("Binding backup service on address %s", backupAddress); return(Optional.of(new CatchupServerBuilder(_catchupServerHandler) .serverHandler(_parentHandler).catchupProtocols(_catchupProtocols).modifierProtocols(_supportedModifierProtocols).pipelineBuilder(_serverPipelineBuilderFactory).userLogProvider(_userLogProvider).debugLogProvider(_logProvider).listenAddress(backupAddress).serverName("backup-server").build())); } else { return(null); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotAppendToFileWhenRetryingWithNewFile() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotAppendToFileWhenRetryingWithNewFile() { // given string fileName = "foo"; string copyFileName = "bar"; string unfinishedContent = "abcd"; string finishedContent = "abcdefgh"; IEnumerator <string> contents = Iterators.iterator(unfinishedContent, finishedContent); // and TestCatchupServerHandler halfWayFailingServerhandler = new TestCatchupServerHandlerAnonymousInnerClass(this, _logProvider, TestDirectory, _fsa, fileName, copyFileName, contents); Server halfWayFailingServer = null; try { // when ListenSocketAddress listenAddress = new ListenSocketAddress("localhost", PortAuthority.allocatePort()); halfWayFailingServer = (new CatchupServerBuilder(halfWayFailingServerhandler)).listenAddress(listenAddress).build(); halfWayFailingServer.Start(); CatchupAddressProvider addressProvider = CatchupAddressProvider.fromSingleAddress(new AdvertisedSocketAddress(listenAddress.Hostname, listenAddress.Port)); StoreId storeId = halfWayFailingServerhandler.StoreId; File databaseDir = TestDirectory.databaseDir(); StreamToDiskProvider streamToDiskProvider = new StreamToDiskProvider(databaseDir, _fsa, new Monitors()); // and _subject.copyStoreFiles(addressProvider, storeId, streamToDiskProvider, () => _defaultTerminationCondition, _targetLocation); // then assertEquals(FileContent(new File(databaseDir, fileName)), finishedContent); // and File fileCopy = new File(databaseDir, copyFileName); ByteBuffer buffer = ByteBuffer.wrap(new sbyte[finishedContent.Length]); using (StoreChannel storeChannel = _fsa.create(fileCopy)) { storeChannel.read(buffer); } assertEquals(finishedContent, new string( buffer.array(), Charsets.UTF_8 )); } finally { halfWayFailingServer.Stop(); halfWayFailingServer.Shutdown(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: protected void startWebServer() throws Exception protected internal virtual void StartWebServer() { try { SetUpHttpLogging(); WebServerConflict.start(); RegisterHttpAddressAfterStartup(); RegisterHttpsAddressAfterStartup(); _log.info("Remote interface available at %s", BaseUri()); } catch (Exception e) { ListenSocketAddress address = _httpListenAddress != null ? _httpListenAddress : _httpsListenAddress; _log.error("Failed to start Neo4j on %s: %s", address, e.Message); throw e; } }
private NettyServer.ProtocolInitializer CreateProtocolInitializer(BoltConnector connector, BoltProtocolFactory boltProtocolFactory, TransportThrottleGroup throttleGroup, Log log) { SslContext sslCtx; bool requireEncryption; BoltConnector.EncryptionLevel encryptionLevel = _config.get(connector.EncryptionLevel); SslPolicyLoader sslPolicyLoader = _dependencyResolver.resolveDependency(typeof(SslPolicyLoader)); switch (encryptionLevel) { case BoltConnector.EncryptionLevel.REQUIRED: // Encrypted connections are mandatory, a self-signed certificate may be generated. requireEncryption = true; sslCtx = CreateSslContext(sslPolicyLoader, _config); break; case BoltConnector.EncryptionLevel.OPTIONAL: // Encrypted connections are optional, a self-signed certificate may be generated. requireEncryption = false; sslCtx = CreateSslContext(sslPolicyLoader, _config); break; case BoltConnector.EncryptionLevel.DISABLED: // Encryption is turned off, no self-signed certificate will be generated. requireEncryption = false; sslCtx = null; break; default: // In the unlikely event that we happen to fall through to the default option here, // there is a mismatch between the BoltConnector.EncryptionLevel enum and the options // handled in this switch statement. In this case, we'll log a warning and default to // disabling encryption, since this mirrors the functionality introduced in 3.0. log.Warn("Unhandled encryption level %s - assuming DISABLED.", encryptionLevel.name()); requireEncryption = false; sslCtx = null; break; } ListenSocketAddress listenAddress = _config.get(connector.ListenAddress); return(new SocketTransport(connector.Key(), listenAddress, sslCtx, requireEncryption, _logService.InternalLogProvider, throttleGroup, boltProtocolFactory, _connectionTracker)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGivePortConflictErrorWithPortNumberInIt() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldGivePortConflictErrorWithPortNumberInIt() { // Given an occupied port int port = 16000; using (ServerSocketChannel ignore = ServerSocketChannel.open().bind(new InetSocketAddress("localhost", port))) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.helpers.ListenSocketAddress address = new org.neo4j.helpers.ListenSocketAddress("localhost", port); ListenSocketAddress address = new ListenSocketAddress("localhost", port); // Expect Exception.expect(typeof(PortBindException)); // When IDictionary <BoltConnector, NettyServer.ProtocolInitializer> initializersMap = genericMap(new BoltConnector("test"), ProtocolOnAddress(address)); (new NettyServer(new NamedThreadFactory("mythreads"), initializersMap, new ConnectorPortRegister(), NullLog.Instance)).start(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldCloseHandlerIfChannelIsClosedInClient() throws org.neo4j.kernel.lifecycle.LifecycleException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldCloseHandlerIfChannelIsClosedInClient() { // given string hostname = "localhost"; int port = PortAuthority.allocatePort(); ListenSocketAddress listenSocketAddress = new ListenSocketAddress(hostname, port); AtomicBoolean wasClosedByClient = new AtomicBoolean(false); Server emptyServer = CatchupServer(listenSocketAddress); CatchUpClient closingClient = ClosingChannelCatchupClient(wasClosedByClient); _lifeSupport.add(emptyServer); _lifeSupport.add(closingClient); // when _lifeSupport.init(); _lifeSupport.start(); // then AssertClosedChannelException(hostname, port, closingClient); assertTrue(wasClosedByClient.get()); }
public AbstractNeoServer(Config config, GraphFactory graphFactory, Dependencies dependencies) { this._config = config; this.UserLogProvider = dependencies.UserLogProvider(); this._log = UserLogProvider.getLog(this.GetType()); _log.info(Neo4jIsStartingMessage); VerifyConnectorsConfiguration(config); _httpConnector = FindConnector(config, HttpConnector.Encryption.NONE); _httpListenAddress = ListenAddressFor(config, _httpConnector); _httpAdvertisedAddress = AdvertisedAddressFor(config, _httpConnector); _httpsConnector = FindConnector(config, HttpConnector.Encryption.TLS); _httpsListenAddress = ListenAddressFor(config, _httpsConnector); _httpsAdvertisedAddress = AdvertisedAddressFor(config, _httpsConnector); DatabaseConflict = new LifecycleManagingDatabase(config, graphFactory, dependencies); this._availabilityGuardSupplier = (( LifecycleManagingDatabase )DatabaseConflict).getAvailabilityGuard; _life.add(DatabaseConflict); _life.add(new ServerDependenciesLifeCycleAdapter(this)); _life.add(new ServerComponentsLifecycleAdapter(this)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldCloseHandlerIfChannelIsClosedOnServer() internal virtual void ShouldCloseHandlerIfChannelIsClosedOnServer() { // given string hostname = "localhost"; int port = PortAuthority.allocatePort(); ListenSocketAddress listenSocketAddress = new ListenSocketAddress(hostname, port); AtomicBoolean wasClosedByServer = new AtomicBoolean(false); Server closingChannelServer = ClosingChannelCatchupServer(listenSocketAddress, wasClosedByServer); CatchUpClient emptyClient = emptyClient(); _lifeSupport.add(closingChannelServer); _lifeSupport.add(emptyClient); // when _lifeSupport.init(); _lifeSupport.start(); // then CatchUpClientException catchUpClientException = assertThrows(typeof(CatchUpClientException), () => emptyClient.MakeBlockingRequest(new AdvertisedSocketAddress(hostname, port), new GetStoreIdRequest(), NeverCompletingAdaptor())); assertEquals(typeof(ClosedChannelException), Exceptions.rootCause(catchUpClientException).GetType()); assertTrue(wasClosedByServer.get()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldTimeoutDueToInactivity() internal virtual void ShouldTimeoutDueToInactivity() { // given string hostname = "localhost"; int port = PortAuthority.allocatePort(); ListenSocketAddress listenSocketAddress = new ListenSocketAddress(hostname, port); _inactivityTimeoutMillis = 0; Server closingChannelServer = CatchupServer(listenSocketAddress); CatchUpClient emptyClient = emptyClient(); _lifeSupport.add(closingChannelServer); _lifeSupport.add(emptyClient); // when _lifeSupport.init(); _lifeSupport.start(); // then CatchUpClientException catchUpClientException = assertThrows(typeof(CatchUpClientException), () => emptyClient.MakeBlockingRequest(new AdvertisedSocketAddress(hostname, port), new GetStoreIdRequest(), NeverCompletingAdaptor())); assertEquals(typeof(TimeoutException), Exceptions.rootCause(catchUpClientException).GetType()); }
private Server ClosingChannelCatchupServer(ListenSocketAddress listenSocketAddress, AtomicBoolean wasClosedByServer) { return(CatchupServer(listenSocketAddress, new ByteToMessageDecoderAnonymousInnerClass(this, wasClosedByServer))); }
public virtual CatchupServerBuilder ListenAddress(ListenSocketAddress listenAddress) { this._listenAddress = listenAddress; return(this); }
public Server(ChildInitializer childInitializer, LogProvider debugLogProvider, LogProvider userLogProvider, ListenSocketAddress listenAddress, string serverName) : this(childInitializer, null, debugLogProvider, userLogProvider, listenAddress, serverName) { }
public Server(ChildInitializer childInitializer, ChannelInboundHandler parentHandler, LogProvider debugLogProvider, LogProvider userLogProvider, ListenSocketAddress listenAddress, string serverName) : base(debugLogProvider.GetLog(typeof(Server))) { this._childInitializer = childInitializer; this._parentHandler = parentHandler; this._listenAddress = listenAddress; this._debugLog = debugLogProvider.getLog(this.GetType()); this._userLog = userLogProvider.getLog(this.GetType()); this._serverName = serverName; this._threadFactory = new NamedThreadFactory(serverName); }
public virtual ServerConnector CreateConnector(Server server, SslPolicy sslPolicy, ListenSocketAddress address, JettyThreadCalculator jettyThreadCalculator) { SslConnectionFactory sslConnectionFactory = CreateSslConnectionFactory(sslPolicy); return(createConnector(server, address, jettyThreadCalculator, sslConnectionFactory, CreateHttpConnectionFactory())); }
public Server(ChildInitializer childInitializer, ListenSocketAddress listenAddress, string serverName) : this(childInitializer, null, NullLogProvider.Instance, NullLogProvider.Instance, listenAddress, serverName) { }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: private org.neo4j.bolt.transport.NettyServer.ProtocolInitializer protocolOnAddress(final org.neo4j.helpers.ListenSocketAddress address) private NettyServer.ProtocolInitializer ProtocolOnAddress(ListenSocketAddress address) { return(new ProtocolInitializerAnonymousInnerClass(this, address)); }
public ProtocolInitializerAnonymousInnerClass(NettyServerTest outerInstance, ListenSocketAddress address) { this.outerInstance = outerInstance; this._address = address; }
private Server CatchupServer(ListenSocketAddress listenSocketAddress, params ChannelHandler[] channelHandlers) { return(new Server(channel => channel.pipeline().addLast(channelHandlers), listenSocketAddress, "empty-test-server")); }
public virtual CommunityServerBuilder OnHttpsAddress(ListenSocketAddress address) { this._httpsAddress = address; return(this); }
private HazelcastInstance CreateHazelcastInstance() { JoinConfig joinConfig = new JoinConfig(); joinConfig.MulticastConfig.Enabled = false; TcpIpConfig tcpIpConfig = joinConfig.TcpIpConfig; tcpIpConfig.Enabled = true; //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: ICollection <string> initialMembers = _remoteMembersResolver.resolve(SocketAddress::toString); initialMembers.forEach(tcpIpConfig.addMember); ListenSocketAddress hazelcastAddress = Config.get(discovery_listen_address); NetworkConfig networkConfig = new NetworkConfig(); if (!hazelcastAddress.Wildcard) { InterfacesConfig interfaces = new InterfacesConfig(); interfaces.addInterface(hazelcastAddress.Hostname); interfaces.Enabled = true; networkConfig.Interfaces = interfaces; } networkConfig.Port = hazelcastAddress.Port; networkConfig.Join = joinConfig; networkConfig.PortAutoIncrement = false; // We'll use election_timeout as a base value to calculate HZ timeouts. We multiply by 1.5 long?electionTimeoutMillis = Config.get(CausalClusteringSettings.leader_election_timeout).toMillis(); long?baseHazelcastTimeoutMillis = (3 * electionTimeoutMillis) / 2; /* * Some HZ settings require the value in seconds. Adding the divider and subtracting 1 is equivalent to the * ceiling function for integers ( Math.ceil() returns double ). Anything < 0 will return 0, any * multiple of 1000 returns the result of the division by 1000, any non multiple of 1000 returns the result * of the division + 1. In other words, values in millis are rounded up. */ long baseHazelcastTimeoutSeconds = (baseHazelcastTimeoutMillis + 1000 - 1) / 1000; com.hazelcast.config.Config c = new com.hazelcast.config.Config(); c.setProperty(OPERATION_CALL_TIMEOUT_MILLIS.Name, baseHazelcastTimeoutMillis.ToString()); c.setProperty(MERGE_NEXT_RUN_DELAY_SECONDS.Name, baseHazelcastTimeoutSeconds.ToString()); c.setProperty(MERGE_FIRST_RUN_DELAY_SECONDS.Name, baseHazelcastTimeoutSeconds.ToString()); c.setProperty(INITIAL_MIN_CLUSTER_SIZE.Name, HAZELCAST_MIN_CLUSTER.ToString()); if (Config.get(disable_middleware_logging)) { c.setProperty(LOGGING_TYPE.Name, "none"); } if (hazelcastAddress.IPv6) { c.setProperty(PREFER_IPv4_STACK.Name, "false"); } c.NetworkConfig = networkConfig; MemberAttributeConfig memberAttributeConfig = HazelcastClusterTopology.BuildMemberAttributesForCore(MyselfConflict, Config); c.MemberAttributeConfig = memberAttributeConfig; LogConnectionInfo(initialMembers); c.addListenerConfig(new ListenerConfig(new OurMembershipListener(this))); JobHandle logJob = _scheduler.schedule(Group.HZ_TOPOLOGY_HEALTH, _hazelcastIsHealthyTimeoutMs, () => Log.warn("The server has not been able to connect in a timely fashion to the " + "cluster. Please consult the logs for more details. Rebooting the server may " + "solve the problem.")); try { _hazelcastInstance = Hazelcast.newHazelcastInstance(c); logJob.Cancel(true); } catch (HazelcastException e) { string errorMessage = string.Format("Hazelcast was unable to start with setting: {0} = {1}", discovery_listen_address.name(), Config.get(discovery_listen_address)); UserLog.error(errorMessage); Log.error(errorMessage, e); throw new Exception(e); } IList <string> groups = Config.get(CausalClusteringSettings.server_groups); refreshGroups(_hazelcastInstance, MyselfConflict.Uuid.ToString(), groups); return(_hazelcastInstance); }