use of com.github.ambry.protocol.AdminResponse in project ambry by linkedin.
the class ServerAdminTool method controlRequest.
/**
* Sends a {@link RequestControlAdminRequest} to set the enable state of {@code toControl} on {@code partitionIdStr}
* to {@code enable} in {@code dataNodeId}.
* @param dataNodeId the {@link DataNodeId} to contact.
* @param partitionId the {@link PartitionId} to control requests to. Can be {@code null}.
* @param toControl the {@link RequestOrResponseType} to control.
* @param enable the enable (or disable) status required for {@code toControl}.
* @return the {@link ServerErrorCode} that is returned.
* @throws IOException
* @throws TimeoutException
*/
public ServerErrorCode controlRequest(DataNodeId dataNodeId, PartitionId partitionId, RequestOrResponseType toControl, boolean enable) throws IOException, TimeoutException {
AdminRequest adminRequest = new AdminRequest(AdminRequestOrResponseType.RequestControl, partitionId, correlationId.incrementAndGet(), CLIENT_ID);
RequestControlAdminRequest controlRequest = new RequestControlAdminRequest(toControl, enable, adminRequest);
ResponseInfo response = sendRequestGetResponse(dataNodeId, partitionId, controlRequest);
AdminResponse adminResponse = AdminResponse.readFrom(new NettyByteBufDataInputStream(response.content()));
response.release();
return adminResponse.getError();
}
use of com.github.ambry.protocol.AdminResponse in project ambry by linkedin.
the class ServerAdminTool method controlBlobStore.
/**
* Sends a {@link BlobStoreControlAdminRequest} to start or stop a store associated with {@code partitionId}
* on {@code dataNodeId}.
* @param dataNodeId the {@link DataNodeId} to contact.
* @param partitionId the {@link PartitionId} to start or stop.
* @param numReplicasCaughtUpPerPartition the minimum number of peers should catch up with partition if the store is
* being stopped
* @param storeControlRequestType the type of control operation that will performed on certain store.
* @return the {@link ServerErrorCode} that is returned.
* @throws IOException
* @throws TimeoutException
*/
private ServerErrorCode controlBlobStore(DataNodeId dataNodeId, PartitionId partitionId, short numReplicasCaughtUpPerPartition, BlobStoreControlAction storeControlRequestType) throws IOException, TimeoutException {
AdminRequest adminRequest = new AdminRequest(AdminRequestOrResponseType.BlobStoreControl, partitionId, correlationId.incrementAndGet(), CLIENT_ID);
BlobStoreControlAdminRequest controlRequest = new BlobStoreControlAdminRequest(numReplicasCaughtUpPerPartition, storeControlRequestType, adminRequest);
ResponseInfo response = sendRequestGetResponse(dataNodeId, partitionId, controlRequest);
AdminResponse adminResponse = AdminResponse.readFrom(new NettyByteBufDataInputStream(response.content()));
response.release();
return adminResponse.getError();
}
use of com.github.ambry.protocol.AdminResponse 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();
}
Aggregations