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);
}
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);
}
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");
}
}
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);
}
}
}
Aggregations