use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class LonerDMJUnitTest method testMemberId.
@Test
public void testMemberId() throws UnknownHostException {
String host = InetAddress.getLocalHost().getCanonicalHostName();
String name = "Foo";
Properties cfg = new Properties();
cfg.setProperty(MCAST_PORT, "0");
cfg.setProperty(LOCATORS, "");
cfg.setProperty(ROLES, "lonelyOne");
cfg.setProperty(NAME, name);
cfg.setProperty(ENABLE_NETWORK_PARTITION_DETECTION, "false");
DistributedSystem ds = DistributedSystem.connect(cfg);
System.out.println("MemberId = " + ds.getMemberId());
assertEquals(host.toString(), ds.getDistributedMember().getHost());
assertEquals(OSProcess.getId(), ds.getDistributedMember().getProcessId());
if (!PureJavaMode.isPure()) {
String pid = String.valueOf(OSProcess.getId());
assertTrue(ds.getMemberId().indexOf(pid) > -1);
}
assertTrue(ds.getMemberId().indexOf(name) > -1);
String memberid = ds.getMemberId();
String shortname = shortName(host);
assertTrue("'" + memberid + "' does not contain '" + shortname + "'", memberid.indexOf(shortname) > -1);
// make sure the loner port can be updated
((LonerDistributionManager) ((InternalDistributedSystem) ds).getDM()).updateLonerPort(100);
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class NewDeclarativeIndexCreationJUnitTest method testIndexCreationExceptionOnRegionWithNewDTD.
/**
* TODO: move this to a different test class because it requires different setup
*/
@Test
public void testIndexCreationExceptionOnRegionWithNewDTD() throws Exception {
if (this.cache != null && !this.cache.isClosed()) {
this.cache.close();
}
this.cacheXmlFile = this.temporaryFolder.newFile("cachequeryindexwitherror.xml");
FileUtils.copyURLToFile(getClass().getResource("cachequeryindexwitherror.xml"), this.cacheXmlFile);
// precondition
assertThat(this.cacheXmlFile).exists();
Properties props = new Properties();
props.setProperty(CACHE_XML_FILE, this.cacheXmlFile.getAbsolutePath());
props.setProperty(MCAST_PORT, "0");
DistributedSystem ds = DistributedSystem.connect(props);
// TODO: refactoring GemFireCacheImpl.initializeDeclarativeCache requires change here
assertThatThrownBy(() -> CacheFactory.create(ds)).isExactlyInstanceOf(CacheXmlException.class).hasCauseInstanceOf(InternalGemFireException.class);
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class ProgRegionCreationIndexUpdateTypeJUnitTest method testProgrammaticIndexUpdateType.
@Test
public void testProgrammaticIndexUpdateType() throws Exception {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOG_LEVEL, "config");
DistributedSystem ds = DistributedSystem.connect(props);
cache = CacheFactory.create(ds);
// Create a Region with index maintenance type as explicit synchronous
AttributesFactory attributesFactory = new AttributesFactory();
attributesFactory.setIndexMaintenanceSynchronous(true);
RegionAttributes regionAttributes = attributesFactory.create();
Region region = cache.createRegion("region1", regionAttributes);
IndexManager im = IndexUtils.getIndexManager(region, true);
if (!im.isIndexMaintenanceTypeSynchronous())
fail("IndexMaintenanceTest::testProgrammaticIndexUpdateType: Index Update Type found to be asynchronous when it was marked explicitly synchronous");
// Create a Region with index mainteneace type as explicit asynchronous
attributesFactory = new AttributesFactory();
attributesFactory.setIndexMaintenanceSynchronous(false);
regionAttributes = attributesFactory.create();
region = cache.createRegion("region2", regionAttributes);
im = IndexUtils.getIndexManager(region, true);
if (im.isIndexMaintenanceTypeSynchronous())
fail("IndexMaintenanceTest::testProgrammaticIndexUpdateType: Index Update Type found to be synchronous when it was marked explicitly asynchronous");
// create a default region & check index maintenecae type .It should be
// synchronous
attributesFactory = new AttributesFactory();
regionAttributes = attributesFactory.create();
region = cache.createRegion("region3", regionAttributes);
im = IndexUtils.getIndexManager(region, true);
if (!im.isIndexMaintenanceTypeSynchronous())
fail("IndexMaintenanceTest::testProgrammaticIndexUpdateType: Index Update Type found to be asynchronous when it default RegionAttributes should have created synchronous update type");
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class RegionSubRegionsSizeResponse method populateSnapshot.
void populateSnapshot(DistributionManager dm) {
if (this.cancelled) {
return;
}
DistributedSystem sys = dm.getSystem();
InternalCache cache = (InternalCache) CacheFactory.getInstance(sys);
if (this.cancelled) {
return;
}
RegionSubRegionSnapshot root = new RegionSubRegionSnapshot();
/*
* This root exists only on admin side as a root of all root-region just to create a tree-like
* structure
*/
root.setName("Root");
root.setParent(null);
root.setEntryCount(0);
Set rootRegions = cache.rootRegions();
this.snapshot = root;
populateRegionSubRegions(root, rootRegions, cache);
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class RefreshMemberSnapshotResponse method create.
/**
* Returns a {@code FetchSysCfgResponse} that will be returned to the specified recipient. The
* message will contains a copy of the local manager's config.
*/
public static RefreshMemberSnapshotResponse create(DistributionManager dm, InternalDistributedMember recipient) {
RefreshMemberSnapshotResponse m = new RefreshMemberSnapshotResponse();
m.setRecipient(recipient);
try {
DistributedSystem sys = dm.getSystem();
InternalCache c = (InternalCache) CacheFactory.getInstance(sys);
m.snapshot = new GemFireMemberStatus(c);
} catch (Exception ignore) {
m.snapshot = null;
}
return m;
}
Aggregations