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 });
}
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;
}
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;
}
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;
}
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;
}
Aggregations