Search in sources :

Example 1 with ResourceInst

use of org.apache.geode.internal.statistics.StatArchiveReader.ResourceInst in project geode by apache.

the class StatTypesAreRolledOverRegressionTest method verifyStatisticsTypeIsInArchiveFile.

private void verifyStatisticsTypeIsInArchiveFile(final File archiveFile, final int expectedResources) throws IOException {
    StatArchiveReader reader = new StatArchiveReader(new File[] { archiveFile }, null, false);
    // compare all resourceInst values against what was printed above
    List<ResourceInst> resources = reader.getResourceInstList();
    if (expectedResources > 0) {
        assertThat(resources).hasAtLeastOneElementOfType(ResourceInst.class);
    }
    for (ResourceInst resourceInstance : resources) {
        if (resourceInstance == null)
            continue;
        assertThat(resourceInstance.getName()).isNotNull();
        assertThat(resourceInstance.getType()).isNotNull();
        assertThat(resourceInstance.getType().getName()).isEqualTo(this.statisticsType.getName());
    }
}
Also used : ResourceInst(org.apache.geode.internal.statistics.StatArchiveReader.ResourceInst)

Example 2 with ResourceInst

use of org.apache.geode.internal.statistics.StatArchiveReader.ResourceInst in project geode by apache.

the class ResourceInstTest method differentFirstTSidxIsNotEqual.

@Test
public void differentFirstTSidxIsNotEqual() throws Exception {
    ResourceInst resourceInst1 = new ResourceInst(this.archive1, 0, "name", 0, this.resourceType, false);
    setFirstTSidx(resourceInst1, 1);
    ResourceInst resourceInst2 = new ResourceInst(this.archive1, 0, "name", 0, this.resourceType, false);
    setFirstTSidx(resourceInst2, 2);
    assertThat(resourceInst1).isNotEqualTo(resourceInst2);
}
Also used : ResourceInst(org.apache.geode.internal.statistics.StatArchiveReader.ResourceInst) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 3 with ResourceInst

use of org.apache.geode.internal.statistics.StatArchiveReader.ResourceInst in project geode by apache.

the class ResourceInstTest method sameFirstTSidxEquals.

@Test
public void sameFirstTSidxEquals() throws Exception {
    ResourceInst resourceInst1 = new ResourceInst(this.archive1, 0, "name", 0, this.resourceType, false);
    setFirstTSidx(resourceInst1, 1);
    ResourceInst resourceInst2 = new ResourceInst(this.archive1, 0, "name", 0, this.resourceType, false);
    setFirstTSidx(resourceInst2, 1);
    assertThat(resourceInst1).isEqualTo(resourceInst2);
}
Also used : ResourceInst(org.apache.geode.internal.statistics.StatArchiveReader.ResourceInst) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 4 with ResourceInst

use of org.apache.geode.internal.statistics.StatArchiveReader.ResourceInst in project geode by apache.

the class StatArchiveWithConsecutiveResourceInstGenerator method validateArchiveFile.

protected void validateArchiveFile() throws IOException {
    final File archiveFile = new File(this.archiveFileName);
    assertTrue(archiveFile.exists());
    logger.info("ArchiveFile: {}", archiveFile.getAbsolutePath());
    logger.info("ArchiveFile length: {}", archiveFile.length());
    for (ResourceInst resourceInst : findResourceInsts(archiveFile, STATS_SPEC_STRING)) {
        logger.info("ResourceInst: {}", resourceInst);
    }
}
Also used : ResourceInst(org.apache.geode.internal.statistics.StatArchiveReader.ResourceInst) File(java.io.File)

Example 5 with ResourceInst

use of org.apache.geode.internal.statistics.StatArchiveReader.ResourceInst in project geode by apache.

the class StatUtils method addResourceInstsToSet.

private static void addResourceInstsToSet(final File archiveFile, final String specString, final Set<ResourceInst> resourceInsts) throws IOException {
    StatSpec statSpec = new StatSpec(specString);
    StatArchiveReader reader = new StatArchiveReader(new File[] { archiveFile }, new StatSpec[] { statSpec }, true);
    StatValue[] statValues = reader.matchSpec(statSpec);
    for (StatValue statValue : statValues) {
        for (ResourceInst resourceInst : statValue.getResources()) {
            resourceInsts.add(resourceInst);
        }
    }
}
Also used : ResourceInst(org.apache.geode.internal.statistics.StatArchiveReader.ResourceInst) StatSpec(org.apache.geode.internal.SystemAdmin.StatSpec) StatValue(org.apache.geode.internal.statistics.StatArchiveReader.StatValue)

Aggregations

ResourceInst (org.apache.geode.internal.statistics.StatArchiveReader.ResourceInst)8 StatValue (org.apache.geode.internal.statistics.StatArchiveReader.StatValue)4 Test (org.junit.Test)4 File (java.io.File)2 UnitTest (org.apache.geode.test.junit.categories.UnitTest)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Properties (java.util.Properties)1 Random (java.util.Random)1 Statistics (org.apache.geode.Statistics)1 StatisticsType (org.apache.geode.StatisticsType)1 Cache (org.apache.geode.cache.Cache)1 Region (org.apache.geode.cache.Region)1 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)1 DistributedMember (org.apache.geode.distributed.DistributedMember)1 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)1 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)1 StatSpec (org.apache.geode.internal.SystemAdmin.StatSpec)1 StatArchiveReader (org.apache.geode.internal.statistics.StatArchiveReader)1