use of org.apache.geode.management.internal.cli.result.ResultDataException in project geode by apache.
the class JsonUtil method getStringArray.
public static String[] getStringArray(GfJsonObject jsonObject, String byName) {
String[] stringArray = null;
try {
GfJsonArray jsonArray = jsonObject.getJSONArray(byName);
stringArray = GfJsonArray.toStringArray(jsonArray);
} catch (GfJsonException e) {
throw new ResultDataException(e.getMessage());
}
return stringArray;
}
use of org.apache.geode.management.internal.cli.result.ResultDataException in project geode by apache.
the class JsonUtil method getList.
public static List<CliJsonSerializable> getList(GfJsonObject jsonObject, String byName) {
List<CliJsonSerializable> cliJsonSerializables = Collections.emptyList();
try {
GfJsonArray cliJsonSerializableArray = jsonObject.getJSONArray(byName);
int size = cliJsonSerializableArray.size();
if (size > 0) {
cliJsonSerializables = new ArrayList<CliJsonSerializable>();
}
for (int i = 0; i < size; i++) {
GfJsonObject cliJsonSerializableState = cliJsonSerializableArray.getJSONObject(i);
int jsId = cliJsonSerializableState.getInt(CliJsonSerializable.JSID);
CliJsonSerializable cliJsonSerializable = CliJsonSerializableFactory.getCliJsonSerializable(jsId);
cliJsonSerializable.fromJson(cliJsonSerializableState);
cliJsonSerializables.add(cliJsonSerializable);
}
} catch (GfJsonException e) {
throw new ResultDataException(e.getMessage());
}
return cliJsonSerializables;
}
use of org.apache.geode.management.internal.cli.result.ResultDataException in project geode by apache.
the class JsonUtil method getSet.
public static Set<CliJsonSerializable> getSet(GfJsonObject jsonObject, String byName) {
Set<CliJsonSerializable> cliJsonSerializables = Collections.emptySet();
try {
GfJsonArray cliJsonSerializableArray = jsonObject.getJSONArray(byName);
int size = cliJsonSerializableArray.size();
if (size > 0) {
cliJsonSerializables = new HashSet<CliJsonSerializable>();
}
for (int i = 0; i < size; i++) {
GfJsonObject cliJsonSerializableState = cliJsonSerializableArray.getJSONObject(i);
int jsId = cliJsonSerializableState.getInt(CliJsonSerializable.JSID);
CliJsonSerializable cliJsonSerializable = CliJsonSerializableFactory.getCliJsonSerializable(jsId);
cliJsonSerializable.fromJson(cliJsonSerializableState);
cliJsonSerializables.add(cliJsonSerializable);
}
} catch (GfJsonException e) {
throw new ResultDataException(e.getMessage());
}
return cliJsonSerializables;
}
use of org.apache.geode.management.internal.cli.result.ResultDataException in project geode by apache.
the class DiskStoreCommands method toMissingDiskStoresTabularResult.
protected Result toMissingDiskStoresTabularResult(final List<Object> resultDetails) throws ResultDataException {
CompositeResultData crd = ResultBuilder.createCompositeResultData();
List<PersistentMemberPattern> missingDiskStores = new ArrayList<PersistentMemberPattern>();
List<ColocatedRegionDetails> missingColocatedRegions = new ArrayList<ColocatedRegionDetails>();
for (Object detail : resultDetails) {
if (detail instanceof PersistentMemberPattern) {
missingDiskStores.add((PersistentMemberPattern) detail);
} else if (detail instanceof ColocatedRegionDetails) {
missingColocatedRegions.add((ColocatedRegionDetails) detail);
} else {
throw new ResultDataException("Unknown type of PersistentRecoveryFailures result");
}
}
boolean hasMissingDiskStores = !missingDiskStores.isEmpty();
boolean hasMissingColocatedRegions = !missingColocatedRegions.isEmpty();
if (hasMissingDiskStores) {
SectionResultData missingDiskStoresSection = crd.addSection();
missingDiskStoresSection.setHeader("Missing Disk Stores");
TabularResultData missingDiskStoreData = missingDiskStoresSection.addTable();
for (PersistentMemberPattern peristentMemberDetails : missingDiskStores) {
missingDiskStoreData.accumulate("Disk Store ID", peristentMemberDetails.getUUID());
missingDiskStoreData.accumulate("Host", peristentMemberDetails.getHost());
missingDiskStoreData.accumulate("Directory", peristentMemberDetails.getDirectory());
}
} else {
SectionResultData noMissingDiskStores = crd.addSection();
noMissingDiskStores.setHeader("No missing disk store found");
}
if (hasMissingDiskStores || hasMissingColocatedRegions) {
// For clarity, separate disk store and colocated region information
crd.addSection().setHeader("\n");
}
if (hasMissingColocatedRegions) {
SectionResultData missingRegionsSection = crd.addSection();
missingRegionsSection.setHeader("Missing Colocated Regions");
TabularResultData missingRegionData = missingRegionsSection.addTable();
for (ColocatedRegionDetails colocatedRegionDetails : missingColocatedRegions) {
missingRegionData.accumulate("Host", colocatedRegionDetails.getHost());
missingRegionData.accumulate("Distributed Member", colocatedRegionDetails.getMember());
missingRegionData.accumulate("Parent Region", colocatedRegionDetails.getParent());
missingRegionData.accumulate("Missing Colocated Region", colocatedRegionDetails.getChild());
}
} else {
SectionResultData noMissingColocatedRegions = crd.addSection();
noMissingColocatedRegions.setHeader("No missing colocated region found");
}
return ResultBuilder.buildResult(crd);
}
use of org.apache.geode.management.internal.cli.result.ResultDataException in project geode by apache.
the class JsonUtil method getByteArray.
public static byte[] getByteArray(GfJsonObject jsonObject, String byName) {
byte[] byteArray = null;
try {
GfJsonArray jsonArray = jsonObject.getJSONArray(byName);
byteArray = GfJsonArray.toByteArray(jsonArray);
} catch (GfJsonException e) {
throw new ResultDataException(e.getMessage());
}
return byteArray;
}
Aggregations