Search in sources :

Example 1 with DescribeDiskStoreFunction

use of org.apache.geode.management.internal.cli.functions.DescribeDiskStoreFunction 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)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 DistributedMember (org.apache.geode.distributed.DistributedMember)1 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)1 DiskStoreDetails (org.apache.geode.management.internal.cli.domain.DiskStoreDetails)1 DescribeDiskStoreFunction (org.apache.geode.management.internal.cli.functions.DescribeDiskStoreFunction)1 DiskStoreNotFoundException (org.apache.geode.management.internal.cli.util.DiskStoreNotFoundException)1