org.apache.geode.cache.query.CqEvent Java Examples

The following examples show how to use org.apache.geode.cache.query.CqEvent. 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: RandomEventListener.java    From geode-examples with Apache License 2.0 5 votes vote down vote up
@Override
public void onEvent(CqEvent cqEvent) {

  Operation queryOperation = cqEvent.getQueryOperation();


  if (queryOperation.isUpdate()) {
    System.out.print("-------Updated Value\n");
  } else if (queryOperation.isCreate()) {
    System.out.print("-------Value Created\n");
  }
}
 
Example #2
Source File: TemperatureMonitor.java    From spring-boot-data-geode with Apache License 2.0 5 votes vote down vote up
@ContinuousQuery(name = "BoilingTemperatureMonitor",
	query = "SELECT * FROM /TemperatureReadings WHERE temperature >= 212")
public void boilingTemperatureReadings(CqEvent event) {

	Optional.ofNullable(event)
		.map(CqEvent::getNewValue)
		.filter(TemperatureReading.class::isInstance)
		.map(TemperatureReading.class::cast)
		.map(it -> new BoilingTemperatureEvent(this, it))
		.ifPresent(this.applicationEventPublisher::publishEvent);
}
 
Example #3
Source File: TemperatureMonitor.java    From spring-boot-data-geode with Apache License 2.0 5 votes vote down vote up
@ContinuousQuery(name = "FreezingTemperatureMonitor",
	query = "SELECT * FROM /TemperatureReadings WHERE temperature <= 32")
public void freezingTemperatureReadings(CqEvent event) {

	Optional.ofNullable(event)
		.map(CqEvent::getNewValue)
		.filter(TemperatureReading.class::isInstance)
		.map(TemperatureReading.class::cast)
		.map(it -> new FreezingTemperatureEvent(this, it))
		.ifPresent(this.applicationEventPublisher::publishEvent);
}
 
Example #4
Source File: TemperatureReadingsContinuousQueriesHandler.java    From spring-boot-data-geode with Apache License 2.0 5 votes vote down vote up
@ContinuousQuery(name = "BoilingTemperatures",
	query = "SELECT * FROM /TemperatureReadings r WHERE r.temperature >= 212")
public void boilingTemperatures(CqEvent event) {

	TemperatureReading temperatureReading = (TemperatureReading) event.getNewValue();

	this.boilingTemperatureReadings.add(temperatureReading);
	this.temperatureReadingsCounter.incrementAndGet();
}
 
Example #5
Source File: TemperatureReadingsContinuousQueriesHandler.java    From spring-boot-data-geode with Apache License 2.0 5 votes vote down vote up
@ContinuousQuery(name = "FreezingTemperatures",
	query = "SELECT * FROM /TemperatureReadings r WHERE r.temperature <= 32")
public void freezingTemperatures(CqEvent event) {

	TemperatureReading temperatureReading = (TemperatureReading) event.getNewValue();

	this.freezingTemperatureReadings.add(temperatureReading);
	this.temperatureReadingsCounter.incrementAndGet();
}
 
Example #6
Source File: RandomEventListener.java    From geode-examples with Apache License 2.0 5 votes vote down vote up
@Override
public void onEvent(CqEvent cqEvent) {

  Operation queryOperation = cqEvent.getQueryOperation();


  if (queryOperation.isUpdate()) {
    System.out.print("-------Updated Value\n");
  } else if (queryOperation.isCreate()) {
    System.out.print("-------Value Created\n");
  }
}
 
Example #7
Source File: GeodeWatchEvent.java    From immutables with Apache License 2.0 5 votes vote down vote up
GeodeWatchEvent(CqEvent cqEvent) {
  this.key = Objects.requireNonNull(cqEvent.getKey(), "event.key");
  @SuppressWarnings("unchecked")
  final T newValue = (T) cqEvent.getNewValue();
  this.newValue = newValue;
  this.operation = toOperation(cqEvent);
}
 
Example #8
Source File: RandomEventListener.java    From geode-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void onError(CqEvent cqEvent) {
  System.out.print("**Something bad happened**");
}
 
Example #9
Source File: RandomEventListener.java    From geode-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void onError(CqEvent cqEvent) {
  System.out.print("**Something bad happened**");
}
 
Example #10
Source File: QueryTests.java    From spring-data-examples with Apache License 2.0 4 votes vote down vote up
@ContinuousQuery(name = "CustomerCQ", query = "SELECT * FROM /Customers")
public void handleEvent(CqEvent event) {
	log.info("Received message for CQ 'CustomerCQ'" + event);
	counter.incrementAndGet();
}
 
Example #11
Source File: AuthorService.java    From tutorials with MIT License 4 votes vote down vote up
@ContinuousQuery(query = "SELECT * FROM /Authors a WHERE a.id = 1")
public void process(CqEvent event) {
    System.out.println("Author #" + event.getKey() + " updated to " + event.getNewValue());
}
 
Example #12
Source File: GeodeEventListener.java    From immutables with Apache License 2.0 4 votes vote down vote up
@Override
public void onEvent(CqEvent event) {
  emitter.onNext(new GeodeWatchEvent<>(event));
}
 
Example #13
Source File: GeodeEventListener.java    From immutables with Apache License 2.0 4 votes vote down vote up
@Override
public void onError(CqEvent event) {
  emitter.onError(event.getThrowable());
}
 
Example #14
Source File: GeodeWatchEvent.java    From immutables with Apache License 2.0 4 votes vote down vote up
private static WatchEvent.Operation toOperation(CqEvent event) {
  // TODO add proper mapping between Geode and Criteria operations
  return Operation.UPDATE;
}