Created
October 18, 2013 16:06
-
-
Save enesakar/7043802 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| public class ClientContinuousQueryTest { | |
| public static void main(String[] args) { | |
| Config config = new Config(); | |
| HazelcastInstance instance = Hazelcast.newHazelcastInstance(config); | |
| IMap<Integer,Deal> theMap = instance.getMap("tradeMap"); | |
| theMap.put(3, new Deal(3)); | |
| ClientConfig clientConfig = new ClientConfig(); | |
| clientConfig.addAddress("192.168.1.41:5701"); | |
| HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig); | |
| IMap<Integer,Deal> tradeMap = client.getMap("tradeMap"); | |
| System.out.println("size:"+tradeMap.size()); | |
| // /* | |
| EntryListener<Integer, Deal> listener = new EntListener(); | |
| tradeMap.addEntryListener(listener, | |
| new SqlPredicate("id=1"), | |
| //null, | |
| true); | |
| //*/ | |
| theMap.put(2, new Deal(34)); | |
| } | |
| static class EntListener implements EntryListener<Integer, Deal>, Serializable { | |
| EntListener() { | |
| } | |
| @Override | |
| public void entryAdded(EntryEvent<Integer, Deal> arg0) { | |
| System.out.println(arg0); | |
| } | |
| @Override | |
| public void entryEvicted(EntryEvent<Integer, Deal> arg0) { | |
| System.out.println(arg0); | |
| } | |
| @Override | |
| public void entryRemoved(EntryEvent<Integer, Deal> arg0) { | |
| System.out.println(arg0); | |
| } | |
| @Override | |
| public void entryUpdated(EntryEvent<Integer, Deal> arg0) { | |
| System.out.println(arg0); | |
| } | |
| } | |
| static class Deal implements Serializable { | |
| Integer id; | |
| Deal(Integer id) { | |
| this.id = id; | |
| } | |
| public Integer getId() { | |
| return id; | |
| } | |
| public void setId(Integer id) { | |
| this.id = id; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment