Search in sources :

Example 91 with DistributedSystem

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);
}
Also used : ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) DistributedSystem(org.apache.geode.distributed.DistributedSystem) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) LonerDistributionManager(org.apache.geode.distributed.internal.LonerDistributionManager) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 92 with DistributedSystem

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);
}
Also used : CacheXmlException(org.apache.geode.cache.CacheXmlException) Properties(java.util.Properties) DistributedSystem(org.apache.geode.distributed.DistributedSystem) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 93 with DistributedSystem

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");
}
Also used : ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) DistributedSystem(org.apache.geode.distributed.DistributedSystem) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 94 with DistributedSystem

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);
}
Also used : RegionSubRegionSnapshot(org.apache.geode.admin.RegionSubRegionSnapshot) Set(java.util.Set) InternalCache(org.apache.geode.internal.cache.InternalCache) DistributedSystem(org.apache.geode.distributed.DistributedSystem)

Example 95 with DistributedSystem

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;
}
Also used : InternalCache(org.apache.geode.internal.cache.InternalCache) GemFireMemberStatus(org.apache.geode.admin.GemFireMemberStatus) DistributedSystem(org.apache.geode.distributed.DistributedSystem) IOException(java.io.IOException)

Aggregations

DistributedSystem (org.apache.geode.distributed.DistributedSystem)250 Properties (java.util.Properties)102 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)65 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)61 Test (org.junit.Test)59 Cache (org.apache.geode.cache.Cache)55 AttributesFactory (org.apache.geode.cache.AttributesFactory)34 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)30 Region (org.apache.geode.cache.Region)24 IOException (java.io.IOException)20 CacheServer (org.apache.geode.cache.server.CacheServer)20 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)20 InternalCache (org.apache.geode.internal.cache.InternalCache)16 IgnoredException (org.apache.geode.test.dunit.IgnoredException)16 ArrayList (java.util.ArrayList)15 LogWriter (org.apache.geode.LogWriter)15 DistributedMember (org.apache.geode.distributed.DistributedMember)15 LocalRegion (org.apache.geode.internal.cache.LocalRegion)15 RegionAttributes (org.apache.geode.cache.RegionAttributes)14 Pool (org.apache.geode.cache.client.Pool)14