Java Code Examples for javax.cache.event.CacheEntryEvent#getValue()
The following examples show how to use
javax.cache.event.CacheEntryEvent#getValue() .
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: ReadStoreExtractor.java From spring-boot-akka-event-sourcing-starter with Apache License 2.0 | 6 votes |
/** * @param msg the cache entry event which contain the added/update value object * @return the mapped read cache entry which will be streamed to the target cache */ @Override public Map.Entry<String, JournalReadItem> extract(CacheEntryEvent<Object, BinaryObject> msg) { IgniteBiTuple<String, JournalReadItem> readRecord = null; final BinaryObject value = msg.getValue(); final String orderId = value.field(FieldNames.persistenceId.name()); final byte[] payload = value.field(FieldNames.payload.name()); try { final MessageFormats.PersistentMessage persistentMessage = MessageFormats.PersistentMessage.parseFrom(payload); if (persistentMessage.hasPayload()) { final OrderEvent event = (OrderEvent) orderOrderManagerSerializer.fromBinary(persistentMessage.getPayload().getPayload().toByteArray(), persistentMessage.getPayload().getPayloadManifest().toStringUtf8()); readRecord = new IgniteBiTuple<>(event.getOrderId(), new JournalReadItem(event.getOrderId(), event.getOrderStatus().name())); } } catch (InvalidProtocolBufferException | NotSerializableException e) { log.error("error in parsing the msg for id {} with error {}", orderId, e); } return readRecord; }
Example 2
Source File: HadoopJobTracker.java From ignite with Apache License 2.0 | 5 votes |
/** * @param updated Updated cache entries. * @throws IgniteCheckedException If failed. */ private void processJobMetadataUpdates( Iterable<CacheEntryEvent<? extends HadoopJobId, ? extends HadoopJobMetadata>> updated) throws IgniteCheckedException { UUID locNodeId = ctx.localNodeId(); for (CacheEntryEvent<? extends HadoopJobId, ? extends HadoopJobMetadata> entry : updated) { HadoopJobId jobId = entry.getKey(); HadoopJobMetadata meta = entry.getValue(); if (meta == null || !ctx.isParticipating(meta)) continue; if (log.isDebugEnabled()) log.debug("Processing job metadata update callback [locNodeId=" + locNodeId + ", meta=" + meta + ']'); try { ctx.taskExecutor().onJobStateChanged(meta); } catch (IgniteCheckedException e) { U.error(log, "Failed to process job state changed callback (will fail the job) " + "[locNodeId=" + locNodeId + ", jobId=" + jobId + ", meta=" + meta + ']', e); transform(jobId, new CancelJobProcessor(null, e)); continue; } processJobMetaUpdate(jobId, meta, locNodeId); } }
Example 3
Source File: GridServiceProcessor.java From ignite with Apache License 2.0 | 5 votes |
/** * @param e Entry. */ private void processAssignment(CacheEntryEvent<GridServiceAssignmentsKey, GridServiceAssignments> e) { GridServiceAssignments assigns; try { assigns = e.getValue(); } catch (IgniteException ex) { if (X.hasCause(ex, ClassNotFoundException.class)) return; else throw ex; } if (e.getEventType() != REMOVED) { svcName.set(assigns.name()); Throwable t = null; try { redeploy(assigns); } catch (Error | RuntimeException th) { t = th; } GridServiceDeploymentFuture<String> fut = depFuts.get(assigns.name()); if (fut != null && fut.configuration().equalsIgnoreNodeFilter(assigns.configuration())) { depFuts.remove(assigns.name(), fut); // Complete deployment futures once the assignments have been stored in cache. fut.onDone(null, t); } } // Handle undeployment. else undeploy(e.getKey().name()); }
Example 4
Source File: CacheContinuousWithTransformerReplicatedSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public String apply(CacheEntryEvent<?, ?> evt) { if (keepBinary) return ((BinaryObject)evt.getValue()).field("name"); return ((Employee)evt.getValue()).name; }
Example 5
Source File: CacheContinuousQueryVariationsTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @param evtsQueues Event queue. * @param key Key. * @param val Value. * @param oldVal Old value. * @param keepBinary Keep binary. * @param withFilter With filter. * @throws Exception If failed. */ private void waitAndCheckEvent(List<BlockingQueue<CacheEntryEvent<?, ?>>> evtsQueues, Object key, Object val, Object oldVal, boolean keepBinary, boolean withFilter) throws Exception { if (val == null && oldVal == null || (withFilter && val != null && !isAccepted(val, false, dataMode))) { checkNoEvent(evtsQueues); return; } for (BlockingQueue<CacheEntryEvent<?, ?>> evtsQueue : evtsQueues) { CacheEntryEvent<?, ?> evt = evtsQueue.poll(5, SECONDS); assertNotNull("Failed to wait for event [key=" + key + ", val=" + val + ", oldVal=" + oldVal + ']', evt); Object actKey = evt.getKey(); Object actVal = evt.getValue(); Object actOldVal = evt.getOldValue(); if (keepBinary) { actKey = checkAndGetObject(actKey); actVal = checkAndGetObject(actVal); actOldVal = checkAndGetObject(actOldVal); } assertEquals(key, actKey); assertEquals(val, actVal); assertEquals(oldVal, actOldVal); } }
Example 6
Source File: CacheContinuousQueryFailoverAbstractSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public synchronized void onUpdated(Iterable<CacheEntryEvent<?, ?>> evts) throws CacheEntryListenerException { try { for (CacheEntryEvent<?, ?> evt : evts) { Integer key = (Integer)evt.getKey(); Integer val = (Integer)evt.getValue(); assertNotNull(key); assertNotNull(val); Integer prevVal = vals.get(key); boolean dup = false; if (prevVal != null && prevVal.equals(val)) dup = true; if (!dup) { vals.put(key, val); List<CacheEntryEvent<?, ?>> keyEvts = this.evts.get(key); if (keyEvts == null) { keyEvts = Collections.synchronizedList(new ArrayList<CacheEntryEvent<?, ?>>()); this.evts.put(key, keyEvts); } keyEvts.add(evt); } } } catch (Throwable e) { err = true; log.error("Unexpected error", e); } }
Example 7
Source File: CacheListenersTest.java From blazingcache with Apache License 2.0 | 5 votes |
@Override public void onCreated(Iterable<CacheEntryEvent<? extends K, ? extends V>> events) throws CacheEntryListenerException { for (CacheEntryEvent<? extends K, ? extends V> event : events) { assertEquals(CREATED.toString(), event.getEventType().toString()); created.incrementAndGet(); // added for code coverage. event.getKey(); event.getValue(); event.getSource(); } }
Example 8
Source File: OAuthCacheRemoveListener.java From carbon-identity with Apache License 2.0 | 5 votes |
@Override public void entryRemoved(CacheEntryEvent<? extends OAuthCacheKey, ? extends CacheEntry> cacheEntryEvent) throws CacheEntryListenerException { CacheEntry cacheEntry = cacheEntryEvent.getValue(); if(cacheEntry == null || !(cacheEntry instanceof AccessTokenDO)){ return; } AccessTokenDO accessTokenDO = (AccessTokenDO) cacheEntryEvent.getValue(); if (accessTokenDO != null) { if (log.isDebugEnabled()) { log.debug("OAuth cache removed for consumer id : " + accessTokenDO.getConsumerKey()); } boolean isUsernameCaseSensitive = IdentityUtil .isUserStoreInUsernameCaseSensitive(accessTokenDO.getAuthzUser().getUserName()); String cacheKeyString; if (isUsernameCaseSensitive){ cacheKeyString = accessTokenDO.getConsumerKey() + ":" + accessTokenDO.getAuthzUser().getUserName() + ":" + OAuth2Util.buildScopeString(accessTokenDO.getScope()); }else { cacheKeyString = accessTokenDO.getConsumerKey() + ":" + accessTokenDO.getAuthzUser().getUserName().toLowerCase() + ":" + OAuth2Util.buildScopeString(accessTokenDO.getScope()); } OAuthCacheKey oauthcacheKey = new OAuthCacheKey(cacheKeyString); OAuthCache oauthCache = OAuthCache.getInstance(); oauthCache.clearCacheEntry(oauthcacheKey); oauthcacheKey = new OAuthCacheKey(accessTokenDO.getAccessToken()); oauthCache.clearCacheEntry(oauthcacheKey); } }
Example 9
Source File: CacheTestSupport.java From cache2k with Apache License 2.0 | 5 votes |
@Override public void onCreated(Iterable<CacheEntryEvent<? extends K, ? extends V>> events) throws CacheEntryListenerException { for (CacheEntryEvent<? extends K, ? extends V> event : events) { assertEquals(CREATED, event.getEventType()); created.incrementAndGet(); // added for code coverage. event.getKey(); event.getValue(); event.getSource(); } }
Example 10
Source File: CacheDeploymentEntryEventFilter.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public boolean evaluate(CacheEntryEvent<? extends Integer, ? extends Integer> evt) throws CacheEntryListenerException { return evt.getValue() == null || evt.getValue() % 2 != 0; }
Example 11
Source File: CacheContinuousQueryFailoverAbstractSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public boolean evaluate(CacheEntryEvent<?, ?> e) throws CacheEntryListenerException { return (Integer)e.getValue() % 2 == 0; }
Example 12
Source File: CacheContinuousQueryFailoverAbstractSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public boolean evaluate(CacheEntryEvent<?, ?> evt) throws CacheEntryListenerException { return ((Integer)evt.getValue()) >= 0; }