use of com.github.ambry.clustermap.DataNodeId in project ambry by linkedin.
the class ServerSSLTokenTest method endToEndSSLReplicationWithMultiNodeSinglePartitionTest.
@Test
public void endToEndSSLReplicationWithMultiNodeSinglePartitionTest() {
DataNodeId dataNodeId = sslCluster.getClusterMap().getDataNodeIds().get(0);
ArrayList<String> dataCenterList = new ArrayList<String>(Arrays.asList("DC1", "DC2", "DC3"));
List<DataNodeId> dataNodes = sslCluster.getOneDataNodeFromEachDatacenter(dataCenterList);
ServerTestUtil.endToEndReplicationWithMultiNodeSinglePartitionTest("DC1", dataNodeId.getPort(), new Port(dataNodes.get(0).getSSLPort(), PortType.SSL), new Port(dataNodes.get(1).getSSLPort(), PortType.SSL), new Port(dataNodes.get(2).getSSLPort(), PortType.SSL), sslCluster, clientSSLConfig, clientSSLSocketFactory, notificationSystem, routerProps, testEncryption);
}
use of com.github.ambry.clustermap.DataNodeId in project ambry by linkedin.
the class MockReadableStreamChannel method testPutWithTwoNodesFailure.
/**
* Test ensures failure when two out of three nodes fail.
*/
@Test
public void testPutWithTwoNodesFailure() throws Exception {
requestAndResultsList.clear();
requestAndResultsList.add(new RequestAndResult(chunkSize * 5));
List<DataNodeId> dataNodeIds = mockClusterMap.getDataNodeIds();
// Note: The assumption is that there are 3 nodes per DC.
for (int i = 0; i < dataNodeIds.size(); i++) {
if (i % 3 != 0) {
String host = dataNodeIds.get(i).getHostname();
int port = dataNodeIds.get(i).getPort();
MockServer server = mockServerLayout.getMockServer(host, port);
server.setServerErrorForAllRequests(ServerErrorCode.Unknown_Error);
}
}
Exception expectedException = new RouterException("", RouterErrorCode.AmbryUnavailable);
submitPutsAndAssertFailure(expectedException, true, false, false);
}
use of com.github.ambry.clustermap.DataNodeId in project ambry by linkedin.
the class RouterTestHelpers method setServerErrorCodes.
/**
* Set the servers containing the specified partition to respond with the designated error codes.
* @param serverErrorCodesInOrder The error codes to set in the order of the servers returned by
* {@link PartitionId#getReplicaIds()}. If there are fewer error codes in this array
* than there are servers containing the partition, the rest of the servers are set to
* {@link ServerErrorCode#No_Error}
* @param partition The partition contained by the servers to set error codes on.
* @param serverLayout A {@link MockServerLayout} that is used to find the {@link MockServer}s to set error codes on.
* @throws IllegalArgumentException If there are more error codes in the input array then there are servers.
*/
static void setServerErrorCodes(ServerErrorCode[] serverErrorCodesInOrder, PartitionId partition, MockServerLayout serverLayout) {
List<? extends ReplicaId> replicas = partition.getReplicaIds();
if (serverErrorCodesInOrder.length > replicas.size()) {
throw new IllegalArgumentException("More server error codes provided than replicas in partition");
}
// Assume number of nodes in each dc is 3 and do serverErrorCodes assignment based on Operation Tracker logic.
// TODO: Use a shared queue among all mock servers to avoid assumption above.
int numOfNodesEachDatacenter = 3;
List<ServerErrorCode> serverErrorInLocalDC = Arrays.asList(serverErrorCodesInOrder).subList(0, numOfNodesEachDatacenter);
List<ServerErrorCode> serverErrorInOtherDCs = Arrays.asList(serverErrorCodesInOrder).subList(numOfNodesEachDatacenter, serverErrorCodesInOrder.length);
Collections.reverse(serverErrorInLocalDC);
Collections.reverse(serverErrorInOtherDCs);
List<ServerErrorCode> serverErrorCodesInOperationTrackerOrder = new ArrayList<>(serverErrorInLocalDC);
serverErrorCodesInOperationTrackerOrder.addAll(serverErrorInOtherDCs);
for (int i = 0; i < partition.getReplicaIds().size(); i++) {
DataNodeId node = partition.getReplicaIds().get(i).getDataNodeId();
MockServer mockServer = serverLayout.getMockServer(node.getHostname(), node.getPort());
mockServer.setServerErrorForAllRequests(serverErrorCodesInOperationTrackerOrder.get(i));
}
}
use of com.github.ambry.clustermap.DataNodeId in project ambry by linkedin.
the class MockNotificationSystem method getOneDataNodeFromEachDatacenter.
public List<DataNodeId> getOneDataNodeFromEachDatacenter(List<String> datacenterList) {
HashSet<String> datacenters = new HashSet<String>();
List<DataNodeId> toReturn = new ArrayList<DataNodeId>();
for (DataNodeId dataNodeId : clusterMap.getDataNodeIds()) {
if (datacenterList.contains(dataNodeId.getDatacenterName())) {
if (!datacenters.contains(dataNodeId.getDatacenterName())) {
datacenters.add(dataNodeId.getDatacenterName());
toReturn.add(dataNodeId);
}
}
}
return toReturn;
}
use of com.github.ambry.clustermap.DataNodeId in project ambry by linkedin.
the class ServerPlaintextTest method undeleteRecoveryTest.
/**
* Test index recovery for undelete.
* @throws Exception
*/
@Test
public void undeleteRecoveryTest() throws Exception {
assumeTrue(!testEncryption);
plaintextCluster.startServers();
DataNodeId dataNodeId = plaintextCluster.getGeneralDataNode();
ServerTestUtil.undeleteRecoveryTest(new Port(dataNodeId.getPort(), PortType.PLAINTEXT), plaintextCluster, null, null);
}
Aggregations