use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class ListAndDescribeRegionDUnitTest method testListRegion.
@Test
public void testListRegion() {
setupSystem();
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_REGION);
String commandString = csb.toString();
CommandResult commandResult = executeCommand(commandString);
String commandResultAsString = commandResultToString(commandResult);
getLogWriter().info("Command String : " + commandString);
getLogWriter().info("Output : \n" + commandResultAsString);
assertEquals(Status.OK, commandResult.getStatus());
assertTrue(commandResultAsString.contains(PR1));
assertTrue(commandResultAsString.contains(LOCALREGIONONMANAGER));
assertTrue(commandResultAsString.contains(REGION1));
assertTrue(commandResultAsString.contains(REGION2));
assertTrue(commandResultAsString.contains(REGION3));
csb = new CommandStringBuilder(CliStrings.LIST_REGION);
csb.addOption(CliStrings.LIST_REGION__MEMBER, "Manager");
commandString = csb.toString();
commandResult = executeCommand(commandString);
commandResultAsString = commandResultToString(commandResult);
getLogWriter().info("Command String : " + commandString);
getLogWriter().info("Output : \n" + commandResultAsString);
assertEquals(Status.OK, commandResult.getStatus());
assertTrue(commandResultAsString.contains(PR1));
assertTrue(commandResultAsString.contains(LOCALREGIONONMANAGER));
csb = new CommandStringBuilder(CliStrings.LIST_REGION);
csb.addOption(CliStrings.LIST_REGION__MEMBER, "Server1");
commandString = csb.toString();
commandResult = executeCommand(commandString);
commandResultAsString = commandResultToString(commandResult);
getLogWriter().info("Command String : " + commandString);
getLogWriter().info("Output : \n" + commandResultAsString);
assertEquals(Status.OK, commandResult.getStatus());
assertTrue(commandResultAsString.contains(PR1));
assertTrue(commandResultAsString.contains(REGION1));
assertTrue(commandResultAsString.contains(REGION2));
assertTrue(commandResultAsString.contains(REGION3));
assertTrue(commandResultAsString.contains(SUBREGION1A));
csb = new CommandStringBuilder(CliStrings.LIST_REGION);
csb.addOption(CliStrings.LIST_REGION__GROUP, "G1");
commandString = csb.toString();
commandResult = executeCommand(commandString);
commandResultAsString = commandResultToString(commandResult);
getLogWriter().info("Command String : " + commandString);
getLogWriter().info("Output : \n" + commandResultAsString);
assertEquals(Status.OK, commandResult.getStatus());
assertTrue(commandResultAsString.contains(PR1));
assertTrue(commandResultAsString.contains(LOCALREGIONONMANAGER));
csb = new CommandStringBuilder(CliStrings.LIST_REGION);
csb.addOption(CliStrings.LIST_REGION__GROUP, "G2");
commandString = csb.toString();
commandResult = executeCommand(commandString);
commandResultAsString = commandResultToString(commandResult);
getLogWriter().info("Command String : " + commandString);
getLogWriter().info("Output : \n" + commandResultAsString);
assertEquals(Status.OK, commandResult.getStatus());
assertTrue(commandResultAsString.contains(PR1));
assertTrue(commandResultAsString.contains(REGION1));
assertTrue(commandResultAsString.contains(REGION2));
assertTrue(commandResultAsString.contains(REGION3));
assertTrue(commandResultAsString.contains(SUBREGION1A));
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class ListAndDescribeRegionDUnitTest method testDescribeRegionWithCompressionCodec.
/**
* Asserts that a describe region command issued on a region with compression returns the correct
* non default region attribute for compression and the correct codec value.
*/
// GEODE-1033: HeadlesssGFSH, random port, Snappy dependency
@Category(FlakyTest.class)
@Test
public void testDescribeRegionWithCompressionCodec() {
final String regionName = "compressedRegion";
VM vm = Host.getHost(0).getVM(1);
setupSystem();
// Create compressed region
vm.invoke(new SerializableRunnable() {
@Override
public void run() {
createCompressedRegion(regionName);
}
});
// Test the describe command; look for compression
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESCRIBE_REGION);
csb.addOption(CliStrings.DESCRIBE_REGION__NAME, regionName);
String commandString = csb.toString();
CommandResult commandResult = executeCommand(commandString);
String commandResultAsString = commandResultToString(commandResult);
assertEquals(Status.OK, commandResult.getStatus());
assertTrue(commandResultAsString.contains(regionName));
assertTrue(commandResultAsString.contains(RegionAttributesNames.COMPRESSOR));
assertTrue(commandResultAsString.contains(RegionEntryContext.DEFAULT_COMPRESSION_PROVIDER));
// Destroy compressed region
vm.invoke(new SerializableRunnable() {
@Override
public void run() {
Region region = getCache().getRegion(regionName);
assertNotNull(region);
region.destroyRegion();
}
});
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class ListAndDescribeRegionDUnitTest method testDescribeRegion.
@Test
public void testDescribeRegion() {
setupSystem();
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESCRIBE_REGION);
csb.addOption(CliStrings.DESCRIBE_REGION__NAME, PR1);
String commandString = csb.toString();
CommandResult commandResult = executeCommand(commandString);
String commandResultAsString = commandResultToString(commandResult);
getLogWriter().info("Command String : " + commandString);
getLogWriter().info("Output : \n" + commandResultAsString);
assertEquals(Status.OK, commandResult.getStatus());
assertTrue(commandResultAsString.contains(PR1));
assertTrue(commandResultAsString.contains("Server1"));
csb = new CommandStringBuilder(CliStrings.DESCRIBE_REGION);
csb.addOption(CliStrings.DESCRIBE_REGION__NAME, LOCALREGIONONMANAGER);
commandString = csb.toString();
commandResult = executeCommand(commandString);
commandResultAsString = commandResultToString(commandResult);
getLogWriter().info("Command String : " + commandString);
getLogWriter().info("Output : \n" + commandResultAsString);
assertEquals(Status.OK, commandResult.getStatus());
assertTrue(commandResultAsString.contains(LOCALREGIONONMANAGER));
assertTrue(commandResultAsString.contains("Manager"));
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class LauncherLifecycleCommands method doOnConnectionFailure.
private void doOnConnectionFailure(final String locatorHostName, final int locatorPort, final boolean jmxManagerAuthEnabled, final boolean jmxManagerSslEnabled, final InfoResultData infoResultData) {
infoResultData.addLine("\n");
infoResultData.addLine(CliStrings.format(CliStrings.START_LOCATOR__USE__0__TO__CONNECT, new CommandStringBuilder(CliStrings.CONNECT).addOption(CliStrings.CONNECT__LOCATOR, locatorHostName + "[" + locatorPort + "]").toString()));
StringBuilder message = new StringBuilder();
if (jmxManagerAuthEnabled) {
message.append("Authentication");
}
if (jmxManagerSslEnabled) {
message.append(jmxManagerAuthEnabled ? " and " : StringUtils.EMPTY).append("SSL configuration");
}
if (jmxManagerAuthEnabled || jmxManagerSslEnabled) {
message.append(" required to connect to the Manager.");
infoResultData.addLine("\n");
infoResultData.addLine(message.toString());
}
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class DurableClientCommandsController method closeDurableContinuousQuery.
@RequestMapping(method = RequestMethod.POST, value = "/durable-clients/{durable-client-id}/cqs/{durable-cq-name}", params = "op=close")
@ResponseBody
public String closeDurableContinuousQuery(@PathVariable(ConfigurationProperties.DURABLE_CLIENT_ID) final String durableClientId, @PathVariable("durable-cq-name") final String durableCqName, @RequestParam(value = CliStrings.CLOSE_DURABLE_CQS__MEMBER, required = false) final String memberNameId, @RequestParam(value = CliStrings.CLOSE_DURABLE_CQS__GROUP, required = false) final String[] groups) {
final CommandStringBuilder command = new CommandStringBuilder(CliStrings.CLOSE_DURABLE_CQS);
command.addOption(CliStrings.CLOSE_DURABLE_CQS__DURABLE__CLIENT__ID, decode(durableClientId));
command.addOption(CliStrings.CLOSE_DURABLE_CQS__NAME, decode(durableCqName));
if (hasValue(memberNameId)) {
command.addOption(CliStrings.CLOSE_DURABLE_CQS__MEMBER, memberNameId);
}
if (hasValue(groups)) {
command.addOption(CliStrings.CLOSE_DURABLE_CQS__GROUP, StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
}
return processCommand(command.toString());
}
Aggregations