Skip to content

Commit

Permalink
Cleanup of JMX->REST replacement (MID-5058)
Browse files Browse the repository at this point in the history
All components are in now place and finished. Implemented auto-detection
of intra-cluster HTTP URL. Remaining traces of JMX were hidden.
  • Loading branch information
mederly committed Feb 5, 2019
1 parent 7951452 commit d2f43ac
Show file tree
Hide file tree
Showing 11 changed files with 254 additions and 120 deletions.
Expand Up @@ -358,42 +358,36 @@ public int getRefreshInterval() {
private List<IColumn<NodeDto, String>> initNodeColumns() {
List<IColumn<NodeDto, String>> columns = new ArrayList<>();

IColumn column = new CheckBoxHeaderColumn<>();
IColumn<NodeDto, String> column = new CheckBoxHeaderColumn<>();
columns.add(column);

column = new PropertyColumn<>(createStringResource("pageTasks.node.name"), "name", "name");
column = new PropertyColumn<>(createStringResource("pageTasks.node.name"), NodeDto.F_NAME, NodeDto.F_NAME);
columns.add(column);

columns.add(new EnumPropertyColumn<NodeDto>(createStringResource("pageTasks.node.executionStatus"),
"executionStatus") {
NodeDto.F_EXECUTION_STATUS) {

@Override
protected String translate(Enum en) {
return createStringResource(en).getString();
}
});

columns.add(new PropertyColumn(createStringResource("pageTasks.node.managementPort"), "managementPort"));
columns.add(new PropertyColumn<>(createStringResource("pageTasks.node.contact"), NodeDto.F_CONTACT));
columns.add(new AbstractColumn<NodeDto, String>(createStringResource("pageTasks.node.lastCheckInTime")) {

@Override
public void populateItem(Item<ICellPopulator<NodeDto>> item, String componentId,
final IModel<NodeDto> rowModel) {
item.add(new Label(componentId, new IModel<Object>() {

@Override
public Object getObject() {
return getLastCheckInTime(rowModel);
}
}));
item.add(new Label(componentId, (IModel<Object>) () -> getLastCheckInTime(rowModel)));
}
});
CheckBoxColumn check = new CheckBoxColumn(createStringResource("pageTasks.node.clustered"), "clustered");
CheckBoxColumn<NodeDto> check = new CheckBoxColumn<>(createStringResource("pageTasks.node.clustered"), NodeDto.F_CLUSTERED);
check.setEnabled(false);
columns.add(check);
columns.add(new PropertyColumn(createStringResource("pageTasks.node.statusMessage"), "statusMessage"));
columns.add(new PropertyColumn<>(createStringResource("pageTasks.node.statusMessage"), NodeDto.F_STATUS_MESSAGE));

IColumn<NodeDto, String> menuColumn = new InlineMenuButtonColumn<NodeDto>(createNodesInlineMenu(), PageTasks.this);
IColumn<NodeDto, String> menuColumn = new InlineMenuButtonColumn<>(createNodesInlineMenu(), PageTasks.this);
columns.add(menuColumn);

return columns;
Expand Down
Expand Up @@ -38,10 +38,15 @@
*/
public class NodeDto extends Selectable implements InlineMenuable {

public static final String F_CONTACT = "contact";
public static final String F_NAME = "name";
public static final String F_EXECUTION_STATUS = "executionStatus";
public static final String F_CLUSTERED = "clustered";
public static final String F_STATUS_MESSAGE = "statusMessage";
private String oid;
private String name;
private String nodeIdentifier;
private String managementPort;
private String contact;
private Long lastCheckInTime;
private boolean clustered;

Expand All @@ -65,7 +70,7 @@ public NodeDto(NodeType node) {

nodeIdentifier = node.getNodeIdentifier();
clustered = node.isClustered();
managementPort = node.getHostname() + ":" + node.getJmxPort();
contact = node.getUrl() != null ? node.getUrl() : node.getHostname();

executionStatus = node.getExecutionStatus();
errorStatus = node.getErrorStatus();
Expand Down Expand Up @@ -122,8 +127,8 @@ public NodeExecutionStatusType getExecutionStatus() {
return executionStatus;
}

public String getManagementPort() {
return managementPort;
public String getContact() {
return contact;
}

public static List<String> getNodeIdentifiers(List<NodeDto> nodeDtoList) {
Expand Down
Expand Up @@ -61,7 +61,6 @@
import com.evolveum.midpoint.wf.api.WorkflowManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.DeploymentInformationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.io.IOUtils;
import org.apache.wicket.*;
Expand Down Expand Up @@ -98,6 +97,7 @@
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.security.web.csrf.CsrfToken;

import javax.servlet.ServletContext;
import java.io.*;
import java.net.URI;
import java.net.URL;
Expand Down Expand Up @@ -320,6 +320,11 @@ public void updateAjaxAttributes(AbstractDefaultAjaxBehavior behavior, AjaxReque

// for schrodinger selenide library
initializeSchrodinger();

ServletContext servletContext = getServletContext();
if (servletContext != null) {
taskManager.setWebContextPath(servletContext.getContextPath());
}
}

public DeploymentInformationType getDeploymentInfo() {
Expand Down
Expand Up @@ -2357,7 +2357,7 @@ pageTasks.message.noTaskSelected=No task has been selected.
pageTasks.node.clustered=Clustered
pageTasks.node.executionStatus=Status
pageTasks.node.lastCheckInTime=Last check-in time
pageTasks.node.managementPort=Management port
pageTasks.node.contact=Contact
pageTasks.node.name=Name
pageTasks.nodes=Nodes
pageTasks.node.statusMessage=Status message
Expand Down
Expand Up @@ -31,10 +31,13 @@ public interface MidpointConfiguration {
String MIDPOINT_LOGGING_ALT_PREFIX_PROPERTY = "midpoint.logging.alt.prefix";
String MIDPOINT_NODE_ID_PROPERTY = "midpoint.nodeId";
String MIDPOINT_NODE_ID_SOURCE_PROPERTY = "midpoint.nodeIdSource";
@Deprecated String MIDPOINT_JMX_HOST_NAME_PROPERTY = "midpoint.jmxHostName";
String MIDPOINT_URL_PROPERTY = "midpoint.url";
String MIDPOINT_HOST_NAME_PROPERTY = "midpoint.hostName";
String MIDPOINT_HTTP_PORT_PROPERTY = "midpoint.httpPort";

// TODO read these from the MidpointConfiguration instead of system properties.
// It will provide greater flexibility, as the administrator will be able to set them permanently in config.xml.
String MIDPOINT_JMX_HOST_NAME_PROPERTY = "midpoint.jmxHostName";
String MIDPOINT_SCHRODINGER_PROPERTY = "midpoint.schrodinger";

// names of configuration sections
Expand Down
Expand Up @@ -1997,37 +1997,42 @@
<xsd:element name="url" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
URL of midPoint that can be used by other nodes to contact this node over the
network. It is manually configured. If not present, it is automatically derived by
infrastructure/intraClusterHttpUrlPattern system configuration property.

Use only if really necessary. Support for this item is currently limited
to clusterwide cache invalidation and managing node task scheduler.
URL of midPoint that can be used by other nodes to contact this node over the network.
It is either provided manually (see urlOverride), constructed using
infrastructure/intraClusterHttpUrlPattern configuration property, or determined
automatically.
</xsd:documentation>
<xsd:appinfo>
<a:since>3.9</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="ipAddress" type="xsd:string" minOccurs="0" maxOccurs="unbounded">
<xsd:element name="urlOverride" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
IP addresses of the node (both IPv4 and IPv6 addresses in textual notation)
Value to override constructed or determined URL.
</xsd:documentation>
<xsd:appinfo>
<a:since>4.0</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="restPort" type="xsd:int" minOccurs="0">
<xsd:element name="ipAddress" type="xsd:string" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Port at which this node can be contacted via REST.
IP addresses of the node (both IPv4 and IPv6 addresses in textual notation)
</xsd:documentation>
<xsd:appinfo>
<a:since>4.0</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="jmxPort" type="xsd:int" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Port at which this node can be contacted via JMX.
</xsd:documentation>
<xsd:appinfo>
<a:deprecated>true</a:deprecated>
<a:deprecatedSince>4.0</a:deprecatedSince>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="lastCheckInTime" type="xsd:dateTime" minOccurs="0">
Expand Down
Expand Up @@ -711,4 +711,9 @@ ObjectQuery narrowQueryForWorkBucket(ObjectQuery query, Class<? extends ObjectTy
* To be used for demonstration/testing only. Avoid using in production environments.
*/
boolean isLocalNodeClusteringEnabled();

/**
* EXPERIMENTAL. Used to provide midPoint URL path (typically "/midpoint") when determined by the web layer.
*/
void setWebContextPath(String path);
}
Expand Up @@ -51,6 +51,7 @@
*
* @author Pavol Mederly
*/
@SuppressWarnings("DeprecatedIsStillUsed")
@Component
public class TaskManagerConfiguration {

Expand All @@ -69,15 +70,13 @@ public class TaskManagerConfiguration {
private static final String CREATE_QUARTZ_TABLES_CONFIG_ENTRY = "createQuartzTables";
private static final String JDBC_DRIVER_DELEGATE_CLASS_CONFIG_ENTRY = "jdbcDriverDelegateClass";
private static final String USE_THREAD_INTERRUPT_CONFIG_ENTRY = "useThreadInterrupt";
private static final String JMX_CONNECT_TIMEOUT_CONFIG_ENTRY = "jmxConnectTimeout";
@Deprecated private static final String JMX_CONNECT_TIMEOUT_CONFIG_ENTRY = "jmxConnectTimeout";
private static final String QUARTZ_NODE_REGISTRATION_INTERVAL_CONFIG_ENTRY = "quartzNodeRegistrationInterval";
private static final String NODE_REGISTRATION_INTERVAL_CONFIG_ENTRY = "nodeRegistrationInterval";
private static final String NODE_TIMEOUT_CONFIG_ENTRY = "nodeTimeout";
private static final String DEFAULT_URL_CONFIG_ENTRY = "defaultUrl";
private static final String DEFAULT_REST_PORT_CONFIG_ENTRY = "defaultRestPort";
private static final String USE_JMX_CONFIG_ENTRY = "useJmx";
private static final String JMX_USERNAME_CONFIG_ENTRY = "jmxUsername";
private static final String JMX_PASSWORD_CONFIG_ENTRY = "jmxPassword";
@Deprecated private static final String JMX_USERNAME_CONFIG_ENTRY = "jmxUsername";
@Deprecated private static final String JMX_PASSWORD_CONFIG_ENTRY = "jmxPassword";
private static final String TEST_MODE_CONFIG_ENTRY = "testMode";
private static final String WAITING_TASKS_CHECK_INTERVAL_CONFIG_ENTRY = "waitingTasksCheckInterval";
private static final String STALLED_TASKS_CHECK_INTERVAL_CONFIG_ENTRY = "stalledTasksCheckInterval";
Expand All @@ -95,23 +94,23 @@ public class TaskManagerConfiguration {
private static final String WORK_ALLOCATION_INITIAL_DELAY_ENTRY = "workAllocationInitialDelay";
private static final String WORK_ALLOCATION_DEFAULT_FREE_BUCKET_WAIT_INTERVAL_ENTRY = "workAllocationDefaultFreeBucketWaitInterval";

private static final String JMX_PORT_PROPERTY = "com.sun.management.jmxremote.port";
@Deprecated private static final String JMX_PORT_PROPERTY = "com.sun.management.jmxremote.port";
private static final String SUREFIRE_PRESENCE_PROPERTY = "surefire.real.class.path";

private static final boolean STOP_ON_INITIALIZATION_FAILURE_DEFAULT = true;
private static final int THREADS_DEFAULT = 10;
private static final boolean CLUSTERED_DEFAULT = false; // do not change this value!
private static final boolean CREATE_QUARTZ_TABLES_DEFAULT = true;
private static final String NODE_ID_DEFAULT = "DefaultNode";
private static final int JMX_PORT_DEFAULT = 20001;
private static final int JMX_CONNECT_TIMEOUT_DEFAULT = 5;
@Deprecated private static final int JMX_PORT_DEFAULT = 20001;
@Deprecated private static final int JMX_CONNECT_TIMEOUT_DEFAULT = 5;
private static final String USE_THREAD_INTERRUPT_DEFAULT = "whenNecessary";
private static final int QUARTZ_NODE_REGISTRATION_CYCLE_TIME_DEFAULT = 10;
private static final int NODE_REGISTRATION_CYCLE_TIME_DEFAULT = 10;
private static final int NODE_TIMEOUT_DEFAULT = 30;
private static final boolean USE_JMX_DEFAULT = false;
private static final String JMX_USERNAME_DEFAULT = "midpoint";
private static final String JMX_PASSWORD_DEFAULT = "secret";
@Deprecated private static final String JMX_USERNAME_DEFAULT = "midpoint";
@Deprecated private static final String JMX_PASSWORD_DEFAULT = "secret";
private static final int WAITING_TASKS_CHECK_INTERVAL_DEFAULT = 600;
private static final int STALLED_TASKS_CHECK_INTERVAL_DEFAULT = 600;
private static final int STALLED_TASKS_THRESHOLD_DEFAULT = 600; // if a task does not advance its progress for 10 minutes, it is considered stalled
Expand All @@ -132,11 +131,13 @@ public class TaskManagerConfiguration {
private boolean jdbcJobStore;
private boolean clustered;
private String nodeId;
private String defaultUrl;
private Integer defaultRestPort;
private String jmxHostName;
private int jmxPort;
private int jmxConnectTimeout;
private String url;
private String hostName;
private Integer httpPort;

@Deprecated private String jmxHostName;
@Deprecated private int jmxPort;
@Deprecated private int jmxConnectTimeout;
private int quartzNodeRegistrationCycleTime; // UNUSED (currently) !
private int nodeRegistrationCycleTime, nodeTimeout;
private UseThreadInterrupt useThreadInterrupt;
Expand All @@ -157,8 +158,8 @@ public class TaskManagerConfiguration {

private boolean useJmx;
// JMX credentials for connecting to remote nodes
private String jmxUsername;
private String jmxPassword;
@Deprecated private String jmxUsername;
@Deprecated private String jmxPassword;

// quartz jdbc job store specific information
private String sqlSchemaFile;
Expand Down Expand Up @@ -209,8 +210,6 @@ public class TaskManagerConfiguration {
QUARTZ_NODE_REGISTRATION_INTERVAL_CONFIG_ENTRY,
NODE_REGISTRATION_INTERVAL_CONFIG_ENTRY,
NODE_TIMEOUT_CONFIG_ENTRY,
DEFAULT_URL_CONFIG_ENTRY,
DEFAULT_REST_PORT_CONFIG_ENTRY,
USE_JMX_CONFIG_ENTRY,
JMX_USERNAME_CONFIG_ENTRY,
JMX_PASSWORD_CONFIG_ENTRY,
Expand Down Expand Up @@ -276,18 +275,21 @@ void setBasicInformation(MidpointConfiguration masterConfig) throws TaskManagerC
}
}

jmxHostName = System.getProperty(MidpointConfiguration.MIDPOINT_JMX_HOST_NAME_PROPERTY);
hostName = root.getString(MidpointConfiguration.MIDPOINT_HOST_NAME_PROPERTY, null);
jmxHostName = root.getString(MidpointConfiguration.MIDPOINT_JMX_HOST_NAME_PROPERTY, null);

String portString = System.getProperty(JMX_PORT_PROPERTY);
if (StringUtils.isEmpty(portString)) {
String jmxPortString = System.getProperty(JMX_PORT_PROPERTY);
if (StringUtils.isEmpty(jmxPortString)) {
jmxPort = JMX_PORT_DEFAULT;
} else {
try {
jmxPort = Integer.parseInt(portString);
jmxPort = Integer.parseInt(jmxPortString);
} catch(NumberFormatException nfe) {
throw new TaskManagerConfigurationException("Cannot get JMX management port - invalid integer value of " + portString, nfe);
throw new TaskManagerConfigurationException("Cannot get JMX management port - invalid integer value of " + jmxPortString, nfe);
}
}
httpPort = root.getInteger(MidpointConfiguration.MIDPOINT_HTTP_PORT_PROPERTY, null);
url = root.getString(MidpointConfiguration.MIDPOINT_URL_PROPERTY, null);

jmxConnectTimeout = c.getInt(JMX_CONNECT_TIMEOUT_CONFIG_ENTRY, JMX_CONNECT_TIMEOUT_DEFAULT);

Expand Down Expand Up @@ -317,8 +319,6 @@ void setBasicInformation(MidpointConfiguration masterConfig) throws TaskManagerC
nodeRegistrationCycleTime = c.getInt(NODE_REGISTRATION_INTERVAL_CONFIG_ENTRY, NODE_REGISTRATION_CYCLE_TIME_DEFAULT);
nodeTimeout = c.getInt(NODE_TIMEOUT_CONFIG_ENTRY, NODE_TIMEOUT_DEFAULT);

defaultUrl = c.getString(DEFAULT_URL_CONFIG_ENTRY, null);
defaultRestPort = c.getInteger(DEFAULT_REST_PORT_CONFIG_ENTRY, null);
useJmx = c.getBoolean(USE_JMX_CONFIG_ENTRY, USE_JMX_DEFAULT);
jmxUsername = c.getString(JMX_USERNAME_CONFIG_ENTRY, JMX_USERNAME_DEFAULT);
jmxPassword = c.getString(JMX_PASSWORD_CONFIG_ENTRY, JMX_PASSWORD_DEFAULT);
Expand Down Expand Up @@ -568,12 +568,16 @@ public int getQuartzNodeRegistrationCycleTime() {
return quartzNodeRegistrationCycleTime;
}

public String getDefaultUrl() {
return defaultUrl;
public String getUrl() {
return url;
}

public Integer getHttpPort() {
return httpPort;
}

public Integer getDefaultRestPort() {
return defaultRestPort;
public String getHostName() {
return hostName;
}

public boolean isUseJmx() {
Expand Down

0 comments on commit d2f43ac

Please sign in to comment.