Skip to content

Instantly share code, notes, and snippets.

@enesakar
Created October 18, 2013 16:06
Show Gist options
  • Select an option

  • Save enesakar/7043802 to your computer and use it in GitHub Desktop.

Select an option

Save enesakar/7043802 to your computer and use it in GitHub Desktop.
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