use of com.haulmont.cuba.core.entity.JmxInstance in project cuba by cuba-platform.
the class MbeansDisplayWindow method init.
@Override
public void init(Map<String, Object> params) {
super.init(params);
objectNameField.addValueChangeListener(new ObjectNameFieldListener());
mbeansTable.addAction(new RefreshAction(mbeansTable));
Action inspectAction = new ItemTrackingAction("inspect").withCaption(getMessage("action.inspect")).withHandler(event -> {
Set<ManagedBeanInfo> selected = mbeansTable.getSelected();
if (!selected.isEmpty()) {
ManagedBeanInfo mbi = selected.iterator().next();
if (mbi.getObjectName() != null) {
// otherwise it's a fake root node
Window editor = openEditor("jmxConsoleInspectMbean", mbi, OpenType.THIS_TAB);
editor.addCloseListener(actionId -> {
mbeansTable.requestFocus();
});
} else {
// expand / collapse fake root node
UUID itemId = mbi.getId();
if (mbeansTable.isExpanded(itemId)) {
mbeansTable.collapse(itemId);
} else {
mbeansTable.expand(itemId);
}
}
}
});
mbeansTable.addAction(inspectAction);
mbeansTable.setItemClickAction(inspectAction);
localJmxInstance = jmxControlAPI.getLocalInstance();
jmxInstancesDs.refresh();
jmxConnectionField.setValue(localJmxInstance);
jmxConnectionField.setRequired(true);
jmxConnectionField.addValueChangeListener(e -> {
JmxInstance jmxInstance = (JmxInstance) e.getValue();
try {
mbeanDs.setJmxInstance(jmxInstance);
mbeanDs.refresh();
} catch (JmxControlException ex) {
showNotification(getMessage("unableToConnectToInterface"), NotificationType.WARNING);
if (jmxInstance != localJmxInstance) {
jmxConnectionField.setValue(localJmxInstance);
}
}
});
jmxConnectionField.removeAllActions();
jmxConnectionField.addAction(new PickerField.LookupAction(jmxConnectionField) {
@Override
public void afterCloseLookup(String actionId) {
jmxInstancesDs.refresh();
}
});
jmxConnectionField.addAction(new BaseAction("actions.Add").withIcon("icons/plus-btn.png").withHandler(event -> {
JmxInstanceEditor instanceEditor = (JmxInstanceEditor) openEditor(metadata.create(JmxInstance.class), OpenType.DIALOG);
instanceEditor.addCloseListener(actionId -> {
if (COMMIT_ACTION_ID.equals(actionId)) {
jmxInstancesDs.refresh();
jmxConnectionField.setValue(instanceEditor.getItem());
}
});
}));
mbeanDs.setJmxInstance(localJmxInstance);
mbeanDs.refresh();
localJmxField.setValue(jmxControlAPI.getLocalNodeName());
localJmxField.setEditable(false);
mbeansTable.setStyleProvider((entity, property) -> {
if (entity != null && entity.getObjectName() == null) {
return "c-jmx-tree-table-domain";
}
return null;
});
}
use of com.haulmont.cuba.core.entity.JmxInstance in project cuba by cuba-platform.
the class JmxInstancesDatasource method loadData.
@Override
protected void loadData(Map<String, Object> params) {
String tag = getLoggingTag("CDS");
StopWatch sw = new Slf4JStopWatch(tag, LoggerFactory.getLogger(UIPerformanceLogger.class));
detachListener(data.values());
data.clear();
for (JmxInstance jmxInstance : jmxControlAPI.getInstances()) {
data.put(jmxInstance.getId(), jmxInstance);
attachListener(jmxInstance);
}
sw.stop();
}
use of com.haulmont.cuba.core.entity.JmxInstance in project cuba by cuba-platform.
the class ServerLogWindow method init.
@Override
public void init(Map<String, Object> params) {
localJmxField.setValue(jmxControlAPI.getLocalNodeName());
localJmxField.setEditable(false);
localJmxInstance = jmxControlAPI.getLocalInstance();
jmxInstancesDs.refresh();
jmxConnectionField.setValue(localJmxInstance);
jmxConnectionField.setRequired(true);
jmxConnectionField.addValueChangeListener(e -> {
JmxInstance jmxInstance = (JmxInstance) e.getValue();
try {
refreshHostInfo();
} catch (JmxControlException ex) {
showNotification(getMessage("exception.unableToConnectToInterface"), NotificationType.WARNING);
if (jmxInstance != localJmxInstance) {
jmxConnectionField.setValue(localJmxInstance);
}
}
});
autoRefreshCheck.addValueChangeListener(e -> {
if (Boolean.TRUE.equals(e.getValue())) {
updateLogTailTimer.start();
} else {
updateLogTailTimer.stop();
}
});
jmxConnectionField.removeAllActions();
LookupAction action = LookupAction.create(jmxConnectionField);
action.setAfterLookupCloseHandler((window, actionId) -> {
jmxInstancesDs.refresh();
});
jmxConnectionField.addAction(action);
jmxConnectionField.addAction(new BaseAction("actions.Add").withIcon("icons/plus-btn.png").withHandler(event -> {
JmxInstanceEditor instanceEditor = (JmxInstanceEditor) openEditor(metadata.create(JmxInstance.class), OpenType.DIALOG);
instanceEditor.addCloseListener(actionId -> {
if (COMMIT_ACTION_ID.equals(actionId)) {
jmxInstancesDs.refresh();
jmxConnectionField.setValue(instanceEditor.getItem());
}
});
}));
logTailLabel.setSizeAuto();
logTailLabel.setHtmlEnabled(true);
logTailLabel.setStyleName("c-log-content");
loggerLevelField.setOptionsList(LoggingHelper.getLevels());
appenderLevelField.setOptionsList(LoggingHelper.getLevels());
refreshHostInfo();
loggerNameField.addValueChangeListener(e -> {
List<String> currentLoggers = new ArrayList<>(jmxRemoteLoggingAPI.getLoggerNames(getSelectedConnection()));
Collections.sort(currentLoggers);
currentLoggers.add(0, getMessage("logger.new"));
if (e.getValue() != null && e.getValue().equals(currentLoggers.get(0))) {
openAddLoggerDialog();
}
});
downloadButton.setEnabled(security.isSpecificPermitted("cuba.gui.administration.downloadlogs"));
ComboBox comboBox = logFileNameField.unwrap(ComboBox.class);
comboBox.addShortcutListener(new ShortcutListener("", KeyCode.D, new int[] { ModifierKey.CTRL, ModifierKey.SHIFT }) {
@Override
public void handleAction(Object sender, Object target) {
downloadLog();
}
});
comboBox.addShortcutListener(new ShortcutListener("", KeyCode.S, new int[] { ModifierKey.CTRL, ModifierKey.SHIFT }) {
@Override
public void handleAction(Object sender, Object target) {
showLogTail();
}
});
downloadButton.setDescription("CTRL-SHIFT-D");
showTailButton.setDescription("CTRL-SHIFT-S");
}
use of com.haulmont.cuba.core.entity.JmxInstance in project cuba by cuba-platform.
the class StatisticsDatasource method loadData.
@Override
protected void loadData(Map<String, Object> params) {
JmxInstance node = (JmxInstance) params.get("node");
if (node != this.node) {
mwStatCounter = null;
webStatCounter = null;
}
this.node = node;
this.refreshPeriod = (int) params.get("refreshPeriod");
if (mwStatCounter == null)
mwStatCounter = new StatCounter(true);
if (webStatCounter == null)
webStatCounter = new StatCounter(false);
if (data.isEmpty()) {
initParameters();
}
loadCurrentValues();
// attachListeners is called in getParameter.
}
use of com.haulmont.cuba.core.entity.JmxInstance in project cuba by cuba-platform.
the class StatisticsWindow method initJMXTable.
protected void initJMXTable() {
localJmxInstance = jmxControlAPI.getLocalInstance();
jmxInstancesDs.refresh();
jmxConnectionField.setValue(localJmxInstance);
jmxConnectionField.setRequired(true);
jmxConnectionField.addValueChangeListener(e -> {
try {
setNode(jmxConnectionField.getValue());
} catch (JmxControlException ex) {
JmxInstance jmxInstance = jmxConnectionField.getValue();
showNotification(messages.getMessage("com.haulmont.cuba.web.app.ui.jmxcontrol", "unableToConnectToInterface"), NotificationType.WARNING);
if (jmxInstance != localJmxInstance) {
jmxConnectionField.setValue(localJmxInstance);
}
}
});
jmxConnectionField.removeAllActions();
jmxConnectionField.addAction(new PickerField.LookupAction(jmxConnectionField) {
@Override
public void afterCloseLookup(String actionId) {
jmxInstancesDs.refresh();
}
});
jmxConnectionField.addAction(new BaseAction("actions.Add").withIcon("icons/plus-btn.png").withHandler(event -> {
JmxInstanceEditor instanceEditor = (JmxInstanceEditor) openEditor(metadata.create(JmxInstance.class), OpenType.DIALOG);
instanceEditor.addCloseWithCommitListener(() -> {
jmxInstancesDs.refresh();
jmxConnectionField.setValue(instanceEditor.getItem());
});
}));
localNodeLab.setValue(jmxControlAPI.getLocalNodeName());
localNodeLab.setEditable(false);
}
Aggregations