@Override
public void execute(FunctionContext context) {
final GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
if (cache != null && !cache.isClosed()) {
Collection<DiskStoreImpl> diskStores =
cache.listDiskStoresIncludingRegionOwned();
ArrayList<DiskStoreInformation> diskStoreInfos = new ArrayList<>(
diskStores.size());
for (DiskStoreImpl ds : diskStores) {
StringBuilder dirs = new StringBuilder();
for (File dir : ds.getDiskDirs()) {
if (dirs.length() > 0) {
dirs.append(',');
}
String dirPath;
try {
dirPath = dir.getCanonicalPath();
} catch (IOException ioe) {
dirPath = dir.getAbsolutePath();
}
dirs.append(dirPath);
}
diskStoreInfos.add(new DiskStoreInformation(cache.getMyId().getId(),
ds.getName(), ds.getDiskStoreUUID().toString(), dirs.toString()));
}
context.getResultSender().lastResult(diskStoreInfos);
} else {
context.getResultSender().lastResult(new ArrayList<>(0));
}
}