com.hazelcast.map.EntryProcessor Java Examples

The following examples show how to use com.hazelcast.map.EntryProcessor. 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: OperationTest.java    From eventapis with Apache License 2.0 6 votes vote down vote up
@Test
public void testReadWriteExternal() throws Exception {
    HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance();
    IMap<Object, Object> test = hazelcastInstance.getMap("test");
    test.executeOnKey("123", new EntryProcessor() {
        @Override
        public Object process(Map.Entry entry) {
            entry.setValue("Blabla");
            return entry;
        }

        @Override
        public EntryBackupProcessor getBackupProcessor() {
            return null;
        }
    });

    System.out.println(test.get("123"));


}
 
Example #2
Source File: HazelcastIndexedSessionRepositoryTests.java    From spring-session with Apache License 2.0 6 votes vote down vote up
@Test
void saveUpdatedMaxInactiveIntervalInSecondsFlushModeImmediate() {
	verify(this.sessions, times(1)).addEntryListener(any(MapListener.class), anyBoolean());

	this.repository.setFlushMode(FlushMode.IMMEDIATE);

	HazelcastSession session = this.repository.createSession();
	String sessionId = session.getId();
	session.setMaxInactiveInterval(Duration.ofSeconds(1));
	verify(this.sessions, times(1)).set(eq(sessionId), eq(session.getDelegate()), isA(Long.class),
			eq(TimeUnit.SECONDS));
	verify(this.sessions).setTtl(eq(sessionId), anyLong(), any());
	verify(this.sessions, times(1)).executeOnKey(eq(sessionId), any(EntryProcessor.class));

	this.repository.save(session);
	verifyZeroInteractions(this.sessions);
}
 
Example #3
Source File: HazelcastIndexedSessionRepositoryTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void saveUpdatedAttributeFlushModeImmediate() {
	verify(this.sessions, times(1)).addEntryListener(any(MapListener.class), anyBoolean());

	this.repository.setFlushMode(FlushMode.IMMEDIATE);

	HazelcastSession session = this.repository.createSession();
	session.setAttribute("testName", "testValue");
	verify(this.sessions, times(1)).set(eq(session.getId()), eq(session.getDelegate()), isA(Long.class),
			eq(TimeUnit.SECONDS));
	verify(this.sessions, times(1)).executeOnKey(eq(session.getId()), any(EntryProcessor.class));

	this.repository.save(session);
	verifyZeroInteractions(this.sessions);
}
 
Example #4
Source File: HazelcastIndexedSessionRepositoryTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void removeAttributeFlushModeImmediate() {
	verify(this.sessions, times(1)).addEntryListener(any(MapListener.class), anyBoolean());

	this.repository.setFlushMode(FlushMode.IMMEDIATE);

	HazelcastSession session = this.repository.createSession();
	session.removeAttribute("testName");
	verify(this.sessions, times(1)).set(eq(session.getId()), eq(session.getDelegate()), isA(Long.class),
			eq(TimeUnit.SECONDS));
	verify(this.sessions, times(1)).executeOnKey(eq(session.getId()), any(EntryProcessor.class));

	this.repository.save(session);
	verifyZeroInteractions(this.sessions);
}
 
Example #5
Source File: HazelcastIndexedSessionRepositoryTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void saveUpdatedLastAccessedTimeFlushModeImmediate() {
	verify(this.sessions, times(1)).addEntryListener(any(MapListener.class), anyBoolean());

	this.repository.setFlushMode(FlushMode.IMMEDIATE);

	HazelcastSession session = this.repository.createSession();
	session.setLastAccessedTime(Instant.now());
	verify(this.sessions, times(1)).set(eq(session.getId()), eq(session.getDelegate()), isA(Long.class),
			eq(TimeUnit.SECONDS));
	verify(this.sessions, times(1)).executeOnKey(eq(session.getId()), any(EntryProcessor.class));

	this.repository.save(session);
	verifyZeroInteractions(this.sessions);
}
 
Example #6
Source File: HazelcastEntryProcessorAdapter.java    From bucket4j with Apache License 2.0 4 votes vote down vote up
@Override
public EntryProcessor<K, GridBucketState, Object> getBackupProcessor() {
    return backupProcessor;
}
 
Example #7
Source File: HazelcastProxy.java    From bucket4j with Apache License 2.0 4 votes vote down vote up
private <T extends Serializable> EntryProcessor adoptEntryProcessor(final JCacheEntryProcessor<K, T> entryProcessor) {
    return new HazelcastEntryProcessorAdapter<>(entryProcessor);
}
 
Example #8
Source File: HazelcastProxy.java    From bucket4j with Apache License 2.0 4 votes vote down vote up
private <T extends Serializable>  EntryProcessor adoptEntryProcessor(final JCacheEntryProcessor<K, T> entryProcessor) {
    return new HazelcastEntryProcessorAdapter<>(entryProcessor);
}