Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 14 additions & 47 deletions clients/src/main/java/org/apache/kafka/clients/admin/Admin.java
Original file line number Diff line number Diff line change
Expand Up @@ -356,74 +356,41 @@ default DescribeTopicPartitionsResult describeTopicPartitions(Collection<String>
DescribeTopicPartitionsResult describeTopicPartitions(Collection<String> topics, DescribeTopicsOptions options);

/**
* Override the classic-to-diskless switch state of a single partition. This is an operator
* tool that writes the {@code classicToDisklessStartOffset} directly on the controller without
* requiring the caller to be the partition leader.
* Alter the classic-to-diskless switch of a single partition. This is an operator tool that accepts two
* seal offsets: {@code -2} re-arms a pending switch, so the leader seals again and re-runs the switch, and
* a seal of at least {@code 0} lowers a committed seal in phase 1. Lowering the seal loses the records
* between the new seal and the old one.
*
* This is a convenience method for {@link #alterDisklessSwitch(String, int, long, AlterDisklessSwitchOptions)}
* with default options. The same rules apply: once the partition's classic prefix is in remote
* storage, the controller rejects every seal offset.
* with default options.
*
* @param topic The topic name.
* @param partition The partition index.
* @param sealOffset The seal offset to commit: {@code >= 0} forces (re-)sealing at that offset,
* {@code -1} aborts the switch and reverts the partition to classic, and
* {@code -2} re-arms the switch as pending.
* @param sealOffset {@code -2} to re-arm, or the new, lower seal.
* @return The AlterDisklessSwitchResult.
*/
default AlterDisklessSwitchResult alterDisklessSwitch(String topic, int partition, long sealOffset) {
return alterDisklessSwitch(topic, partition, sealOffset, new AlterDisklessSwitchOptions());
}

/**
* Override the classic-to-diskless switch state of a single partition. This is an operator
* tool that writes the {@code classicToDisklessStartOffset} directly on the controller without
* requiring the caller to be the partition leader.
* Alter the classic-to-diskless switch of a single partition. This is an operator tool that accepts two
* seal offsets: {@code -2} re-arms a pending switch, so the leader seals again and re-runs the switch, and
* a seal of at least {@code 0} lowers a committed seal in phase 1. Lowering the seal loses the records
* between the new seal and the old one.
*
* Once the partition's classic prefix is in remote storage ({@code classicPrefixInRemoteStorage} is
* set), the controller rejects every seal offset and the result fails with
* {@code InvalidRequestException}.
* The result fails with {@code InvalidRequestException} for {@code -2} if the switch isn't pending, and for
* a seal of at least {@code 0} if the partition has no committed seal, is in phase 2, or the seal isn't
* lower than the committed seal. It also fails for every other negative seal offset.
*
* @param topic The topic name.
* @param partition The partition index.
* @param sealOffset The seal offset to commit: {@code >= 0} forces (re-)sealing at that offset,
* {@code -1} aborts the switch and reverts the partition to classic, and
* {@code -2} re-arms the switch as pending.
* @param sealOffset {@code -2} to re-arm, or the new, lower seal.
* @param options The options to use.
* @return The AlterDisklessSwitchResult.
*/
AlterDisklessSwitchResult alterDisklessSwitch(String topic, int partition, long sealOffset, AlterDisklessSwitchOptions options);

/**
* Reconcile the control-plane diskless log entry of a single partition with the seal committed in
* KRaft. This is an operator tool; the request must be sent to the partition leader, which owns the
* control-plane connection, so the caller supplies its broker id.
*
* This is a convenience method for {@link #repairDisklessLog(String, int, int, RepairDisklessLogOptions)}
* with default options.
*
* @param topic The topic name.
* @param partition The partition index.
* @param brokerId The id of the partition leader broker to send the request to.
* @return The RepairDisklessLogResult.
*/
default RepairDisklessLogResult repairDisklessLog(String topic, int partition, int brokerId) {
return repairDisklessLog(topic, partition, brokerId, new RepairDisklessLogOptions());
}

/**
* Reconcile the control-plane diskless log entry of a single partition with the seal committed in
* KRaft. This is an operator tool; the request must be sent to the partition leader, which owns the
* control-plane connection, so the caller supplies its broker id.
*
* @param topic The topic name.
* @param partition The partition index.
* @param brokerId The id of the partition leader broker to send the request to.
* @param options The options to use.
* @return The RepairDisklessLogResult.
*/
RepairDisklessLogResult repairDisklessLog(String topic, int partition, int brokerId, RepairDisklessLogOptions options);

/**
* Get information about the nodes in the cluster, using the default options.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,4 @@
*/
@InterfaceStability.Unstable
public class AlterDisklessSwitchOptions extends AbstractOptions<AlterDisklessSwitchOptions> {
private boolean clearProducerStates = false;

/**
* When forcing a seal (offset {@code >= 0}), whether to clear the committed producer states.
* Ignored for negative seal offsets, which always clear them.
*/
public AlterDisklessSwitchOptions clearProducerStates(boolean clearProducerStates) {
this.clearProducerStates = clearProducerStates;
return this;
}

public boolean clearProducerStates() {
return clearProducerStates;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ public AlterDisklessSwitchResult alterDisklessSwitch(String topic, int partition
return delegate.alterDisklessSwitch(topic, partition, sealOffset, options);
}

@Override
public RepairDisklessLogResult repairDisklessLog(String topic, int partition, int brokerId, RepairDisklessLogOptions options) {
return delegate.repairDisklessLog(topic, partition, brokerId, options);
}

@Override
public DescribeClusterResult describeCluster(DescribeClusterOptions options) {
return delegate.describeCluster(options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@
import org.apache.kafka.common.message.MetadataRequestData;
import org.apache.kafka.common.message.RemoveRaftVoterRequestData;
import org.apache.kafka.common.message.RenewDelegationTokenRequestData;
import org.apache.kafka.common.message.RepairDisklessLogRequestData;
import org.apache.kafka.common.message.UnregisterBrokerRequestData;
import org.apache.kafka.common.message.UpdateFeaturesRequestData;
import org.apache.kafka.common.message.UpdateFeaturesResponseData.UpdatableFeatureResult;
Expand Down Expand Up @@ -251,8 +250,6 @@
import org.apache.kafka.common.requests.RemoveRaftVoterResponse;
import org.apache.kafka.common.requests.RenewDelegationTokenRequest;
import org.apache.kafka.common.requests.RenewDelegationTokenResponse;
import org.apache.kafka.common.requests.RepairDisklessLogRequest;
import org.apache.kafka.common.requests.RepairDisklessLogResponse;
import org.apache.kafka.common.requests.UnregisterBrokerRequest;
import org.apache.kafka.common.requests.UnregisterBrokerResponse;
import org.apache.kafka.common.requests.UpdateFeaturesRequest;
Expand Down Expand Up @@ -4919,8 +4916,7 @@ AlterDisklessSwitchRequest.Builder createRequest(int timeoutMs) {
AlterDisklessSwitchRequestData data = new AlterDisklessSwitchRequestData()
.setTopicName(topic)
.setPartitionIndex(partition)
.setSealOffset(sealOffset)
.setClearProducerStates(options.clearProducerStates());
.setSealOffset(sealOffset);
return new AlterDisklessSwitchRequest.Builder(data);
}

Expand All @@ -4944,43 +4940,6 @@ void handleFailure(Throwable throwable) {
return new AlterDisklessSwitchResult(future);
}

@Override
public RepairDisklessLogResult repairDisklessLog(String topic, int partition, int brokerId,
RepairDisklessLogOptions options) {
final KafkaFutureImpl<Void> future = new KafkaFutureImpl<>();
final long now = time.milliseconds();
// The control-plane write happens on the partition leader, so send directly to that broker.
final Call call = new Call("repairDisklessLog", calcDeadlineMs(now, options.timeoutMs()),
new ConstantNodeIdProvider(brokerId)) {

@Override
RepairDisklessLogRequest.Builder createRequest(int timeoutMs) {
RepairDisklessLogRequestData data = new RepairDisklessLogRequestData()
.setTopicName(topic)
.setPartitionIndex(partition);
return new RepairDisklessLogRequest.Builder(data);
}

@Override
void handleResponse(AbstractResponse abstractResponse) {
final RepairDisklessLogResponse response = (RepairDisklessLogResponse) abstractResponse;
Errors error = Errors.forCode(response.data().errorCode());
if (error == Errors.NONE) {
future.complete(null);
} else {
future.completeExceptionally(error.exception(response.data().errorMessage()));
}
}

@Override
void handleFailure(Throwable throwable) {
future.completeExceptionally(throwable);
}
};
runnable.call(call, now);
return new RepairDisklessLogResult(future);
}

@Override
public DescribeProducersResult describeProducers(Collection<TopicPartition> topicPartitions, DescribeProducersOptions options) {
PartitionLeaderStrategy.PartitionLeaderFuture<DescribeProducersResult.PartitionProducerState> future =
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ public enum ApiKeys {
DELETE_SHARE_GROUP_OFFSETS(ApiMessageType.DELETE_SHARE_GROUP_OFFSETS),
INIT_DISKLESS_LOG(ApiMessageType.INIT_DISKLESS_LOG, true),
ALTER_DISKLESS_SWITCH(ApiMessageType.ALTER_DISKLESS_SWITCH, false, true),
REPAIR_DISKLESS_LOG(ApiMessageType.REPAIR_DISKLESS_LOG, false, false),
SET_CLASSIC_PREFIX_IN_REMOTE_STORAGE(ApiMessageType.SET_CLASSIC_PREFIX_IN_REMOTE_STORAGE, true);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,6 @@ private static AbstractRequest doParseRequest(ApiKeys apiKey, short apiVersion,
return InitDisklessLogRequest.parse(readable, apiVersion);
case ALTER_DISKLESS_SWITCH:
return AlterDisklessSwitchRequest.parse(readable, apiVersion);
case REPAIR_DISKLESS_LOG:
return RepairDisklessLogRequest.parse(readable, apiVersion);
case SET_CLASSIC_PREFIX_IN_REMOTE_STORAGE:
return SetClassicPrefixInRemoteStorageRequest.parse(readable, apiVersion);
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,6 @@ public static AbstractResponse parseResponse(ApiKeys apiKey, Readable readable,
return InitDisklessLogResponse.parse(readable, version);
case ALTER_DISKLESS_SWITCH:
return AlterDisklessSwitchResponse.parse(readable, version);
case REPAIR_DISKLESS_LOG:
return RepairDisklessLogResponse.parse(readable, version);
case SET_CLASSIC_PREFIX_IN_REMOTE_STORAGE:
return SetClassicPrefixInRemoteStorageResponse.parse(readable, version);
default:
Expand Down

This file was deleted.

Loading
Loading