Search in sources :

Example 1 with GatewaySenderFunctionArgs

use of org.apache.geode.management.internal.cli.functions.GatewaySenderFunctionArgs in project geode by apache.

the class WanCommands method createGatewaySender.

@CliCommand(value = CliStrings.CREATE_GATEWAYSENDER, help = CliStrings.CREATE_GATEWAYSENDER__HELP)
@CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
@ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
public Result createGatewaySender(@CliOption(key = CliStrings.CREATE_GATEWAYSENDER__GROUP, optionContext = ConverterHint.MEMBERGROUP, help = CliStrings.CREATE_GATEWAYSENDER__GROUP__HELP) String[] onGroups, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__MEMBER, optionContext = ConverterHint.MEMBERIDNAME, unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.CREATE_GATEWAYSENDER__MEMBER__HELP) String[] onMember, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__ID, mandatory = true, help = CliStrings.CREATE_GATEWAYSENDER__ID__HELP) String id, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID, mandatory = true, help = CliStrings.CREATE_GATEWAYSENDER__REMOTEDISTRIBUTEDSYSTEMID__HELP) Integer remoteDistributedSystemId, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__PARALLEL, help = CliStrings.CREATE_GATEWAYSENDER__PARALLEL__HELP) Boolean parallel, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__MANUALSTART, help = CliStrings.CREATE_GATEWAYSENDER__MANUALSTART__HELP) Boolean manualStart, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE, help = CliStrings.CREATE_GATEWAYSENDER__SOCKETBUFFERSIZE__HELP) Integer socketBufferSize, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT, help = CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT__HELP) Integer socketReadTimeout, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION, help = CliStrings.CREATE_GATEWAYSENDER__ENABLEBATCHCONFLATION__HELP) Boolean enableBatchConflation, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE, help = CliStrings.CREATE_GATEWAYSENDER__BATCHSIZE__HELP) Integer batchSize, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL, help = CliStrings.CREATE_GATEWAYSENDER__BATCHTIMEINTERVAL__HELP) Integer batchTimeInterval, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE, help = CliStrings.CREATE_GATEWAYSENDER__ENABLEPERSISTENCE__HELP) Boolean enablePersistence, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__DISKSTORENAME, help = CliStrings.CREATE_GATEWAYSENDER__DISKSTORENAME__HELP) String diskStoreName, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS, help = CliStrings.CREATE_GATEWAYSENDER__DISKSYNCHRONOUS__HELP) Boolean diskSynchronous, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY, help = CliStrings.CREATE_GATEWAYSENDER__MAXQUEUEMEMORY__HELP) Integer maxQueueMemory, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD, help = CliStrings.CREATE_GATEWAYSENDER__ALERTTHRESHOLD__HELP) Integer alertThreshold, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS, help = CliStrings.CREATE_GATEWAYSENDER__DISPATCHERTHREADS__HELP) Integer dispatcherThreads, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY, help = CliStrings.CREATE_GATEWAYSENDER__ORDERPOLICY__HELP) String orderPolicy, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__GATEWAYEVENTFILTER, help = CliStrings.CREATE_GATEWAYSENDER__GATEWAYEVENTFILTER__HELP) String[] gatewayEventFilters, @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__GATEWAYTRANSPORTFILTER, help = CliStrings.CREATE_GATEWAYSENDER__GATEWAYTRANSPORTFILTER__HELP) String[] gatewayTransportFilter) {
    Result result = null;
    AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
    try {
        GatewaySenderFunctionArgs gatewaySenderFunctionArgs = new GatewaySenderFunctionArgs(id, remoteDistributedSystemId, parallel, manualStart, socketBufferSize, socketReadTimeout, enableBatchConflation, batchSize, batchTimeInterval, enablePersistence, diskStoreName, diskSynchronous, maxQueueMemory, alertThreshold, dispatcherThreads, orderPolicy, gatewayEventFilters, gatewayTransportFilter);
        Set<DistributedMember> membersToCreateGatewaySenderOn = CliUtil.findMembers(onGroups, onMember);
        if (membersToCreateGatewaySenderOn.isEmpty()) {
            return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
        }
        ResultCollector<?, ?> resultCollector = CliUtil.executeFunction(GatewaySenderCreateFunction.INSTANCE, gatewaySenderFunctionArgs, membersToCreateGatewaySenderOn);
        @SuppressWarnings("unchecked") List<CliFunctionResult> gatewaySenderCreateResults = (List<CliFunctionResult>) resultCollector.getResult();
        TabularResultData tabularResultData = ResultBuilder.createTabularResultData();
        final String errorPrefix = "ERROR: ";
        for (CliFunctionResult gatewaySenderCreateResult : gatewaySenderCreateResults) {
            boolean success = gatewaySenderCreateResult.isSuccessful();
            tabularResultData.accumulate("Member", gatewaySenderCreateResult.getMemberIdOrName());
            tabularResultData.accumulate("Status", (success ? "" : errorPrefix) + gatewaySenderCreateResult.getMessage());
            if (success && xmlEntity.get() == null) {
                xmlEntity.set(gatewaySenderCreateResult.getXmlEntity());
            }
        }
        result = ResultBuilder.buildResult(tabularResultData);
    } catch (IllegalArgumentException e) {
        LogWrapper.getInstance().info(e.getMessage());
        result = ResultBuilder.createUserErrorResult(e.getMessage());
    }
    if (xmlEntity.get() != null) {
        persistClusterConfiguration(result, () -> getSharedConfiguration().addXmlEntity(xmlEntity.get(), onGroups));
    }
    return result;
}
Also used : TabularResultData(org.apache.geode.management.internal.cli.result.TabularResultData) GatewaySenderFunctionArgs(org.apache.geode.management.internal.cli.functions.GatewaySenderFunctionArgs) AtomicReference(java.util.concurrent.atomic.AtomicReference) Result(org.apache.geode.management.cli.Result) CliFunctionResult(org.apache.geode.management.internal.cli.functions.CliFunctionResult) XmlEntity(org.apache.geode.management.internal.configuration.domain.XmlEntity) CliFunctionResult(org.apache.geode.management.internal.cli.functions.CliFunctionResult) DistributedMember(org.apache.geode.distributed.DistributedMember) ArrayList(java.util.ArrayList) List(java.util.List) CliCommand(org.springframework.shell.core.annotation.CliCommand) CliMetaData(org.apache.geode.management.cli.CliMetaData) ResourceOperation(org.apache.geode.management.internal.security.ResourceOperation)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 DistributedMember (org.apache.geode.distributed.DistributedMember)1 CliMetaData (org.apache.geode.management.cli.CliMetaData)1 Result (org.apache.geode.management.cli.Result)1 CliFunctionResult (org.apache.geode.management.internal.cli.functions.CliFunctionResult)1 GatewaySenderFunctionArgs (org.apache.geode.management.internal.cli.functions.GatewaySenderFunctionArgs)1 TabularResultData (org.apache.geode.management.internal.cli.result.TabularResultData)1 XmlEntity (org.apache.geode.management.internal.configuration.domain.XmlEntity)1 ResourceOperation (org.apache.geode.management.internal.security.ResourceOperation)1 CliCommand (org.springframework.shell.core.annotation.CliCommand)1