use of org.apache.geode.management.internal.cli.domain.MemberConfigurationInfo in project geode by apache.
the class ConfigCommands method describeConfig.
@CliCommand(value = { CliStrings.DESCRIBE_CONFIG }, help = CliStrings.DESCRIBE_CONFIG__HELP)
@CliMetaData(relatedTopic = { CliStrings.TOPIC_GEODE_CONFIG })
@ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
public Result describeConfig(@CliOption(key = CliStrings.DESCRIBE_CONFIG__MEMBER, optionContext = ConverterHint.ALL_MEMBER_IDNAME, help = CliStrings.DESCRIBE_CONFIG__MEMBER__HELP, mandatory = true) String memberNameOrId, @CliOption(key = CliStrings.DESCRIBE_CONFIG__HIDE__DEFAULTS, help = CliStrings.DESCRIBE_CONFIG__HIDE__DEFAULTS__HELP, unspecifiedDefaultValue = "true", specifiedDefaultValue = "true") boolean hideDefaults) {
Result result = null;
try {
DistributedMember targetMember = null;
if (memberNameOrId != null && !memberNameOrId.isEmpty()) {
targetMember = CliUtil.getDistributedMemberByNameOrId(memberNameOrId);
}
if (targetMember != null) {
ResultCollector<?, ?> rc = CliUtil.executeFunction(getMemberConfigFunction, new Boolean(hideDefaults), targetMember);
ArrayList<?> output = (ArrayList<?>) rc.getResult();
Object obj = output.get(0);
if (obj != null && obj instanceof MemberConfigurationInfo) {
MemberConfigurationInfo memberConfigInfo = (MemberConfigurationInfo) obj;
CompositeResultData crd = ResultBuilder.createCompositeResultData();
crd.setHeader(CliStrings.format(CliStrings.DESCRIBE_CONFIG__HEADER__TEXT, memberNameOrId));
List<String> jvmArgsList = memberConfigInfo.getJvmInputArguments();
TabularResultData jvmInputArgs = crd.addSection().addSection().addTable();
for (String jvmArg : jvmArgsList) {
jvmInputArgs.accumulate("JVM command line arguments", jvmArg);
}
addSection(crd, memberConfigInfo.getGfePropsSetUsingApi(), "GemFire properties defined using the API");
addSection(crd, memberConfigInfo.getGfePropsRuntime(), "GemFire properties defined at the runtime");
addSection(crd, memberConfigInfo.getGfePropsSetFromFile(), "GemFire properties defined with the property file");
addSection(crd, memberConfigInfo.getGfePropsSetWithDefaults(), "GemFire properties using default values");
addSection(crd, memberConfigInfo.getCacheAttributes(), "Cache attributes");
List<Map<String, String>> cacheServerAttributesList = memberConfigInfo.getCacheServerAttributes();
if (cacheServerAttributesList != null && !cacheServerAttributesList.isEmpty()) {
SectionResultData cacheServerSection = crd.addSection();
cacheServerSection.setHeader("Cache-server attributes");
for (Map<String, String> cacheServerAttributes : cacheServerAttributesList) {
addSubSection(cacheServerSection, cacheServerAttributes, "");
}
}
result = ResultBuilder.buildResult(crd);
}
} else {
ErrorResultData erd = ResultBuilder.createErrorResultData();
erd.addLine(CliStrings.format(CliStrings.DESCRIBE_CONFIG__MEMBER__NOT__FOUND, new Object[] { memberNameOrId }));
result = ResultBuilder.buildResult(erd);
}
} catch (FunctionInvocationTargetException e) {
result = ResultBuilder.createGemFireErrorResult(CliStrings.format(CliStrings.COULD_NOT_EXECUTE_COMMAND_TRY_AGAIN, CliStrings.DESCRIBE_CONFIG));
} catch (Exception e) {
ErrorResultData erd = ResultBuilder.createErrorResultData();
erd.addLine(e.getMessage());
result = ResultBuilder.buildResult(erd);
}
return result;
}
use of org.apache.geode.management.internal.cli.domain.MemberConfigurationInfo in project geode by apache.
the class GetMemberConfigInformationFunction method execute.
@Override
public void execute(FunctionContext context) {
Object argsObject = context.getArguments();
boolean hideDefaults = ((Boolean) argsObject).booleanValue();
Cache cache = CacheFactory.getAnyInstance();
InternalDistributedSystem system = (InternalDistributedSystem) cache.getDistributedSystem();
DistributionConfig config = system.getConfig();
DistributionConfigImpl distConfigImpl = ((DistributionConfigImpl) config);
MemberConfigurationInfo memberConfigInfo = new MemberConfigurationInfo();
memberConfigInfo.setJvmInputArguments(getJvmInputArguments());
memberConfigInfo.setGfePropsRuntime(distConfigImpl.getConfigPropsFromSource(ConfigSource.runtime()));
memberConfigInfo.setGfePropsSetUsingApi(distConfigImpl.getConfigPropsFromSource(ConfigSource.api()));
if (!hideDefaults)
memberConfigInfo.setGfePropsSetWithDefaults(distConfigImpl.getConfigPropsFromSource(null));
memberConfigInfo.setGfePropsSetFromFile(distConfigImpl.getConfigPropsDefinedUsingFiles());
// CacheAttributes
Map<String, String> cacheAttributes = new HashMap<String, String>();
cacheAttributes.put("copy-on-read", Boolean.toString(cache.getCopyOnRead()));
cacheAttributes.put("is-server", Boolean.toString(cache.isServer()));
cacheAttributes.put("lock-timeout", Integer.toString(cache.getLockTimeout()));
cacheAttributes.put("lock-lease", Integer.toString(cache.getLockLease()));
cacheAttributes.put("message-sync-interval", Integer.toString(cache.getMessageSyncInterval()));
cacheAttributes.put("search-timeout", Integer.toString(cache.getSearchTimeout()));
if (cache.getPdxDiskStore() == null) {
cacheAttributes.put("pdx-disk-store", "");
} else {
cacheAttributes.put("pdx-disk-store", cache.getPdxDiskStore());
}
cacheAttributes.put("pdx-ignore-unread-fields", Boolean.toString(cache.getPdxIgnoreUnreadFields()));
cacheAttributes.put("pdx-persistent", Boolean.toString(cache.getPdxPersistent()));
cacheAttributes.put("pdx-read-serialized", Boolean.toString(cache.getPdxReadSerialized()));
if (hideDefaults) {
removeDefaults(cacheAttributes, getCacheAttributesDefaultValues());
}
memberConfigInfo.setCacheAttributes(cacheAttributes);
List<Map<String, String>> cacheServerAttributesList = new ArrayList<Map<String, String>>();
List<CacheServer> cacheServers = cache.getCacheServers();
if (cacheServers != null)
for (CacheServer cacheServer : cacheServers) {
Map<String, String> cacheServerAttributes = new HashMap<String, String>();
cacheServerAttributes.put("bind-address", cacheServer.getBindAddress());
cacheServerAttributes.put("hostname-for-clients", cacheServer.getHostnameForClients());
cacheServerAttributes.put("max-connections", Integer.toString(cacheServer.getMaxConnections()));
cacheServerAttributes.put("maximum-message-count", Integer.toString(cacheServer.getMaximumMessageCount()));
cacheServerAttributes.put("maximum-time-between-pings", Integer.toString(cacheServer.getMaximumTimeBetweenPings()));
cacheServerAttributes.put("max-threads", Integer.toString(cacheServer.getMaxThreads()));
cacheServerAttributes.put("message-time-to-live", Integer.toString(cacheServer.getMessageTimeToLive()));
cacheServerAttributes.put("notify-by-subscription", Boolean.toString(cacheServer.getNotifyBySubscription()));
cacheServerAttributes.put("port", Integer.toString(cacheServer.getPort()));
cacheServerAttributes.put(SOCKET_BUFFER_SIZE, Integer.toString(cacheServer.getSocketBufferSize()));
cacheServerAttributes.put("load-poll-interval", Long.toString(cacheServer.getLoadPollInterval()));
cacheServerAttributes.put("tcp-no-delay", Boolean.toString(cacheServer.getTcpNoDelay()));
if (hideDefaults)
removeDefaults(cacheServerAttributes, getCacheServerAttributesDefaultValues());
cacheServerAttributesList.add(cacheServerAttributes);
}
memberConfigInfo.setCacheServerAttributes(cacheServerAttributesList);
context.getResultSender().lastResult(memberConfigInfo);
}
Aggregations