Search in sources :

Example 61 with Port

use of com.github.ambry.network.Port 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)

Example 62 with Port

use of com.github.ambry.network.Port in project ambry by linkedin.

the class ServerSSLTest method endToEndSSLTest.

@Test
public void endToEndSSLTest() throws IOException, InstantiationException {
    sslCluster.startServers();
    DataNodeId dataNodeId = sslCluster.getGeneralDataNode();
    ServerTestUtil.endToEndTest(new Port(dataNodeId.getSSLPort(), PortType.SSL), "DC1", sslCluster, clientSSLConfig1, clientSSLSocketFactory1, routerProps, testEncryption);
}
Also used : Port(com.github.ambry.network.Port) DataNodeId(com.github.ambry.clustermap.DataNodeId) Test(org.junit.Test)

Example 63 with Port

use of com.github.ambry.network.Port in project ambry by linkedin.

the class MockDataNodeId method populatePorts.

private void populatePorts(List<Port> ports) {
    boolean plainTextPortFound = false;
    for (Port port : ports) {
        if (port.getPortType() == PortType.PLAINTEXT) {
            plainTextPortFound = true;
            this.portNum = port.getPort();
        }
        this.ports.put(port.getPortType(), port);
    }
    if (!plainTextPortFound) {
        throw new IllegalArgumentException("No Plain Text port found");
    }
}
Also used : Port(com.github.ambry.network.Port)

Example 64 with Port

use of com.github.ambry.network.Port in project ambry by linkedin.

the class DirectoryUploader method writeToAmbryReplica.

/**
 * Adding a blob to a particular server.
 * @param stream stream containing the actual blob
 * @param blobId blob id generated by ambry
 * @param replicaId replica to which the blob has to be added
 * @param correlationId coorelation id to uniquely identify the call
 * @return true if write succeeds, else false
 * @throws Exception
 */
private boolean writeToAmbryReplica(BlobProperties blobProperties, ByteBuffer userMetaData, InputStream stream, BlobId blobId, ReplicaId replicaId, AtomicInteger correlationId, boolean enableVerboseLogging) throws Exception {
    ArrayList<BlobId> blobIds = new ArrayList<BlobId>();
    blobIds.add(blobId);
    ConnectedChannel blockingChannel = null;
    try {
        blockingChannel = connectionPool.checkOutConnection(replicaId.getDataNodeId().getHostname(), new Port(replicaId.getDataNodeId().getPort(), PortType.PLAINTEXT), 100000);
        int size = (int) blobProperties.getBlobSize();
        ByteBufferInputStream blobStream = new ByteBufferInputStream(stream, size);
        PutRequest putRequest = new PutRequest(correlationId.incrementAndGet(), "consumerThread", blobId, blobProperties, userMetaData, Unpooled.wrappedBuffer(blobStream.getByteBuffer()), size, BlobType.DataBlob, null);
        if (enableVerboseLogging) {
            System.out.println("Put Request to a replica : " + putRequest + " for blobId " + blobId);
        }
        PutResponse putResponse = getPutResponseFromStream(blockingChannel, putRequest, connectionPool);
        if (putResponse == null) {
            System.out.println("PutResponse to a replica " + replicaId + " failed with null Response for blobId " + blobId);
            blockingChannel = null;
            return false;
        } else {
            if (putResponse.getError() != ServerErrorCode.No_Error && putResponse.getError() != ServerErrorCode.Blob_Already_Exists) {
                System.out.println("PutResponse to a replica " + replicaId + " failed with Error code  " + putResponse.getError() + " for blobId " + blobId);
                return false;
            }
            return true;
        }
    } finally {
        if (stream != null) {
            stream.close();
        }
        if (blockingChannel != null) {
            connectionPool.checkInConnection(blockingChannel);
        }
    }
}
Also used : Port(com.github.ambry.network.Port) ArrayList(java.util.ArrayList) ByteBufferInputStream(com.github.ambry.utils.ByteBufferInputStream) PutRequest(com.github.ambry.protocol.PutRequest) ConnectedChannel(com.github.ambry.network.ConnectedChannel) PutResponse(com.github.ambry.protocol.PutResponse) BlobId(com.github.ambry.commons.BlobId)

Aggregations

Port (com.github.ambry.network.Port)64 Test (org.junit.Test)33 MockDataNodeId (com.github.ambry.clustermap.MockDataNodeId)29 ArrayList (java.util.ArrayList)28 MockClusterMap (com.github.ambry.clustermap.MockClusterMap)27 MockPartitionId (com.github.ambry.clustermap.MockPartitionId)23 DataNodeId (com.github.ambry.clustermap.DataNodeId)22 ReplicaId (com.github.ambry.clustermap.ReplicaId)17 BlobId (com.github.ambry.commons.BlobId)15 VerifiableProperties (com.github.ambry.config.VerifiableProperties)15 BlobProperties (com.github.ambry.messageformat.BlobProperties)15 Properties (java.util.Properties)15 MetricRegistry (com.codahale.metrics.MetricRegistry)12 PartitionId (com.github.ambry.clustermap.PartitionId)12 ConnectedChannel (com.github.ambry.network.ConnectedChannel)12 PartitionRequestInfo (com.github.ambry.protocol.PartitionRequestInfo)10 MockReplicaId (com.github.ambry.clustermap.MockReplicaId)9 ClusterMapConfig (com.github.ambry.config.ClusterMapConfig)9 GetResponse (com.github.ambry.protocol.GetResponse)9 DataInputStream (java.io.DataInputStream)9