use of org.apache.kafka.streams.state.internals.StreamsMetadataImpl in project kafka by apache.
the class NamedTopologyIntegrationTest method verifyMetadataForTopology.
/**
* Validates that each metadata object has only partitions & state stores for its specific topology name and
* asserts that {@code left} and {@code right} differ only by {@link StreamsMetadata#hostInfo()}
*/
private void verifyMetadataForTopology(final String topologyName, final Collection<StreamsMetadata> left, final Collection<StreamsMetadata> right) {
assertThat(left.size(), equalTo(right.size()));
final Iterator<StreamsMetadata> leftIter = left.iterator();
final Iterator<StreamsMetadata> rightIter = right.iterator();
while (leftIter.hasNext()) {
final StreamsMetadataImpl leftMetadata = (StreamsMetadataImpl) leftIter.next();
final StreamsMetadataImpl rightMetadata = (StreamsMetadataImpl) rightIter.next();
verifyPartitionsAndStoresForTopology(topologyName, leftMetadata);
verifyPartitionsAndStoresForTopology(topologyName, rightMetadata);
assertThat(verifyEquivalentMetadataForHost(leftMetadata, rightMetadata), is(true));
}
}
use of org.apache.kafka.streams.state.internals.StreamsMetadataImpl in project kafka by apache.
the class StreamsMetadataState method getAllMetadataForTopology.
public synchronized Collection<StreamsMetadata> getAllMetadataForTopology(final String topologyName) {
Objects.requireNonNull(topologyName, "topologyName cannot be null");
if (!isInitialized()) {
return Collections.emptyList();
}
final ArrayList<StreamsMetadata> results = new ArrayList<>();
for (final StreamsMetadata metadata : allMetadata) {
final String metadataTopologyName = ((StreamsMetadataImpl) metadata).topologyName();
if (metadataTopologyName != null && metadataTopologyName.equals(topologyName)) {
results.add(metadata);
}
}
return results;
}
use of org.apache.kafka.streams.state.internals.StreamsMetadataImpl in project kafka by apache.
the class StreamsMetadataTest method shouldNotBeEqualIfDifferInHostInfo.
@Test
public void shouldNotBeEqualIfDifferInHostInfo() {
final StreamsMetadata differHostInfo = new StreamsMetadataImpl(new HostInfo("different", 122), STATE_STORE_NAMES, TOPIC_PARTITIONS, STAND_BY_STORE_NAMES, STANDBY_TOPIC_PARTITIONS);
assertThat(streamsMetadata, not(equalTo(differHostInfo)));
assertThat(streamsMetadata.hashCode(), not(equalTo(differHostInfo.hashCode())));
}
use of org.apache.kafka.streams.state.internals.StreamsMetadataImpl in project kafka by apache.
the class StreamsMetadataTest method shouldNotBeEqualIfDifferInStandByTopicPartitions.
@Test
public void shouldNotBeEqualIfDifferInStandByTopicPartitions() {
final StreamsMetadata differStandByTopicPartitions = new StreamsMetadataImpl(HOST_INFO, STATE_STORE_NAMES, TOPIC_PARTITIONS, STAND_BY_STORE_NAMES, mkSet(TP_0));
assertThat(streamsMetadata, not(equalTo(differStandByTopicPartitions)));
assertThat(streamsMetadata.hashCode(), not(equalTo(differStandByTopicPartitions.hashCode())));
}
use of org.apache.kafka.streams.state.internals.StreamsMetadataImpl in project kafka by apache.
the class StreamsMetadataTest method shouldNotBeEqualIfDifferStateStoreNames.
@Test
public void shouldNotBeEqualIfDifferStateStoreNames() {
final StreamsMetadata differStateStoreNames = new StreamsMetadataImpl(HOST_INFO, mkSet("store1"), TOPIC_PARTITIONS, STAND_BY_STORE_NAMES, STANDBY_TOPIC_PARTITIONS);
assertThat(streamsMetadata, not(equalTo(differStateStoreNames)));
assertThat(streamsMetadata.hashCode(), not(equalTo(differStateStoreNames.hashCode())));
}
Aggregations