use of io.grpc.xds.SharedCallCounterMap.CounterReference in project grpc-java by grpc.
the class SharedCallCounterMapTest method gcAndRecreate.
@Test
public void gcAndRecreate() {
// assign to null for GC only
@SuppressWarnings("UnusedVariable") AtomicLong counter = map.getOrCreate(CLUSTER, EDS_SERVICE_NAME);
final CounterReference ref = counters.get(CLUSTER).get(EDS_SERVICE_NAME);
assertThat(counter.get()).isEqualTo(0);
counter = null;
GcFinalization.awaitDone(new FinalizationPredicate() {
@Override
public boolean isDone() {
return ref.isEnqueued();
}
});
map.getOrCreate(CLUSTER, EDS_SERVICE_NAME);
assertThat(counters.get(CLUSTER)).isNotNull();
assertThat(counters.get(CLUSTER).get(EDS_SERVICE_NAME)).isNotNull();
}
use of io.grpc.xds.SharedCallCounterMap.CounterReference in project grpc-java by grpc.
the class SharedCallCounterMapTest method autoCleanUp.
@Test
public void autoCleanUp() {
@SuppressWarnings("UnusedVariable") AtomicLong counter = map.getOrCreate(CLUSTER, EDS_SERVICE_NAME);
final CounterReference ref = counters.get(CLUSTER).get(EDS_SERVICE_NAME);
counter = null;
GcFinalization.awaitDone(new FinalizationPredicate() {
@Override
public boolean isDone() {
return ref.isEnqueued();
}
});
map.cleanQueue();
assertThat(counters).isEmpty();
}
Aggregations