use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.
the class GMSJoinLeaveTestHelper method getGmsJoinLeave.
private static GMSJoinLeave getGmsJoinLeave() {
InternalDistributedSystem distributedSystem = getInternalDistributedSystem();
DM dm = distributedSystem.getDM();
GMSMembershipManager membershipManager = (GMSMembershipManager) dm.getMembershipManager();
Services services = membershipManager.getServices();
return (GMSJoinLeave) services.getJoinLeave();
}
use of org.apache.geode.distributed.internal.InternalDistributedSystem 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.distributed.internal.InternalDistributedSystem 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.distributed.internal.InternalDistributedSystem in project geode by apache.
the class PRFunctionExecutionDUnitTest method bug41118.
public static void bug41118() {
InternalDistributedSystem ds = new PRFunctionExecutionDUnitTest().getSystem();
assertNotNull(ds);
ds.disconnect();
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
ds = (InternalDistributedSystem) DistributedSystem.connect(props);
DM dm = ds.getDistributionManager();
assertEquals("Distributed System is not loner", true, dm instanceof LonerDistributionManager);
Cache cache = CacheFactory.create(ds);
AttributesFactory factory = new AttributesFactory();
factory.setDataPolicy(DataPolicy.PARTITION);
assertNotNull(cache);
Region region = cache.createRegion("PartitonedRegion", factory.create());
for (int i = 0; i < 20; i++) {
region.put("KEY_" + i, "VALUE_" + i);
}
Set<String> keysForGet = new HashSet<String>();
keysForGet.add("KEY_4");
keysForGet.add("KEY_9");
keysForGet.add("KEY_7");
try {
Execution execution = FunctionService.onRegion(region).withFilter(keysForGet).setArguments(Boolean.TRUE);
ResultCollector rc = execution.execute(new FunctionAdapter() {
@Override
public void execute(FunctionContext fc) {
RegionFunctionContext context = (RegionFunctionContext) fc;
Set keys = context.getFilter();
Set keysTillSecondLast = new HashSet();
int setSize = keys.size();
Iterator keysIterator = keys.iterator();
for (int i = 0; i < (setSize - 1); i++) {
keysTillSecondLast.add(keysIterator.next());
}
for (Object k : keysTillSecondLast) {
context.getResultSender().sendResult((Serializable) PartitionRegionHelper.getLocalDataForContext(context).get(k));
}
Object lastResult = keysIterator.next();
context.getResultSender().lastResult((Serializable) PartitionRegionHelper.getLocalDataForContext(context).get(lastResult));
}
@Override
public String getId() {
return getClass().getName();
}
});
rc.getResult();
ds.disconnect();
} catch (Exception e) {
LogWriterUtils.getLogWriter().info("Exception Occurred : " + e.getMessage());
e.printStackTrace();
Assert.fail("Test failed", e);
}
}
use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.
the class MsgDestreamer method getLogger.
private static LogWriterI18n getLogger() {
LogWriterI18n result = null;
InternalDistributedSystem ids = InternalDistributedSystem.unsafeGetConnectedInstance();
if (ids != null) {
result = ids.getLogWriter().convertToLogWriterI18n();
}
return result;
}
Aggregations