use of org.apache.geode.management.internal.cli.shell.Gfsh in project geode by apache.
the class GatewaySenderIdConverter method getGatewaySenderIds.
public Set<String> getGatewaySenderIds() {
Set<String> gatewaySenderIds = Collections.emptySet();
Gfsh gfsh = Gfsh.getCurrentInstance();
if (gfsh != null && gfsh.isConnectedAndReady()) {
final String[] gatewaySenderIdArray = (String[]) gfsh.getOperationInvoker().invoke(ManagementConstants.OBJECTNAME__DISTRIBUTEDSYSTEM_MXBEAN, "listGatewaySenders", new Object[0], new String[0]);
if (gatewaySenderIdArray != null && gatewaySenderIdArray.length != 0) {
gatewaySenderIds = new TreeSet<String>(Arrays.asList(gatewaySenderIdArray));
}
}
return gatewaySenderIds;
}
use of org.apache.geode.management.internal.cli.shell.Gfsh in project geode by apache.
the class MemberIdNameConverter method getMemberIdAndNames.
private Set<String> getMemberIdAndNames() {
final Set<String> nonLocatorMembers = new TreeSet<String>();
final Gfsh gfsh = Gfsh.getCurrentInstance();
if (gfsh != null && gfsh.isConnectedAndReady()) {
nonLocatorMembers.addAll(Arrays.asList(gfsh.getOperationInvoker().getDistributedSystemMXBean().listMembers()));
final String[] locatorMembers = gfsh.getOperationInvoker().getDistributedSystemMXBean().listLocatorMembers(true);
if (locatorMembers != null && locatorMembers.length != 0) {
nonLocatorMembers.removeAll(Arrays.asList(locatorMembers));
}
}
return nonLocatorMembers;
}
use of org.apache.geode.management.internal.cli.shell.Gfsh in project geode by apache.
the class RegionPathConverter method getAllPossibleValues.
@Override
public boolean getAllPossibleValues(List<Completion> completions, Class<?> targetType, String existingData, String optionContext, MethodTarget target) {
Set<String> regionPathSet = getAllRegionPaths();
Gfsh gfsh = Gfsh.getCurrentInstance();
String currentContextPath = "";
if (gfsh != null) {
currentContextPath = gfsh.getEnvProperty(Gfsh.ENV_APP_CONTEXT_PATH);
if (currentContextPath != null && !org.apache.geode.management.internal.cli.converters.RegionPathConverter.DEFAULT_APP_CONTEXT_PATH.equals(currentContextPath)) {
regionPathSet.remove(currentContextPath);
regionPathSet.add(org.apache.geode.management.internal.cli.converters.RegionPathConverter.DEFAULT_APP_CONTEXT_PATH);
}
}
for (String regionPath : regionPathSet) {
if (existingData != null) {
if (regionPath.startsWith(existingData)) {
completions.add(new Completion(regionPath));
}
} else {
completions.add(new Completion(regionPath));
}
}
return !completions.isEmpty();
}
use of org.apache.geode.management.internal.cli.shell.Gfsh in project geode by apache.
the class LocatorIdNameConverter method getLocatorIdAndNames.
private Set<String> getLocatorIdAndNames() {
final Set<String> locatorIdsAndNames = new TreeSet<String>();
final Gfsh gfsh = Gfsh.getCurrentInstance();
if (gfsh != null && gfsh.isConnectedAndReady()) {
final String[] locatorIds = gfsh.getOperationInvoker().getDistributedSystemMXBean().listLocatorMembers(true);
if (locatorIds != null && locatorIds.length != 0) {
locatorIdsAndNames.addAll(Arrays.asList(locatorIds));
}
}
return locatorIdsAndNames;
}
use of org.apache.geode.management.internal.cli.shell.Gfsh in project geode by apache.
the class DiskStoreCommandsDUnitTest method testAlterDiskStore.
/**
* 1) Create a disk-store in a member, get the disk-dirs. 2) Close the member. 3) Execute the
* command. 4) Restart the member. 5) Check if the disk-store is altered.
*
* @throws IOException
* @throws ClassNotFoundException
*/
@Test
public void testAlterDiskStore() throws ClassNotFoundException, IOException {
final String regionName = "region1";
final String diskStoreName = "disk-store1";
final String diskDirName = "diskStoreDir";
final File diskStoreDir = new File(diskDirName);
diskStoreDir.deleteOnExit();
if (!diskStoreDir.exists()) {
diskStoreDir.mkdir();
}
final String diskDirPath = diskStoreDir.getCanonicalPath();
final VM vm1 = Host.getHost(0).getVM(1);
vm1.invoke(new SerializableCallable() {
@Override
public Object call() throws Exception {
getSystem();
Region region = createParRegWithPersistence(regionName, diskStoreName, diskDirPath);
region.put("a", "QWE");
return region.put("b", "ASD");
}
});
// Close the cache and all the connections , so the disk-store can be altered
disconnectAllFromDS();
// Now do the command execution
setUpJmxManagerOnVm0ThenConnect(null);
Gfsh gfshInstance = Gfsh.getCurrentInstance();
if (gfshInstance == null) {
fail("In testAlterDiskStore command gfshInstance is null");
}
gfshInstance.setDebug(true);
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_DISK_STORE);
csb.addOption(CliStrings.ALTER_DISK_STORE__DISKSTORENAME, diskStoreName);
csb.addOption(CliStrings.ALTER_DISK_STORE__REGIONNAME, regionName);
csb.addOption(CliStrings.ALTER_DISK_STORE__DISKDIRS, diskDirPath);
csb.addOption(CliStrings.ALTER_DISK_STORE__CONCURRENCY__LEVEL, "5");
csb.addOption(CliStrings.ALTER_DISK_STORE__INITIAL__CAPACITY, "6");
csb.addOption(CliStrings.ALTER_DISK_STORE__LRU__EVICTION__ACTION, "local-destroy");
csb.addOption(CliStrings.ALTER_DISK_STORE__COMPRESSOR, "org.apache.geode.compression.SnappyCompressor");
csb.addOption(CliStrings.ALTER_DISK_STORE__STATISTICS__ENABLED, "true");
String commandString = csb.getCommandString();
commandString.trim();
CommandResult cmdResult = executeCommand(commandString);
String resultString = commandResultToString(cmdResult);
getLogWriter().info("#SB command output : \n" + resultString);
assertEquals(true, Result.Status.OK.equals(cmdResult.getStatus()));
assertEquals(true, resultString.contains("concurrencyLevel=5"));
assertEquals(true, resultString.contains("lruAction=local-destroy"));
assertEquals(true, resultString.contains("compressor=org.apache.geode.compression.SnappyCompressor"));
assertEquals(true, resultString.contains("initialCapacity=6"));
csb = new CommandStringBuilder(CliStrings.ALTER_DISK_STORE);
csb.addOption(CliStrings.ALTER_DISK_STORE__DISKSTORENAME, diskStoreName);
csb.addOption(CliStrings.ALTER_DISK_STORE__REGIONNAME, regionName);
csb.addOption(CliStrings.ALTER_DISK_STORE__DISKDIRS, diskDirPath);
csb.addOption(CliStrings.ALTER_DISK_STORE__COMPRESSOR, "none");
cmdResult = executeCommand(csb.getCommandString().trim());
resultString = commandResultToString(cmdResult);
assertEquals(true, Result.Status.OK.equals(cmdResult.getStatus()));
assertTrue(stringContainsLine(resultString, "-compressor=none"));
// Alter DiskStore with remove option
csb = new CommandStringBuilder(CliStrings.ALTER_DISK_STORE);
csb.addOption(CliStrings.ALTER_DISK_STORE__DISKSTORENAME, diskStoreName);
csb.addOption(CliStrings.ALTER_DISK_STORE__REGIONNAME, regionName);
csb.addOption(CliStrings.ALTER_DISK_STORE__DISKDIRS, diskDirPath);
csb.addOption(CliStrings.ALTER_DISK_STORE__REMOVE, "true");
commandString = csb.getCommandString();
commandString.trim();
cmdResult = executeCommand(commandString);
resultString = commandResultToString(cmdResult);
getLogWriter().info("command output : \n" + resultString);
assertEquals(true, Result.Status.OK.equals(cmdResult.getStatus()));
Object postDestroyValue = vm1.invoke(new SerializableCallable() {
@Override
public Object call() throws Exception {
getSystem();
Region region = createParRegWithPersistence(regionName, diskStoreName, diskDirPath);
return region.get("a");
}
});
assertNull(postDestroyValue);
csb = new CommandStringBuilder(CliStrings.ALTER_DISK_STORE);
csb.addOption(CliStrings.ALTER_DISK_STORE__DISKSTORENAME, diskStoreName);
csb.addOption(CliStrings.ALTER_DISK_STORE__REGIONNAME, regionName);
csb.addOption(CliStrings.ALTER_DISK_STORE__DISKDIRS, diskDirPath);
csb.addOption(CliStrings.ALTER_DISK_STORE__CONCURRENCY__LEVEL, "5");
csb.addOption(CliStrings.ALTER_DISK_STORE__REMOVE, "true");
commandString = csb.getCommandString();
commandString.trim();
cmdResult = executeCommand(commandString);
resultString = commandResultToString(cmdResult);
getLogWriter().info("Alter DiskStore with wrong remove option : \n" + resultString);
assertEquals(true, Result.Status.ERROR.equals(cmdResult.getStatus()));
filesToBeDeleted.add(diskDirName);
}
Aggregations