Search in sources :

Example 11 with DiskStoreDetails

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

the class DiskStoreCommands method getDiskStoreDescription.

protected DiskStoreDetails getDiskStoreDescription(final String memberName, final String diskStoreName) {
    // may throw a
    final DistributedMember member = getMember(getCache(), memberName);
    // MemberNotFoundException
    final ResultCollector<?, ?> resultCollector = getMembersFunctionExecutor(Collections.singleton(member)).setArguments(diskStoreName).execute(new DescribeDiskStoreFunction());
    final Object result = ((List<?>) resultCollector.getResult()).get(0);
    if (result instanceof DiskStoreDetails) {
        // disk store details in hand...
        return (DiskStoreDetails) result;
    } else if (result instanceof DiskStoreNotFoundException) {
        // bad disk store name...
        throw (DiskStoreNotFoundException) result;
    } else {
        // unknown and unexpected return type...
        final Throwable cause = (result instanceof Throwable ? (Throwable) result : null);
        if (isLogging()) {
            if (cause != null) {
                getGfsh().logSevere(String.format("Exception (%1$s) occurred while executing '%2$s' on member (%3$s) with disk store (%4$s).", ClassUtils.getClassName(cause), CliStrings.DESCRIBE_DISK_STORE, memberName, diskStoreName), cause);
            } else {
                getGfsh().logSevere(String.format("Received an unexpected result of type (%1$s) while executing '%2$s' on member (%3$s) with disk store (%4$s).", ClassUtils.getClassName(result), CliStrings.DESCRIBE_DISK_STORE, memberName, diskStoreName), null);
            }
        }
        throw new RuntimeException(CliStrings.format(CliStrings.UNEXPECTED_RETURN_TYPE_EXECUTING_COMMAND_ERROR_MESSAGE, ClassUtils.getClassName(result), CliStrings.DESCRIBE_DISK_STORE), cause);
    }
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedMember(org.apache.geode.distributed.DistributedMember) DiskStoreDetails(org.apache.geode.management.internal.cli.domain.DiskStoreDetails) DiskStoreNotFoundException(org.apache.geode.management.internal.cli.util.DiskStoreNotFoundException) List(java.util.List) ArrayList(java.util.ArrayList) DescribeDiskStoreFunction(org.apache.geode.management.internal.cli.functions.DescribeDiskStoreFunction)

Example 12 with DiskStoreDetails

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

the class DescribeDiskStoreFunction method setCacheServerDetails.

protected void setCacheServerDetails(final InternalCache cache, final DiskStore diskStore, final DiskStoreDetails diskStoreDetails) {
    for (CacheServer cacheServer : cache.getCacheServers()) {
        if (isUsingDiskStore(cacheServer, diskStore)) {
            DiskStoreDetails.CacheServerDetails cacheServerDetails = new DiskStoreDetails.CacheServerDetails(cacheServer.getBindAddress(), cacheServer.getPort());
            cacheServerDetails.setHostName(cacheServer.getHostnameForClients());
            diskStoreDetails.add(cacheServerDetails);
        }
    }
}
Also used : DiskStoreDetails(org.apache.geode.management.internal.cli.domain.DiskStoreDetails) CacheServer(org.apache.geode.cache.server.CacheServer)

Example 13 with DiskStoreDetails

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

the class DescribeDiskStoreFunction method execute.

public void execute(final FunctionContext context) {
    Cache cache = getCache();
    try {
        if (cache instanceof InternalCache) {
            InternalCache gemfireCache = (InternalCache) cache;
            DistributedMember member = gemfireCache.getMyId();
            String diskStoreName = (String) context.getArguments();
            String memberId = member.getId();
            String memberName = member.getName();
            DiskStore diskStore = gemfireCache.findDiskStore(diskStoreName);
            if (diskStore != null) {
                DiskStoreDetails diskStoreDetails = new DiskStoreDetails(diskStore.getDiskStoreUUID(), diskStore.getName(), memberId, memberName);
                diskStoreDetails.setAllowForceCompaction(diskStore.getAllowForceCompaction());
                diskStoreDetails.setAutoCompact(diskStore.getAutoCompact());
                diskStoreDetails.setCompactionThreshold(diskStore.getCompactionThreshold());
                diskStoreDetails.setMaxOplogSize(diskStore.getMaxOplogSize());
                diskStoreDetails.setQueueSize(diskStore.getQueueSize());
                diskStoreDetails.setTimeInterval(diskStore.getTimeInterval());
                diskStoreDetails.setWriteBufferSize(diskStore.getWriteBufferSize());
                diskStoreDetails.setDiskUsageWarningPercentage(diskStore.getDiskUsageWarningPercentage());
                diskStoreDetails.setDiskUsageCriticalPercentage(diskStore.getDiskUsageCriticalPercentage());
                setDiskDirDetails(diskStore, diskStoreDetails);
                setRegionDetails(gemfireCache, diskStore, diskStoreDetails);
                setCacheServerDetails(gemfireCache, diskStore, diskStoreDetails);
                setGatewayDetails(gemfireCache, diskStore, diskStoreDetails);
                setPdxSerializationDetails(gemfireCache, diskStore, diskStoreDetails);
                setAsyncEventQueueDetails(gemfireCache, diskStore, diskStoreDetails);
                context.getResultSender().lastResult(diskStoreDetails);
            } else {
                context.getResultSender().sendException(new DiskStoreNotFoundException(String.format("A disk store with name (%1$s) was not found on member (%2$s).", diskStoreName, memberName)));
            }
        }
    } catch (Exception e) {
        logger.error("Error occurred while executing 'describe disk-store': {}!", e.getMessage(), e);
        context.getResultSender().sendException(e);
    }
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) DistributedMember(org.apache.geode.distributed.DistributedMember) DiskStoreDetails(org.apache.geode.management.internal.cli.domain.DiskStoreDetails) InternalCache(org.apache.geode.internal.cache.InternalCache) DiskStoreNotFoundException(org.apache.geode.management.internal.cli.util.DiskStoreNotFoundException) DiskStoreNotFoundException(org.apache.geode.management.internal.cli.util.DiskStoreNotFoundException) InternalCache(org.apache.geode.internal.cache.InternalCache) Cache(org.apache.geode.cache.Cache)

Example 14 with DiskStoreDetails

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

the class DescribeDiskStoreFunction method setGatewayDetails.

protected void setGatewayDetails(final InternalCache cache, final DiskStore diskStore, final DiskStoreDetails diskStoreDetails) {
    for (GatewaySender gatewaySender : cache.getGatewaySenders()) {
        if (isUsingDiskStore(gatewaySender, diskStore)) {
            DiskStoreDetails.GatewayDetails gatewayDetails = new DiskStoreDetails.GatewayDetails(gatewaySender.getId());
            gatewayDetails.setPersistent(isPersistent(gatewaySender));
            diskStoreDetails.add(gatewayDetails);
        }
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) DiskStoreDetails(org.apache.geode.management.internal.cli.domain.DiskStoreDetails)

Example 15 with DiskStoreDetails

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

the class ListDiskStoresFunction method execute.

public void execute(final FunctionContext context) {
    final Set<DiskStoreDetails> memberDiskStores = new HashSet<DiskStoreDetails>();
    try {
        final Cache cache = getCache();
        if (cache instanceof InternalCache) {
            final InternalCache gemfireCache = (InternalCache) cache;
            final DistributedMember member = gemfireCache.getMyId();
            for (final DiskStore memberDiskStore : gemfireCache.listDiskStoresIncludingRegionOwned()) {
                memberDiskStores.add(new DiskStoreDetails(memberDiskStore.getDiskStoreUUID(), memberDiskStore.getName(), member.getId(), member.getName()));
            }
        }
        context.getResultSender().lastResult(memberDiskStores);
    } catch (Exception e) {
        context.getResultSender().sendException(e);
    }
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) DiskStoreDetails(org.apache.geode.management.internal.cli.domain.DiskStoreDetails) DistributedMember(org.apache.geode.distributed.DistributedMember) InternalCache(org.apache.geode.internal.cache.InternalCache) HashSet(java.util.HashSet) Cache(org.apache.geode.cache.Cache) InternalCache(org.apache.geode.internal.cache.InternalCache)

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