Skip to content

Commit

Permalink
NodeRegistrar does not depend on TaskManager anymore
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Tkáčik <tonydamage@gmail.com>
  • Loading branch information
tonydamage committed Oct 6, 2023
1 parent f68943f commit c671b96
Showing 1 changed file with 16 additions and 6 deletions.
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;
}
}

0 comments on commit c671b96

Please sign in to comment.