本文整理汇总了Java中javax.cache.event.EventType.UPDATED属性的典型用法代码示例。如果您正苦于以下问题:Java EventType.UPDATED属性的具体用法?Java EventType.UPDATED怎么用?Java EventType.UPDATED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.cache.event.EventType
的用法示例。
在下文中一共展示了EventType.UPDATED属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAndReplace
@Override
public V getAndReplace(K key, V value)
{
throwISEwhenClosed();
Action<K, V, Object> action = new ReplaceAction<K, V, Object>(key, value, EventType.UPDATED);
V oldValue = null;
if (actionRunnerWriteBehind.preMutate(action))
{
oldValue = tcache.getAndReplace(key, value);
boolean replaced = oldValue != null;
ChangeStatus changeStatus = replaced ? ChangeStatus.CHANGED : ChangeStatus.UNCHANGED;
actionRunnerWriteBehind.postMutate(action, changeStatus);
}
action.close();
return oldValue;
}
示例2: put0
void put0(K key, V value, boolean writeThrough)
{
throwISEwhenClosed();
kvUtil.verifyKeyAndValueNotNull(key, value);
Action<K,V,Object> action = new PutAction<>(key, value, EventType.CREATED, false, writeThrough);
if (actionRunner.preMutate(action))
{
Holders<V> holders = tcache.putToMapI(key, value, tcache.cacheTimeSpread(), false);
final EventType eventType;
if (holders == null)
eventType = null;
else
{
if (holders.newHolder == null || holders.newHolder.isInvalid())
eventType = null; // new is invalid
else
eventType = holders.oldHolder == null ? EventType.CREATED : EventType.UPDATED;
}
action.setEventType(eventType);
actionRunner.postMutate(action);
}
action.close();
}
示例3: replace
@Override
public boolean replace(K key, V oldValue, V newValue)
{
throwISEwhenClosed();
kvUtil.verifyKeyAndValueNotNull(key, newValue);
kvUtil.verifyValueNotNull(oldValue);
boolean replaced = false;
Action<K, V, Object> action = new ReplaceAction<K, V, Object>(key, newValue, EventType.UPDATED);
if (actionRunnerWriteBehind.preMutate(action))
{
ChangeStatus changeStatus = tcache.replace(key, oldValue, newValue);
actionRunnerWriteBehind.postMutate(action, changeStatus);
replaced = changeStatus == ChangeStatus.CHANGED;
}
return replaced;
}
示例4: onEntryUpdated
void onEntryUpdated(K key, V oldValue, V value) {
if (onUpdate) {
BlazingCacheCacheEntryEvent event = new BlazingCacheCacheEntryEvent(key, oldValue, value, parent, EventType.UPDATED, true);
if (filter != null && !filter.evaluate(event)) {
return;
}
((CacheEntryUpdatedListener) listener).onUpdated(Arrays.asList(event));
}
}
示例5: testCacheContinuousQueryEntrySerialization
/**
*
*/
public void testCacheContinuousQueryEntrySerialization() {
CacheContinuousQueryEntry e0 = new CacheContinuousQueryEntry(
1,
EventType.UPDATED,
new KeyCacheObjectImpl(1, new byte[] {0, 0, 0, 1}, 1),
new CacheObjectImpl(2, new byte[] {0, 0, 0, 2}),
new CacheObjectImpl(2, new byte[] {0, 0, 0, 3}),
true,
1,
1L,
new AffinityTopologyVersion(1L),
(byte)0);
e0.markFiltered();
ByteBuffer buf = ByteBuffer.allocate(4096);
DirectMessageWriter writer = new DirectMessageWriter((byte)1);
// Skip write class header.
writer.onHeaderWritten();
e0.writeTo(buf, writer);
CacheContinuousQueryEntry e1 = new CacheContinuousQueryEntry();
e1.readFrom(ByteBuffer.wrap(buf.array()), new DirectMessageReader(new GridIoMessageFactory(null), (byte)1));
assertEquals(e0.cacheId(), e1.cacheId());
assertEquals(e0.eventType(), e1.eventType());
assertEquals(e0.isFiltered(), e1.isFiltered());
assertEquals(e0.isBackup(), e1.isBackup());
assertEquals(e0.isKeepBinary(), e1.isKeepBinary());
assertEquals(e0.partition(), e1.partition());
assertEquals(e0.updateCounter(), e1.updateCounter());
// Key and value shouldn't be serialized in case an event is filtered.
assertNull(e1.key());
assertNotNull(e0.key());
assertNull(e1.oldValue());
assertNotNull(e0.oldValue());
assertNull(e1.value());
assertNotNull(e0.value());
}
示例6: AbstractJCacheTest
protected AbstractJCacheTest(String cacheName) {
this(cacheName, EventType.CREATED, EventType.UPDATED, EventType.REMOVED, EventType.EXPIRED);
}
示例7: shouldHandleCacheEntryEventFromServerWithClient
/**
* Ensure that values can be loaded from the {@link org.jsr107.tck.event.CacheEntryListenerClient} via
* the {@link org.jsr107.tck.event.CacheEntryListenerServer}.
*/
@Test
public void shouldHandleCacheEntryEventFromServerWithClient() {
CacheTestSupport.MyCacheEntryListener<String, String> listener = new CacheTestSupport.MyCacheEntryListener<>();
CacheEntryListenerServer<String, String> serverListener =
new CacheEntryListenerServer<>(10011, String.class, String.class);
serverListener.addCacheEventListener(listener);
try {
serverListener.open();
CacheEntryListenerClient<String, String> clientListener =
new CacheEntryListenerClient<>(serverListener.getInetAddress(), serverListener.getPort());
TestCacheEntryEvent<String, String> event = new TestCacheEntryEvent(null, EventType.CREATED);
event.setKey("key");
event.setValue("value");
event.setOldValueAvailable(false);
ArrayList events = new ArrayList();
events.add(event);
clientListener.onCreated(events);
Assert.assertThat(listener.getCreated(), is(1));
clientListener.onRemoved(events);
Assert.assertThat(listener.getRemoved(), is(0));
event = new TestCacheEntryEvent(null, EventType.UPDATED);
event.setKey("key");
event.setValue("value");
event.setOldValue("oldValue");
event.setOldValueAvailable(true);
events.clear();
events.add(event);
clientListener.onUpdated(events);
Assert.assertThat(listener.getUpdated(), is(1));
Assert.assertThat(listener.getCreated(), is(1));
} catch (Exception e) {
} finally {
serverListener.close();
}
}
示例8: getEventType
@Override
public EventType getEventType() {
return EventType.UPDATED;
}