private void theEntryAdded(EntryEvent<String, DeploymentManagement> entryEvent) { DeploymentManagement deploymentManagement = entryEvent.getValue(); Validate.notNull(deploymentManagement, "deploymentManagement must not be null"); if (!deploymentManagement.getDeploymentDescription(). getLocationInCluster().equals(gatewayRulesService.fetchGatewayRules().getLocation())) { if (LOG.isDebugEnabled()) LOG.debug("BeyondJManagementService ignoring incoming deploymentManagement " + "since it references a service not in this instance. Current server is {} and target server is {}", gatewayRulesService.fetchGatewayRules().getLocation(), deploymentManagement.getDeploymentDescription(). getLocationInCluster()); return; //do nothing } try { String supervisorId = deploymentManagement.getDeploymentDescription().getSupervisorId(); BeyondJRemotingService remotingService = new BeyondJRemotingService(); ActorRefService actorRefService = remotingService.getRemoteServiceProxy(ActorRefService.class, ACTOR_REF_SERVICE); ActorRef deploymentSupervisor = actorRefService.getActorRefs().get(supervisorId); deploymentSupervisor.tell(deploymentManagement, null); } catch (Exception e) { LOG.error("Error calling actor", e); } }
@Override public void entryAdded(EntryEvent<Serializable, V> event) { try { final Serializable t = intercept(event.getKey(), event.getValue(), event.getOldValue()); feederThreads.submit(new Runnable() { @Override public void run() { outChannel.feed(t); } }); } catch (Exception e) { log.error("Exception on message interception. Not fed to downstream", e); } }
@Override public void entryUpdated(EntryEvent<Serializable, V> event) { try { final Serializable t = intercept(event.getKey(), event.getValue(), event.getOldValue()); feederThreads.submit(new Runnable() { @Override public void run() { outChannel.feed(t); } }); } catch (Exception e) { log.error("Exception on message interception. Not fed to downstream", e); } }
@Override public void entryAdded(EntryEvent<String, BpmEvent> event) { BpmEvent bpmEvent = event.getValue(); logger.log(Level.INFO, "BpmEventListener.entryAdded executor {0}", new Object[]{bpmEvent.getExecutor()}); try { BpmEvent.EXECUTOR executor = bpmEvent.getExecutor(); switch (executor) { case ACTOR_RESOLVER: InternalAPI.get().executeActorResolver(bpmEvent.getCaseId(), bpmEvent.getTaskId()); break; case CONNECTOR: InternalAPI.get().executeConnectorOut(bpmEvent.getCaseId(), bpmEvent.getTaskId()); break; case JOIN: InternalAPI.get().executeJoin(bpmEvent.getCaseId(), bpmEvent.getTaskId(), bpmEvent.getJoinId()); break; case TRANSITION: InternalAPI.get().executeTransition(bpmEvent.getCaseId(), bpmEvent.getTaskId()); break; } HazelcastServer.removeBpmEvent(bpmEvent); } catch (Exception ex) { logger.log(Level.SEVERE, ex.getMessage(), ex); } }
@Override public void entryUpdated(EntryEvent<DeviceId, RoleValue> event) { // compare old and current RoleValues. If master is different, // emit MASTER_CHANGED. else, emit BACKUPS_CHANGED. RoleValue oldValue = event.getOldValue(); RoleValue newValue = event.getValue(); // There will be no oldValue at the very first instance of an EntryEvent. // Technically, the progression is: null event -> null master -> some master; // We say a null master and a null oldValue are the same condition. NodeId oldMaster = null; if (oldValue != null) { oldMaster = oldValue.get(MASTER); } NodeId newMaster = newValue.get(MASTER); if (!Objects.equal(oldMaster, newMaster)) { notifyDelegate(new MastershipEvent( MASTER_CHANGED, event.getKey(), event.getValue().roleInfo())); } else { notifyDelegate(new MastershipEvent( BACKUPS_CHANGED, event.getKey(), event.getValue().roleInfo())); } }
@Override public void entryAdded(final EntryEvent<String, Object> ee) { log.info("Entry added for " + ee.getKey()); final List<DistributedPropertyChangedAction<?>> actions = propertyChangedActions.get(ee.getKey()); if (actions == null) { return; } ClusterThreadManager.get().enqueue(new Callable<Void>() { @SuppressWarnings( { "unchecked" }) @Override public Void call() throws Exception { for (@SuppressWarnings("rawtypes") DistributedPropertyChangedAction pca : actions) { pca.distributedPropertyDidChange(ee.getMember(), null, ee.getValue()); } return null; } }); }
@Override public void entryAdded(final EntryEvent<G, H> e) { ClusterThreadManager.get().enqueue(new Callable<Void>() { @Override public Void call() throws Exception { for (ItemAddedAction<G, H> action : addedActions) { action.itemAddedToCollection(collection, e.getKey(), e.getValue(), e.getMember()); } return null; } }); }
@Override public void entryRemoved(final EntryEvent<G, H> e) { ClusterThreadManager.get().enqueue(new Callable<Void>() { @Override public Void call() throws Exception { for (ItemRemovedAction<G, H> action : removedActions) { action.itemRemovedFromCollection(collection, e.getKey(), e.getValue(), e.getMember()); } return null; } }); }
@Override public void entryUpdated(final EntryEvent<G, H> e) { ClusterThreadManager.get().enqueue(new Callable<Void>() { @Override public Void call() throws Exception { for (ItemUpdatedAction<G, H> action : updatedActions) { action.itemUpdatedInCollection(collection, e.getKey(), e.getOldValue(), e.getValue(), e.getMember()); } return null; } }); }
private void simulateCacheInserts(Cache cache) { EntryListener EntryListener = EntryListeners.get(cache); if (EntryListener != null) { if (cache instanceof CacheWrapper) { Cache wrapped = ((CacheWrapper) cache).getWrappedCache(); if (wrapped instanceof ClusteredCache) { ClusteredCache clusteredCache = (ClusteredCache) wrapped; for (Map.Entry entry : (Set<Map.Entry>) cache.entrySet()) { EntryEvent event = new EntryEvent(clusteredCache.map.getName(), cluster.getLocalMember(), EntryEventType.ADDED.getType(), entry.getKey(), null, entry.getValue()); EntryListener.entryAdded(event); } } } } }
private void handleEntryEvent(EntryEvent event, boolean removal) { NodeID nodeID = NodeID.getInstance(StringUtils.getBytes(event.getMember().getUuid())); // ignore events which were triggered by this node if (!XMPPServer.getInstance().getNodeID().equals(nodeID)) { Set<DomainPair> sessionJIDS = nodeRoutes.get(nodeID); if (sessionJIDS == null) { sessionJIDS = new HashSet<>(); } if (removal) { sessionJIDS.remove(event.getKey()); } else { sessionJIDS.add((DomainPair)event.getKey()); } } }
public HazelcastEventStore(int maxLogSizePerAggregate, IMap<InstanceId, List<InstanceEvent>> eventLog) { super(maxLogSizePerAggregate, eventLog); eventLog.addEntryListener((MapListener) new EntryAdapter<InstanceId, List<InstanceEvent>>() { @Override public void entryUpdated(EntryEvent<InstanceId, List<InstanceEvent>> event) { log.debug("Updated {}", event); long lastKnownVersion = getLastVersion(event.getOldValue()); List<InstanceEvent> newEvents = event.getValue() .stream() .filter(e -> e.getVersion() > lastKnownVersion) .collect(Collectors.toList()); HazelcastEventStore.this.publish(newEvents); } }, true); }
public void entryAdded(EntryEvent event) { byte[] nodeID = StringUtils.getBytes(event.getMember().getUuid()); // Ignore events originated from this JVM if (!XMPPServer.getInstance().getNodeID().equals(nodeID)) { // Check if the directed presence was sent to an entity hosted by this JVM RoutingTable routingTable = XMPPServer.getInstance().getRoutingTable(); String sender = event.getKey().toString(); Collection<String> handlers = new HashSet<String>(); for (JID handler : getHandlers(event)) { if (routingTable.isLocalRoute(handler)) { // Keep track of the remote sender and local handler that got the directed presence handlers.addAll(getReceivers(event, handler)); } } if (!handlers.isEmpty()) { Map<String, Collection<String>> senders = nodePresences.get(NodeID.getInstance(nodeID)); if (senders == null) { senders = new ConcurrentHashMap<String, Collection<String>>(); nodePresences.put(NodeID.getInstance(nodeID), senders); } senders.put(sender, handlers); } } }
@Override public void entryRemoved(EntryEvent<String, byte[]> event) { final Object value = KryoFactory.deserialize(event.getValue()); if (value instanceof Flow) { // Handles events from flowMap. final Flow flow = (Flow) value; log.trace("Flow {} was removed", flow); for (FlowMapEventListener e : listeners) { e.flowRemoved(flow.getId()); } } else if (value instanceof FlowState) { // Handles events from flowStateMap. log.trace("FlowState {} of FlowId {} was removed", value, event.getKey()); } else { throw new IllegalStateException("Removed illegal value: " + value.toString()); } }
@Override public void entryUpdated(EntryEvent<String, byte[]> event) { final Object value = KryoFactory.deserialize(event.getValue()); if (value instanceof Flow) { // Handles events from flowMap. log.trace("Flow Updated by {}", value); } else if (value instanceof FlowState) { // Handles events from flowStateMap. Object oldValue = KryoFactory.deserialize(event.getOldValue()); final FlowState state = (FlowState) value; final FlowState oldState = (FlowState) oldValue; final FlowId id = FlowId.valueOf(event.getKey()); log.trace("FlowState of FlowId {} was updated from {} to {}", id, oldState, state); for (FlowMapEventListener e : listeners) { e.flowStateChanged(id, oldState, state); } } else { throw new IllegalStateException("Updated illegal value: " + value.toString()); } }
@Override public void entryRemoved(EntryEvent<String, byte[]> event) { final Object value = KryoFactory.deserialize(event.getValue()); if (value instanceof FlowBatchOperation) { // Handles events from flowBatchMap. final FlowBatchOperation flowOp = (FlowBatchOperation) value; final FlowBatchId id = FlowBatchId.valueOf(event.getKey()); log.trace("Flow batch operation ID:{}, {} was removed", id, flowOp); for (FlowBatchMapEventListener e : listeners) { e.flowBatchOperationRemoved(id); } } else if (value instanceof FlowBatchState) { // Handles events from flowBatchStateMap. log.trace("Flow batch state {} of ID:{} was removed", value, event.getKey()); } else { throw new IllegalStateException("Removed illegal value: " + value); } }
@Override public void entryUpdated(EntryEvent<String, byte[]> event) { final Object value = KryoFactory.deserialize(event.getValue()); if (value instanceof FlowBatchOperation) { // Handles events from flowBatchMap. log.trace("Flow batch operation ID:{} updated by {}", event.getKey(), value); } else if (value instanceof FlowBatchState) { // Handles events from flowBatchStateMap. Object oldValue = KryoFactory.deserialize(event.getOldValue()); final FlowBatchState currentState = (FlowBatchState) value; final FlowBatchState oldState = (FlowBatchState) oldValue; final FlowBatchId id = FlowBatchId.valueOf(event.getKey()); log.trace("Flow batch state of ID:{} was updated from {} to {}", id, oldState, currentState); for (FlowBatchMapEventListener e : listeners) { e.flowBatchOperationStateChanged(id, oldState, currentState); } } else { throw new IllegalStateException("Updated illegal value: " + value); } }
private void onEntryChange(RefreshableConfiguration refreshableConfiguration, EntryEvent<String, String> entry, IMap<String, String> configMap) { String entryKey = entry.getKey(); String configContent = configMap.get(entryKey); if (refreshableConfiguration.isListeningConfiguration(entryKey)) { refreshableConfiguration.onRefresh(entryKey, configContent); log.info( "Process config update event: " + "[key = {}, evtType = {}, size = {}, newHash = {}, oldHash = {}] in bean: [{}]", entryKey, entry.getEventType(), StringUtils.length(configContent), getValueHash(configContent), getValueHash(entry.getOldValue()), getBeanName(refreshableConfiguration)); } else { log.debug("Ignored config update event: [key = {}, evtType = {}, configSize = {} in bean [{}]", entryKey, entry.getEventType(), StringUtils.length(configContent), getBeanName(refreshableConfiguration)); } }
@Override public void entryAdded(EntryEvent<String, RateLimitingSettings> paramEntryEvent) { if (paramEntryEvent.getMember().localMember()) { logger.debug("Configuration added by local member, ignoring"); return; } watcher.configChanged(paramEntryEvent.getValue()); }
@Override public void entryUpdated(EntryEvent<String, RateLimitingSettings> paramEntryEvent) { if (paramEntryEvent.getMember().localMember()) { logger.debug("Configuration change affected by local member, ignoring"); return; } watcher.configChanged(paramEntryEvent.getValue()); }
@Override public void entryAdded(final EntryEvent<String, Object> event) { if (LOG.isDebugEnabled()) { LOG.debug("{} name={} key={}", event.getEventType(), event.getName(), event.getKey()); } }
@Override public void entryAdded(EntryEvent<String, DeploymentDescription> entryEvent) { if (entryEvent == null || entryEvent.getValue() == null) { throw new RuntimeException("Received a null message. Something is wrong"); } for (DestinationDiscoveryCallback callback : callBacks) { System.out.println("CALLBACK IS " + callback); callback.destinationAdded(entryEvent); } }
@Override public void entryEvicted(EntryEvent<String, DeploymentDescription> entryEvent) { if (entryEvent == null || entryEvent.getValue() == null) { throw new RuntimeException("Received a null message. Something is wrong"); } for (DestinationDiscoveryCallback callback : callBacks) { callback.destinationEntryEvicted(entryEvent); } }
@Override public void entryRemoved(EntryEvent<String, DeploymentDescription> entryEvent) { if (entryEvent == null || entryEvent.getValue() == null) { throw new RuntimeException("Received a null message. Something is wrong"); } for (DestinationDiscoveryCallback callback : callBacks) { callback.destinationEntryRemoved(entryEvent); } }
@Override public void entryUpdated(EntryEvent<String, DeploymentDescription> entryEvent) { if (entryEvent == null || entryEvent.getValue() == null) { throw new RuntimeException("Received a null message. Something is wrong"); } for (DestinationDiscoveryCallback callback : callBacks) { callback.destinationUpdated(entryEvent); } }
@Override public void entryAdded(Object object) { EntryEvent<String, DeploymentManagement> entryEvent = (EntryEvent<String, DeploymentManagement>) object; DeploymentManagement deploymentManagement = entryEvent.getValue(); Validate.notNull(deploymentManagement, "deploymentManagement must not be null"); if (!deploymentManagement.getDeploymentDescription(). getLocationInCluster().equals(gatewayRulesService.fetchGatewayRules().getLocation())) { if (LOG.isDebugEnabled()) LOG.debug("BeyondJManagementService ignoring incoming deploymentManagement " + "since it references a service not in this instance. Current server is {} and target server is {}", gatewayRulesService.fetchGatewayRules().getLocation(), deploymentManagement.getDeploymentDescription(). getLocationInCluster()); return; //do nothing } try { String supervisorId = deploymentManagement.getDeploymentDescription().getSupervisorId(); BeyondJRemotingService remotingService = new BeyondJRemotingService(); ActorRefService actorRefService = remotingService.getRemoteServiceProxy(ActorRefService.class, ACTOR_REF_SERVICE); ActorRef deploymentSupervisor = actorRefService.getActorRefs().get(supervisorId); deploymentSupervisor.tell(deploymentManagement, null); } catch (Exception e) { LOG.error("Error calling actor", e); } }
@SuppressWarnings("unchecked") private synchronized void adaptListener() { if (listenerCleaner == null) { // TODO - move in separated jar as some sort of provider AsyncMap<String, Session> map = Reflection.field("sessionMap").ofType(AsyncMap.class).in(sessionStore).get(); String listenerId = tryGetHazelcastMap(map) .map(imap -> imap.addEntryListener(new MapListenerAdapter<String, Session>() { @Override public void entryExpired(EntryEvent<String, Session> event) { sessionExpiredProducer.send(event.getKey()); } }, true)).orElse(null); listenerCleaner = () -> tryGetHazelcastMap(map).ifPresent(imap -> imap.removeEntryListener(listenerId)); } }
@Override public void entryAdded(EntryEvent<Serializable, AsciiFileChunk> event) { synchronized (builders) { String rId = chunkKey(event); if(!builders.containsKey(rId)) { builders.put(rId, new RecordBuilder()); } builders.get(rId).handleNext(event.getValue(), rId); } }
@Test @SuppressWarnings("unchecked") public void testAdd() throws InterruptedException { MockEndpoint out = getMockEndpoint("mock:added"); out.expectedMessageCount(1); EntryEvent<Object, Object> event = new EntryEvent<Object, Object>("foo", null, EntryEventType.ADDED.getType(), "4711", "my-foo"); argument.getValue().entryAdded(event); assertMockEndpointsSatisfied(5000, TimeUnit.MILLISECONDS); this.checkHeaders(out.getExchanges().get(0).getIn().getHeaders(), HazelcastConstants.ADDED); }
@Test @SuppressWarnings("unchecked") public void testEnict() throws InterruptedException { MockEndpoint out = super.getMockEndpoint("mock:evicted"); out.expectedMessageCount(1); EntryEvent<Object, Object> event = new EntryEvent<Object, Object>("foo", null, EntryEventType.EVICTED.getType(), "4711", "my-foo"); argument.getValue().entryEvicted(event); assertMockEndpointsSatisfied(30000, TimeUnit.MILLISECONDS); }
@Test @SuppressWarnings("unchecked") public void testUpdate() throws InterruptedException { MockEndpoint out = getMockEndpoint("mock:updated"); out.expectedMessageCount(1); EntryEvent<Object, Object> event = new EntryEvent<Object, Object>("foo", null, EntryEventType.UPDATED.getType(), "4711", "my-foo"); argument.getValue().entryUpdated(event); assertMockEndpointsSatisfied(5000, TimeUnit.MILLISECONDS); this.checkHeaders(out.getExchanges().get(0).getIn().getHeaders(), HazelcastConstants.UPDATED); }
@Test @SuppressWarnings("unchecked") public void testEvict() throws InterruptedException { MockEndpoint out = getMockEndpoint("mock:evicted"); out.expectedMessageCount(1); EntryEvent<Object, Object> event = new EntryEvent<Object, Object>("foo", null, EntryEventType.EVICTED.getType(), "4711", "my-foo"); argument.getValue().entryEvicted(event); assertMockEndpointsSatisfied(5000, TimeUnit.MILLISECONDS); this.checkHeaders(out.getExchanges().get(0).getIn().getHeaders(), HazelcastConstants.EVICTED); }
@Test @SuppressWarnings("unchecked") public void testRemove() throws InterruptedException { MockEndpoint out = getMockEndpoint("mock:removed"); out.expectedMessageCount(1); EntryEvent<Object, Object> event = new EntryEvent<Object, Object>("foo", null, EntryEventType.REMOVED.getType(), "4711", "my-foo"); argument.getValue().entryRemoved(event); assertMockEndpointsSatisfied(5000, TimeUnit.MILLISECONDS); this.checkHeaders(out.getExchanges().get(0).getIn().getHeaders(), HazelcastConstants.REMOVED); }
@Test @SuppressWarnings("unchecked") public void testEvict() throws InterruptedException { MockEndpoint out = getMockEndpoint("mock:evicted"); out.expectedMessageCount(1); EntryEvent<Object, Object> event = new EntryEvent<Object, Object>("foo", null, EntryEventType.EVICTED.getType(), "4711", "my-foo"); argument.getValue().entryEvicted(event); assertMockEndpointsSatisfied(30000, TimeUnit.MILLISECONDS); }
@Override public void entryAdded(final EntryEvent<String, JsonObject> event) { m_logger.debug("Member: {} {} - entry added: {}", event.getMember().getSocketAddress(), event.getMember().getUuid(), event.getKey()); }