use of org.apache.kafka.common.KafkaException in project kafka by apache.
the class KafkaAdminClient method getMembersFromGroup.
private List<MemberIdentity> getMembersFromGroup(String groupId) {
Collection<MemberDescription> members;
try {
members = describeConsumerGroups(Collections.singleton(groupId)).describedGroups().get(groupId).get().members();
} catch (Exception ex) {
throw new KafkaException("Encounter exception when trying to get members from group: " + groupId, ex);
}
List<MemberIdentity> membersToRemove = new ArrayList<>();
for (final MemberDescription member : members) {
if (member.groupInstanceId().isPresent()) {
membersToRemove.add(new MemberIdentity().setGroupInstanceId(member.groupInstanceId().get()));
} else {
membersToRemove.add(new MemberIdentity().setMemberId(member.consumerId()));
}
}
return membersToRemove;
}
use of org.apache.kafka.common.KafkaException in project kafka by apache.
the class Metadata method clearErrorsAndMaybeThrowException.
private void clearErrorsAndMaybeThrowException(Supplier<KafkaException> recoverableExceptionSupplier) {
KafkaException metadataException = Optional.ofNullable(fatalException).orElseGet(recoverableExceptionSupplier);
fatalException = null;
clearRecoverableErrors();
if (metadataException != null)
throw metadataException;
}
use of org.apache.kafka.common.KafkaException in project kafka by apache.
the class ListSerializerTest method testListValueSerializerNoArgConstructorsShouldThrowKafkaExceptionDueInvalidClass.
@Test
public void testListValueSerializerNoArgConstructorsShouldThrowKafkaExceptionDueInvalidClass() {
props.put(CommonClientConfigs.DEFAULT_LIST_VALUE_SERDE_INNER_CLASS, new FakeObject());
final KafkaException exception = assertThrows(KafkaException.class, () -> listSerializer.configure(props, false));
assertEquals("Could not create a serializer class instance using \"" + CommonClientConfigs.DEFAULT_LIST_VALUE_SERDE_INNER_CLASS + "\" property.", exception.getMessage());
}
use of org.apache.kafka.common.KafkaException in project kafka by apache.
the class ListSerializerTest method testListKeySerializerNoArgConstructorsShouldThrowKafkaExceptionDueInvalidClass.
@Test
public void testListKeySerializerNoArgConstructorsShouldThrowKafkaExceptionDueInvalidClass() {
props.put(CommonClientConfigs.DEFAULT_LIST_KEY_SERDE_INNER_CLASS, new FakeObject());
final KafkaException exception = assertThrows(KafkaException.class, () -> listSerializer.configure(props, true));
assertEquals("Could not create a serializer class instance using \"" + CommonClientConfigs.DEFAULT_LIST_KEY_SERDE_INNER_CLASS + "\" property.", exception.getMessage());
}
use of org.apache.kafka.common.KafkaException in project kafka by apache.
the class ListDeserializerTest method testListKeyDeserializerNoArgConstructorsShouldThrowKafkaExceptionDueInvalidInnerClass.
@Test
public void testListKeyDeserializerNoArgConstructorsShouldThrowKafkaExceptionDueInvalidInnerClass() {
props.put(CommonClientConfigs.DEFAULT_LIST_KEY_SERDE_TYPE_CLASS, ArrayList.class);
props.put(CommonClientConfigs.DEFAULT_LIST_KEY_SERDE_INNER_CLASS, new FakeObject());
final KafkaException exception = assertThrows(KafkaException.class, () -> listDeserializer.configure(props, true));
assertEquals("Could not determine the inner serde class instance using " + "\"" + CommonClientConfigs.DEFAULT_LIST_KEY_SERDE_INNER_CLASS + "\" property.", exception.getMessage());
}
Aggregations