use of org.apache.kafka.server.log.remote.storage.RemoteResourceNotFoundException in project kafka by apache.
the class RemotePartitionMetadataStore method handleRemoteLogSegmentMetadataUpdate.
@Override
public void handleRemoteLogSegmentMetadataUpdate(RemoteLogSegmentMetadataUpdate rlsmUpdate) {
log.debug("Updating remote log segment: [{}]", rlsmUpdate);
RemoteLogSegmentId remoteLogSegmentId = rlsmUpdate.remoteLogSegmentId();
TopicIdPartition topicIdPartition = remoteLogSegmentId.topicIdPartition();
RemoteLogMetadataCache remoteLogMetadataCache = idToRemoteLogMetadataCache.get(topicIdPartition);
if (remoteLogMetadataCache != null) {
try {
remoteLogMetadataCache.updateRemoteLogSegmentMetadata(rlsmUpdate);
} catch (RemoteResourceNotFoundException e) {
log.warn("Error occurred while updating the remote log segment.", e);
}
} else {
throw new IllegalStateException("No partition metadata found for : " + topicIdPartition);
}
}
use of org.apache.kafka.server.log.remote.storage.RemoteResourceNotFoundException in project kafka by apache.
the class RemoteLogMetadataCache method updateRemoteLogSegmentMetadata.
public void updateRemoteLogSegmentMetadata(RemoteLogSegmentMetadataUpdate metadataUpdate) throws RemoteResourceNotFoundException {
log.debug("Updating remote log segment metadata: [{}]", metadataUpdate);
Objects.requireNonNull(metadataUpdate, "metadataUpdate can not be null");
RemoteLogSegmentState targetState = metadataUpdate.state();
RemoteLogSegmentId remoteLogSegmentId = metadataUpdate.remoteLogSegmentId();
RemoteLogSegmentMetadata existingMetadata = idToSegmentMetadata.get(remoteLogSegmentId);
if (existingMetadata == null) {
throw new RemoteResourceNotFoundException("No remote log segment metadata found for :" + remoteLogSegmentId);
}
// Check the state transition.
checkStateTransition(existingMetadata.state(), targetState);
switch(targetState) {
case COPY_SEGMENT_STARTED:
// RemoteLogSegmentState.COPY_SEGMENT_STARTED.
throw new IllegalArgumentException("metadataUpdate: " + metadataUpdate + " with state " + RemoteLogSegmentState.COPY_SEGMENT_STARTED + " can not be updated");
case COPY_SEGMENT_FINISHED:
handleSegmentWithCopySegmentFinishedState(existingMetadata.createWithUpdates(metadataUpdate));
break;
case DELETE_SEGMENT_STARTED:
handleSegmentWithDeleteSegmentStartedState(existingMetadata.createWithUpdates(metadataUpdate));
break;
case DELETE_SEGMENT_FINISHED:
handleSegmentWithDeleteSegmentFinishedState(existingMetadata.createWithUpdates(metadataUpdate));
break;
default:
throw new IllegalArgumentException("Metadata with the state " + targetState + " is not supported");
}
}
use of org.apache.kafka.server.log.remote.storage.RemoteResourceNotFoundException in project kafka by apache.
the class RemoteLogLeaderEpochState method collectConvertedIdToMetadata.
private void collectConvertedIdToMetadata(Collection<RemoteLogSegmentId> segmentIds, Map<RemoteLogSegmentId, RemoteLogSegmentMetadata> idToSegmentMetadata, Collection<RemoteLogSegmentMetadata> result) throws RemoteResourceNotFoundException {
for (RemoteLogSegmentId id : segmentIds) {
RemoteLogSegmentMetadata metadata = idToSegmentMetadata.get(id);
if (metadata == null) {
throw new RemoteResourceNotFoundException("No remote log segment metadata found for :" + id);
}
result.add(metadata);
}
}
Aggregations