Search in sources :

Example 36 with HostnamePort

use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.

the class PortRangeSocketBinderTest method shouldReturnChannelAndSocketIfPortRangeIsInverted.

@Test
public void shouldReturnChannelAndSocketIfPortRangeIsInverted() {
    // given
    HostnamePort localhost = new HostnamePort("localhost", 9001, 9000);
    ServerBootstrap bootstrap = mock(ServerBootstrap.class);
    Channel channel = mock(Channel.class);
    when(bootstrap.bind(new InetSocketAddress("localhost", 9001))).thenReturn(channel);
    // when
    Connection connection = new PortRangeSocketBinder(bootstrap).bindToFirstAvailablePortInRange(localhost);
    //then
    assertEquals(channel, connection.getChannel());
    assertEquals(new InetSocketAddress(localhost.getHost(), 9001), connection.getSocketAddress());
}
Also used : InetSocketAddress(java.net.InetSocketAddress) HostnamePort(org.neo4j.helpers.HostnamePort) Channel(org.jboss.netty.channel.Channel) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap) Test(org.junit.Test)

Example 37 with HostnamePort

use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.

the class HighlyAvailableEditionModule method createCommitProcessFactory.

private CommitProcessFactory createCommitProcessFactory(Dependencies dependencies, LogService logging, Monitors monitors, Config config, LifeSupport paxosLife, ClusterClient clusterClient, ClusterMembers members, JobScheduler jobScheduler, Master master, RequestContextFactory requestContextFactory, ComponentSwitcherContainer componentSwitcherContainer, Supplier<LogEntryReader<ReadableClosablePositionAwareChannel>> logEntryReader) {
    DefaultSlaveFactory slaveFactory = dependencies.satisfyDependency(new DefaultSlaveFactory(logging.getInternalLogProvider(), monitors, config.get(HaSettings.com_chunk_size).intValue(), logEntryReader));
    HostnamePort me = config.get(ClusterSettings.cluster_server);
    Slaves slaves = dependencies.satisfyDependency(paxosLife.add(new HighAvailabilitySlaves(members, clusterClient, slaveFactory, me)));
    TransactionPropagator transactionPropagator = new TransactionPropagator(TransactionPropagator.from(config), logging.getInternalLog(TransactionPropagator.class), slaves, new CommitPusher(jobScheduler));
    paxosLife.add(transactionPropagator);
    DelegateInvocationHandler<TransactionCommitProcess> commitProcessDelegate = new DelegateInvocationHandler<>(TransactionCommitProcess.class);
    CommitProcessSwitcher commitProcessSwitcher = new CommitProcessSwitcher(transactionPropagator, master, commitProcessDelegate, requestContextFactory, lockManager, monitors, dependencies, config.get(GraphDatabaseSettings.release_schema_lock_while_building_constraint));
    componentSwitcherContainer.add(commitProcessSwitcher);
    return new HighlyAvailableCommitProcessFactory(commitProcessDelegate);
}
Also used : TransactionPropagator(org.neo4j.kernel.ha.transaction.TransactionPropagator) CommitPusher(org.neo4j.kernel.ha.transaction.CommitPusher) HostnamePort(org.neo4j.helpers.HostnamePort) TransactionCommitProcess(org.neo4j.kernel.impl.api.TransactionCommitProcess) DefaultSlaveFactory(org.neo4j.kernel.ha.com.master.DefaultSlaveFactory) DelegateInvocationHandler(org.neo4j.kernel.ha.DelegateInvocationHandler) CommitProcessSwitcher(org.neo4j.kernel.ha.cluster.modeswitch.CommitProcessSwitcher) HighAvailabilitySlaves(org.neo4j.kernel.ha.cluster.member.HighAvailabilitySlaves) Slaves(org.neo4j.kernel.ha.com.master.Slaves) HighAvailabilitySlaves(org.neo4j.kernel.ha.cluster.member.HighAvailabilitySlaves)

Example 38 with HostnamePort

use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.

the class EventReporterBuilder method build.

public CompositeEventReporter build() {
    CompositeEventReporter reporter = new CompositeEventReporter();
    final String prefix = createMetricsPrefix(config);
    if (config.get(csvEnabled)) {
        CsvOutput csvOutput = new CsvOutput(config, registry, logger, kernelContext);
        reporter.add(csvOutput);
        life.add(csvOutput);
    }
    if (config.get(graphiteEnabled)) {
        HostnamePort server = config.get(graphiteServer);
        long period = config.get(graphiteInterval);
        GraphiteOutput graphiteOutput = new GraphiteOutput(server, period, registry, logger, prefix);
        reporter.add(graphiteOutput);
        life.add(graphiteOutput);
    }
    return reporter;
}
Also used : HostnamePort(org.neo4j.helpers.HostnamePort)

Example 39 with HostnamePort

use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.

the class BoltMetricsIT method shouldMonitorBolt.

@Test
public void shouldMonitorBolt() throws Throwable {
    // Given
    File metricsFolder = tmpDir.newFolder("metrics");
    db = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().setConfig(new BoltConnector("bolt").type, "BOLT").setConfig(new BoltConnector("bolt").enabled, "true").setConfig(GraphDatabaseSettings.auth_enabled, "false").setConfig(MetricsSettings.boltMessagesEnabled, "true").setConfig(MetricsSettings.csvEnabled, "true").setConfig(MetricsSettings.csvInterval, "100ms").setConfig(MetricsSettings.csvPath, metricsFolder.getAbsolutePath()).newGraphDatabase();
    // When
    conn = new SocketConnection().connect(new HostnamePort("localhost", 7687)).send(acceptedVersions(1, 0, 0, 0)).send(chunk(InitMessage.init("TestClient", map("scheme", "basic", "principal", "neo4j", "credentials", "neo4j"))));
    // Then
    assertEventually("session shows up as started", () -> readLongValue(metricsCsv(metricsFolder, SESSIONS_STARTED)), equalTo(1L), 5, SECONDS);
    assertEventually("init request shows up as received", () -> readLongValue(metricsCsv(metricsFolder, MESSAGES_RECIEVED)), equalTo(1L), 5, SECONDS);
    assertEventually("init request shows up as started", () -> readLongValue(metricsCsv(metricsFolder, MESSAGES_STARTED)), equalTo(1L), 5, SECONDS);
    assertEventually("init request shows up as done", () -> readLongValue(metricsCsv(metricsFolder, MESSAGES_DONE)), equalTo(1L), 5, SECONDS);
    assertEventually("queue time shows up", () -> readLongValue(metricsCsv(metricsFolder, TOTAL_QUEUE_TIME)), greaterThanOrEqualTo(0L), 5, SECONDS);
    assertEventually("processing time shows up", () -> readLongValue(metricsCsv(metricsFolder, TOTAL_PROCESSING_TIME)), greaterThanOrEqualTo(0L), 5, SECONDS);
}
Also used : BoltConnector(org.neo4j.kernel.configuration.BoltConnector) SocketConnection(org.neo4j.bolt.v1.transport.socket.client.SocketConnection) HostnamePort(org.neo4j.helpers.HostnamePort) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) File(java.io.File) Test(org.junit.Test)

Example 40 with HostnamePort

use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.

the class InProcessBuilderTest method shouldOpenBoltPort.

@Test
public void shouldOpenBoltPort() throws Throwable {
    // given
    try (ServerControls controls = newInProcessBuilder().newServer()) {
        URI uri = controls.boltURI();
        // when
        new SocketConnection().connect(new HostnamePort(uri.getHost(), uri.getPort()));
    // then no exception
    }
}
Also used : SocketConnection(org.neo4j.bolt.v1.transport.socket.client.SocketConnection) HostnamePort(org.neo4j.helpers.HostnamePort) URI(java.net.URI) Test(org.junit.Test)

Aggregations

HostnamePort (org.neo4j.helpers.HostnamePort)41 Test (org.junit.Test)29 File (java.io.File)9 Config (org.neo4j.kernel.configuration.Config)9 URI (java.net.URI)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 Cluster (org.neo4j.cluster.protocol.cluster.Cluster)6 PrintStream (java.io.PrintStream)5 InetSocketAddress (java.net.InetSocketAddress)5 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)5 Matchers.anyString (org.mockito.Matchers.anyString)5 DefaultSlaveFactory (org.neo4j.kernel.ha.com.master.DefaultSlaveFactory)5 HashMap (java.util.HashMap)4 SocketConnection (org.neo4j.bolt.v1.transport.socket.client.SocketConnection)4 SlaveFactory (org.neo4j.kernel.ha.com.master.SlaveFactory)4 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)4 InputStream (java.io.InputStream)3 Socket (java.net.Socket)3 Channel (org.jboss.netty.channel.Channel)3 ChannelException (org.jboss.netty.channel.ChannelException)3