-
Notifications
You must be signed in to change notification settings - Fork 998
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
Redis sink flushes only rows that have more recent eventTimestamp #913
Merged
feast-ci-bot
merged 11 commits into
feast-dev:master
from
pyalex:redis-read-before-write
Aug 1, 2020
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1d1c048
redis sink read then write
pyalex 24d83fd
fix load tests
pyalex 4e91993
e2e
pyalex fc8e019
fix
pyalex 982f700
specify feature ref
pyalex 07fc09c
move test up in order
pyalex c1ecd03
set project default
pyalex 2c83445
some docs
pyalex cf9f274
reorder e2e tests
pyalex db1b76a
reorder e2e tests
pyalex 19a41e7
reorder e2e tests
pyalex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...nectors/redis/src/main/java/feast/storage/connectors/redis/writer/BatchDoFnWithRedis.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright 2018-2020 The Feast Authors | ||
* | ||
* Licensed 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 | ||
* | ||
* https://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 feast.storage.connectors.redis.writer; | ||
|
||
import feast.storage.common.retry.Retriable; | ||
import io.lettuce.core.RedisException; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.Future; | ||
import java.util.function.Function; | ||
import org.apache.beam.sdk.transforms.DoFn; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Base class for redis-related DoFns. Assumes that operations will be batched. Prepares redisClient | ||
* on DoFn.Setup stage and close it on DoFn.Teardown stage. | ||
* | ||
* @param <Input> | ||
* @param <Output> | ||
*/ | ||
public class BatchDoFnWithRedis<Input, Output> extends DoFn<Input, Output> { | ||
private static final Logger log = LoggerFactory.getLogger(BatchDoFnWithRedis.class); | ||
|
||
private final RedisIngestionClient redisIngestionClient; | ||
|
||
BatchDoFnWithRedis(RedisIngestionClient redisIngestionClient) { | ||
this.redisIngestionClient = redisIngestionClient; | ||
} | ||
|
||
@Setup | ||
public void setup() { | ||
this.redisIngestionClient.setup(); | ||
} | ||
|
||
@StartBundle | ||
public void startBundle() { | ||
try { | ||
redisIngestionClient.connect(); | ||
} catch (RedisException e) { | ||
log.error("Connection to redis cannot be established: %s", e); | ||
} | ||
} | ||
|
||
void executeBatch(Function<RedisIngestionClient, Iterable<Future<? extends Object>>> executor) | ||
throws Exception { | ||
this.redisIngestionClient | ||
.getBackOffExecutor() | ||
.execute( | ||
new Retriable() { | ||
@Override | ||
public void execute() throws ExecutionException, InterruptedException { | ||
if (!redisIngestionClient.isConnected()) { | ||
redisIngestionClient.connect(); | ||
} | ||
|
||
Iterable<Future<?>> futures = executor.apply(redisIngestionClient); | ||
redisIngestionClient.sync(futures); | ||
} | ||
|
||
@Override | ||
public Boolean isExceptionRetriable(Exception e) { | ||
return e instanceof RedisException; | ||
} | ||
|
||
@Override | ||
public void cleanUpAfterFailure() {} | ||
}); | ||
} | ||
|
||
@Teardown | ||
public void teardown() { | ||
redisIngestionClient.shutdown(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There seems to be only one extension of this base class (
RedisCustomIO.WriteDoFn
). Is this base class necessary?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.
Just wanted to separate redis wrapper code from business logic