Skip to content

Commit

Permalink
Node-sticky tasks: thread limits per node and task group (using quart…
Browse files Browse the repository at this point in the history
…z 2.3.0.e2)
  • Loading branch information
mederly committed Aug 23, 2017
1 parent a95ad5d commit 423aa83
Show file tree
Hide file tree
Showing 33 changed files with 440 additions and 224 deletions.
2 changes: 1 addition & 1 deletion build-system/pom.xml
Expand Up @@ -59,7 +59,7 @@
<junit.version>4.8.2</junit.version>
<opendj.version>2.6.2</opendj.version>
<mockito.version>1.10.8</mockito.version>
<quartz.version>2.3.0.e1</quartz.version>
<quartz.version>2.3.0.e2</quartz.version>
<selenium.version>1.0.1</selenium.version>
<slf4j.version>1.7.12</slf4j.version>
<spring.version>4.2.5.RELEASE</spring.version>
Expand Down
File renamed without changes.
Expand Up @@ -1584,6 +1584,7 @@ DESCRIPTION VARCHAR(250) NULL,
NEXT_FIRE_TIME BIGINT(13) NULL,
PREV_FIRE_TIME BIGINT(13) NULL,
PRIORITY INTEGER NULL,
EXECUTION_GROUP VARCHAR(200) NULL,
TRIGGER_STATE VARCHAR(16) NOT NULL,
TRIGGER_TYPE VARCHAR(8) NOT NULL,
START_TIME BIGINT(13) NOT NULL,
Expand Down Expand Up @@ -1673,6 +1674,7 @@ INSTANCE_NAME VARCHAR(200) NOT NULL,
FIRED_TIME BIGINT(13) NOT NULL,
SCHED_TIME BIGINT(13) NOT NULL,
PRIORITY INTEGER NOT NULL,
EXECUTION_GROUP VARCHAR(200) NULL,
STATE VARCHAR(16) NOT NULL,
JOB_NAME VARCHAR(200) NULL,
JOB_GROUP VARCHAR(200) NULL,
Expand Down
Expand Up @@ -1390,6 +1390,7 @@ CREATE TABLE qrtz_triggers
NEXT_FIRE_TIME NUMBER(13) NULL,
PREV_FIRE_TIME NUMBER(13) NULL,
PRIORITY NUMBER(13) NULL,
EXECUTION_GROUP VARCHAR2(200) NULL,
TRIGGER_STATE VARCHAR2(16) NOT NULL,
TRIGGER_TYPE VARCHAR2(8) NOT NULL,
START_TIME NUMBER(13) NOT NULL,
Expand Down Expand Up @@ -1477,6 +1478,7 @@ CREATE TABLE qrtz_fired_triggers
FIRED_TIME NUMBER(13) NOT NULL,
SCHED_TIME NUMBER(13) NOT NULL,
PRIORITY NUMBER(13) NOT NULL,
EXECUTION_GROUP VARCHAR2(200) NULL,
STATE VARCHAR2(16) NOT NULL,
JOB_NAME VARCHAR2(200) NULL,
JOB_GROUP VARCHAR2(200) NULL,
Expand Down
Expand Up @@ -1371,6 +1371,7 @@ CREATE TABLE qrtz_triggers
NEXT_FIRE_TIME BIGINT NULL,
PREV_FIRE_TIME BIGINT NULL,
PRIORITY INTEGER NULL,
EXECUTION_GROUP VARCHAR(200) NULL,
TRIGGER_STATE VARCHAR(16) NOT NULL,
TRIGGER_TYPE VARCHAR(8) NOT NULL,
START_TIME BIGINT NOT NULL,
Expand Down Expand Up @@ -1466,6 +1467,7 @@ CREATE TABLE qrtz_fired_triggers
FIRED_TIME BIGINT NOT NULL,
SCHED_TIME BIGINT NOT NULL,
PRIORITY INTEGER NOT NULL,
EXECUTION_GROUP VARCHAR(200) NULL,
STATE VARCHAR(16) NOT NULL,
JOB_NAME VARCHAR(200) NULL,
JOB_GROUP VARCHAR(200) NULL,
Expand Down
Expand Up @@ -1446,6 +1446,7 @@ CREATE TABLE [dbo].[QRTZ_FIRED_TRIGGERS] (
[FIRED_TIME] [BIGINT] NOT NULL ,
[SCHED_TIME] [BIGINT] NOT NULL ,
[PRIORITY] [INTEGER] NOT NULL ,
[EXECUTION_GROUP] [VARCHAR] (200) NULL ,
[STATE] [VARCHAR] (16) NOT NULL,
[JOB_NAME] [VARCHAR] (200) NULL ,
[JOB_GROUP] [VARCHAR] (200) NULL ,
Expand Down Expand Up @@ -1534,6 +1535,7 @@ CREATE TABLE [dbo].[QRTZ_TRIGGERS] (
[NEXT_FIRE_TIME] [BIGINT] NULL ,
[PREV_FIRE_TIME] [BIGINT] NULL ,
[PRIORITY] [INTEGER] NULL ,
[EXECUTION_GROUP] [VARCHAR] (200) NULL ,
[TRIGGER_STATE] [VARCHAR] (16) NOT NULL ,
[TRIGGER_TYPE] [VARCHAR] (8) NOT NULL ,
[START_TIME] [BIGINT] NOT NULL ,
Expand Down
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.evolveum.midpoint.web.component.util;

import org.jetbrains.annotations.NotNull;

/**
* @author mederly
*/
public class EnableBehaviour extends VisibleEnableBehaviour {

@NotNull private final SerializableBooleanProducer producer;

public EnableBehaviour(@NotNull SerializableBooleanProducer producer) {
this.producer = producer;
}

@Override
public boolean isEnabled() {
return producer.run();
}
}
Expand Up @@ -17,6 +17,7 @@
package com.evolveum.midpoint.web.page.admin.server;

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.PrismPropertyDefinition;
import com.evolveum.midpoint.prism.delta.ItemDelta;
Expand Down Expand Up @@ -81,7 +82,7 @@ public void deleteSyncTokenPerformed(AjaxRequestTarget target) {
LOGGER.debug("Deleting sync token:\n{}", delta.debugDump());
}
parentPage.getModelService()
.executeChanges(Collections.<ObjectDelta<? extends ObjectType>>singleton(delta), null, operationTask, result);
.executeChanges(Collections.singleton(delta), null, operationTask, result);
result.recomputeStatus();
}
} catch (Exception ex) {
Expand All @@ -102,7 +103,7 @@ void savePerformed(AjaxRequestTarget target) {
try {
List<ItemDelta<?, ?>> itemDeltas = getDeltasToExecute(dto);
ObjectDelta<TaskType> delta = ObjectDelta.createModifyDelta(dto.getOid(), itemDeltas, TaskType.class, parentPage.getPrismContext());
final Collection<ObjectDelta<? extends ObjectType>> deltas = Collections.<ObjectDelta<? extends ObjectType>>singletonList(delta);
final Collection<ObjectDelta<? extends ObjectType>> deltas = Collections.singletonList(delta);

if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Saving task modifications:\n{}", DebugUtil.debugDump(deltas));
Expand Down Expand Up @@ -155,8 +156,21 @@ void savePerformed(AjaxRequestTarget target) {
addDelta(rv, TaskType.F_THREAD_STOP_ACTION, curr.getThreadStopActionType());
}

if (!StringUtils.equals(orig.getRequiredCapability(), curr.getRequiredCapability())) {
addDelta(rv, TaskType.F_REQUIRED_CAPABILITY, curr.getRequiredCapability());
if (dto.getTaskType().getExecutionConstraints() == null) {
if (curr.getExecutionGroup() != null || curr.getGroupTaskLimit() != null) {
TaskExecutionConstraintsType constraints =
new TaskExecutionConstraintsType(getPrismContext())
.group(curr.getExecutionGroup())
.groupTaskLimit(curr.getGroupTaskLimit());
addDelta(rv, TaskType.F_EXECUTION_CONSTRAINTS, constraints);
}
} else {
if (!ObjectUtils.equals(orig.getExecutionGroup(), curr.getExecutionGroup())) {
addDelta(rv, TaskType.F_EXECUTION_CONSTRAINTS, TaskExecutionConstraintsType.F_GROUP, curr.getExecutionGroup());
}
if (!ObjectUtils.equals(orig.getGroupTaskLimit(), curr.getGroupTaskLimit())) {
addDelta(rv, TaskType.F_EXECUTION_CONSTRAINTS, TaskExecutionConstraintsType.F_GROUP_TASK_LIMIT, curr.getExecutionGroup());
}
}

if (!ObjectUtils.equals(orig.getWorkerThreads(), curr.getWorkerThreads())) {
Expand All @@ -172,12 +186,22 @@ void savePerformed(AjaxRequestTarget target) {
return rv;
}

private PrismContext getPrismContext() {
return parentPage.getPrismContext();
}

private void addDelta(List<ItemDelta<?, ?>> deltas, QName itemName, Object itemRealValue) throws SchemaException {
deltas.add(DeltaBuilder.deltaFor(TaskType.class, parentPage.getPrismContext())
.item(itemName).replace(itemRealValue)
.asItemDelta());
}

private void addDelta(List<ItemDelta<?, ?>> deltas, QName itemName1, QName itemName2, Object itemRealValue) throws SchemaException {
deltas.add(DeltaBuilder.deltaFor(TaskType.class, parentPage.getPrismContext())
.item(itemName1, itemName2).replace(itemRealValue)
.asItemDelta());
}

void suspendPerformed(AjaxRequestTarget target) {
String oid = parentPage.getTaskDto().getOid();
OperationResult result = TaskOperationUtils.suspendPerformed(parentPage.getTaskService(), Collections.singleton(oid));
Expand All @@ -186,13 +210,13 @@ void suspendPerformed(AjaxRequestTarget target) {

void resumePerformed(AjaxRequestTarget target) {
String oid = parentPage.getTaskDto().getOid();
OperationResult result = TaskOperationUtils.resumePerformed(parentPage.getTaskService(), Arrays.asList(oid));
OperationResult result = TaskOperationUtils.resumePerformed(parentPage.getTaskService(), Collections.singletonList(oid));
afterStateChangingOperation(target, result);
}

void runNowPerformed(AjaxRequestTarget target) {
String oid = parentPage.getTaskDto().getOid();
OperationResult result = TaskOperationUtils.runNowPerformed(parentPage.getTaskService(), Arrays.asList(oid));
OperationResult result = TaskOperationUtils.runNowPerformed(parentPage.getTaskService(), Collections.singletonList(oid));
afterStateChangingOperation(target, result);
}

Expand Down
Expand Up @@ -28,10 +28,7 @@
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.task.api.TaskManager;
import com.evolveum.midpoint.util.exception.ExpressionEvaluationException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
Expand All @@ -49,6 +46,7 @@
import com.evolveum.midpoint.web.page.admin.server.dto.TaskDtoExecutionStatus;
import com.evolveum.midpoint.web.page.admin.server.dto.TaskDtoProviderOptions;
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.WfContextType;
import org.apache.wicket.Component;
Expand All @@ -61,6 +59,8 @@

import javax.xml.namespace.QName;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
* @author mederly
Expand All @@ -82,6 +82,7 @@ public class PageTaskEdit extends PageAdmin implements Refreshable {

public static final String DOT_CLASS = PageTaskEdit.class.getName() + ".";
private static final String OPERATION_LOAD_TASK = DOT_CLASS + "loadTask";
private static final String OPERATION_LOAD_NODES = DOT_CLASS + "loadNodes";
static final String OPERATION_SAVE_TASK = DOT_CLASS + "saveTask";
static final String OPERATION_DELETE_SYNC_TOKEN = DOT_CLASS + "deleteSyncToken";

Expand All @@ -102,6 +103,7 @@ public class PageTaskEdit extends PageAdmin implements Refreshable {
private TaskMainPanel mainPanel;
private IModel<AutoRefreshDto> refreshModel;
private IModel<Boolean> showAdvancedFeaturesModel;
private IModel<List<NodeType>> nodeListModel;

public PageTaskEdit(PageParameters parameters) {
taskOid = parameters.get(OnePageParameterEncoder.PARAMETER).toString();
Expand All @@ -128,6 +130,20 @@ protected ObjectWrapper<TaskType> load() {
}
};
showAdvancedFeaturesModel = new Model<>(false); // todo save setting in session
nodeListModel = new LoadableModel<List<NodeType>>(false) {
@Override
protected List<NodeType> load() {
OperationResult result = new OperationResult(OPERATION_LOAD_NODES);
Task opTask = getTaskManager().createTaskInstance(OPERATION_LOAD_NODES);
try {
return PrismObject.asObjectableList(
getModelService().searchObjects(NodeType.class, null, null, opTask, result));
} catch (Throwable t) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't retrieve nodes", t);
return Collections.emptyList();
}
}
};
edit = false;
initLayout();
}
Expand Down Expand Up @@ -162,7 +178,11 @@ private TaskType loadTaskTypeChecked(String taskOid, Task operationTask, Operati
return taskType;
}

TaskType loadTaskType(String taskOid, Task operationTask, OperationResult result) {
public IModel<List<NodeType>> getNodeListModel() {
return nodeListModel;
}

private TaskType loadTaskType(String taskOid, Task operationTask, OperationResult result) {
TaskType taskType = null;

try {
Expand Down
Expand Up @@ -97,9 +97,17 @@
<td><wicket:message key="pageTaskEdit.threadStop"/></td>
<td><select class="form-control input-sm" wicket:id="threadStop"/></td>
</tr>
<tr wicket:id="requiredCapabilityContainer">
<td><wicket:message key="pageTaskEdit.requiredCapability"/></td>
<td><input class="form-control input-sm" wicket:id="requiredCapability"/></td>
<tr wicket:id="executionGroupContainer">
<td><wicket:message key="pageTaskEdit.executionGroup"/></td>
<td><input class="form-control input-sm" wicket:id="executionGroup"/></td>
</tr>
<tr wicket:id="groupTaskLimitContainer">
<td><wicket:message key="pageTaskEdit.groupTaskLimit"/></td>
<td><input class="form-control input-sm" wicket:id="groupTaskLimit"/></td>
</tr>
<tr wicket:id="allowedNodesContainer">
<td><wicket:message key="pageTaskEdit.allowedNodes"/></td>
<td><label wicket:id="allowedNodes" style="font-weight:normal"></label></td>
</tr>
</table>
</div>
Expand Down

0 comments on commit 423aa83

Please sign in to comment.