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());
}
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);
}
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;
}
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);
}
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
}
}
Aggregations