-
Notifications
You must be signed in to change notification settings - Fork 137
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
WIP: Add redis backed cache as alternative for infinispan #3534
WIP: Add redis backed cache as alternative for infinispan #3534
Conversation
… modules (common, infinispan and redis) and a client-device-connection module
Addresses #3532 |
caches/cache-redis/src/main/java/org/eclipse/hono/deviceconnection/redis/RedisCache.java
Outdated
Show resolved
Hide resolved
...nd-router/src/main/java/org/eclipse/hono/commandrouter/app/DeviceConnectionInfoProducer.java
Outdated
Show resolved
Hide resolved
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.
On first glance, I believe that it would be sufficient to introduce modules client-device-connection
and client-device-connection-redis
with client-device-connection
containing the interfaces and generic classes.
Any particular reason why you want to introduce the cache-*
modules?
Mainly just because I saw the I don't really have a concrete example of some other higher level logic that might need a caching backend in Hono currently. Possibly keeping track of running adapter instances for cleanup purposes since that's something we've been running into issues with recently (as reported by my colleague). Essentially the ides is to minimize the "domain" that you want to create multiple implementations of. It seems to me that if I have a Am I making any sense? |
In general, you do :-) And I agree that the The other place(s) where we are using caches include the protocol adapters where we try to keep information from the device registry local by putting them to a Caffeine cache. However, I do not really see how the All in all, I guess we should simply start by putting the common classes into client-device-connection instead of introducing three additional modules for the cache classes. WDYT? |
Allright, sounds good to me. I'll change the layout and go from there. |
…ng of redis client (stop retrying connections for now).
Okay, so I've modified the way I split up the modules as per your suggestions @sophokles73 . I've also changed the redis client library to So my first two questions are: 1) does the module structure now look more like what you had imagined and 2) from the looks of it, would you recommend that I stick to using the There are some issues that I'm not sure about how to solve with using that client library, it assumes that keys and values are I noticed that there are some Quarkus client libraries being used in Hono and there does exist a Quarkus Redis client (see also here). I haven't looked much into it but it does seem to have some generics support. So I'm wondering whether I should look further into that or do you think I should stick with the I've also noticed some interesting things regarding the semantics of the
Other than that I'm making some progress. There are values being written and read to/from Redis but running the integration tests still fails on some of the tests. I haven't investigated that much so I'm not gonna ask for help on that just yet. But I did want to check in to see if you could possibly give me your thoughts about the above notes. |
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.
FMPOV the project layout looks good.
...n/src/main/java/org/eclipse/hono/deviceconnection/common/CacheBasedDeviceConnectionInfo.java
Outdated
Show resolved
Hide resolved
...c/test/java/org/eclipse/hono/deviceconnection/common/CacheBasedDeviceConnectionInfoTest.java
Outdated
Show resolved
Hide resolved
IMHO you should try to use the Quarkus redis-client extension instead. Even if you then want to use the vertx-redis-client API for interacting with Redis, the extension will make sure that everything fits into the Quarkus build, in particular when it comes to the native images. |
No, you got the purpose correctly. The key should only be removed if the current value matches the given value. In our case it is actually more like: Only remove the key if its value is still the (old) value which I believe it has. @calohmn I hope I got this right ... |
Yes, IMHO that is the right thing to do. @calohmn WDYT? |
Yes, the cache is used to keep a mapping of a device ID (for which a command subscription exists) to the ID of the protocol adapter instance that the device is connected to (and that shall receive commands for that device then).
That is interesting actually. Our implementation invokes AsyncCache.getAllAsync() here. There is no documentation for that - just a hint that it probably is meant to behave like AdvancedCache.getAll() for which this behaviour is documented:
So, the If it's not causing difficulties in the implementation, I would probably go with the documented The places where we currently invoke EDIT: But the approach of omitting |
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.
I have taken a look based on my very limited knowledge of Redis. My gut feeling is that the vert.x client based variant is easier to read (for me) as we do not use Mutiny anywhere in the code.
On the other hand, it seems like the Quarkus project puts more focus on the Mutiny based data source approach. I cannot tell which one will work better in reality. One thing to try out in the vert.x client based impl would be to get a RedisAPI instance injected by Quarkus so we do not need to manually create and maintain the connection...
client-device-connection-redis/src/test/resources/logback-test.xml
Outdated
Show resolved
Hide resolved
...tion-redis/src/main/java/org/eclipse/hono/deviceconnection/redis/client/VertxRedisCache.java
Outdated
Show resolved
Hide resolved
...tion-redis/src/main/java/org/eclipse/hono/deviceconnection/redis/client/VertxRedisCache.java
Outdated
Show resolved
Hide resolved
...tion-redis/src/main/java/org/eclipse/hono/deviceconnection/redis/client/VertxRedisCache.java
Outdated
Show resolved
Hide resolved
I would suggest to rebase your branch on HEAD instead of merging master into your branch ... |
Okay, I must admit that I'm not used to using rebase. Are you suggesting that I do that now to clean up the history here or do you mean that I should try doing that from now on. If I do a |
I can squash the commits of the feature branch and force push it to get rid of the merge commits... but that would of course also squash the commits that I've made but personally I'm fine with that as most of these commits are experiments and playing around. I think that once I get to a point where I've properly decided on how to approach this I may create a new branch / PR and just close this one to clean things up. |
<artifactId>hono-client-common</artifactId> | ||
</dependency> | ||
|
||
<dependency> <!-- TODO: changed from vertx-web because there only seems to be dependency on -core. Maybe there are runtime dependencies though??? --> |
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.
@sophokles73 do you know? Is it safe to change this or do you think there might be some runtime dependencies that we need from -web?
That sounds like a great idea 👍 |
… the quarkus-redis-client extension and not manually managing connections. Minor cleanup based on PR comments. Experiment with configuration.
Finally taking a look again. I've changed to using the Vert.X RedisAPI instance that the quarkus-redis-client extension provides (code has been checked in but is still very incomplete). Integration tests are running and passing now. However, there is one consideration that I'd like to get input on. The thing is that the Quarkus Redis Client extension receives its configuration via properties rooted in |
…edis config values to hono.commandRouter.cache.redis.
…edis config values to hono.commandRouter.cache.redis.
…to implement_redis_backed_cache
… copying the behavior of it into Hono. Integration Tests are now working for both embedded and redis cache configurations. Still some work to be done to enable metrics and health checks.
Closing this PR until it's ready for a proper review. |
This PR is very much WIP still.
So far I have refactored the
client-device-connection-infinispan
module into 3 cache modules (common, infinispan and redis) and aclient-device-connection
module.The idea is that the
client-device-connection
can be backed by different types of caches, one being the Infinispan data grid that has been used in Hono so far but another possibly being Redis.Currently I've only refactored the module structure and copied the existing code to new places. I've added an extremely crude proof of concept implementation for a Redis cache and hard coded that to be the type of cache that is created (it works, but as I said, it's not configurable in any way and the implementation is absolute garbage).