Infinispan distributed cache and executing tasks on primary key owner
Is it possible to get Infinispan (9.4+) to execute a task on a primary key owner? Like if I give it a cache, a key in that cache, and a Runnable/Callable, can it just execute that task on the owner of that key?
This would be similar to Hazelcast IExecutorService's submitToKeyOwner or executeOnKeyOwner.
Thanks.
infinispan
add a comment |
Is it possible to get Infinispan (9.4+) to execute a task on a primary key owner? Like if I give it a cache, a key in that cache, and a Runnable/Callable, can it just execute that task on the owner of that key?
This would be similar to Hazelcast IExecutorService's submitToKeyOwner or executeOnKeyOwner.
Thanks.
infinispan
add a comment |
Is it possible to get Infinispan (9.4+) to execute a task on a primary key owner? Like if I give it a cache, a key in that cache, and a Runnable/Callable, can it just execute that task on the owner of that key?
This would be similar to Hazelcast IExecutorService's submitToKeyOwner or executeOnKeyOwner.
Thanks.
infinispan
Is it possible to get Infinispan (9.4+) to execute a task on a primary key owner? Like if I give it a cache, a key in that cache, and a Runnable/Callable, can it just execute that task on the owner of that key?
This would be similar to Hazelcast IExecutorService's submitToKeyOwner or executeOnKeyOwner.
Thanks.
infinispan
infinispan
asked Nov 15 '18 at 19:38
Scott Van WartScott Van Wart
84
84
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
There are a few ways.
The simplest if the key exists is just to use DistributedStreams
cache.entrySet().stream().filterKeys(Collections.singleton(key)).forEach((cache, k) -> <do stuff>);
If the key doesn't exist you can use the ClusterExecutor
cacheManager.executor().singleNodeSubmission().filterTargets(Collections.singleton(address)
.submit(<runnable>);
You can find the target address by invoking
Address address = cache.getAdvancedCache().getDistributionManager()
.getCacheTopology().getDistributionInfo(key).primary();
I also suggest you check out this section http://infinispan.org/docs/stable/user_guide/user_guide.html#execute_code_grid
Also to note you can use DistributedExecutor, however this is deprecated and will eventually be removed.
– Mudokonman
Nov 19 '18 at 14:51
I think I had your second suggestion figured out but I really like the first one using streams. I hadn't considered that. Thanks very much.
– Scott Van Wart
Nov 20 '18 at 15:03
Also to note that the forEach method on distributed streams runs in an at least once delivery mode. Not sure if that is problematic or not. You can make it run in at most once mode by disabling rehash awareness. infinispan.org/docs/stable/user_guide/…
– Mudokonman
Nov 20 '18 at 15:57
It's definitely something I need to be aware of. I'm assuming that's only an issue on an unstable cluster (e.g. member just left/degraded or member joining).
– Scott Van Wart
Nov 21 '18 at 16:04
Correct, if the cluster is stable it will guarantee exactly once semantics.
– Mudokonman
Nov 23 '18 at 1:08
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326810%2finfinispan-distributed-cache-and-executing-tasks-on-primary-key-owner%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
There are a few ways.
The simplest if the key exists is just to use DistributedStreams
cache.entrySet().stream().filterKeys(Collections.singleton(key)).forEach((cache, k) -> <do stuff>);
If the key doesn't exist you can use the ClusterExecutor
cacheManager.executor().singleNodeSubmission().filterTargets(Collections.singleton(address)
.submit(<runnable>);
You can find the target address by invoking
Address address = cache.getAdvancedCache().getDistributionManager()
.getCacheTopology().getDistributionInfo(key).primary();
I also suggest you check out this section http://infinispan.org/docs/stable/user_guide/user_guide.html#execute_code_grid
Also to note you can use DistributedExecutor, however this is deprecated and will eventually be removed.
– Mudokonman
Nov 19 '18 at 14:51
I think I had your second suggestion figured out but I really like the first one using streams. I hadn't considered that. Thanks very much.
– Scott Van Wart
Nov 20 '18 at 15:03
Also to note that the forEach method on distributed streams runs in an at least once delivery mode. Not sure if that is problematic or not. You can make it run in at most once mode by disabling rehash awareness. infinispan.org/docs/stable/user_guide/…
– Mudokonman
Nov 20 '18 at 15:57
It's definitely something I need to be aware of. I'm assuming that's only an issue on an unstable cluster (e.g. member just left/degraded or member joining).
– Scott Van Wart
Nov 21 '18 at 16:04
Correct, if the cluster is stable it will guarantee exactly once semantics.
– Mudokonman
Nov 23 '18 at 1:08
add a comment |
There are a few ways.
The simplest if the key exists is just to use DistributedStreams
cache.entrySet().stream().filterKeys(Collections.singleton(key)).forEach((cache, k) -> <do stuff>);
If the key doesn't exist you can use the ClusterExecutor
cacheManager.executor().singleNodeSubmission().filterTargets(Collections.singleton(address)
.submit(<runnable>);
You can find the target address by invoking
Address address = cache.getAdvancedCache().getDistributionManager()
.getCacheTopology().getDistributionInfo(key).primary();
I also suggest you check out this section http://infinispan.org/docs/stable/user_guide/user_guide.html#execute_code_grid
Also to note you can use DistributedExecutor, however this is deprecated and will eventually be removed.
– Mudokonman
Nov 19 '18 at 14:51
I think I had your second suggestion figured out but I really like the first one using streams. I hadn't considered that. Thanks very much.
– Scott Van Wart
Nov 20 '18 at 15:03
Also to note that the forEach method on distributed streams runs in an at least once delivery mode. Not sure if that is problematic or not. You can make it run in at most once mode by disabling rehash awareness. infinispan.org/docs/stable/user_guide/…
– Mudokonman
Nov 20 '18 at 15:57
It's definitely something I need to be aware of. I'm assuming that's only an issue on an unstable cluster (e.g. member just left/degraded or member joining).
– Scott Van Wart
Nov 21 '18 at 16:04
Correct, if the cluster is stable it will guarantee exactly once semantics.
– Mudokonman
Nov 23 '18 at 1:08
add a comment |
There are a few ways.
The simplest if the key exists is just to use DistributedStreams
cache.entrySet().stream().filterKeys(Collections.singleton(key)).forEach((cache, k) -> <do stuff>);
If the key doesn't exist you can use the ClusterExecutor
cacheManager.executor().singleNodeSubmission().filterTargets(Collections.singleton(address)
.submit(<runnable>);
You can find the target address by invoking
Address address = cache.getAdvancedCache().getDistributionManager()
.getCacheTopology().getDistributionInfo(key).primary();
I also suggest you check out this section http://infinispan.org/docs/stable/user_guide/user_guide.html#execute_code_grid
There are a few ways.
The simplest if the key exists is just to use DistributedStreams
cache.entrySet().stream().filterKeys(Collections.singleton(key)).forEach((cache, k) -> <do stuff>);
If the key doesn't exist you can use the ClusterExecutor
cacheManager.executor().singleNodeSubmission().filterTargets(Collections.singleton(address)
.submit(<runnable>);
You can find the target address by invoking
Address address = cache.getAdvancedCache().getDistributionManager()
.getCacheTopology().getDistributionInfo(key).primary();
I also suggest you check out this section http://infinispan.org/docs/stable/user_guide/user_guide.html#execute_code_grid
answered Nov 19 '18 at 14:51
MudokonmanMudokonman
70636
70636
Also to note you can use DistributedExecutor, however this is deprecated and will eventually be removed.
– Mudokonman
Nov 19 '18 at 14:51
I think I had your second suggestion figured out but I really like the first one using streams. I hadn't considered that. Thanks very much.
– Scott Van Wart
Nov 20 '18 at 15:03
Also to note that the forEach method on distributed streams runs in an at least once delivery mode. Not sure if that is problematic or not. You can make it run in at most once mode by disabling rehash awareness. infinispan.org/docs/stable/user_guide/…
– Mudokonman
Nov 20 '18 at 15:57
It's definitely something I need to be aware of. I'm assuming that's only an issue on an unstable cluster (e.g. member just left/degraded or member joining).
– Scott Van Wart
Nov 21 '18 at 16:04
Correct, if the cluster is stable it will guarantee exactly once semantics.
– Mudokonman
Nov 23 '18 at 1:08
add a comment |
Also to note you can use DistributedExecutor, however this is deprecated and will eventually be removed.
– Mudokonman
Nov 19 '18 at 14:51
I think I had your second suggestion figured out but I really like the first one using streams. I hadn't considered that. Thanks very much.
– Scott Van Wart
Nov 20 '18 at 15:03
Also to note that the forEach method on distributed streams runs in an at least once delivery mode. Not sure if that is problematic or not. You can make it run in at most once mode by disabling rehash awareness. infinispan.org/docs/stable/user_guide/…
– Mudokonman
Nov 20 '18 at 15:57
It's definitely something I need to be aware of. I'm assuming that's only an issue on an unstable cluster (e.g. member just left/degraded or member joining).
– Scott Van Wart
Nov 21 '18 at 16:04
Correct, if the cluster is stable it will guarantee exactly once semantics.
– Mudokonman
Nov 23 '18 at 1:08
Also to note you can use DistributedExecutor, however this is deprecated and will eventually be removed.
– Mudokonman
Nov 19 '18 at 14:51
Also to note you can use DistributedExecutor, however this is deprecated and will eventually be removed.
– Mudokonman
Nov 19 '18 at 14:51
I think I had your second suggestion figured out but I really like the first one using streams. I hadn't considered that. Thanks very much.
– Scott Van Wart
Nov 20 '18 at 15:03
I think I had your second suggestion figured out but I really like the first one using streams. I hadn't considered that. Thanks very much.
– Scott Van Wart
Nov 20 '18 at 15:03
Also to note that the forEach method on distributed streams runs in an at least once delivery mode. Not sure if that is problematic or not. You can make it run in at most once mode by disabling rehash awareness. infinispan.org/docs/stable/user_guide/…
– Mudokonman
Nov 20 '18 at 15:57
Also to note that the forEach method on distributed streams runs in an at least once delivery mode. Not sure if that is problematic or not. You can make it run in at most once mode by disabling rehash awareness. infinispan.org/docs/stable/user_guide/…
– Mudokonman
Nov 20 '18 at 15:57
It's definitely something I need to be aware of. I'm assuming that's only an issue on an unstable cluster (e.g. member just left/degraded or member joining).
– Scott Van Wart
Nov 21 '18 at 16:04
It's definitely something I need to be aware of. I'm assuming that's only an issue on an unstable cluster (e.g. member just left/degraded or member joining).
– Scott Van Wart
Nov 21 '18 at 16:04
Correct, if the cluster is stable it will guarantee exactly once semantics.
– Mudokonman
Nov 23 '18 at 1:08
Correct, if the cluster is stable it will guarantee exactly once semantics.
– Mudokonman
Nov 23 '18 at 1:08
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326810%2finfinispan-distributed-cache-and-executing-tasks-on-primary-key-owner%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown