use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.
the class HighAvailabilitySlavesTest method shouldNotReturnUnavailableSlaves.
@Test
public void shouldNotReturnUnavailableSlaves() {
// given
Cluster cluster = mock(Cluster.class);
ClusterMembers clusterMembers = mock(ClusterMembers.class);
when(clusterMembers.getAliveMembers()).thenReturn(Iterables.option(new ClusterMember(INSTANCE_ID)));
SlaveFactory slaveFactory = mock(SlaveFactory.class);
HighAvailabilitySlaves slaves = new HighAvailabilitySlaves(clusterMembers, cluster, slaveFactory, new HostnamePort(null, 0));
slaves.init();
// when
Iterable<Slave> memberSlaves = slaves.getSlaves();
// then
assertThat(count(memberSlaves), equalTo(0L));
}
use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.
the class SocketConnectionTest method shouldThrowIfNotEnoughBytesAreRead.
@Test
public void shouldThrowIfNotEnoughBytesAreRead() throws Exception {
// GIVEN
Socket socket = mock(Socket.class);
InputStream stream = mock(InputStream.class);
when(socket.getInputStream()).thenReturn(stream);
when(stream.read(any(byte[].class), anyInt(), anyInt())).thenReturn(4).thenReturn(-1);
SocketConnection connection = new SocketConnection(socket);
connection.connect(new HostnamePort("my.domain", 1234));
// EXPECT
expectedException.expect(IOException.class);
// WHEN
connection.recv(10);
}
use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.
the class UdcKernelExtension method start.
@Override
public void start() throws Throwable {
if (!config.get(UdcSettings.udc_enabled)) {
return;
}
int firstDelay = config.get(UdcSettings.first_delay);
int interval = config.get(UdcSettings.interval);
HostnamePort hostAddress = config.get(UdcSettings.udc_host);
UdcInformationCollector collector = new DefaultUdcInformationCollector(config, xadsm, idGeneratorFactory, startupStats, usageData);
UdcTimerTask task = new UdcTimerTask(hostAddress, collector);
timer.scheduleAtFixedRate(task, firstDelay, interval);
}
use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.
the class PingerTest method shouldPingServer.
@Test
public void shouldPingServer() {
final HostnamePort hostURL = new HostnamePort(hostname, server.getLocalPort());
final Map<String, String> udcFields = new HashMap<String, String>();
udcFields.put(ID, EXPECTED_STORE_ID);
udcFields.put(UdcConstants.VERSION, EXPECTED_KERNEL_VERSION);
Pinger p = new Pinger(hostURL, new TestUdcCollector(udcFields));
Exception thrownException = null;
try {
p.ping();
} catch (IOException e) {
thrownException = e;
e.printStackTrace();
}
assertThat(thrownException, nullValue());
Map<String, String> actualQueryMap = handler.getQueryMap();
assertThat(actualQueryMap, notNullValue());
assertThat(actualQueryMap.get(ID), is(EXPECTED_STORE_ID));
}
use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.
the class PingerTest method shouldIncludePingCountInURI.
@Test
public void shouldIncludePingCountInURI() throws IOException {
final int EXPECTED_PING_COUNT = 16;
final HostnamePort hostURL = new HostnamePort(hostname, server.getLocalPort());
final Map<String, String> udcFields = new HashMap<String, String>();
Pinger p = new Pinger(hostURL, new TestUdcCollector(udcFields));
for (int i = 0; i < EXPECTED_PING_COUNT; i++) {
p.ping();
}
assertThat(p.getPingCount(), is(equalTo(EXPECTED_PING_COUNT)));
Map<String, String> actualQueryMap = handler.getQueryMap();
assertThat(actualQueryMap.get(UdcConstants.PING), is(Integer.toString(EXPECTED_PING_COUNT)));
}
Aggregations