Search in sources :

Example 1 with RemoteResourceNotFoundException

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);
    }
}
Also used : RemoteResourceNotFoundException(org.apache.kafka.server.log.remote.storage.RemoteResourceNotFoundException) TopicIdPartition(org.apache.kafka.common.TopicIdPartition) RemoteLogSegmentId(org.apache.kafka.server.log.remote.storage.RemoteLogSegmentId)

Example 2 with RemoteResourceNotFoundException

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");
    }
}
Also used : RemoteResourceNotFoundException(org.apache.kafka.server.log.remote.storage.RemoteResourceNotFoundException) RemoteLogSegmentState(org.apache.kafka.server.log.remote.storage.RemoteLogSegmentState) RemoteLogSegmentId(org.apache.kafka.server.log.remote.storage.RemoteLogSegmentId) RemoteLogSegmentMetadata(org.apache.kafka.server.log.remote.storage.RemoteLogSegmentMetadata)

Example 3 with RemoteResourceNotFoundException

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);
    }
}
Also used : RemoteResourceNotFoundException(org.apache.kafka.server.log.remote.storage.RemoteResourceNotFoundException) RemoteLogSegmentId(org.apache.kafka.server.log.remote.storage.RemoteLogSegmentId) RemoteLogSegmentMetadata(org.apache.kafka.server.log.remote.storage.RemoteLogSegmentMetadata)

Aggregations

RemoteLogSegmentId (org.apache.kafka.server.log.remote.storage.RemoteLogSegmentId)3 RemoteResourceNotFoundException (org.apache.kafka.server.log.remote.storage.RemoteResourceNotFoundException)3 RemoteLogSegmentMetadata (org.apache.kafka.server.log.remote.storage.RemoteLogSegmentMetadata)2 TopicIdPartition (org.apache.kafka.common.TopicIdPartition)1 RemoteLogSegmentState (org.apache.kafka.server.log.remote.storage.RemoteLogSegmentState)1