use of com.datastax.oss.driver.internal.core.adminrequest.AdminRow in project java-driver by datastax.
the class SchemaAgreementCheckerTest method mockLocalRow.
private AdminRow mockLocalRow(@SuppressWarnings("SameParameterValue") UUID schemaVersion) {
AdminRow row = mock(AdminRow.class);
when(row.getUuid("host_id")).thenReturn(node1.getHostId());
when(row.getUuid("schema_version")).thenReturn(schemaVersion);
return row;
}
use of com.datastax.oss.driver.internal.core.adminrequest.AdminRow in project java-driver by datastax.
the class SchemaAgreementCheckerTest method mockPeerRow.
private static AdminRow mockPeerRow(UUID hostId, UUID schemaVersion, boolean hasDatacenter, boolean hasRack, boolean hasRpcAddress, boolean hasTokens) {
AdminRow row = mock(AdminRow.class);
when(row.getUuid("host_id")).thenReturn(hostId);
when(row.isNull("host_id")).thenReturn(hostId == null);
when(row.getUuid("schema_version")).thenReturn(schemaVersion);
when(row.isNull("schema_version")).thenReturn(schemaVersion == null);
when(row.isNull("data_center")).thenReturn(!hasDatacenter);
when(row.isNull("rack")).thenReturn(!hasRack);
when(row.isNull("tokens")).thenReturn(!hasTokens);
when(row.isNull("rpc_address")).thenReturn(!hasRpcAddress);
when(row.isNull("native_address")).thenReturn(true);
when(row.isNull("native_port")).thenReturn(true);
return row;
}
use of com.datastax.oss.driver.internal.core.adminrequest.AdminRow in project java-driver by datastax.
the class DefaultTopologyMonitorTest method mockLocalRow.
private AdminRow mockLocalRow(int i, UUID hostId) {
try {
AdminRow row = mock(AdminRow.class);
when(row.isNull("host_id")).thenReturn(hostId == null);
when(row.getUuid("host_id")).thenReturn(hostId);
when(row.getInetAddress("broadcast_address")).thenReturn(InetAddress.getByName("127.0.0." + i));
when(row.isNull("data_center")).thenReturn(false);
when(row.getString("data_center")).thenReturn("dc" + i);
when(row.getInetAddress("listen_address")).thenReturn(InetAddress.getByName("127.0.0." + i));
when(row.isNull("rack")).thenReturn(false);
when(row.getString("rack")).thenReturn("rack" + i);
when(row.getString("release_version")).thenReturn("release_version" + i);
// The driver should not use this column for the local row, because it can contain the
// non-broadcast RPC address. Simulate the bug to ensure it's handled correctly.
when(row.isNull("rpc_address")).thenReturn(false);
when(row.getInetAddress("rpc_address")).thenReturn(InetAddress.getByName("0.0.0.0"));
when(row.isNull("tokens")).thenReturn(false);
when(row.getSetOfString("tokens")).thenReturn(ImmutableSet.of("token" + i));
when(row.contains("peer")).thenReturn(false);
return row;
} catch (UnknownHostException e) {
fail("unexpected", e);
return null;
}
}
use of com.datastax.oss.driver.internal.core.adminrequest.AdminRow in project java-driver by datastax.
the class DefaultTopologyMonitorTest method mockPeersRow.
private AdminRow mockPeersRow(int i, UUID hostId) {
try {
AdminRow row = mock(AdminRow.class);
when(row.isNull("host_id")).thenReturn(hostId == null);
when(row.getUuid("host_id")).thenReturn(hostId);
when(row.getInetAddress("peer")).thenReturn(InetAddress.getByName("127.0.0." + i));
when(row.isNull("data_center")).thenReturn(false);
when(row.getString("data_center")).thenReturn("dc" + i);
when(row.isNull("rack")).thenReturn(false);
when(row.getString("rack")).thenReturn("rack" + i);
when(row.getString("release_version")).thenReturn("release_version" + i);
when(row.isNull("rpc_address")).thenReturn(false);
when(row.getInetAddress("rpc_address")).thenReturn(InetAddress.getByName("127.0.0." + i));
when(row.isNull("tokens")).thenReturn(false);
when(row.getSetOfString("tokens")).thenReturn(ImmutableSet.of("token" + i));
when(row.contains("peer")).thenReturn(true);
when(row.isNull("native_address")).thenReturn(true);
when(row.isNull("native_port")).thenReturn(true);
return row;
} catch (UnknownHostException e) {
fail("unexpected", e);
return null;
}
}
use of com.datastax.oss.driver.internal.core.adminrequest.AdminRow in project java-driver by datastax.
the class DefaultTopologyMonitorTest method should_skip_invalid_peers_row.
@Test
@UseDataProvider("columnsToCheckV1")
public void should_skip_invalid_peers_row(String columnToCheck) {
// Given
topologyMonitor.isSchemaV2 = false;
node2.broadcastAddress = ADDRESS2;
AdminRow peer2 = mockPeersRow(2, node2.getHostId());
when(peer2.isNull(columnToCheck)).thenReturn(true);
topologyMonitor.stubQueries(new StubbedQuery("SELECT * FROM system.peers WHERE peer = :address", ImmutableMap.of("address", ADDRESS2.getAddress()), mockResult(peer2)));
// When
CompletionStage<Optional<NodeInfo>> futureInfo = topologyMonitor.refreshNode(node2);
// Then
assertThatStage(futureInfo).isSuccess(maybeInfo -> assertThat(maybeInfo).isEmpty());
assertThat(node2.broadcastAddress).isNotNull().isEqualTo(ADDRESS2);
assertLog(Level.WARN, "[null] Found invalid row in system.peers for peer: /127.0.0.2. " + "This is likely a gossip or snitch issue, this node will be ignored.");
}
Aggregations