/** * Create an instance of {@link TaskGroupExecutionLimitationType } * */ public TaskGroupExecutionLimitationType createTaskGroupExecutionLimitationType() { return new TaskGroupExecutionLimitationType(); }
/** * Creates a new {@code TaskGroupExecutionLimitationType} instance by deeply copying a given {@code TaskGroupExecutionLimitationType} instance. * * * @param o * The instance to copy. * @throws NullPointerException * if {@code o} is {@code null}. */ public TaskGroupExecutionLimitationType(final TaskGroupExecutionLimitationType o) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 super(); if (o == null) { throw new NullPointerException("Cannot create a copy of 'TaskGroupExecutionLimitationType' from 'null'."); } // CBuiltinLeafInfo: java.lang.String this.groupName = ((o.groupName == null)?null:o.getGroupName()); // CBuiltinLeafInfo: java.lang.Integer this.limit = ((o.limit == null)?null:o.getLimit()); }
@NotNull private NodeType createLocalNodeObject(TaskManagerConfiguration configuration) { NodeType node = getPrismContext().createKnownObjectable(NodeType.class); String nodeId = configuration.getNodeId(); node.setNodeIdentifier(nodeId); node.setName(new PolyStringType(nodeId)); node.setHostname(getMyHostname()); node.getIpAddress().addAll(getMyIpAddresses()); node.setJmxPort(configuration.getJmxPort()); node.setClustered(configuration.isClustered()); node.setRunning(true); node.setLastCheckInTime(getCurrentTime()); node.setBuild(getBuildInformation()); node.setTaskExecutionLimitations( new TaskExecutionLimitationsType() .groupLimitation(new TaskGroupExecutionLimitationType().groupName("").limit(null)) .groupLimitation(new TaskGroupExecutionLimitationType().groupName(nodeId).limit(null)) .groupLimitation(new TaskGroupExecutionLimitationType().groupName(TaskConstants.LIMIT_FOR_OTHER_GROUPS).limit(0))); generateInternalNodeIdentifier(node); return node; }
/** * Copies all values of property {@code GroupLimitation} deeply. * * @param source * The source to copy from. * @param target * The target to copy {@code source} to. * @throws NullPointerException * if {@code target} is {@code null}. */ @SuppressWarnings("unchecked") private static void copyGroupLimitation(final List<TaskGroupExecutionLimitationType> source, final List<TaskGroupExecutionLimitationType> target) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 if ((source!= null)&&(!source.isEmpty())) { for (final Iterator<?> it = source.iterator(); it.hasNext(); ) { final Object next = it.next(); if (next instanceof TaskGroupExecutionLimitationType) { // CClassInfo: com.evolveum.midpoint.xml.ns._public.common.common_3.TaskGroupExecutionLimitationType target.add(((TaskGroupExecutionLimitationType) next).clone()); continue; } // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ throw new AssertionError((("Unexpected instance '"+ next)+"' for property 'GroupLimitation' of class 'com.evolveum.midpoint.xml.ns._public.common.common_3.TaskExecutionLimitationsType'.")); } } }
@Test public void test120NodeAllowed() throws Exception { final String TEST_NAME = "test120NodeAllowed"; final OperationResult result = createResult(TEST_NAME, LOGGER); taskManager.getExecutionManager().setLocalExecutionLimitations( new TaskExecutionLimitationsType() .groupLimitation(new TaskGroupExecutionLimitationType().groupName("lightweight-tasks")) .groupLimitation(new TaskGroupExecutionLimitationType().groupName(null)) .groupLimitation(new TaskGroupExecutionLimitationType().groupName(TaskConstants.LIMIT_FOR_OTHER_GROUPS).limit(0))); TaskType task = (TaskType) addObjectFromFile(taskFilename(TEST_NAME)).asObjectable(); waitForTaskStart(task.getOid(), result, 10000, 500); task = getTaskType(task.getOid(), result); assertNotNull("Task was not started even if it should be", task.getLastRunStartTimestamp()); }
/** * Creates and returns a deep copy of this object. * * * @return * A deep copy of this object. */ @Override public TaskGroupExecutionLimitationType clone() { try { { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 final TaskGroupExecutionLimitationType clone = ((TaskGroupExecutionLimitationType) super.clone()); // CBuiltinLeafInfo: java.lang.String clone.groupName = ((this.groupName == null)?null:this.getGroupName()); // CBuiltinLeafInfo: java.lang.Integer clone.limit = ((this.limit == null)?null:this.getLimit()); return clone; } } catch (CloneNotSupportedException e) { // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ throw new AssertionError(e); } }
/** * Create an instance of {@link TaskGroupExecutionLimitationType } * */ public TaskGroupExecutionLimitationType createTaskGroupExecutionLimitationType() { return new TaskGroupExecutionLimitationType(); }
private static Integer getNodeLimitation(NodeType node, String group) { if (node.getTaskExecutionLimitations() == null) { return null; } group = MiscUtil.nullIfEmpty(group); for (TaskGroupExecutionLimitationType limit : node.getTaskExecutionLimitations().getGroupLimitation()) { if (Objects.equals(group, MiscUtil.nullIfEmpty(limit.getGroupName()))) { return limit.getLimit(); } } for (TaskGroupExecutionLimitationType limit : node.getTaskExecutionLimitations().getGroupLimitation()) { if (TaskConstants.LIMIT_FOR_OTHER_GROUPS.equals(limit.getGroupName())) { return limit.getLimit(); } } return null; }
/** * Create an instance of {@link TaskGroupExecutionLimitationType } * */ public TaskGroupExecutionLimitationType createTaskGroupExecutionLimitationType() { return new TaskGroupExecutionLimitationType(); }
public int hashCode(ObjectLocator locator, HashCodeStrategy strategy) { int currentHashCode = 1; { String theGroupName; theGroupName = this.getGroupName(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "groupName", theGroupName), currentHashCode, theGroupName); } { Integer theLimit; theLimit = this.getLimit(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "limit", theLimit), currentHashCode, theLimit); } return currentHashCode; }
public TaskGroupExecutionLimitationType beginGroupLimitation() { TaskGroupExecutionLimitationType value = new TaskGroupExecutionLimitationType(); groupLimitation(value); return value; }
public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy strategy) { if (!(object instanceof TaskGroupExecutionLimitationType)) { return false; } if (this == object) { return true; } final TaskGroupExecutionLimitationType that = ((TaskGroupExecutionLimitationType) object); { String lhsGroupName; lhsGroupName = this.getGroupName(); String rhsGroupName; rhsGroupName = that.getGroupName(); if (!strategy.equals(LocatorUtils.property(thisLocator, "groupName", lhsGroupName), LocatorUtils.property(thatLocator, "groupName", rhsGroupName), lhsGroupName, rhsGroupName)) { return false; } } { Integer lhsLimit; lhsLimit = this.getLimit(); Integer rhsLimit; rhsLimit = that.getLimit(); if (!strategy.equals(LocatorUtils.property(thisLocator, "limit", lhsLimit), LocatorUtils.property(thatLocator, "limit", rhsLimit), lhsLimit, rhsLimit)) { return false; } } return true; }
void setLocalExecutionLimitations(Scheduler scheduler, TaskExecutionLimitationsType limitations) { try { Map<String, Integer> newLimits = new HashMap<>(); if (limitations != null) { for (TaskGroupExecutionLimitationType limit : limitations.getGroupLimitation()) { newLimits.put(MiscUtil.nullIfEmpty(limit.getGroupName()), limit.getLimit()); } } else { // no limits -> everything is allowed } Map<String, Integer> oldLimits = scheduler.getExecutionLimits(); // just for the logging purposes scheduler.setExecutionLimits(newLimits); if (oldLimits == null || !new HashMap<>(oldLimits).equals(newLimits)) { LOGGER.info("Quartz scheduler execution limits set to: {} (were: {})", newLimits, oldLimits); } } catch (SchedulerException e) { // should never occur, as local scheduler shouldn't throw such exceptions throw new SystemException("Couldn't set local Quartz scheduler execution capabilities: " + e.getMessage(), e); } } }