use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class IiopFolbGmsClient method getClusterInstanceInfo.
// For addMember.
private ClusterInstanceInfo getClusterInstanceInfo(String instanceName) {
fineLog("getClusterInstanceInfo: instanceName {0}", instanceName);
final Servers servers = services.getService(Servers.class);
fineLog("getClusterInstanceInfo: servers {0}", servers);
final Server server = servers.getServer(instanceName);
fineLog("getClusterInstanceInfo: server {0}", server);
final Config config = getConfigForServer(server);
fineLog("getClusterInstanceInfo: servers {0}", servers);
// assumeInstanceIsRunning is set to true since this is
// coming from addMember, because shoal just told us that the instance is up.
ClusterInstanceInfo result = getClusterInstanceInfo(server, config, true);
fineLog("getClusterInstanceInfo: result {0}", result);
return result;
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class OSGIConsoleHandlers method getConsoleUrl.
@Handler(id = "getConsoleUrl", input = { @HandlerInput(name = "instanceName", type = String.class, required = true) }, output = { @HandlerOutput(name = "consoleUrl", type = String.class) })
public static void getConsoleUrl(HandlerContext handlerCtx) {
String instanceName = (String) handlerCtx.getInputValue("instanceName");
Domain domain = Globals.get(Domain.class);
Server server = domain.getServerNamed(instanceName);
String port = null;
SystemProperty httpPort = server.getSystemProperty(http_port);
if (httpPort != null) {
port = httpPort.getValue();
} else {
// if port is not set as system property, get it from config
Config cfg = server.getConfig();
SystemProperty httpConfigPort = cfg.getSystemProperty(http_port);
if (httpConfigPort != null) {
port = httpConfigPort.getValue();
}
}
if (port == null) {
throw new RuntimeException("Not able to get HTTP_LISTENER_PORT " + "for instance : " + instanceName);
}
Node node = domain.getNodeNamed(server.getNodeRef());
String host = node.getNodeHost();
String consoleUrl = "http://" + host + ":" + port + consolePath;
handlerCtx.setOutputValue("consoleUrl", consoleUrl);
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class MigrateTimers method validateDG.
private String validateDG() {
List<DeploymentGroup> dgs = targetUtil.getDGForInstance(fromServer);
if (dgs == null) {
return localStrings.getString("migrate.timers.fromServerNotDG", fromServer);
}
// in the same cluster as fromServer
if (target.equals(SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME)) {
List<Server> instances = dgs.get(0).getInstances();
for (Server instance : instances) {
if (instance.isRunning() && !instance.getName().equals(fromServer)) {
target = instance.getName();
needRedirect = true;
}
}
// if destination is still DAS, that means no running server is available
if (target.equals(SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME)) {
return localStrings.getString("migrate.timers.noRunningInstanceToChoose", target);
}
} else {
// verify fromServer and destinationServer are in the same dg, and
boolean inSameDG = false;
for (DeploymentGroup dg : dgs) {
for (Server instance : dg.getInstances()) {
if (instance.getName().equals(target)) {
inSameDG = true;
break;
}
}
}
if (!inSameDG) {
return localStrings.getString("migrate.timers.destinationIsNotInDG", target);
}
// verify destinationServer is running
if (!isServerRunning(target)) {
return localStrings.getString("migrate.timers.destinationServerIsNotAlive", target);
}
}
return null;
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class MicroProfileHealthChecker method pingAllInstances.
/**
* Pings MP health check endpoint of all instances and returns a map containing a {@link Future} returning the ping
* status code for that instance. Any exceptions thrown in the process will raise a {@link ExecutionException} when
* the {@link Future} is resolved.
*/
private Map<String, Future<Integer>> pingAllInstances(long timeoutMillis) {
Map<String, Future<Integer>> tasks = new ConcurrentHashMap<>();
Map<UUID, Future<ClusterCommandResult>> configs = payaraMicro.executeClusteredASAdmin(GET_MP_CONFIG_STRING);
for (Server server : domain.getServers().getServer()) {
@Pattern(regexp = "[A-Za-z0-9_][A-Za-z0-9\\-_\\.;]*", message = "{server.invalid.name}", payload = Server.class) String instanceName = server.getName();
tasks.put(instanceName, payaraExecutorService.submit(() -> {
// get the remote server's MP HealthCheck config
MicroprofileHealthCheckConfiguration healthCheckConfig = server.getConfig().getExtensionByType(MicroprofileHealthCheckConfiguration.class);
if (healthCheckConfig != null && Boolean.valueOf(healthCheckConfig.getEnabled())) {
return pingHealthEndpoint(buildURI(server, healthCheckConfig.getEndpoint()));
}
return -1;
}));
}
for (InstanceDescriptor instance : payaraMicro.getClusteredPayaras()) {
String instanceName = instance.getInstanceName();
if (tasks.containsKey(instanceName)) {
continue;
}
tasks.put(instanceName, payaraExecutorService.submit(() -> {
ClusterCommandResult mpHealthConfigResult = //
configs.get(instance.getMemberUUID()).get(timeoutMillis, MILLISECONDS);
String values = mpHealthConfigResult.getOutput().split("\n")[1];
Boolean enabled = Boolean.parseBoolean(values.split(" ")[0]);
if (enabled) {
String endpoint = values.split(" ", 2)[1].trim();
return pingHealthEndpoint(buildURI(instance, endpoint));
}
return -1;
}));
}
return tasks;
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class ListTimers method execute.
/**
* Executes the command
*
* @param context information
*/
@Override
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
String[] serverIds = null;
if (targetUtil.isCluster(target) || targetUtil.isDeploymentGroup(target)) {
List<Server> serversInCluster = targetUtil.getInstances(target);
serverIds = new String[serversInCluster.size()];
for (int i = 0; i < serverIds.length; i++) {
serverIds[i] = serversInCluster.get(i).getName();
}
} else {
serverIds = new String[] { target };
}
try {
String[] timerCounts = listTimers(serverIds);
ActionReport actionReport = context.getActionReport();
Properties extraProperties = actionReport.getExtraProperties();
if (extraProperties == null) {
extraProperties = new Properties();
actionReport.setExtraProperties(extraProperties);
}
List<Map<String, String>> property = new LinkedList<>();
extraProperties.put("ejbTimers", property);
for (int i = 0; i < serverIds.length; i++) {
final ActionReport.MessagePart part = report.getTopMessagePart().addChild();
part.setMessage(serverIds[i] + ": " + timerCounts[i]);
HashMap<String, String> values = new HashMap<>();
values.put("server", serverIds[i]);
values.put("timerCount", timerCounts[i]);
property.add(values);
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
} catch (Exception e) {
report.setMessage(localStrings.getLocalString("list.timers.failed", "List Timers command failed"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
}
}
Aggregations