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);
}
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());
}
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);
}
Aggregations