use of org.jvnet.hk2.config.types.Property in project Payara by payara.
the class AdminConsoleAdapter method init.
/**
*/
private void init() {
Property locProp = adminService.getProperty(ServerTags.ADMIN_CONSOLE_DOWNLOAD_LOCATION);
if (locProp == null || locProp.getValue() == null || locProp.getValue().equals("")) {
String iRoot = System.getProperty(INSTALL_ROOT) + "/lib/install/applications/admingui.war";
warFile = new File(iRoot.replace('/', File.separatorChar));
writeAdminServiceProp(ServerTags.ADMIN_CONSOLE_DOWNLOAD_LOCATION, "${" + INSTALL_ROOT + "}/lib/install/applications/admingui.war");
} else {
// For any non-absolute path, we start from the installation, ie glassfish4
// eg, v3 prelude upgrade, where the location property was "glassfish/lib..."
String locValue = locProp.getValue();
warFile = new File(locValue);
if (!warFile.isAbsolute()) {
File tmp = new File(System.getProperty(INSTALL_ROOT), "..");
warFile = new File(tmp, locValue);
}
}
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "Admin Console download location: {0}", warFile.getAbsolutePath());
}
initState();
try {
epd = new AdminEndpointDecider(serverConfig);
contextRoot = epd.getGuiContextRoot();
} catch (Exception ex) {
logger.log(Level.INFO, KernelLoggerInfo.consoleCannotInitialize, ex);
return;
}
}
use of org.jvnet.hk2.config.types.Property in project Payara by payara.
the class AdminConsoleStartupService method postConstruct.
@Override
public void postConstruct() {
if (adminConsoleAdapter == null) {
// there may be no console in this environment.
return;
}
/* This service must run only on the server where the console should run. Currently, that server is DAS. If and when
* the console becomes dis-associated with DAS, this logic will need to be modified.
*/
if (!env.isDas())
return;
// FIXME : Use ServerTags, when this is finalized.
Property initProp = adminService.getProperty("adminConsoleStartup");
String initPropVal = "DEFAULT";
if (initProp != null) {
initPropVal = initProp.getValue();
if (!(initPropVal.equals("ALWAYS") || initPropVal.equals("NEVER") || initPropVal.equals("DEFAULT"))) {
initPropVal = "DEFAULT";
}
}
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "AdminConsoleStartupService, console loading option is {0}", initPropVal);
}
if (initPropVal.equalsIgnoreCase("DEFAULT")) {
handleDefault();
} else if (initPropVal.equalsIgnoreCase("ALWAYS")) {
handleHigh();
}
}
use of org.jvnet.hk2.config.types.Property in project Payara by payara.
the class GetHealthCheckConfiguration method execute.
@Override
public void execute(AdminCommandContext context) {
Config config = targetUtil.getConfig(target);
if (config == null) {
context.getActionReport().setMessage("No such config named: " + target);
context.getActionReport().setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
ActionReport mainActionReport = context.getActionReport();
// subReport(0)
ActionReport baseActionReport = mainActionReport.addSubActionsReport();
// subReport(1)
ActionReport hoggingThreadsActionReport = mainActionReport.addSubActionsReport();
// subReport(2)
ActionReport thresholdDiagnosticsActionReport = mainActionReport.addSubActionsReport();
// subReport(3)
ActionReport stuckThreadsActionReport = mainActionReport.addSubActionsReport();
ColumnFormatter baseColumnFormatter = new ColumnFormatter(baseHeaders);
ColumnFormatter hoggingThreadsColumnFormatter = new ColumnFormatter(hoggingThreadsHeaders);
ColumnFormatter stuckThreadsColumnFormatter = new ColumnFormatter(stuckThreadsHeaders);
ColumnFormatter thresholdDiagnosticsColumnFormatter = new ColumnFormatter(thresholdDiagnosticsHeaders);
ColumnFormatter notifiersColumnFormatter = new ColumnFormatter(notifierHeaders);
HealthCheckServiceConfiguration configuration = config.getExtensionByType(HealthCheckServiceConfiguration.class);
List<ServiceHandle<BaseHealthCheck>> allServiceHandles = habitat.getAllServiceHandles(BaseHealthCheck.class);
List<ServiceHandle<BaseNotifierService>> allNotifierServiceHandles = habitat.getAllServiceHandles(BaseNotifierService.class);
mainActionReport.appendMessage("Health Check Service Configuration is enabled?: " + configuration.getEnabled() + "\n");
if (Boolean.parseBoolean(configuration.getEnabled())) {
mainActionReport.appendMessage("Historical Tracing Enabled?: " + configuration.getHistoricalTraceEnabled() + "\n");
if (Boolean.parseBoolean(configuration.getHistoricalTraceEnabled())) {
mainActionReport.appendMessage("Historical Tracing Store Size: " + configuration.getHistoricalTraceStoreSize() + "\n");
}
if (!Strings.isNullOrEmpty(configuration.getHistoricalTraceStoreTimeout())) {
mainActionReport.appendMessage("Health Check Historical Tracing Store Timeout in Seconds: " + configuration.getHistoricalTraceStoreTimeout() + "\n");
}
}
// Create the extraProps map for the general healthcheck configuration
Properties mainExtraProps = new Properties();
Map<String, Object> mainExtraPropsMap = new HashMap<>();
mainExtraPropsMap.put("enabled", configuration.getEnabled());
mainExtraPropsMap.put("historicalTraceEnabled", configuration.getHistoricalTraceEnabled());
mainExtraPropsMap.put("historicalTraceStoreSize", configuration.getHistoricalTraceStoreSize());
mainExtraPropsMap.put("historicalTraceStoreTimeout", configuration.getHistoricalTraceStoreTimeout());
mainExtraProps.put("healthcheckConfiguration", mainExtraPropsMap);
mainActionReport.setExtraProperties(mainExtraProps);
if (!configuration.getNotifierList().isEmpty()) {
List<Class<Notifier>> notifierClassList = Lists.transform(configuration.getNotifierList(), new Function<Notifier, Class<Notifier>>() {
@Override
public Class<Notifier> apply(Notifier input) {
return resolveNotifierClass(input);
}
});
Properties extraProps = new Properties();
for (ServiceHandle<BaseNotifierService> serviceHandle : allNotifierServiceHandles) {
Notifier notifier = configuration.getNotifierByType(serviceHandle.getService().getNotifierType());
if (notifier != null) {
ConfigView view = ConfigSupport.getImpl(notifier);
NotifierConfigurationType annotation = view.getProxyType().getAnnotation(NotifierConfigurationType.class);
if (notifierClassList.contains(view.<Notifier>getProxyType())) {
Object[] values = new Object[2];
values[0] = annotation.type();
values[1] = notifier.getEnabled();
notifiersColumnFormatter.addRow(values);
Map<String, Object> map = new HashMap<>(2);
map.put("notifierName", values[0]);
map.put("notifierEnabled", values[1]);
extraProps.put("notifierList" + annotation.type(), map);
}
}
}
mainActionReport.getExtraProperties().putAll(extraProps);
mainActionReport.appendMessage(notifiersColumnFormatter.toString());
mainActionReport.appendMessage(StringUtils.EOL);
}
mainActionReport.appendMessage("Below are the list of configuration details of each checker listed by its name.");
mainActionReport.appendMessage(StringUtils.EOL);
Properties baseExtraProps = new Properties();
Properties hoggingThreadsExtraProps = new Properties();
Properties stuckThreadsExtrasProps = new Properties();
Properties thresholdDiagnosticsExtraProps = new Properties();
for (ServiceHandle<BaseHealthCheck> serviceHandle : allServiceHandles) {
Checker checker = configuration.getCheckerByType(serviceHandle.getService().getCheckerType());
if (checker instanceof HoggingThreadsChecker) {
HoggingThreadsChecker hoggingThreadsChecker = (HoggingThreadsChecker) checker;
Object[] values = new Object[6];
values[0] = hoggingThreadsChecker.getName();
values[1] = hoggingThreadsChecker.getEnabled();
values[2] = hoggingThreadsChecker.getTime();
values[3] = hoggingThreadsChecker.getUnit();
values[4] = hoggingThreadsChecker.getThresholdPercentage();
values[5] = hoggingThreadsChecker.getRetryCount();
hoggingThreadsColumnFormatter.addRow(values);
// Create the extra props map for a hogging thread checker
addHoggingThreadsCheckerExtraProps(hoggingThreadsExtraProps, hoggingThreadsChecker);
} else if (checker instanceof ThresholdDiagnosticsChecker) {
ThresholdDiagnosticsChecker thresholdDiagnosticsChecker = (ThresholdDiagnosticsChecker) checker;
Object[] values = new Object[7];
values[0] = thresholdDiagnosticsChecker.getName();
values[1] = thresholdDiagnosticsChecker.getEnabled();
values[2] = thresholdDiagnosticsChecker.getTime();
values[3] = thresholdDiagnosticsChecker.getUnit();
Property thresholdCriticalProperty = thresholdDiagnosticsChecker.getProperty(THRESHOLD_CRITICAL);
values[4] = thresholdCriticalProperty != null ? thresholdCriticalProperty.getValue() : "-";
Property thresholdWarningProperty = thresholdDiagnosticsChecker.getProperty(THRESHOLD_WARNING);
values[5] = thresholdWarningProperty != null ? thresholdWarningProperty.getValue() : "-";
Property thresholdGoodProperty = thresholdDiagnosticsChecker.getProperty(THRESHOLD_GOOD);
values[6] = thresholdGoodProperty != null ? thresholdGoodProperty.getValue() : "-";
thresholdDiagnosticsColumnFormatter.addRow(values);
// Create the extra props map for a checker with thresholds
addThresholdDiagnosticsCheckerExtraProps(thresholdDiagnosticsExtraProps, thresholdDiagnosticsChecker);
} else if (checker instanceof StuckThreadsChecker) {
StuckThreadsChecker stuckThreadsChecker = (StuckThreadsChecker) checker;
Object[] values = new Object[6];
values[0] = stuckThreadsChecker.getName();
values[1] = stuckThreadsChecker.getEnabled();
values[2] = stuckThreadsChecker.getTime();
values[3] = stuckThreadsChecker.getUnit();
values[4] = stuckThreadsChecker.getThreshold();
values[5] = stuckThreadsChecker.getThresholdTimeUnit();
stuckThreadsColumnFormatter.addRow(values);
addStuckThreadsCheckerExtrasProps(stuckThreadsExtrasProps, stuckThreadsChecker);
} else if (checker != null) {
Object[] values = new Object[4];
values[0] = checker.getName();
values[1] = checker.getEnabled();
values[2] = checker.getTime();
values[3] = checker.getUnit();
baseColumnFormatter.addRow(values);
// Create the extra props map for a base checker
addBaseCheckerExtraProps(baseExtraProps, checker);
}
}
if (!baseColumnFormatter.getContent().isEmpty()) {
baseActionReport.setMessage(baseColumnFormatter.toString());
baseActionReport.appendMessage(StringUtils.EOL);
}
if (!hoggingThreadsColumnFormatter.getContent().isEmpty()) {
hoggingThreadsActionReport.setMessage(hoggingThreadsColumnFormatter.toString());
hoggingThreadsActionReport.appendMessage(StringUtils.EOL);
}
if (!thresholdDiagnosticsColumnFormatter.getContent().isEmpty()) {
thresholdDiagnosticsActionReport.setMessage(thresholdDiagnosticsColumnFormatter.toString());
thresholdDiagnosticsActionReport.appendMessage(StringUtils.EOL);
}
if (!stuckThreadsColumnFormatter.getContent().isEmpty()) {
stuckThreadsActionReport.setMessage(stuckThreadsColumnFormatter.toString());
stuckThreadsActionReport.appendMessage(StringUtils.EOL);
}
// Populate the extraProps with defaults for any checker that isn't present
baseExtraProps = checkCheckerPropertyPresence(thresholdDiagnosticsExtraProps, garbageCollectorPropertyName);
hoggingThreadsExtraProps = checkCheckerPropertyPresence(hoggingThreadsExtraProps, hoggingThreadsPropertyName);
stuckThreadsExtrasProps = checkCheckerPropertyPresence(stuckThreadsExtrasProps, stuckThreadsPropertyName);
thresholdDiagnosticsExtraProps = checkCheckerPropertyPresence(thresholdDiagnosticsExtraProps, cpuUsagePropertyName);
thresholdDiagnosticsExtraProps = checkCheckerPropertyPresence(thresholdDiagnosticsExtraProps, connectionPoolPropertyName);
thresholdDiagnosticsExtraProps = checkCheckerPropertyPresence(thresholdDiagnosticsExtraProps, heapMemoryUsagePropertyName);
thresholdDiagnosticsExtraProps = checkCheckerPropertyPresence(thresholdDiagnosticsExtraProps, machineMemoryUsagePropertyName);
// Add the extra props to their respective action reports
baseActionReport.setExtraProperties(baseExtraProps);
hoggingThreadsActionReport.setExtraProperties(hoggingThreadsExtraProps);
thresholdDiagnosticsActionReport.setExtraProperties(thresholdDiagnosticsExtraProps);
stuckThreadsActionReport.setExtraProperties(stuckThreadsExtrasProps);
mainActionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of org.jvnet.hk2.config.types.Property in project Payara by payara.
the class GetHealthCheckConfiguration method addThresholdDiagnosticsCheckerExtraProps.
private void addThresholdDiagnosticsCheckerExtraProps(Properties thresholdDiagnosticsExtraProps, ThresholdDiagnosticsChecker thresholdDiagnosticsChecker) {
Map<String, Object> extraPropsMap = new HashMap<>(7);
extraPropsMap.put("checkerName", thresholdDiagnosticsChecker.getName());
extraPropsMap.put("enabled", thresholdDiagnosticsChecker.getEnabled());
extraPropsMap.put("time", thresholdDiagnosticsChecker.getTime());
extraPropsMap.put("unit", thresholdDiagnosticsChecker.getUnit());
if (thresholdDiagnosticsChecker.getProperty(THRESHOLD_CRITICAL) != null) {
extraPropsMap.put("thresholdCritical", thresholdDiagnosticsChecker.getProperty(THRESHOLD_CRITICAL).getValue());
}
if (thresholdDiagnosticsChecker.getProperty(THRESHOLD_WARNING) != null) {
extraPropsMap.put("thresholdWarning", thresholdDiagnosticsChecker.getProperty(THRESHOLD_WARNING).getValue());
}
if (thresholdDiagnosticsChecker.getProperty(THRESHOLD_GOOD) != null) {
extraPropsMap.put("thresholdGood", thresholdDiagnosticsChecker.getProperty(THRESHOLD_GOOD).getValue());
}
// Get the checker type
ConfigView view = ConfigSupport.getImpl(thresholdDiagnosticsChecker);
CheckerConfigurationType annotation = view.getProxyType().getAnnotation(CheckerConfigurationType.class);
// Add the extraPropsMap as a property with a name matching its checker type
switch(annotation.type()) {
case CONNECTION_POOL:
thresholdDiagnosticsExtraProps.put(connectionPoolPropertyName, extraPropsMap);
break;
case CPU_USAGE:
thresholdDiagnosticsExtraProps.put(cpuUsagePropertyName, extraPropsMap);
break;
case GARBAGE_COLLECTOR:
thresholdDiagnosticsExtraProps.put(garbageCollectorPropertyName, extraPropsMap);
break;
case HEAP_MEMORY_USAGE:
thresholdDiagnosticsExtraProps.put(heapMemoryUsagePropertyName, extraPropsMap);
break;
case MACHINE_MEMORY_USAGE:
thresholdDiagnosticsExtraProps.put(machineMemoryUsagePropertyName, extraPropsMap);
break;
case STUCK_THREAD:
thresholdDiagnosticsExtraProps.put(stuckThreadsPropertyName, extraPropsMap);
break;
}
}
use of org.jvnet.hk2.config.types.Property in project Payara by payara.
the class WriteableView method removeNestedElements.
boolean removeNestedElements(Object object) {
InvocationHandler h = Proxy.getInvocationHandler(object);
if (!(h instanceof WriteableView)) {
// h instanceof ConfigView
ConfigBean bean = (ConfigBean) ((ConfigView) h).getMasterView();
h = bean.getWriteableView();
if (h == null) {
ConfigBeanProxy writable;
try {
writable = currentTx.enroll((ConfigBeanProxy) object);
} catch (TransactionFailure e) {
// something is seriously wrong
throw new RuntimeException(e);
}
h = Proxy.getInvocationHandler(writable);
} else {
// so oldValue was already processed
return false;
}
}
WriteableView writableView = (WriteableView) h;
synchronized (writableView) {
writableView.isDeleted = true;
}
boolean removed = false;
for (Property property : writableView.bean.model.elements.values()) {
if (property.isCollection()) {
Object nested = writableView.getter(property, parameterizedType);
ProtectedList list = (ProtectedList) nested;
if (list.size() > 0) {
list.clear();
removed = true;
}
} else if (!property.isLeaf()) {
// Element
Object oldValue = writableView.getter(property, ConfigBeanProxy.class);
if (oldValue != null) {
writableView.setter(property, null, Dom.class);
removed = true;
removeNestedElements(oldValue);
}
}
}
return removed;
}
Aggregations