Search in sources :

Example 1 with InstanceDescriptor

use of fish.payara.micro.data.InstanceDescriptor in project Payara by payara.

the class PayaraMicroImpl method dumpFinalStatus.

private void dumpFinalStatus(long bootTime) {
    // Print instance descriptor
    InstanceDescriptor id = getRuntime().getLocalDescriptor();
    LOGGER.log(Level.INFO, id.toJsonString(showServletMappings));
    // Get Payara Micro endpoints
    StringBuilder sb = new StringBuilder();
    sb.append("\nPayara Micro URLs:\n");
    List<URL> urls = id.getApplicationURLS();
    for (URL url : urls) {
        sb.append(url.toString()).append('\n');
    }
    // Count through applications and add their REST endpoints
    try {
        ListRestEndpointsCommand cmd = gf.getService(ListRestEndpointsCommand.class);
        id.getDeployedApplications().forEach(app -> {
            Map<String, Set<String>> endpoints = null;
            try {
                endpoints = cmd.getEndpointMap(app.getName());
            } catch (IllegalArgumentException ex) {
                // The application has no endpoints
                endpoints = null;
            }
            if (endpoints != null) {
                sb.append("\n'" + app.getName() + "' REST Endpoints:\n");
                endpoints.forEach((path, methods) -> {
                    methods.forEach(method -> {
                        sb.append(method + "\t" + path + "\n");
                    });
                });
            }
        });
    } catch (GlassFishException ex) {
        // Really shouldn't happen, the command catches it's own errors most of the time
        LOGGER.log(Level.SEVERE, "Failed to get REST endpoints for application", ex);
    }
    sb.append("\n");
    // Print out all endpoints
    LOGGER.log(Level.INFO, sb.toString());
    // Print the logo if it's enabled
    if (generateLogo) {
        generateLogo();
    }
    // Print final ready message
    LOGGER.log(Level.INFO, "{0} ready in {1} (ms)", new Object[] { Version.getFullVersion(), bootTime });
}
Also used : InstanceDescriptor(fish.payara.micro.data.InstanceDescriptor) GlassFishException(org.glassfish.embeddable.GlassFishException) Set(java.util.Set) ListRestEndpointsCommand(fish.payara.appserver.rest.endpoints.config.admin.ListRestEndpointsCommand) URL(java.net.URL)

Example 2 with InstanceDescriptor

use of fish.payara.micro.data.InstanceDescriptor in project Payara by payara.

the class PayaraMicroRuntimeImpl method run.

/**
 * Runs a Callable object on specified members of the Payara Micro Cluster
 * Functionally equivalent to the run method on ClusterCommandRunner passing in
 * all cluster members obtained from getClusteredPayaras()
 * @param <T> The Type of the Callable
 * @param members The collection of members to run the callable on
 * @param callable The Callable object to run
 * @return
 */
@Override
public <T extends Serializable> Map<InstanceDescriptor, Future<T>> run(Collection<InstanceDescriptor> members, Callable<T> callable) {
    HashSet<String> memberUUIDs = new HashSet<>(members.size());
    for (InstanceDescriptor member : members) {
        memberUUIDs.add(member.getMemberUUID());
    }
    Map<String, Future<T>> runCallable = instanceService.runCallable(memberUUIDs, callable);
    Map<InstanceDescriptor, Future<T>> result = new HashMap<>(runCallable.size());
    for (String uuid : runCallable.keySet()) {
        InstanceDescriptor id = instanceService.getDescriptor(uuid);
        if (id != null) {
            result.put(id, runCallable.get(uuid));
        }
    }
    return result;
}
Also used : InstanceDescriptor(fish.payara.micro.data.InstanceDescriptor) HashMap(java.util.HashMap) Future(java.util.concurrent.Future) HashSet(java.util.HashSet)

Example 3 with InstanceDescriptor

use of fish.payara.micro.data.InstanceDescriptor in project Payara by payara.

the class PayaraMicroRuntimeImpl method run.

/**
 * Runs an asadmin command on specified  members of the Payara Micro Cluster
 * Functionally equivalent to the run method of the ClusterCommandRunner passing in
 * all cluster members obtained from getClusteredPayaras()
 * @param command The name of the asadmin command to run
 * @param args The parameters to the command
 * @return
 */
@Override
public Map<InstanceDescriptor, Future<? extends ClusterCommandResult>> run(Collection<InstanceDescriptor> members, String command, String... args) {
    HashSet<String> memberUUIDs = new HashSet<>(members.size());
    for (InstanceDescriptor member : members) {
        memberUUIDs.add(member.getMemberUUID());
    }
    Map<String, Future<ClusterCommandResult>> commandResult = instanceService.executeClusteredASAdmin(memberUUIDs, command, args);
    Map<InstanceDescriptor, Future<? extends ClusterCommandResult>> result = new HashMap<>(commandResult.size());
    for (String uuid : commandResult.keySet()) {
        InstanceDescriptor id = instanceService.getDescriptor(uuid);
        if (id != null) {
            result.put(id, commandResult.get(uuid));
        }
    }
    return result;
}
Also used : InstanceDescriptor(fish.payara.micro.data.InstanceDescriptor) ClusterCommandResult(fish.payara.micro.ClusterCommandResult) HashMap(java.util.HashMap) Future(java.util.concurrent.Future) HashSet(java.util.HashSet)

Example 4 with InstanceDescriptor

use of fish.payara.micro.data.InstanceDescriptor in project Payara by payara.

the class PayaraMicroRuntimeImpl method run.

/**
 * Runs a Callable object on all members of the Payara Micro Cluster
 * Functionally equivalent to the run method on ClusterCommandRunner passing in
 * all cluster members obtained from getClusteredPayaras()
 * @param <T> The Type of the Callable
 * @param callable The Callable object to run
 * @return
 */
@Override
public <T extends Serializable> Map<InstanceDescriptor, Future<T>> run(Callable<T> callable) {
    // NEEDS TO HANDLE THE CASE FOR LOCAL RUNNING IF NO CLUSTER ENABLED
    Map<String, Future<T>> runCallable = instanceService.runCallable(callable);
    Map<InstanceDescriptor, Future<T>> result = new HashMap<>(runCallable.size());
    for (String uuid : runCallable.keySet()) {
        InstanceDescriptor id = instanceService.getDescriptor(uuid);
        if (id != null) {
            result.put(id, runCallable.get(uuid));
        }
    }
    return result;
}
Also used : InstanceDescriptor(fish.payara.micro.data.InstanceDescriptor) HashMap(java.util.HashMap) Future(java.util.concurrent.Future)

Example 5 with InstanceDescriptor

use of fish.payara.micro.data.InstanceDescriptor in project Payara by payara.

the class PayaraInstanceImpl method getClusteredPayaras.

@Override
public Set<InstanceDescriptor> getClusteredPayaras() {
    Set<String> members = cluster.getClusterMembers();
    HashSet<InstanceDescriptor> result = new HashSet<>(members.size());
    for (String member : members) {
        InstanceDescriptor id = (InstanceDescriptor) cluster.getClusteredStore().get(INSTANCE_STORE_NAME, member);
        if (id != null) {
            result.add(id);
        }
    }
    return result;
}
Also used : InstanceDescriptor(fish.payara.micro.data.InstanceDescriptor) HashSet(java.util.HashSet)

Aggregations

InstanceDescriptor (fish.payara.micro.data.InstanceDescriptor)10 HashMap (java.util.HashMap)7 Future (java.util.concurrent.Future)5 ClusterCommandResult (fish.payara.micro.ClusterCommandResult)3 HashSet (java.util.HashSet)3 ArrayList (java.util.ArrayList)2 ActionReport (org.glassfish.api.ActionReport)2 ColumnFormatter (com.sun.enterprise.util.ColumnFormatter)1 ListRestEndpointsCommand (fish.payara.appserver.rest.endpoints.config.admin.ListRestEndpointsCommand)1 URL (java.net.URL)1 List (java.util.List)1 Map (java.util.Map)1 Properties (java.util.Properties)1 Set (java.util.Set)1 ExecutionException (java.util.concurrent.ExecutionException)1 GlassFishException (org.glassfish.embeddable.GlassFishException)1