Skip to content

Commit

Permalink
Issue 30468 remove calls to elastic read only command and disable es …
Browse files Browse the repository at this point in the history
…read only monitor job (#30471)

### Proposed Changes
* Remove all the Used of the ES Read Only Monitor, we still are not
removing all the logic

---------

Co-authored-by: Will Ezell <[email protected]>
  • Loading branch information
freddyDOTCMS and wezell authored Oct 31, 2024
1 parent 3f5e10d commit 1bbd500
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,6 @@ public void addContentToIndex(final Contentlet parentContenlet,
.build()
: List.of(parentContenlet);

if (ElasticReadOnlyCommand.getInstance().isIndexOrClusterReadOnly()) {
ElasticReadOnlyCommand.getInstance().sendReadOnlyMessage();
}

if (parentContenlet.getIndexPolicy() == IndexPolicy.DEFER) {
queueApi.addContentletsReindex(contentToIndex);
} else if (!DbConnectionFactory.inTransaction()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5311,13 +5311,6 @@ private Contentlet internalCheckin(Contentlet contentlet,

if (!isCheckInSafe(contentRelationships)) {

if (contentlet.getBoolProperty(Contentlet.IS_TEST_MODE)) {
this.elasticReadOnlyCommand.executeCheck();
} else {
DotConcurrentFactory.getInstance().getSingleSubmitter()
.submit(() -> this.elasticReadOnlyCommand.executeCheck());
}

final String contentletIdentifier =
null != contentlet && null != contentlet.getIdentifier()
? contentlet.getIdentifier() : StringPool.NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ private void runReindexLoop() {
bulkProcessor = finalizeReIndex(bulkProcessor);
}

if (!workingRecords.isEmpty() && !ElasticReadOnlyCommand.getInstance()
.isIndexOrClusterReadOnly()) {
if (!workingRecords.isEmpty()) {
Logger.debug(this,
"Found " + workingRecords + " index items to process");

Expand All @@ -235,15 +234,19 @@ private void runReindexLoop() {
} finally {
DbConnectionFactory.closeSilently();
}
while (state.get() == ThreadState.PAUSED) {
ThreadUtils.sleep(SLEEP);
//Logs every 60 minutes
Logger.infoEvery(ReindexThread.class, "--- ReindexThread Paused",
Config.getIntProperty("REINDEX_THREAD_PAUSE_IN_MINUTES", 60) * 60000);
Long restartTime = (Long) cache.get().get(REINDEX_THREAD_PAUSED);
if (restartTime == null || restartTime < System.currentTimeMillis()) {
state.set(ThreadState.RUNNING);
}
sleep();
}
}

private void sleep() {
while (state.get() == ThreadState.PAUSED) {
ThreadUtils.sleep(SLEEP);
//Logs every 60 minutes
Logger.infoEvery(ReindexThread.class, "--- ReindexThread Paused",
Config.getIntProperty("REINDEX_THREAD_PAUSE_IN_MINUTES", 60) * 60000);
Long restartTime = (Long) cache.get().get(REINDEX_THREAD_PAUSED);
if (restartTime == null || restartTime < System.currentTimeMillis()) {
state.set(ThreadState.RUNNING);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ private static void addElasticReadyOnlyMonitor (final Scheduler scheduler) {
final String triggerName = "trigger29";
final String triggerGroup = "group98";

if (Config.getBooleanProperty( "ENABLE_ELASTIC_READ_ONLY_MONITOR", true)) {
if (Config.getBooleanProperty( "ENABLE_ELASTIC_READ_ONLY_MONITOR", false)) {

final JobBuilder elasticReadOnlyMonitorJob = new JobBuilder().setJobClass(EsReadOnlyMonitorJob.class)
.setJobName(jobName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,51 +277,6 @@ public void testGetRelatedContentFromMultilingualContent()
}
}

@Test()
public void testCheckInWithLegacyRelationshipsAndReadOnlyClusterShouldThrowAnException()
throws DotDataException, DotSecurityException {
final long time = System.currentTimeMillis();
ContentType contentType = null;
final ElasticReadOnlyCommand esReadOnlyMonitor = mock(ElasticReadOnlyCommand.class);
final ESContentletAPIImpl contentletAPIImpl = new ESContentletAPIImpl(esReadOnlyMonitor);

try {
contentType = createContentType("test" + time);

final Structure structure = new StructureTransformer(contentType).asStructure();

final Contentlet contentlet = new ContentletDataGen(contentType.id()).next();
final ContentletRelationships contentletRelationship = new ContentletRelationships(
contentlet);

final Relationship relationship = new Relationship(structure, structure,
"parent" + contentType.variable(), "child" + contentType.variable(),
RELATIONSHIP_CARDINALITY.ONE_TO_MANY.ordinal(), false, false);

final ContentletRelationshipRecords relationshipsRecord = contentletRelationship.new ContentletRelationshipRecords(
relationship,
false);

contentletRelationship
.setRelationshipsRecords(CollectionsUtils.list(relationshipsRecord));

setClusterAsReadOnly(true);

contentlet.setProperty(Contentlet.IS_TEST_MODE, true);
contentletAPIImpl.checkin(contentlet, contentletRelationship, null, null, user, false);

throw new AssertionError("DotContentletStateException Expected");
} catch(DotContentletStateException e) {
verify(esReadOnlyMonitor).executeCheck();
}finally{
if (contentType != null && contentType.id() != null){
contentTypeAPI.delete(contentType);
}

setClusterAsReadOnly(false);
}
}

/**
* Test for isCheckInSafe method with legacy relationships. It should return false when the cluster
* is in read only mode
Expand Down

0 comments on commit 1bbd500

Please sign in to comment.