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);
}
}
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);
}
}
}
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);
}
}
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);
}
}
}
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);
}
}
Aggregations