Java Code Examples for com.hazelcast.core.EntryEvent#getKey()

The following examples show how to use com.hazelcast.core.EntryEvent#getKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PricePanelListener.java    From hazelcast-jet-demos with Apache License 2.0 6 votes vote down vote up
/**
 * <p>An event is produced each time a price is written
 * into an {@link com.hazelcast.core.IMap IMap}. For each
 * of these, add it to the graph, so producing a plot of
 * the changes to the map.
 * </p>
 *
 * @param entryEvent Produced by Jet writing into an IMap
 */
public void handle(EntryEvent<String, Price> entryEvent) {

	// Initialise the panel on first use
	synchronized (this) {
		if (pricePanel == null) {
			this.activateDisplay();
		}
	}

	// Extract the fields, and simplify the rate for plotting
	String priceKey = entryEvent.getKey();
	LocalDate day = entryEvent.getValue().getLocalDate();
	double rate = entryEvent.getValue().getRate().doubleValue();
	
	// Add this price to the chart
	pricePanel.update(priceKey, day, rate);
}
 
Example 2
Source File: OperationExpirationListener.java    From eventapis with Apache License 2.0 6 votes vote down vote up
@Override
public void entryExpired(EntryEvent<String, Topology> event) {
    event.getKey();
    Topology topology = event.getOldValue();
    try {
        topology.getProducedEvents().forEach(this::setLeafs);
    } catch (Exception ex) {
        log.warn("Error while trying to check Leafs:" + ex.getMessage());
    }
    if (!topology.isFinished()) {
        log.warn("Topology Doesn't Finished:" + topology.toString());
        operationsHistoryMap.putIfAbsent(event.getKey(), event.getOldValue(), 1, TimeUnit.DAYS);
    } else {
        log.info("Topology OK:" + topology.toString());
        operationsHistoryMap.putIfAbsent(event.getKey(), event.getOldValue(), 1, TimeUnit.HOURS);
    }

}
 
Example 3
Source File: CommandListener.java    From hazelcast-jet-demos with Apache License 2.0 5 votes vote down vote up
private void handle(EntryEvent<String, List<String>> arg0) throws Exception {
    log.info("'{}' '{}'", arg0.getKey(), arg0.getValue());

    String noun = arg0.getKey();
    List<String> params = arg0.getValue();
    String verb = params.get(0);

    if (verb.equalsIgnoreCase(Constants.COMMAND_VERB_START)) {
        this.handleStart(noun, (params.size() == 1 ? null : params.get(1)));
    } else {
        log.error("Unknown command verb '{}'", verb);
    }
}
 
Example 4
Source File: ClientManager.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
private void process(EntryEvent<String, Client> event, boolean shouldAdd) {
	if (event.getMember().localMember()) {
		return;
	}
	final String uid = event.getKey();
	synchronized (onlineClients) {
		if (onlineClients.containsKey(uid)) {
			onlineClients.get(uid).merge(event.getValue());
		} else if (shouldAdd) {
			onlineClients.put(uid, event.getValue());
		}
	}
}
 
Example 5
Source File: SubsMapHelper.java    From vertx-hazelcast with Apache License 2.0 5 votes vote down vote up
private void fireRegistrationUpdateEvent(EntryEvent<String, HazelcastRegistrationInfo> event) {
  String address = event.getKey();
  vertx.<List<RegistrationInfo>>executeBlocking(prom -> {
    prom.complete(get(address));
  }, false, ar -> {
    if (ar.succeeded()) {
      nodeSelector.registrationsUpdated(new RegistrationUpdateEvent(address, ar.result()));
    } else {
      log.trace("A failure occured while retrieving the updated registrations", ar.cause());
      nodeSelector.registrationsUpdated(new RegistrationUpdateEvent(address, Collections.emptyList()));
    }
  });
}