Search in sources :

Example 1 with UpdateFeaturesResponseData

use of org.apache.kafka.common.message.UpdateFeaturesResponseData in project kafka by apache.

the class RequestResponseTest method createUpdateFeaturesResponse.

private UpdateFeaturesResponse createUpdateFeaturesResponse() {
    UpdateFeaturesResponseData.UpdatableFeatureResultCollection results = new UpdateFeaturesResponseData.UpdatableFeatureResultCollection();
    results.add(new UpdateFeaturesResponseData.UpdatableFeatureResult().setFeature("feature1").setErrorCode(Errors.NONE.code()).setErrorMessage("error message"));
    UpdateFeaturesResponseData data = new UpdateFeaturesResponseData().setErrorCode(Errors.NONE.code()).setThrottleTimeMs(123).setResults(results).setErrorMessage("error message");
    return new UpdateFeaturesResponse(data);
}
Also used : UpdateFeaturesResponseData(org.apache.kafka.common.message.UpdateFeaturesResponseData)

Example 2 with UpdateFeaturesResponseData

use of org.apache.kafka.common.message.UpdateFeaturesResponseData in project kafka by apache.

the class UpdateFeaturesResponseTest method testErrorCounts.

@Test
public void testErrorCounts() {
    UpdateFeaturesResponseData.UpdatableFeatureResultCollection results = new UpdateFeaturesResponseData.UpdatableFeatureResultCollection();
    results.add(new UpdateFeaturesResponseData.UpdatableFeatureResult().setFeature("foo").setErrorCode(Errors.UNKNOWN_SERVER_ERROR.code()));
    results.add(new UpdateFeaturesResponseData.UpdatableFeatureResult().setFeature("bar").setErrorCode(Errors.UNKNOWN_SERVER_ERROR.code()));
    results.add(new UpdateFeaturesResponseData.UpdatableFeatureResult().setFeature("baz").setErrorCode(Errors.FEATURE_UPDATE_FAILED.code()));
    UpdateFeaturesResponse response = new UpdateFeaturesResponse(new UpdateFeaturesResponseData().setErrorCode(Errors.INVALID_REQUEST.code()).setResults(results));
    Map<Errors, Integer> errorCounts = response.errorCounts();
    assertEquals(3, errorCounts.size());
    assertEquals(1, errorCounts.get(Errors.INVALID_REQUEST).intValue());
    assertEquals(2, errorCounts.get(Errors.UNKNOWN_SERVER_ERROR).intValue());
    assertEquals(1, errorCounts.get(Errors.FEATURE_UPDATE_FAILED).intValue());
}
Also used : Errors(org.apache.kafka.common.protocol.Errors) UpdateFeaturesResponseData(org.apache.kafka.common.message.UpdateFeaturesResponseData) Test(org.junit.jupiter.api.Test)

Example 3 with UpdateFeaturesResponseData

use of org.apache.kafka.common.message.UpdateFeaturesResponseData in project kafka by apache.

the class UpdateFeaturesResponse method createWithErrors.

public static UpdateFeaturesResponse createWithErrors(ApiError topLevelError, Map<String, ApiError> updateErrors, int throttleTimeMs) {
    final UpdatableFeatureResultCollection results = new UpdatableFeatureResultCollection();
    for (final Map.Entry<String, ApiError> updateError : updateErrors.entrySet()) {
        final String feature = updateError.getKey();
        final ApiError error = updateError.getValue();
        final UpdatableFeatureResult result = new UpdatableFeatureResult();
        result.setFeature(feature).setErrorCode(error.error().code()).setErrorMessage(error.message());
        results.add(result);
    }
    final UpdateFeaturesResponseData responseData = new UpdateFeaturesResponseData().setThrottleTimeMs(throttleTimeMs).setErrorCode(topLevelError.error().code()).setErrorMessage(topLevelError.message()).setResults(results).setThrottleTimeMs(throttleTimeMs);
    return new UpdateFeaturesResponse(responseData);
}
Also used : UpdateFeaturesResponseData(org.apache.kafka.common.message.UpdateFeaturesResponseData) UpdatableFeatureResultCollection(org.apache.kafka.common.message.UpdateFeaturesResponseData.UpdatableFeatureResultCollection) UpdatableFeatureResult(org.apache.kafka.common.message.UpdateFeaturesResponseData.UpdatableFeatureResult) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

UpdateFeaturesResponseData (org.apache.kafka.common.message.UpdateFeaturesResponseData)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 UpdatableFeatureResult (org.apache.kafka.common.message.UpdateFeaturesResponseData.UpdatableFeatureResult)1 UpdatableFeatureResultCollection (org.apache.kafka.common.message.UpdateFeaturesResponseData.UpdatableFeatureResultCollection)1 Errors (org.apache.kafka.common.protocol.Errors)1 Test (org.junit.jupiter.api.Test)1