Search in sources :

Example 16 with DiskStoreDetails

use of org.apache.geode.management.internal.cli.domain.DiskStoreDetails in project geode by apache.

the class DiskStoreCommands method toCompositeResult.

protected Result toCompositeResult(final DiskStoreDetails diskStoreDetails) {
    final CompositeResultData diskStoreData = ResultBuilder.createCompositeResultData();
    final CompositeResultData.SectionResultData diskStoreSection = diskStoreData.addSection();
    diskStoreSection.addData("Disk Store ID", diskStoreDetails.getId());
    diskStoreSection.addData("Disk Store Name", diskStoreDetails.getName());
    diskStoreSection.addData("Member ID", diskStoreDetails.getMemberId());
    diskStoreSection.addData("Member Name", diskStoreDetails.getMemberName());
    diskStoreSection.addData("Allow Force Compaction", toString(diskStoreDetails.isAllowForceCompaction(), "Yes", "No"));
    diskStoreSection.addData("Auto Compaction", toString(diskStoreDetails.isAutoCompact(), "Yes", "No"));
    diskStoreSection.addData("Compaction Threshold", diskStoreDetails.getCompactionThreshold());
    diskStoreSection.addData("Max Oplog Size", diskStoreDetails.getMaxOplogSize());
    diskStoreSection.addData("Queue Size", diskStoreDetails.getQueueSize());
    diskStoreSection.addData("Time Interval", diskStoreDetails.getTimeInterval());
    diskStoreSection.addData("Write Buffer Size", diskStoreDetails.getWriteBufferSize());
    diskStoreSection.addData("Disk Usage Warning Percentage", diskStoreDetails.getDiskUsageWarningPercentage());
    diskStoreSection.addData("Disk Usage Critical Percentage", diskStoreDetails.getDiskUsageCriticalPercentage());
    diskStoreSection.addData("PDX Serialization Meta-Data Stored", toString(diskStoreDetails.isPdxSerializationMetaDataStored(), "Yes", "No"));
    final TabularResultData diskDirTable = diskStoreData.addSection().addTable();
    for (DiskStoreDetails.DiskDirDetails diskDirDetails : diskStoreDetails) {
        diskDirTable.accumulate("Disk Directory", diskDirDetails.getAbsolutePath());
        diskDirTable.accumulate("Size", diskDirDetails.getSize());
    }
    final TabularResultData regionTable = diskStoreData.addSection().addTable();
    for (DiskStoreDetails.RegionDetails regionDetails : diskStoreDetails.iterateRegions()) {
        regionTable.accumulate("Region Path", regionDetails.getFullPath());
        regionTable.accumulate("Region Name", regionDetails.getName());
        regionTable.accumulate("Persistent", toString(regionDetails.isPersistent(), "Yes", "No"));
        regionTable.accumulate("Overflow To Disk", toString(regionDetails.isOverflowToDisk(), "Yes", "No"));
    }
    final TabularResultData cacheServerTable = diskStoreData.addSection().addTable();
    for (DiskStoreDetails.CacheServerDetails cacheServerDetails : diskStoreDetails.iterateCacheServers()) {
        cacheServerTable.accumulate("Bind Address", cacheServerDetails.getBindAddress());
        cacheServerTable.accumulate("Hostname for Clients", cacheServerDetails.getHostName());
        cacheServerTable.accumulate("Port", cacheServerDetails.getPort());
    }
    final TabularResultData gatewayTable = diskStoreData.addSection().addTable();
    for (DiskStoreDetails.GatewayDetails gatewayDetails : diskStoreDetails.iterateGateways()) {
        gatewayTable.accumulate("Gateway ID", gatewayDetails.getId());
        gatewayTable.accumulate("Persistent", toString(gatewayDetails.isPersistent(), "Yes", "No"));
    }
    final TabularResultData asyncEventQueueTable = diskStoreData.addSection().addTable();
    for (DiskStoreDetails.AsyncEventQueueDetails asyncEventQueueDetails : diskStoreDetails.iterateAsyncEventQueues()) {
        asyncEventQueueTable.accumulate("Async Event Queue ID", asyncEventQueueDetails.getId());
    }
    return ResultBuilder.buildResult(diskStoreData);
}
Also used : CompositeResultData(org.apache.geode.management.internal.cli.result.CompositeResultData) TabularResultData(org.apache.geode.management.internal.cli.result.TabularResultData) SectionResultData(org.apache.geode.management.internal.cli.result.CompositeResultData.SectionResultData) DiskStoreDetails(org.apache.geode.management.internal.cli.domain.DiskStoreDetails)

Example 17 with DiskStoreDetails

use of org.apache.geode.management.internal.cli.domain.DiskStoreDetails in project geode by apache.

the class DiskStoreCommands method getDiskStoreListing.

@SuppressWarnings("unchecked")
protected List<DiskStoreDetails> getDiskStoreListing(Set<DistributedMember> members) {
    final Execution membersFunctionExecutor = getMembersFunctionExecutor(members);
    if (membersFunctionExecutor instanceof AbstractExecution) {
        ((AbstractExecution) membersFunctionExecutor).setIgnoreDepartedMembers(true);
    }
    final ResultCollector<?, ?> resultCollector = membersFunctionExecutor.execute(new ListDiskStoresFunction());
    final List<?> results = (List<?>) resultCollector.getResult();
    final List<DiskStoreDetails> distributedSystemMemberDiskStores = new ArrayList<DiskStoreDetails>(results.size());
    for (final Object result : results) {
        if (result instanceof Set) {
            // ignore FunctionInvocationTargetExceptions and other
            // Exceptions...
            distributedSystemMemberDiskStores.addAll((Set<DiskStoreDetails>) result);
        }
    }
    Collections.sort(distributedSystemMemberDiskStores);
    return distributedSystemMemberDiskStores;
}
Also used : AbstractExecution(org.apache.geode.internal.cache.execute.AbstractExecution) Execution(org.apache.geode.cache.execute.Execution) AbstractExecution(org.apache.geode.internal.cache.execute.AbstractExecution) ListDiskStoresFunction(org.apache.geode.management.internal.cli.functions.ListDiskStoresFunction) Set(java.util.Set) HashSet(java.util.HashSet) ArrayList(java.util.ArrayList) DiskStoreDetails(org.apache.geode.management.internal.cli.domain.DiskStoreDetails) List(java.util.List) ArrayList(java.util.ArrayList)

Example 18 with DiskStoreDetails

use of org.apache.geode.management.internal.cli.domain.DiskStoreDetails in project geode by apache.

the class DiskStoreCommands method toTabularResult.

protected Result toTabularResult(final List<DiskStoreDetails> diskStoreList) throws ResultDataException {
    if (!diskStoreList.isEmpty()) {
        final TabularResultData diskStoreData = ResultBuilder.createTabularResultData();
        for (final DiskStoreDetails diskStoreDetails : diskStoreList) {
            diskStoreData.accumulate("Member Name", diskStoreDetails.getMemberName());
            diskStoreData.accumulate("Member Id", diskStoreDetails.getMemberId());
            diskStoreData.accumulate("Disk Store Name", diskStoreDetails.getName());
            diskStoreData.accumulate("Disk Store ID", diskStoreDetails.getId());
        }
        return ResultBuilder.buildResult(diskStoreData);
    } else {
        return ResultBuilder.createInfoResult(CliStrings.LIST_DISK_STORE__DISK_STORES_NOT_FOUND_MESSAGE);
    }
}
Also used : TabularResultData(org.apache.geode.management.internal.cli.result.TabularResultData) DiskStoreDetails(org.apache.geode.management.internal.cli.domain.DiskStoreDetails)

Example 19 with DiskStoreDetails

use of org.apache.geode.management.internal.cli.domain.DiskStoreDetails in project geode by apache.

the class DescribeDiskStoreFunctionJUnitTest method testSetPdxSerializationDetailsWhenDiskStoreMismatch.

@Test
public void testSetPdxSerializationDetailsWhenDiskStoreMismatch() {
    final InternalCache mockCache = mockContext.mock(InternalCache.class, "Cache");
    final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");
    mockContext.checking(new Expectations() {

        {
            oneOf(mockCache).getPdxPersistent();
            will(returnValue(true));
            oneOf(mockCache).getPdxDiskStore();
            will(returnValue("mockDiskStore"));
            oneOf(mockDiskStore).getName();
            will(returnValue("testDiskStore"));
        }
    });
    final DiskStoreDetails diskStoreDetails = new DiskStoreDetails("testDiskStore", "memberOne");
    final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(mockCache);
    function.setPdxSerializationDetails(mockCache, mockDiskStore, diskStoreDetails);
    assertFalse(diskStoreDetails.isPdxSerializationMetaDataStored());
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) Expectations(org.jmock.Expectations) DiskStoreDetails(org.apache.geode.management.internal.cli.domain.DiskStoreDetails) InternalCache(org.apache.geode.internal.cache.InternalCache) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 20 with DiskStoreDetails

use of org.apache.geode.management.internal.cli.domain.DiskStoreDetails in project geode by apache.

the class DescribeDiskStoreFunctionJUnitTest method testSetRegionDetails.

@Test
public void testSetRegionDetails() {
    final String diskStoreName = "companyDiskStore";
    final InternalCache mockCache = mockContext.mock(InternalCache.class, "Cache");
    final Region mockCompanyRegion = mockContext.mock(Region.class, "/CompanyRegion");
    final Region mockContractorsRegion = mockContext.mock(Region.class, "/CompanyRegion/ContractorsRegion");
    final Region mockEmployeeRegion = mockContext.mock(Region.class, "/CompanyRegion/EmployeeRegion");
    final Region mockRolesRegion = mockContext.mock(Region.class, "/CompanyRegion/EmployeeRegion/RolesRegion");
    final Region mockProductsRegion = mockContext.mock(Region.class, "/CompanyRegion/ProductsRegion");
    final Region mockServicesRegion = mockContext.mock(Region.class, "/CompanyRegion/ServicesRegion");
    final Region mockPartnersRegion = mockContext.mock(Region.class, "/PartnersRegion");
    final Region mockCustomersRegion = mockContext.mock(Region.class, "/CustomersRegion");
    final RegionAttributes mockCompanyRegionAttributes = mockContext.mock(RegionAttributes.class, "CompanyRegionAttributes");
    final RegionAttributes mockContractorsRegionAttributes = mockContext.mock(RegionAttributes.class, "ContractorsRegionAttributes");
    final RegionAttributes mockProductsServicesRegionAttributes = mockContext.mock(RegionAttributes.class, "ProductsServicesRegionAttributes");
    final RegionAttributes mockPartnersRegionAttributes = mockContext.mock(RegionAttributes.class, "PartnersRegionAttributes");
    final RegionAttributes mockCustomersRegionAttributes = mockContext.mock(RegionAttributes.class, "CustomersRegionAttributes");
    final EvictionAttributes mockCompanyEvictionAttributes = mockContext.mock(EvictionAttributes.class, "CompanyEvictionAttributes");
    final EvictionAttributes mockContractorsEvictionAttributes = mockContext.mock(EvictionAttributes.class, "ContractorsEvictionAttributes");
    final EvictionAttributes mockCustomersEvictionAttributes = mockContext.mock(EvictionAttributes.class, "CustomersEvictionAttributes");
    final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");
    mockContext.checking(new Expectations() {

        {
            oneOf(mockCache).rootRegions();
            will(returnValue(CollectionUtils.asSet(mockCompanyRegion, mockPartnersRegion, mockCustomersRegion)));
            exactly(5).of(mockCompanyRegion).getAttributes();
            will(returnValue(mockCompanyRegionAttributes));
            oneOf(mockCompanyRegion).getFullPath();
            will(returnValue("/CompanyRegion"));
            oneOf(mockCompanyRegion).getName();
            will(returnValue("CompanyRegion"));
            oneOf(mockCompanyRegion).subregions(false);
            will(returnValue(CollectionUtils.asSet(mockContractorsRegion, mockEmployeeRegion, mockProductsRegion, mockServicesRegion)));
            exactly(5).of(mockEmployeeRegion).getAttributes();
            will(returnValue(mockCompanyRegionAttributes));
            oneOf(mockEmployeeRegion).getFullPath();
            will(returnValue("/CompanyRegion/EmployeeRegion"));
            oneOf(mockEmployeeRegion).getName();
            will(returnValue("EmployeeRegion"));
            oneOf(mockEmployeeRegion).subregions(false);
            will(returnValue(CollectionUtils.asSet(mockRolesRegion)));
            exactly(5).of(mockRolesRegion).getAttributes();
            will(returnValue(mockCompanyRegionAttributes));
            oneOf(mockRolesRegion).getFullPath();
            will(returnValue("/CompanyRegion/EmployeeRegion/RolesRegion"));
            oneOf(mockRolesRegion).getName();
            will(returnValue("RolesRegion"));
            oneOf(mockRolesRegion).subregions(false);
            will(returnValue(Collections.emptySet()));
            exactly(6).of(mockCompanyRegionAttributes).getDataPolicy();
            will(returnValue(DataPolicy.PERSISTENT_PARTITION));
            exactly(3).of(mockCompanyRegionAttributes).getDiskStoreName();
            will(returnValue(diskStoreName));
            exactly(6).of(mockCompanyRegionAttributes).getEvictionAttributes();
            will(returnValue(mockCompanyEvictionAttributes));
            exactly(3).of(mockCompanyEvictionAttributes).getAction();
            will(returnValue(EvictionAction.LOCAL_DESTROY));
            exactly(7).of(mockContractorsRegion).getAttributes();
            will(returnValue(mockContractorsRegionAttributes));
            oneOf(mockContractorsRegion).getFullPath();
            will(returnValue("/CompanyRegion/ContractorsRegion"));
            oneOf(mockContractorsRegion).getName();
            will(returnValue("ContractorsRegion"));
            oneOf(mockContractorsRegion).subregions(false);
            will(returnValue(Collections.emptySet()));
            exactly(2).of(mockContractorsRegionAttributes).getDataPolicy();
            will(returnValue(DataPolicy.REPLICATE));
            oneOf(mockContractorsRegionAttributes).getDiskStoreName();
            will(returnValue(diskStoreName));
            exactly(4).of(mockContractorsRegionAttributes).getEvictionAttributes();
            will(returnValue(mockContractorsEvictionAttributes));
            exactly(2).of(mockContractorsEvictionAttributes).getAction();
            will(returnValue(EvictionAction.OVERFLOW_TO_DISK));
            exactly(2).of(mockProductsRegion).getAttributes();
            will(returnValue(mockProductsServicesRegionAttributes));
            oneOf(mockProductsRegion).subregions(false);
            will(returnValue(Collections.emptySet()));
            exactly(2).of(mockServicesRegion).getAttributes();
            will(returnValue(mockProductsServicesRegionAttributes));
            oneOf(mockServicesRegion).subregions(false);
            will(returnValue(Collections.emptySet()));
            exactly(2).of(mockProductsServicesRegionAttributes).getDataPolicy();
            will(returnValue(DataPolicy.PERSISTENT_REPLICATE));
            exactly(2).of(mockProductsServicesRegionAttributes).getDiskStoreName();
            will(returnValue("productsServicesDiskStore"));
            exactly(2).of(mockPartnersRegion).getAttributes();
            will(returnValue(mockPartnersRegionAttributes));
            oneOf(mockPartnersRegion).subregions(false);
            will(returnValue(Collections.emptySet()));
            oneOf(mockPartnersRegionAttributes).getDataPolicy();
            will(returnValue(DataPolicy.PERSISTENT_PARTITION));
            oneOf(mockPartnersRegionAttributes).getDiskStoreName();
            will(returnValue(""));
            exactly(4).of(mockCustomersRegion).getAttributes();
            will(returnValue(mockCustomersRegionAttributes));
            oneOf(mockCustomersRegion).subregions(false);
            will(returnValue(Collections.emptySet()));
            oneOf(mockCustomersRegionAttributes).getDataPolicy();
            will(returnValue(DataPolicy.REPLICATE));
            oneOf(mockCustomersRegionAttributes).getDiskStoreName();
            will(returnValue(null));
            exactly(2).of(mockCustomersRegionAttributes).getEvictionAttributes();
            will(returnValue(mockCustomersEvictionAttributes));
            oneOf(mockCustomersEvictionAttributes).getAction();
            will(returnValue(EvictionAction.OVERFLOW_TO_DISK));
            atLeast(1).of(mockDiskStore).getName();
            will(returnValue(diskStoreName));
        }
    });
    final Set<DiskStoreDetails.RegionDetails> expectedRegionDetails = CollectionUtils.asSet(createRegionDetails("/CompanyRegion", "CompanyRegion", true, false), createRegionDetails("/CompanyRegion/EmployeeRegion", "EmployeeRegion", true, false), createRegionDetails("/CompanyRegion/EmployeeRegion/RolesRegion", "RolesRegion", true, false), createRegionDetails("/CompanyRegion/ContractorsRegion", "ContractorsRegion", false, true));
    final DiskStoreDetails diskStoreDetails = new DiskStoreDetails(diskStoreName, "memberOne");
    final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(mockCache);
    function.setRegionDetails(mockCache, mockDiskStore, diskStoreDetails);
    assertRegionDetails(expectedRegionDetails, diskStoreDetails);
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) Expectations(org.jmock.Expectations) EvictionAttributes(org.apache.geode.cache.EvictionAttributes) RegionAttributes(org.apache.geode.cache.RegionAttributes) DiskStoreDetails(org.apache.geode.management.internal.cli.domain.DiskStoreDetails) InternalCache(org.apache.geode.internal.cache.InternalCache) Region(org.apache.geode.cache.Region) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Aggregations

DiskStoreDetails (org.apache.geode.management.internal.cli.domain.DiskStoreDetails)21 InternalCache (org.apache.geode.internal.cache.InternalCache)15 UnitTest (org.apache.geode.test.junit.categories.UnitTest)13 Expectations (org.jmock.Expectations)13 Test (org.junit.Test)13 DiskStore (org.apache.geode.cache.DiskStore)9 DistributedMember (org.apache.geode.distributed.DistributedMember)6 ArrayList (java.util.ArrayList)5 Set (java.util.Set)5 FunctionContext (org.apache.geode.cache.execute.FunctionContext)4 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)4 AbstractExecution (org.apache.geode.internal.cache.execute.AbstractExecution)4 Cache (org.apache.geode.cache.Cache)3 ResultCollector (org.apache.geode.cache.execute.ResultCollector)3 ListDiskStoresFunction (org.apache.geode.management.internal.cli.functions.ListDiskStoresFunction)3 HashSet (java.util.HashSet)2 List (java.util.List)2 UUID (java.util.UUID)2 Execution (org.apache.geode.cache.execute.Execution)2 CacheServer (org.apache.geode.cache.server.CacheServer)2