You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/05/15 19:45:55 UTC

[GitHub] [kafka] guozhangwang commented on a change in pull request #8676: KAFKA-10005 [DO NO MERGE]: Decouple RestoreListener from RestoreCallback

guozhangwang commented on a change in pull request #8676:
URL: https://github.com/apache/kafka/pull/8676#discussion_r426011578



##########
File path: streams/src/test/java/org/apache/kafka/test/MockStateRestoreListener.java
##########
@@ -18,19 +18,15 @@
 package org.apache.kafka.test;
 
 import org.apache.kafka.common.TopicPartition;
-import org.apache.kafka.streams.KeyValue;
-import org.apache.kafka.streams.processor.AbstractNotifyingRestoreCallback;
+import org.apache.kafka.streams.processor.StateRestoreListener;
 
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
-public class MockStateRestoreListener extends AbstractNotifyingRestoreCallback {
+public class MockStateRestoreListener implements StateRestoreListener {
 
     // verifies store name called for each state
     public final Map<String, String> storeNameCalledStates = new HashMap<>();
-    public final List<KeyValue<byte[], byte[]>> restored = new ArrayList<>();

Review comment:
       This field is not used anywhere in tests.

##########
File path: streams/src/main/java/org/apache/kafka/streams/processor/internals/CompositeRestoreListener.java
##########
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more

Review comment:
       This class is actually not used anywhere except unit tests: it is only a by-product of the coupling.

##########
File path: streams/src/test/java/org/apache/kafka/test/MockBatchingStateRestoreListener.java
##########
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.kafka.test;
-
-import org.apache.kafka.streams.KeyValue;
-import org.apache.kafka.streams.processor.BatchingStateRestoreCallback;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-public class MockBatchingStateRestoreListener extends MockStateRestoreListener implements BatchingStateRestoreCallback {

Review comment:
       This mock can now be replaced by other existing ones.

##########
File path: streams/src/main/java/org/apache/kafka/streams/processor/BatchingStateRestoreCallback.java
##########
@@ -38,4 +38,8 @@
      */
     void restoreAll(Collection<KeyValue<byte[], byte[]>> records);
 
+    @Override
+    default void restore(byte[] key, byte[] value) {

Review comment:
       Minor improvement such that any impls of the batching interface do not have to restore the per-entry `restore` func.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org