-
Notifications
You must be signed in to change notification settings - Fork 15.4k
MINOR: buffer should ignore caching #5819
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,8 +28,6 @@ | |
| import org.apache.kafka.streams.processor.internals.RecordBatchingStateRestoreCallback; | ||
| import org.apache.kafka.streams.processor.internals.RecordCollector; | ||
| import org.apache.kafka.streams.state.StoreBuilder; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import java.nio.ByteBuffer; | ||
| import java.util.Collection; | ||
|
|
@@ -45,7 +43,6 @@ | |
| import java.util.function.Supplier; | ||
|
|
||
| public class InMemoryTimeOrderedKeyValueBuffer implements TimeOrderedKeyValueBuffer { | ||
| private static final Logger LOG = LoggerFactory.getLogger(InMemoryTimeOrderedKeyValueBuffer.class); | ||
| private static final BytesSerializer KEY_SERIALIZER = new BytesSerializer(); | ||
| private static final ByteArraySerializer VALUE_SERIALIZER = new ByteArraySerializer(); | ||
|
|
||
|
|
@@ -72,14 +69,28 @@ public Builder(final String storeName) { | |
| this.storeName = storeName; | ||
| } | ||
|
|
||
| /** | ||
| * As of 2.1, there's no way for users to directly interact with the buffer, | ||
| * so this method is implemented solely to be called by Streams (which | ||
| * it will do based on the {@code cache.max.bytes.buffering} config. | ||
| * | ||
| * It's currently a no-op. | ||
| */ | ||
| @Override | ||
| public StoreBuilder<StateStore> withCachingEnabled() { | ||
| throw new UnsupportedOperationException(); | ||
| return this; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we log a warning here and below?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I agree with a warning. I think it's fine to just ignore the call, since the buffer will behave correctly whether you call these methods or not. In fact, I originally had them no-op, and changed it to throw upon review. There's no publicly facing API to register a buffer, so there's no way that a user could call these methods right now. In fact, the buffer itself is an My thought is that it would be confusing to see warnings that actually indicate nothing is wrong and about which you can do nothing. Would you be satisfied with a javadoc explaining the decision?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, my intent was just some sort of notification to users these methods are ignored, javadoc is fine with me. |
||
| } | ||
|
|
||
| /** | ||
| * As of 2.1, there's no way for users to directly interact with the buffer, | ||
| * so this method is implemented solely to be called by Streams (which | ||
| * it will do based on the {@code cache.max.bytes.buffering} config. | ||
| * | ||
| * It's currently a no-op. | ||
| */ | ||
| @Override | ||
| public StoreBuilder<StateStore> withCachingDisabled() { | ||
| throw new UnsupportedOperationException(); | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* | ||
| * 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.streams.state.internals; | ||
|
|
||
| import org.junit.Test; | ||
|
|
||
| public class InMemoryTimeOrderedKeyValueBufferTest { | ||
|
|
||
| @Test | ||
| public void bufferShouldAllowCacheEnablement() { | ||
| new InMemoryTimeOrderedKeyValueBuffer.Builder(null).withCachingEnabled(); | ||
| } | ||
|
|
||
| @Test | ||
| public void bufferShouldAllowCacheDisablement() { | ||
| new InMemoryTimeOrderedKeyValueBuffer.Builder(null).withCachingDisabled(); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add JavaDoc and point out that he method can be called, but won't do anything, as caching is not supported. Similar below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.