1 package org.onap.msb.apiroute.wrapper.consulextend.expose;
3 import java.math.BigInteger;
4 import java.util.concurrent.atomic.AtomicReference;
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
9 import com.orbitz.consul.model.ConsulResponse;
11 public class ConsulIndexFilter<T> implements WatchTask.Filter<T> {
13 private final static Logger LOGGER = LoggerFactory
14 .getLogger(ConsulIndexFilter.class);
16 private final AtomicReference<BigInteger> latestIndex = new AtomicReference<BigInteger>(
20 public boolean filter(final ConsulResponse<T> object) {
21 // TODO Auto-generated method stub
22 return isChanged(object);
25 private boolean isChanged(final ConsulResponse<T> consulResponse) {
27 if (consulResponse != null && consulResponse.getIndex() != null
28 && !consulResponse.getIndex().equals(latestIndex.get())) {
30 if(LOGGER.isDebugEnabled()){
32 if (latestIndex.get()!=null) {
33 LOGGER.debug("consul index compare:new-"
34 + consulResponse.getIndex() + " old-"
40 this.latestIndex.set(consulResponse.getIndex());