use of org.apache.geode.pdx.internal.TypeRegistry in project geode by apache.
the class GemFireCacheImplTest method checkEvictorsClosed.
@Test
public void checkEvictorsClosed() {
InternalDistributedSystem ds = Fakes.distributedSystem();
CacheConfig cc = new CacheConfig();
TypeRegistry typeRegistry = mock(TypeRegistry.class);
SystemTimer ccpTimer = mock(SystemTimer.class);
HeapEvictor he = mock(HeapEvictor.class);
OffHeapEvictor ohe = mock(OffHeapEvictor.class);
GemFireCacheImpl gfc = GemFireCacheImpl.createWithAsyncEventListeners(ds, cc, typeRegistry);
try {
gfc.setHeapEvictor(he);
gfc.setOffHeapEvictor(ohe);
} finally {
gfc.close();
}
verify(he, times(1)).close();
verify(ohe, times(1)).close();
}
use of org.apache.geode.pdx.internal.TypeRegistry in project geode by apache.
the class GemFireCacheImplTest method checkThatAsyncEventListenersUseAllThreadsInPool.
@Test
public void checkThatAsyncEventListenersUseAllThreadsInPool() {
InternalDistributedSystem ds = Fakes.distributedSystem();
CacheConfig cc = new CacheConfig();
TypeRegistry typeRegistry = mock(TypeRegistry.class);
GemFireCacheImpl gfc = GemFireCacheImpl.createWithAsyncEventListeners(ds, cc, typeRegistry);
try {
ThreadPoolExecutor executor = (ThreadPoolExecutor) gfc.getEventThreadPool();
assertEquals(0, executor.getCompletedTaskCount());
assertEquals(0, executor.getActiveCount());
int MAX_THREADS = GemFireCacheImpl.EVENT_THREAD_LIMIT;
final CountDownLatch cdl = new CountDownLatch(MAX_THREADS);
for (int i = 1; i <= MAX_THREADS; i++) {
executor.execute(() -> {
cdl.countDown();
try {
cdl.await();
} catch (InterruptedException e) {
}
});
}
Awaitility.await().pollInterval(10, TimeUnit.MILLISECONDS).pollDelay(10, TimeUnit.MILLISECONDS).timeout(90, TimeUnit.SECONDS).until(() -> assertEquals(MAX_THREADS, executor.getCompletedTaskCount()));
} finally {
gfc.close();
}
}
use of org.apache.geode.pdx.internal.TypeRegistry in project geode by apache.
the class DataTypeJUnitTest method getDataTypeShouldReturnPDXEnumType.
@Test
public void getDataTypeShouldReturnPDXEnumType() throws IOException {
int somePdxEnumId = 1;
EnumInfo somePdxEnumInfo = mock(EnumInfo.class);
doReturn("PDXENUM").when(somePdxEnumInfo).getClassName();
TypeRegistry mockTypeRegistry = mock(TypeRegistry.class);
when(mockTypeRegistry.getEnumInfoById(0)).thenReturn(somePdxEnumInfo);
GemFireCacheImpl pdxInstance = mock(GemFireCacheImpl.class);
when(pdxInstance.getPdxRegistry()).thenReturn(mockTypeRegistry);
PowerMockito.mockStatic(GemFireCacheImpl.class);
when(GemFireCacheImpl.getForPdx("PDX registry is unavailable because the Cache has been closed.")).thenReturn(pdxInstance);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(baos);
out.writeByte(DSCODE.PDX_ENUM);
out.writeInt(somePdxEnumId);
byte[] bytes = baos.toByteArray();
String type = DataType.getDataType(bytes);
assertThat(type).isEqualTo("PdxRegistry/java.lang.Enum:PDXENUM");
}
use of org.apache.geode.pdx.internal.TypeRegistry in project geode by apache.
the class PdxTypeExportDUnitTest method testPeer.
@Test
public void testPeer() throws Exception {
Region r = getCache().getRegion("pdxtest");
r.get(1);
TypeRegistry tr = ((GemFireCacheImpl) getCache()).getPdxRegistry();
Collection<PdxType> types = tr.typeMap().values();
assertEquals(MyObjectPdx.class.getName(), types.iterator().next().getClassName());
Collection<EnumInfo> enums = tr.enumMap().values();
assertEquals(MyEnumPdx.const1.name(), enums.iterator().next().getEnum().name());
}
use of org.apache.geode.pdx.internal.TypeRegistry in project geode by apache.
the class PdxRegistryRecoveryListener method endpointNowInUse.
@Override
public void endpointNowInUse(Endpoint endpoint) {
int count = endpointCount.incrementAndGet();
if (logger.isDebugEnabled()) {
logger.debug("PdxRegistryRecoveryListener - EndpointNowInUse. Now have {} endpoints", count);
}
if (count == 1) {
InternalCache cache = GemFireCacheImpl.getInstance();
if (cache == null) {
return;
}
TypeRegistry registry = cache.getPdxRegistry();
if (registry == null) {
return;
}
registry.clear();
}
}
Aggregations