use of org.infinispan.cli.resources.ContainerResource in project infinispan by infinispan.
the class RestConnection method refreshServerInfo.
@Override
public void refreshServerInfo() throws IOException {
try {
ContainerResource container = getActiveContainer();
String containerName = container.getName();
Map cacheManagerInfo = parseBody(fetch(() -> client.cacheManager(containerName).info()), Map.class);
List<Map<String, Object>> definedCaches = (List<Map<String, Object>>) cacheManagerInfo.get("defined_caches");
availableCaches = new ArrayList<>();
definedCaches.forEach(m -> availableCaches.add((String) m.get("name")));
availableCaches.remove(PROTOBUF_METADATA_CACHE_NAME);
List configurationList = parseBody(fetch(() -> client.cacheManager(containerName).cacheConfigurations()), List.class);
availableConfigurations = new ArrayList<>(configurationList.size());
for (Object item : configurationList) {
availableConfigurations.add(((Map<String, String>) item).get("name"));
}
String nodeAddress = (String) cacheManagerInfo.get("node_address");
String clusterName = (String) cacheManagerInfo.get("cluster_name");
localSite = (String) cacheManagerInfo.get("local_site");
sitesView = new ArrayList<>((Collection<String>) cacheManagerInfo.get("sites_view"));
Collections.sort(sitesView);
relayNode = cacheManagerInfo.containsKey("relay_node") ? (boolean) cacheManagerInfo.get("relay_node") : false;
relayNodes = (List<String>) cacheManagerInfo.get("relay_nodes_address");
clusterMembers = (Collection<String>) cacheManagerInfo.get("cluster_members");
if (nodeAddress != null) {
serverInfo = nodeAddress + "@" + clusterName;
} else {
ServerConfiguration serverConfiguration = client.getConfiguration().servers().get(0);
serverInfo = serverConfiguration.host() + ":" + serverConfiguration.port();
}
} catch (IllegalStateException e) {
// Cannot refresh if there is no container selected
}
}
use of org.infinispan.cli.resources.ContainerResource in project infinispan by infinispan.
the class SchemaCompleter method getAvailableItems.
@Override
Collection<String> getAvailableItems(Context context) throws IOException {
Connection connection = context.getConnection();
ContainerResource container = connection.getActiveResource().findAncestor(ContainerResource.class);
return container != null ? connection.getAvailableSchemas(container.getName()) : Collections.emptyList();
}
use of org.infinispan.cli.resources.ContainerResource in project infinispan by infinispan.
the class CounterCompleter method getAvailableItems.
@Override
Collection<String> getAvailableItems(Context context) throws IOException {
Connection connection = context.getConnection();
ContainerResource container = connection.getActiveResource().findAncestor(ContainerResource.class);
return container != null ? connection.getAvailableCounters(container.getName()) : Collections.emptyList();
}
Aggregations