Skip to content
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

EntryProcessor should be able to access other entries that are on the same Partition. #964

Closed
fuadm opened this issue Oct 8, 2013 · 10 comments
Labels
Source: Internal PR or issue was opened by an employee Type: Enhancement

Comments

@fuadm
Copy link
Contributor

fuadm commented Oct 8, 2013

It would be nice if we “from an entryprocessor” could also modify entries in related maps on the same partition. Lets say you have an “order” map and an “order items” map with a partitionaware key related to the order. You may also want to update the order items (as a separate map) under the same lock.

We have one thread per partition, that makes the implementation easier. This way one can do an atomic operation that spans multiple data structures on the same Partition.

@mdogan
Copy link
Contributor

mdogan commented Oct 8, 2013

It's already possible to access / modify data on the same partition. You
can try and see..

@fuadm
Copy link
Contributor Author

fuadm commented Oct 8, 2013

how? do you have a code sample? I couldn't see it? Can I just access the IMap?

@mdogan
Copy link
Contributor

mdogan commented Oct 8, 2013

@ChristerF
Copy link

Cool, would this trigger entrylisteners for the other map properly too?

@ChristerF
Copy link

I just tested this and I get an error:
ERROR [2013-10-10 21:15:48,959] com.hazelcast.map.operation.EntryOperation: [192.168.210.38]:5701 [dev] Thread[hz._hzInstance_1_dev.operation.thread-5,5,_hzInstance_1_dev] cannot make remote call: PutOperation{mixerChannels}
! java.lang.IllegalThreadStateException: Thread[hz._hzInstance_1_dev.operation.thread-5,5,_hzInstance_1_dev] cannot make remote call: PutOperation{mixerChannels}

@mdogan
Copy link
Contributor

mdogan commented Oct 11, 2013

Can you post your code?

~Sent from mobile

@ChristerF
Copy link

Simplified version of what I want to do.

Basically two maps, sessions and channels, where channels belong to sessions. The "channel" key is a PartitionAwareKey and I want to store a channel atomically with the storage of the session, while keeping them in separate maps. I also want to make sure that Events are generated for the "channel" map I touch.

Here is some abbreviated code:

import com.google.common.base.Optional;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.HazelcastInstanceAware;
import com.twilio.mixerstate.hazelcast.AbstractEntryProcessor;

import java.util.Map;
public class AllocateChannelForMixerEntryProcessor extends AbstractEntryProcessor implements HazelcastInstanceAware {
private HazelcastInstance hzi;

public AllocateChannelForMixerEntryProcessor() {

}

@Override
public Object process(Map.Entry entry) {
    if (entry.getValue() == null) {
            addToChannelMap(channel,hzi);
            entry.setValue("TEST");
   return session;

    }
}

private void addToChannelMap(String value,MyPartitionAwareKey , HazelcastInstance hzi) {
    IMap<MyPartitionAwareKey, String> channelMap = hzi.getMap("mixerChannels");
    channelMap.put(Id,value);
}

@Override
public void setHazelcastInstance(HazelcastInstance hazelcastInstance) {
    this.hzi = hazelcastInstance;
}

}

@fuadm
Copy link
Contributor Author

fuadm commented Nov 2, 2013

Christer,

Can you try the following:

Test testMapEntryProcessorPartitionAware() in https://github.com/hazelcast/hazelcast/blob/master/hazelcast/src/test/java/com/hazelcast/map/EntryProcessorTest.java

@ghost ghost assigned pveentjer Nov 18, 2013
@ChristerF
Copy link

Fuad and Mehmet,
I have now verified that it works to call an EntryProcessor for another map as long as it ends up in the same partition - just as your unit test is showing.

That solves my immediate concern, thanks!

Now - a question: What about the backup-operations? Will they be happening one by one for each invoked EntryProcessor on that thread? Preferably this would be "batched" up such that there is only one roundtrip for the backup operations.

Thanks,
Christer

@mdogan
Copy link
Contributor

mdogan commented Dec 6, 2013

Currently backup ops are executed one by one.

@mdogan mdogan closed this as completed Dec 6, 2013
@mmedenjak mmedenjak added the Source: Internal PR or issue was opened by an employee label Jan 28, 2020
devOpsHazelcast pushed a commit that referenced this issue Mar 8, 2024
Import of #26271

**Original PR description:**

<!--
Contributing to Hazelcast and looking for a challenge? Why don't you
check out our open positions?

https://hazelcast.pinpointhq.com/
-->

Updates example configuration files for TPC comments

Checklist:
- [ ] Labels (`Team:`, `Type:`, `Source:`, `Module:`) and Milestone set
- [ ] Add `Add to Release Notes` label if changes should be mentioned in
release notes or `Not Release Notes content` if changes are not relevant
for release notes
- [x] Request reviewers if possible
- [ ] New public APIs have `@Nonnull/@Nullable` annotations
- [ ] New public APIs have `@since` tags in Javadoc
- [ ] Send backports/forwardports if fix needs to be applied to
past/future releases

Imported changes:

- 000adfc DOCS-809: Updates example
configuration files for TPC com...
- 709f825 Update
hazelcast/src/main/resources/hazelcast-full-exampl...

Closes #26271

Co-authored-by: Oliver Howell <oliver.howell@hazelcast.com>
GitOrigin-RevId: fdf36b0aa683917fe0193032cf4eafa9f2b91fcd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Source: Internal PR or issue was opened by an employee Type: Enhancement
Projects
None yet
Development

No branches or pull requests

5 participants