Search in sources :

Example 11 with CommandStringBuilder

use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.

the class WanCommandsController method destroyGatewaySender.

@RequestMapping(method = RequestMethod.DELETE, value = "/gateways/senders/{id}")
@ResponseBody
public String destroyGatewaySender(@PathVariable("id") final String gatewaySenderId, @RequestParam(value = CliStrings.DESTROY_GATEWAYSENDER__GROUP, required = false) final String[] groups, @RequestParam(value = CliStrings.DESTROY_GATEWAYSENDER__MEMBER, required = false) final String[] members) {
    CommandStringBuilder command = new CommandStringBuilder(CliStrings.DESTROY_GATEWAYSENDER);
    command.addOption(CliStrings.CREATE_GATEWAYSENDER__ID, gatewaySenderId);
    if (hasValue(groups)) {
        command.addOption(CliStrings.CREATE_GATEWAYSENDER__GROUP, StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
    }
    if (hasValue(members)) {
        command.addOption(CliStrings.CREATE_GATEWAYSENDER__MEMBER, StringUtils.join(members, StringUtils.COMMA_DELIMITER));
    }
    return processCommand(command.toString());
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 12 with CommandStringBuilder

use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.

the class WanCommandsController method startGatewaySender.

// TODO determine whether Async functionality is required
@RequestMapping(method = RequestMethod.POST, value = "/gateways/senders", params = "op=start")
@ResponseBody
public String startGatewaySender(@RequestParam(CliStrings.START_GATEWAYSENDER__ID) final String gatewaySenderId, @RequestParam(value = CliStrings.START_GATEWAYSENDER__GROUP, required = false) final String[] groups, @RequestParam(value = CliStrings.START_GATEWAYSENDER__MEMBER, required = false) final String[] members) {
    CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_GATEWAYSENDER);
    command.addOption(CliStrings.START_GATEWAYSENDER__ID, gatewaySenderId);
    if (hasValue(groups)) {
        command.addOption(CliStrings.START_GATEWAYSENDER__GROUP, StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
    }
    if (hasValue(members)) {
        command.addOption(CliStrings.START_GATEWAYSENDER__MEMBER, StringUtils.join(members, StringUtils.COMMA_DELIMITER));
    }
    return processCommand(command.toString());
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 13 with CommandStringBuilder

use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.

the class WanCommandsController method pauseGatewaySender.

// TODO determine whether Async functionality is required
@RequestMapping(method = RequestMethod.POST, value = "/gateways/senders/{id}", params = "op=pause")
@ResponseBody
public String pauseGatewaySender(@PathVariable("id") final String gatewaySenderId, @RequestParam(value = CliStrings.PAUSE_GATEWAYSENDER__GROUP, required = false) final String[] groups, @RequestParam(value = CliStrings.PAUSE_GATEWAYSENDER__MEMBER, required = false) final String[] members) {
    CommandStringBuilder command = new CommandStringBuilder(CliStrings.PAUSE_GATEWAYSENDER);
    command.addOption(CliStrings.PAUSE_GATEWAYSENDER__ID, decode(gatewaySenderId));
    if (hasValue(groups)) {
        command.addOption(CliStrings.PAUSE_GATEWAYSENDER__GROUP, StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
    }
    if (hasValue(members)) {
        command.addOption(CliStrings.PAUSE_GATEWAYSENDER__MEMBER, StringUtils.join(members, StringUtils.COMMA_DELIMITER));
    }
    return processCommand(command.toString());
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 14 with CommandStringBuilder

use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.

the class PdxCommandsController method pdxDeleteField.

// @RequestMapping(method = RequestMethod.DELETE, value = "/pdx/type/field")
// @ResponseBody
public String pdxDeleteField(@RequestParam(value = CliStrings.PDX_CLASS) final String className, @RequestParam(value = CliStrings.PDX_FIELD) final String fieldName, @RequestParam(value = CliStrings.PDX_DISKSTORE) final String diskStore, @RequestParam(value = CliStrings.PDX_DISKDIR, required = false) final String[] diskDirs) {
    CommandStringBuilder command = new CommandStringBuilder(CliStrings.PDX_DELETE_FIELD);
    command.addOption(CliStrings.PDX_CLASS, className);
    command.addOption(CliStrings.PDX_FIELD, fieldName);
    command.addOption(CliStrings.PDX_DISKSTORE, diskStore);
    if (hasValue(diskDirs)) {
        command.addOption(CliStrings.PDX_DISKDIR, StringUtils.join(diskDirs, StringUtils.COMMA_DELIMITER));
    }
    return processCommand(command.toString());
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder)

Example 15 with CommandStringBuilder

use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.

the class RegionCommandsController method createRegion.

@RequestMapping(method = RequestMethod.POST, value = "/regions")
@ResponseBody
public String createRegion(@RequestParam("name") final String regionNamePath, @RequestParam(value = CliStrings.CREATE_REGION__REGIONSHORTCUT, required = false) final String regionType, @RequestParam(value = CliStrings.CREATE_REGION__USEATTRIBUTESFROM, required = false) final String regionTemplate, @RequestParam(value = CliStrings.CREATE_REGION__GROUP, required = false) final String[] groups, @RequestParam(value = CliStrings.CREATE_REGION__SKIPIFEXISTS, defaultValue = "true") final Boolean skipIfExists, @RequestParam(value = CliStrings.CREATE_REGION__KEYCONSTRAINT, required = false) final String keyConstraint, @RequestParam(value = CliStrings.CREATE_REGION__VALUECONSTRAINT, required = false) final String valueConstraint, @RequestParam(value = CliStrings.CREATE_REGION__STATISTICSENABLED, required = false) final Boolean enableStatistics, @RequestParam(value = CliStrings.CREATE_REGION__ENTRYEXPIRATIONIDLETIME, required = false) final Integer entryIdleTimeExpiration, @RequestParam(value = CliStrings.CREATE_REGION__ENTRYEXPIRATIONIDLETIMEACTION, required = false) final String entryIdleTimeExpirationAction, @RequestParam(value = CliStrings.CREATE_REGION__ENTRYEXPIRATIONTIMETOLIVE, required = false) final Integer entryTimeToLiveExpiration, @RequestParam(value = CliStrings.CREATE_REGION__ENTRYEXPIRATIONTTLACTION, required = false) final String entryTimeToLiveExpirationAction, @RequestParam(value = CliStrings.CREATE_REGION__REGIONEXPIRATIONIDLETIME, required = false) final Integer regionIdleTimeExpiration, @RequestParam(value = CliStrings.CREATE_REGION__REGIONEXPIRATIONIDLETIMEACTION, required = false) final String regionIdleTimeExpirationAction, @RequestParam(value = CliStrings.CREATE_REGION__REGIONEXPIRATIONTTL, required = false) final Integer regionTimeToLiveExpiration, @RequestParam(value = CliStrings.CREATE_REGION__REGIONEXPIRATIONTTLACTION, required = false) final String regionTimeToLiveExpirationAction, @RequestParam(value = CliStrings.CREATE_REGION__DISKSTORE, required = false) final String diskStore, @RequestParam(value = CliStrings.CREATE_REGION__DISKSYNCHRONOUS, required = false) final Boolean enableSynchronousDisk, @RequestParam(value = CliStrings.CREATE_REGION__ENABLEASYNCCONFLATION, required = false) final Boolean enableAsynchronousConflation, @RequestParam(value = CliStrings.CREATE_REGION__ENABLESUBSCRIPTIONCONFLATION, required = false) final Boolean enableSubscriptionConflation, @RequestParam(value = CliStrings.CREATE_REGION__CACHELISTENER, required = false) final String[] cacheListeners, @RequestParam(value = CliStrings.CREATE_REGION__CACHELOADER, required = false) final String cacheLoader, @RequestParam(value = CliStrings.CREATE_REGION__CACHEWRITER, required = false) final String cacheWriter, @RequestParam(value = CliStrings.CREATE_REGION__ASYNCEVENTQUEUEID, required = false) final String[] asyncEventQueueIds, @RequestParam(value = CliStrings.CREATE_REGION__GATEWAYSENDERID, required = false) final String[] gatewaySenderIds, @RequestParam(value = CliStrings.CREATE_REGION__CONCURRENCYCHECKSENABLED, required = false) final Boolean enableConcurrencyChecks, @RequestParam(value = CliStrings.CREATE_REGION__CLONINGENABLED, required = false) final Boolean enableCloning, @RequestParam(value = CliStrings.CREATE_REGION__CONCURRENCYLEVEL, required = false) final Integer concurrencyLevel, @RequestParam(value = CliStrings.CREATE_REGION__COLOCATEDWITH, required = false) final String colocatedWith, @RequestParam(value = CliStrings.CREATE_REGION__LOCALMAXMEMORY, required = false) final Integer localMaxMemory, @RequestParam(value = CliStrings.CREATE_REGION__RECOVERYDELAY, required = false) final Long recoveryDelay, @RequestParam(value = CliStrings.CREATE_REGION__REDUNDANTCOPIES, required = false) final Integer redundantCopies, @RequestParam(value = CliStrings.CREATE_REGION__STARTUPRECOVERYDDELAY, required = false) final Long startupRecoveryDelay, @RequestParam(value = CliStrings.CREATE_REGION__TOTALMAXMEMORY, required = false) final Long totalMaxMemory, @RequestParam(value = CliStrings.CREATE_REGION__TOTALNUMBUCKETS, required = false) final Integer totalNumBuckets, @RequestParam(value = CliStrings.CREATE_REGION__COMPRESSOR, required = false) final String compressor) {
    final CommandStringBuilder command = new CommandStringBuilder(CliStrings.CREATE_REGION);
    assertArgument(hasValue(regionNamePath), "Region name/path is required!");
    assertArgument(hasValue(regionType) || hasValue(regionTemplate), "Either Region type or template-region must be specified!");
    command.addOption(CliStrings.CREATE_REGION__REGION, regionNamePath);
    if (hasValue(regionType)) {
        command.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, regionType);
    } else {
        command.addOption(CliStrings.CREATE_REGION__USEATTRIBUTESFROM, regionTemplate);
    }
    if (hasValue(groups)) {
        command.addOption(CliStrings.CREATE_REGION__GROUP, StringUtils.join(groups, StringUtils.COMMA_DELIMITER));
    }
    command.addOption(CliStrings.CREATE_REGION__SKIPIFEXISTS, String.valueOf(Boolean.TRUE.equals(skipIfExists)));
    if (hasValue(keyConstraint)) {
        command.addOption(CliStrings.CREATE_REGION__KEYCONSTRAINT, keyConstraint);
    }
    if (hasValue(valueConstraint)) {
        command.addOption(CliStrings.CREATE_REGION__VALUECONSTRAINT, valueConstraint);
    }
    if (Boolean.TRUE.equals(enableStatistics)) {
        command.addOption(CliStrings.CREATE_REGION__STATISTICSENABLED, String.valueOf(enableStatistics));
    }
    if (hasValue(entryIdleTimeExpiration)) {
        command.addOption(CliStrings.CREATE_REGION__ENTRYEXPIRATIONIDLETIME, String.valueOf(entryIdleTimeExpiration));
    }
    if (hasValue(entryIdleTimeExpirationAction)) {
        command.addOption(CliStrings.CREATE_REGION__ENTRYEXPIRATIONIDLETIMEACTION, entryIdleTimeExpirationAction);
    }
    if (hasValue(entryTimeToLiveExpiration)) {
        command.addOption(CliStrings.CREATE_REGION__ENTRYEXPIRATIONTIMETOLIVE, String.valueOf(entryTimeToLiveExpiration));
    }
    if (hasValue(entryTimeToLiveExpirationAction)) {
        command.addOption(CliStrings.CREATE_REGION__ENTRYEXPIRATIONTTLACTION, entryTimeToLiveExpirationAction);
    }
    if (hasValue(regionIdleTimeExpiration)) {
        command.addOption(CliStrings.CREATE_REGION__REGIONEXPIRATIONIDLETIME, String.valueOf(regionIdleTimeExpiration));
    }
    if (hasValue(regionIdleTimeExpirationAction)) {
        command.addOption(CliStrings.CREATE_REGION__REGIONEXPIRATIONIDLETIMEACTION, regionIdleTimeExpirationAction);
    }
    if (hasValue(regionTimeToLiveExpiration)) {
        command.addOption(CliStrings.CREATE_REGION__REGIONEXPIRATIONTTL, String.valueOf(regionTimeToLiveExpiration));
    }
    if (hasValue(regionTimeToLiveExpirationAction)) {
        command.addOption(CliStrings.CREATE_REGION__REGIONEXPIRATIONTTLACTION, regionTimeToLiveExpirationAction);
    }
    if (hasValue(diskStore)) {
        command.addOption(CliStrings.CREATE_REGION__DISKSTORE, diskStore);
    }
    if (Boolean.TRUE.equals(enableSynchronousDisk)) {
        command.addOption(CliStrings.CREATE_REGION__DISKSYNCHRONOUS, String.valueOf(enableSynchronousDisk));
    }
    if (Boolean.TRUE.equals(enableAsynchronousConflation)) {
        command.addOption(CliStrings.CREATE_REGION__ENABLEASYNCCONFLATION, String.valueOf(enableAsynchronousConflation));
    }
    if (Boolean.TRUE.equals(enableSubscriptionConflation)) {
        command.addOption(CliStrings.CREATE_REGION__ENABLESUBSCRIPTIONCONFLATION, String.valueOf(enableSubscriptionConflation));
    }
    if (hasValue(cacheListeners)) {
        command.addOption(CliStrings.CREATE_REGION__CACHELISTENER, StringUtils.join(cacheListeners, StringUtils.COMMA_DELIMITER));
    }
    if (hasValue(cacheLoader)) {
        command.addOption(CliStrings.CREATE_REGION__CACHELOADER, cacheLoader);
    }
    if (hasValue(cacheWriter)) {
        command.addOption(CliStrings.CREATE_REGION__CACHEWRITER, cacheWriter);
    }
    if (hasValue(asyncEventQueueIds)) {
        command.addOption(CliStrings.CREATE_REGION__ASYNCEVENTQUEUEID, StringUtils.join(asyncEventQueueIds, StringUtils.COMMA_DELIMITER));
    }
    if (hasValue(gatewaySenderIds)) {
        command.addOption(CliStrings.CREATE_REGION__GATEWAYSENDERID, StringUtils.join(gatewaySenderIds, StringUtils.COMMA_DELIMITER));
    }
    if (Boolean.TRUE.equals(enableConcurrencyChecks)) {
        command.addOption(CliStrings.CREATE_REGION__CONCURRENCYCHECKSENABLED, String.valueOf(enableConcurrencyChecks));
    }
    if (Boolean.TRUE.equals(enableCloning)) {
        command.addOption(CliStrings.CREATE_REGION__CLONINGENABLED, String.valueOf(enableCloning));
    }
    if (hasValue(concurrencyLevel)) {
        command.addOption(CliStrings.CREATE_REGION__CONCURRENCYLEVEL, String.valueOf(concurrencyLevel));
    }
    if (hasValue(colocatedWith)) {
        command.addOption(CliStrings.CREATE_REGION__COLOCATEDWITH, colocatedWith);
    }
    if (hasValue(localMaxMemory)) {
        command.addOption(CliStrings.CREATE_REGION__LOCALMAXMEMORY, String.valueOf(localMaxMemory));
    }
    if (hasValue(recoveryDelay)) {
        command.addOption(CliStrings.CREATE_REGION__RECOVERYDELAY, String.valueOf(recoveryDelay));
    }
    if (hasValue(redundantCopies)) {
        command.addOption(CliStrings.CREATE_REGION__REDUNDANTCOPIES, String.valueOf(redundantCopies));
    }
    if (hasValue(startupRecoveryDelay)) {
        command.addOption(CliStrings.CREATE_REGION__STARTUPRECOVERYDDELAY, String.valueOf(startupRecoveryDelay));
    }
    if (hasValue(totalMaxMemory)) {
        command.addOption(CliStrings.CREATE_REGION__TOTALMAXMEMORY, String.valueOf(totalMaxMemory));
    }
    if (hasValue(totalNumBuckets)) {
        command.addOption(CliStrings.CREATE_REGION__TOTALNUMBUCKETS, String.valueOf(totalNumBuckets));
    }
    if (hasValue(compressor)) {
        command.addOption(CliStrings.CREATE_REGION__COMPRESSOR, compressor);
    }
    return processCommand(command.toString());
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

CommandStringBuilder (org.apache.geode.management.internal.cli.util.CommandStringBuilder)186 Test (org.junit.Test)88 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)87 CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)71 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)47 VM (org.apache.geode.test.dunit.VM)41 File (java.io.File)39 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)37 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)36 Properties (java.util.Properties)16 Region (org.apache.geode.cache.Region)14 Category (org.junit.experimental.categories.Category)14 Cache (org.apache.geode.cache.Cache)12 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)12 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)11 IOException (java.io.IOException)10 UnknownHostException (java.net.UnknownHostException)7 HashMap (java.util.HashMap)6 RegionAttributes (org.apache.geode.cache.RegionAttributes)6 ClusterConfigurationService (org.apache.geode.distributed.internal.ClusterConfigurationService)6