Skip to content

Commit

Permalink
Merge branch 'feature/task-manager-decycling' into feature/ninja-jenk…
Browse files Browse the repository at this point in the history
…ins-tests
  • Loading branch information
tonydamage committed Oct 6, 2023
2 parents 2eb910a + a64027a commit b227b5a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.apache.wicket.core.util.objects.checker.ObjectSerializationChecker;
import org.apache.wicket.core.util.resource.locator.IResourceStreamLocator;
import org.apache.wicket.core.util.resource.locator.caching.CachingResourceStreamLocator;
import org.apache.wicket.csp.CSPDirective;
import org.apache.wicket.csp.CSPDirectiveSrcValue;
import org.apache.wicket.devutils.inspector.InspectorPage;
import org.apache.wicket.devutils.inspector.LiveSessionsPage;
import org.apache.wicket.devutils.pagestore.PageStorePage;
Expand Down Expand Up @@ -227,7 +229,10 @@ public Class<? extends PageAdminLTE> getHomePage() {
public void init() {
super.init();

getCspSettings().blocking().disabled();
getCspSettings().blocking().clear()
.unsafeInline()
.add(CSPDirective.IMG_SRC, "data:")
.add(CSPDirective.FONT_SRC, "data:");

// This is needed for wicket to work correctly. Also jQuery version in webjars should match AdminLTE jQuery version.
// We'll try to use npm/webpack to create this jquery resource directly, without webjars [todo lazyman]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public class ClusterManager {
private static final String CLASS_DOT = ClusterManager.class.getName() + ".";
private static final String CHECK_SYSTEM_CONFIGURATION_CHANGED = CLASS_DOT + "checkSystemConfigurationChanged";

@Autowired private TaskManagerQuartzImpl taskManager;
@Autowired private NodeRegistrar nodeRegistrar;
@Autowired private TaskManagerConfiguration configuration;
@Autowired private StalledTasksWatcher stalledTasksWatcher;
Expand All @@ -67,6 +66,10 @@ public class ClusterManager {
@Autowired private TaskStateManager taskStateManager;
@Autowired private LocalScheduler localScheduler;


@Autowired private RepositoryService repositoryService;
@Autowired private PrismContext prismContext;

private ClusterManagerThread clusterManagerThread;

private static boolean updateNodeExecutionLimitations = true; // turned off when testing
Expand Down Expand Up @@ -141,7 +144,7 @@ public void registerNodeUp(OperationResult result) {
if (node.asObjectable().getOperationalState() == NodeOperationalStateType.UP) {
clusterState.getNodeUp().add(nodeIdentifier);
}
if (taskManager.isUpAndAlive(node.asObjectable())) {
if (isUpAndAlive(node.asObjectable())) {
clusterState.getNodeUpAndAlive().add(nodeIdentifier);
}
}
Expand Down Expand Up @@ -265,7 +268,7 @@ private boolean markNodeAsDown(NodeType node, OperationResult result) {
}

private boolean isRemoteNode(NodeType node) {
return !taskManager.getNodeId().equals(node.getNodeIdentifier());
return !configuration.getNodeId().equals(node.getNodeIdentifier());
}

private boolean shouldBeMarkedAsDown(NodeType node) {
Expand Down Expand Up @@ -313,7 +316,7 @@ public void startClusterManagerThread() {
}

private RepositoryService getRepositoryService() {
return taskManager.getRepositoryService();
return repositoryService;
}

public String dumpNodeInfo(NodeType node) {
Expand All @@ -335,9 +338,8 @@ public PrismObject<NodeType> getNode(String nodeOid, OperationResult result) thr

public PrismObject<NodeType> getNodeById(String nodeIdentifier, OperationResult result) throws ObjectNotFoundException {
try {
ObjectQuery q = ObjectQueryUtil.createNameQuery(NodeType.class, taskManager.getPrismContext(), nodeIdentifier);
List<PrismObject<NodeType>> nodes =
taskManager.getRepositoryService().searchObjects(NodeType.class, q, null, result);
ObjectQuery q = ObjectQueryUtil.createNameQuery(NodeType.class, prismContext, nodeIdentifier);
List<PrismObject<NodeType>> nodes =getRepositoryService().searchObjects(NodeType.class, q, null, result);
if (nodes.isEmpty()) {
throw new ObjectNotFoundException(
"A node with identifier " + nodeIdentifier + " does not exist.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy;
import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.repo.api.Cache;
import com.evolveum.midpoint.repo.api.CacheRegistry;
import com.evolveum.midpoint.repo.api.RepositoryService;
import com.evolveum.midpoint.repo.api.*;
import com.evolveum.midpoint.schema.SchemaService;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectQueryUtil;
Expand Down Expand Up @@ -47,6 +45,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

Expand All @@ -72,7 +71,7 @@
* TODO finish review of this class
*/
@Component
public class NodeRegistrar implements Cache {
public class NodeRegistrar implements Cache, SystemConfigurationChangeListener {

private static final Trace LOGGER = TraceManager.getTrace(NodeRegistrar.class);
private static final Trace LOGGER_CONTENT = TraceManager.getTrace(NodeRegistrar.class.getName() + ".content");
Expand All @@ -83,7 +82,9 @@ public class NodeRegistrar implements Cache {
private static final String OP_REFRESH_CACHED_LOCAL_NODE_OBJECT_ON_INVALIDATION =
NodeRegistrar.class.getName() + ".refreshCachedLocalNodeObjectOnInvalidation";

@Autowired private TaskManagerQuartzImpl taskManager;

@Autowired private SystemConfigurationChangeDispatcher systemConfigurationChangeDispatcher;

@Autowired private TaskManagerConfiguration configuration;
@Autowired private ClusterManager clusterManager;
@Autowired private LocalNodeState localNodeState;
Expand Down Expand Up @@ -121,14 +122,18 @@ public class NodeRegistrar implements Cache {
private String discoveredUrlScheme;
private Integer discoveredHttpPort;

private String intraClusterHttpUrlPattern;

@PostConstruct
public void initialize() {
discoverUrlSchemeAndPort();
systemConfigurationChangeDispatcher.registerListener(this);
cacheRegistry.registerCache(this);
}

@PreDestroy
void preDestroy() {
systemConfigurationChangeDispatcher.unregisterListener(this);
cacheRegistry.unregisterCache(this);
}

Expand Down Expand Up @@ -614,7 +619,6 @@ private String getMyUrl() {
}

String path = webContextPath;
String intraClusterHttpUrlPattern = taskManager.getIntraClusterHttpUrlPattern();
if (intraClusterHttpUrlPattern != null) {
String url = intraClusterHttpUrlPattern.replace("$host", getMyHostname());
if (url.contains("$port")) {
Expand Down Expand Up @@ -792,4 +796,10 @@ private void refreshCachedLocalNodeObjectOnInvalidation(String oid) {
public void dumpContent() {
LOGGER_CONTENT.info("Current node:\n{}", DebugUtil.debugDumpLazily(cachedLocalNodeObject));
}

@Override
public void update(@Nullable SystemConfigurationType value) {
var infraConf = value != null ? value.getInfrastructure() : null;
this.intraClusterHttpUrlPattern = infraConf != null ? infraConf.getIntraClusterHttpUrlPattern() : null;
}
}
2 changes: 1 addition & 1 deletion tools/ninja/src/test/resources/ctx-ninja-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<import resource="classpath:ctx-audit.xml"/>
<import resource="classpath:ctx-security.xml"/>
<import resource="classpath:ctx-task.xml"/>
<import resource="classpath*:ctx-repository-test.xml"/>
<import resource="classpath:ctx-repository-test.xml"/>
<import resource="classpath:ctx-repo-cache.xml"/>
<import resource="classpath:ctx-configuration-test.xml"/>

Expand Down

0 comments on commit b227b5a

Please sign in to comment.