org.apache.geode.cache.EntryEvent Java Examples

The following examples show how to use org.apache.geode.cache.EntryEvent. 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: GeodeConfiguration.java    From spring-boot-data-geode with Apache License 2.0 6 votes vote down vote up
@Bean
RegionConfigurer subscriptionCacheListenerRegionConfigurer() {

	return new RegionConfigurer() {

		@Override
		@SuppressWarnings("unchecked")
		public void configure(String beanName, ClientRegionFactoryBean<?, ?> clientRegion) {

			CacheListener subscriptionCacheListener =
					new AbstractCommonEventProcessingCacheListener() {

				@Override
				protected void processEntryEvent(EntryEvent event, EntryEventType eventType) {

					if (event.isOriginRemote()) {
						System.err.printf("[%1$s] EntryEvent for [%2$s] with value [%3$s]%n",
							event.getKey(), event.getOperation(), event.getNewValue());
					}
				}
			};

			clientRegion.setCacheListeners(ArrayUtils.asArray(subscriptionCacheListener));
		}
	};
}
 
Example #2
Source File: ExampleCacheWriterTest.java    From geode-examples with Apache License 2.0 5 votes vote down vote up
@Test(expected = CacheWriterException.class)
public void testBeforeCreateFailsForBadSSN() throws Exception {
  ExampleCacheWriter writer = new ExampleCacheWriter();

  EntryEvent<String, String> event = mock(EntryEvent.class);
  when(event.getKey()).thenReturn("666-66-6666");
  writer.beforeCreate(event);
}
 
Example #3
Source File: ExampleCacheWriterTest.java    From geode-examples with Apache License 2.0 5 votes vote down vote up
@Test
public void testBeforeCreatePassesWithGoodSSN() throws Exception {
  ExampleCacheWriter writer = new ExampleCacheWriter();

  EntryEvent<String, String> event = mock(EntryEvent.class);
  when(event.getKey()).thenReturn("555-66-6666");
  writer.beforeCreate(event);
}
 
Example #4
Source File: MultiSiteCachingIntegrationTests.java    From spring-boot-data-geode with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void afterCreate(EntryEvent<String, Customer> event) {

	this.entryEventArrived |= Optional.ofNullable(event)
		//.map(this::log)
		.map(EntryEvent::getKey)
		.filter(TEST_CUSTOMER_NAME::equals)
		.isPresent();
}
 
Example #5
Source File: ExampleCacheWriterTest.java    From geode-examples with Apache License 2.0 5 votes vote down vote up
@Test(expected = CacheWriterException.class)
public void testBeforeCreateFailsForBadSSN() throws Exception {
  ExampleCacheWriter writer = new ExampleCacheWriter();

  EntryEvent<String, String> event = mock(EntryEvent.class);
  when(event.getKey()).thenReturn("666-66-6666");
  writer.beforeCreate(event);
}
 
Example #6
Source File: ExampleCacheWriterTest.java    From geode-examples with Apache License 2.0 5 votes vote down vote up
@Test
public void testBeforeCreatePassesWithGoodSSN() throws Exception {
  ExampleCacheWriter writer = new ExampleCacheWriter();

  EntryEvent<String, String> event = mock(EntryEvent.class);
  when(event.getKey()).thenReturn("555-66-6666");
  writer.beforeCreate(event);
}
 
Example #7
Source File: WanEventSubstitutionFilter.java    From spring-data-examples with Apache License 2.0 4 votes vote down vote up
@Override
public Object getSubstituteValue(EntryEvent<Long, Customer> event) {
	Customer customer = event.getNewValue();
	return new Customer(customer.getId(), customer.getEmailAddress(), customer.getFirstName(),
			customer.getLastName().substring(0, 1));
}
 
Example #8
Source File: AbstractCommonEventProcessingCacheListener.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Override
public void afterUpdate(EntryEvent<K, V> event) {
	processEntryEvent(event, EntryEventType.UPDATE);
}
 
Example #9
Source File: ExampleCacheWriter.java    From geode-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void beforeUpdate(EntryEvent<String, String> event) throws CacheWriterException {
  if (!vetter.isValid(event.getKey())) {
    throw new CacheWriterException("Invalid SSN");
  }
}
 
Example #10
Source File: ExampleCacheWriter.java    From geode-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void beforeCreate(EntryEvent<String, String> event) throws CacheWriterException {
  if (!vetter.isValid(event.getKey())) {
    throw new CacheWriterException("Invalid SSN");
  }
}
 
Example #11
Source File: ExampleCacheWriter.java    From geode-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void beforeDestroy(EntryEvent<String, String> event) throws CacheWriterException {
  // N/A
}
 
Example #12
Source File: ExampleCacheListener.java    From geode-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void afterCreate(EntryEvent<Integer, String> event) {
  System.out.println("received create for key " + event.getKey());
}
 
Example #13
Source File: Example.java    From geode-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void afterCreate(EntryEvent<Integer, String> event) {
  System.out.println(
      "Received create for key " + event.getKey() + " after durable client reconnection");
  waitForEventsLatch.countDown();
}
 
Example #14
Source File: AbstractCommonEventProcessingCacheListener.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Override
public void afterCreate(EntryEvent<K, V> event) {
	processEntryEvent(event, EntryEventType.CREATE);
}
 
Example #15
Source File: LoggingCacheListener.java    From spring-data-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void afterCreate(EntryEvent<K, V> event) {
	log.info("In region [" + event.getRegion().getName() + "] created key [" + event.getKey() + "] value ["
			+ event.getNewValue() + "]");
}
 
Example #16
Source File: LoggingCacheListener.java    From spring-data-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void afterDestroy(EntryEvent<K, V> event) {
	log.info("In region [" + event.getRegion().getName() + "] destroyed key [" + event.getKey() + "] ");
}
 
Example #17
Source File: LoggingCacheListener.java    From spring-data-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void afterUpdate(EntryEvent<K, V> event) {
	log.info("In region [" + event.getRegion().getName() + "] updated key [" + event.getNewValue() + "] [oldValue ["
			+ event.getOldValue() + "]] new value [" + event.getNewValue() + "]");
}
 
Example #18
Source File: CustomerCacheWriter.java    From spring-data-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void beforeCreate(EntryEvent<Long, Customer> event) throws CacheWriterException {
	EntryEventImpl e = (EntryEventImpl) event;
	super.beforeCreate(e);
}
 
Example #19
Source File: AbstractCommonEventProcessingCacheListener.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Override
public void afterInvalidate(EntryEvent<K, V> event) {
	processEntryEvent(event, EntryEventType.INVALIDATE);
}
 
Example #20
Source File: AbstractCommonEventProcessingCacheListener.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Override
public void afterDestroy(EntryEvent<K, V> event) {
	processEntryEvent(event, EntryEventType.DESTROY);
}
 
Example #21
Source File: ExampleCacheWriter.java    From geode-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void beforeUpdate(EntryEvent<String, String> event) throws CacheWriterException {
  if (!vetter.isValid(event.getKey())) {
    throw new CacheWriterException("Invalid SSN");
  }
}
 
Example #22
Source File: CacheWriterSupport.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Override
default void beforeDestroy(EntryEvent<K, V> event) throws CacheWriterException { }
 
Example #23
Source File: CacheWriterSupport.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Override
default void beforeUpdate(EntryEvent<K, V> event) throws CacheWriterException { }
 
Example #24
Source File: CacheWriterSupport.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Override
default void beforeCreate(EntryEvent<K, V> event) throws CacheWriterException { }
 
Example #25
Source File: RepositoryCacheWriter.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Override
public void beforeDestroy(EntryEvent<ID, T> event) throws CacheWriterException {

  //doRepositoryOp(event.getOldValue(), FunctionUtils.toNullReturningFunction(getRepository()::delete));
  doRepositoryOp(event.getKey(), FunctionUtils.toNullReturningFunction(getRepository()::deleteById));
}
 
Example #26
Source File: RepositoryCacheWriter.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Override
public void beforeUpdate(EntryEvent<ID, T> event) throws CacheWriterException {
  doRepositoryOp(event.getNewValue(), getRepository()::save);
}
 
Example #27
Source File: RepositoryCacheWriter.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Override
public void beforeCreate(EntryEvent<ID, T> event) throws CacheWriterException {
  doRepositoryOp(event.getNewValue(), getRepository()::save);
}
 
Example #28
Source File: Example.java    From geode-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void afterCreate(EntryEvent<Integer, String> event) {
  System.out.println(
      "Received create for key " + event.getKey() + " after durable client reconnection");
  waitForEventsLatch.countDown();
}
 
Example #29
Source File: ExampleCacheListener.java    From geode-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void afterCreate(EntryEvent<Integer, String> event) {
  System.out.println("received create for key " + event.getKey());
}
 
Example #30
Source File: ExampleCacheWriter.java    From geode-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void beforeDestroy(EntryEvent<String, String> event) throws CacheWriterException {
  // N/A
}