Search in sources :

Example 1 with Connection

use of org.infinispan.cli.connection.Connection in project infinispan by infinispan.

the class Ls method exec.

@Override
public CommandResult exec(ContextAwareCommandInvocation invocation) throws CommandException {
    try {
        Connection connection = invocation.getContext().getConnection();
        connection.refreshServerInfo();
        Resource resource = connection.getActiveResource().getResource(path);
        for (String item : resource.getChildrenNames()) {
            invocation.println(item);
        }
        return CommandResult.SUCCESS;
    } catch (IOException e) {
        throw new CommandException(e);
    }
}
Also used : Connection(org.infinispan.cli.connection.Connection) Resource(org.infinispan.cli.resources.Resource) IOException(java.io.IOException) CommandException(org.aesh.command.CommandException)

Example 2 with Connection

use of org.infinispan.cli.connection.Connection in project infinispan by infinispan.

the class BackupCompleter method getAvailableItems.

@Override
Collection<String> getAvailableItems(Context context) throws IOException {
    Connection connection = context.getConnection();
    String container = connection.getActiveContainer().getName();
    return context.getConnection().getBackupNames(container);
}
Also used : Connection(org.infinispan.cli.connection.Connection)

Example 3 with Connection

use of org.infinispan.cli.connection.Connection in project infinispan by infinispan.

the class SiteCompleter method getAvailableItems.

@Override
protected Collection<String> getAvailableItems(ContextAwareCompleterInvocation invocation) throws IOException {
    Context context = invocation.context;
    Command<?> cmd = invocation.getCommand();
    Connection connection = context.getConnection();
    Optional<String> cacheName = getCacheName(context, cmd);
    return cacheName.map(name -> getAvailableSites(connection, name)).orElseGet(connection::getSitesView);
}
Also used : Context(org.infinispan.cli.Context) CacheCompleter.getCacheName(org.infinispan.cli.completers.CacheCompleter.getCacheName) Context(org.infinispan.cli.Context) Collection(java.util.Collection) Optional(java.util.Optional) IOException(java.io.IOException) Connection(org.infinispan.cli.connection.Connection) Collections(java.util.Collections) Command(org.aesh.command.Command) Connection(org.infinispan.cli.connection.Connection)

Example 4 with Connection

use of org.infinispan.cli.connection.Connection 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();
}
Also used : ContainerResource(org.infinispan.cli.resources.ContainerResource) Connection(org.infinispan.cli.connection.Connection)

Example 5 with Connection

use of org.infinispan.cli.connection.Connection 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();
}
Also used : ContainerResource(org.infinispan.cli.resources.ContainerResource) Connection(org.infinispan.cli.connection.Connection)

Aggregations

Connection (org.infinispan.cli.connection.Connection)5 IOException (java.io.IOException)2 ContainerResource (org.infinispan.cli.resources.ContainerResource)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Optional (java.util.Optional)1 Command (org.aesh.command.Command)1 CommandException (org.aesh.command.CommandException)1 Context (org.infinispan.cli.Context)1 CacheCompleter.getCacheName (org.infinispan.cli.completers.CacheCompleter.getCacheName)1 Resource (org.infinispan.cli.resources.Resource)1