[
https://issues.apache.org/jira/browse/GEODE-2270?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15843429#comment-15843429
]
Kirk Lund commented on GEODE-2270:
----------------------------------
org.apache.geode.management.ManagementService is the API for executing gfsh
commands via API instead of within the cli. This was introduced in GemFire 7.0
(pre-Geode) and the feature was originally intended to receive further work to
complete it but the work halted after GemFire 7.0. The original specification
called for 3 different flavors (sub-classes): Client, Peer, Manager. Those 3
would have slight variations due to communication protocol, contextual scope
and security. For example, the ClientManagementService would be used within a
Client to create a Region on the Server(s) if the Client has sufficient
security privileges.
org.apache.geode.management.MemberMXBean has three MBean operations to provide
this functionality as a JMX API:
* String processCommand(String commandString);
* String processCommand(String commandString, Map<String, String> env);
* String processCommand(String commandString, Map<String, String> env, Byte[][]
binaryData);
Preparing and documenting MemberMXBean#processCommand APIs was spec'ed out but
(same as before) the work was halted after GemFire 7.0.
> Need API to call gfsh and get results dynamically from code
> -----------------------------------------------------------
>
> Key: GEODE-2270
> URL: https://issues.apache.org/jira/browse/GEODE-2270
> Project: Geode
> Issue Type: Improvement
> Components: docs, gfsh, management
> Reporter: Wes Williams
> Labels: ManagementService, MemberMXBean, gfsh, jmx
>
> GIVEN:
> 1) The GfshParser and CommandResult are internal classes.
> 2) CommandResult returns headings, line.separator's and UI concerns along
> with the answer
> WHEN:
> I pass a gfsh command into a public gfsh API from code
> THEN:
> I get back an XML or JSON representation of the core results without the
> headings, line.separator's and UI concerns
> EXAMPLE (idea node and not actual implementation):
> WHEN:
> String gfshResults = gfshPublicAPI("list regions");
> return gfshResults;
> String gfshPublicAPI(String gfshCommand) {
> ParseResult parseResult = gfshParser.parse(gfshCommand);
> String results = (String) parseResult.getMethod()+"Json"
> .invoke(parseResult.getInstance(), parseResult.getArguments())
> return results;
> }
> CommandResult gfshInternalAPI(String gfshCommand) {
> ParseResult parseResult = gfshParser.parse(gfshCommand);
> CommandResult results = (CommandResult) parseResult.getMethod()
> .invoke(parseResult.getInstance(), parseResult.getArguments())
> return results;
> }
> Another option is to include a new property --output=json into gfsh commands
> that return the core results without the UI concerns, per Anthony Baker's
> comment on Fri, 04 Nov, 20:31 at:
> https://mail-archives.apache.org/mod_mbox/incubator-geode-dev/201611.mbox/browser
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)