Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAMZA-2794: SSPGrouperProxy Partition Count Change Error #1688

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
package org.apache.samza.coordinator.metadatastore;

import com.google.common.annotations.VisibleForTesting;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
Expand All @@ -32,6 +35,9 @@
*/
public class NamespaceAwareCoordinatorStreamStore implements MetadataStore {

private static final String SET_TASK_PARTITION_ASSIGNMENT = "set-task-partition-assignment";
private static final String KEY_BUCKET = ",\"keyBucket\":-1}";
private static final String WITHOUT_KEY_BUCKET = "}";
private final MetadataStore metadataStore;
private final String namespace;

Expand Down Expand Up @@ -105,16 +111,23 @@ String getCoordinatorMessageKey(String key) {
private Map<String, byte[]> readMessagesFromCoordinatorStore() {
Map<String, byte[]> bootstrappedMessages = new HashMap<>();
Map<String, byte[]> coordinatorStreamMessages = metadataStore.all();
List<String> keyDeduplicationReference = new ArrayList<>();
coordinatorStreamMessages.forEach((coordinatorMessageKeyAsJson, value) -> {
CoordinatorMessageKey coordinatorMessageKey = CoordinatorStreamStore.deserializeCoordinatorMessageKeyFromJson(coordinatorMessageKeyAsJson);
if (Objects.equals(namespace, coordinatorMessageKey.getNamespace())) {
if (value != null) {
if (namespace.equals(SET_TASK_PARTITION_ASSIGNMENT) && coordinatorMessageKey.getKey().contains(KEY_BUCKET)) {
keyDeduplicationReference.add(coordinatorMessageKey.getKey().replace(KEY_BUCKET, WITHOUT_KEY_BUCKET));
}
bootstrappedMessages.put(coordinatorMessageKey.getKey(), value);
} else {
bootstrappedMessages.remove(coordinatorMessageKey.getKey());
}
}
});
for (String dedupKey: keyDeduplicationReference) {
bootstrappedMessages.remove(dedupKey);
}

return bootstrappedMessages;
}
Expand Down