Search in sources :

Example 6 with ReplicationControlAdminRequest

use of com.github.ambry.protocol.ReplicationControlAdminRequest in project ambry by linkedin.

the class ServerAdminTool method controlReplication.

/**
 * Sends a {@link ReplicationControlAdminRequest} to enable/disable replication from {@code origins} for
 * {@code partitionIdStr} in {@code dataNodeId}.
 * @param dataNodeId the {@link DataNodeId} to contact.
 * @param partitionId the {@link PartitionId} to control replication for. Can be {@code null}.
 * @param origins the names of the datacenters from which replication should be controlled.
 * @param enable the enable (or disable) status required for replication from {@code origins}.
 * @return the {@link ServerErrorCode} that is returned.
 * @throws IOException
 * @throws TimeoutException
 */
public ServerErrorCode controlReplication(DataNodeId dataNodeId, PartitionId partitionId, List<String> origins, boolean enable) throws IOException, TimeoutException {
    AdminRequest adminRequest = new AdminRequest(AdminRequestOrResponseType.ReplicationControl, partitionId, correlationId.incrementAndGet(), CLIENT_ID);
    ReplicationControlAdminRequest controlRequest = new ReplicationControlAdminRequest(origins, enable, adminRequest);
    ResponseInfo response = sendRequestGetResponse(dataNodeId, partitionId, controlRequest);
    AdminResponse adminResponse = AdminResponse.readFrom(new NettyByteBufDataInputStream(response.content()));
    response.release();
    return adminResponse.getError();
}
Also used : CatchupStatusAdminRequest(com.github.ambry.protocol.CatchupStatusAdminRequest) AdminRequest(com.github.ambry.protocol.AdminRequest) ReplicationControlAdminRequest(com.github.ambry.protocol.ReplicationControlAdminRequest) RequestControlAdminRequest(com.github.ambry.protocol.RequestControlAdminRequest) BlobStoreControlAdminRequest(com.github.ambry.protocol.BlobStoreControlAdminRequest) ResponseInfo(com.github.ambry.network.ResponseInfo) NettyByteBufDataInputStream(com.github.ambry.utils.NettyByteBufDataInputStream) CatchupStatusAdminResponse(com.github.ambry.protocol.CatchupStatusAdminResponse) AdminResponse(com.github.ambry.protocol.AdminResponse) ReplicationControlAdminRequest(com.github.ambry.protocol.ReplicationControlAdminRequest)

Aggregations

AdminResponse (com.github.ambry.protocol.AdminResponse)6 ReplicationControlAdminRequest (com.github.ambry.protocol.ReplicationControlAdminRequest)6 CatchupStatusAdminResponse (com.github.ambry.protocol.CatchupStatusAdminResponse)5 PartitionId (com.github.ambry.clustermap.PartitionId)4 AdminRequest (com.github.ambry.protocol.AdminRequest)4 BlobStoreControlAdminRequest (com.github.ambry.protocol.BlobStoreControlAdminRequest)4 CatchupStatusAdminRequest (com.github.ambry.protocol.CatchupStatusAdminRequest)3 RequestControlAdminRequest (com.github.ambry.protocol.RequestControlAdminRequest)3 GetResponse (com.github.ambry.protocol.GetResponse)2 ReplicaMetadataResponse (com.github.ambry.protocol.ReplicaMetadataResponse)2 RequestOrResponse (com.github.ambry.protocol.RequestOrResponse)2 Response (com.github.ambry.protocol.Response)2 NettyByteBufDataInputStream (com.github.ambry.utils.NettyByteBufDataInputStream)2 MockPartitionId (com.github.ambry.clustermap.MockPartitionId)1 ServerErrorCode (com.github.ambry.commons.ServerErrorCode)1 ConnectedChannel (com.github.ambry.network.ConnectedChannel)1 ResponseInfo (com.github.ambry.network.ResponseInfo)1 DataInputStream (java.io.DataInputStream)1