Search in sources :

Example 76 with DataNodeId

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);
}
Also used : Port(com.github.ambry.network.Port) ArrayList(java.util.ArrayList) DataNodeId(com.github.ambry.clustermap.DataNodeId) Test(org.junit.Test)

Example 77 with DataNodeId

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);
}
Also used : DataNodeId(com.github.ambry.clustermap.DataNodeId) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) QuotaException(com.github.ambry.quota.QuotaException) Test(org.junit.Test)

Example 78 with DataNodeId

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));
    }
}
Also used : ArrayList(java.util.ArrayList) DataNodeId(com.github.ambry.clustermap.DataNodeId) ServerErrorCode(com.github.ambry.server.ServerErrorCode)

Example 79 with DataNodeId

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;
}
Also used : ArrayList(java.util.ArrayList) DataNodeId(com.github.ambry.clustermap.DataNodeId) MockDataNodeId(com.github.ambry.clustermap.MockDataNodeId) HashSet(java.util.HashSet)

Example 80 with DataNodeId

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);
}
Also used : Port(com.github.ambry.network.Port) DataNodeId(com.github.ambry.clustermap.DataNodeId) Test(org.junit.Test)

Aggregations

DataNodeId (com.github.ambry.clustermap.DataNodeId)92 ArrayList (java.util.ArrayList)45 Test (org.junit.Test)45 HashMap (java.util.HashMap)29 PartitionId (com.github.ambry.clustermap.PartitionId)28 MockDataNodeId (com.github.ambry.clustermap.MockDataNodeId)27 ReplicaId (com.github.ambry.clustermap.ReplicaId)25 MockClusterMap (com.github.ambry.clustermap.MockClusterMap)23 VerifiableProperties (com.github.ambry.config.VerifiableProperties)23 MetricRegistry (com.codahale.metrics.MetricRegistry)22 MockPartitionId (com.github.ambry.clustermap.MockPartitionId)22 List (java.util.List)22 Map (java.util.Map)22 Port (com.github.ambry.network.Port)21 ClusterMap (com.github.ambry.clustermap.ClusterMap)20 ClusterMapConfig (com.github.ambry.config.ClusterMapConfig)19 StoreKeyFactory (com.github.ambry.store.StoreKeyFactory)18 BlobIdFactory (com.github.ambry.commons.BlobIdFactory)17 HashSet (java.util.HashSet)16 Properties (java.util.Properties)16