diff --git a/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ContentletIndexAPIImpl.java b/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ContentletIndexAPIImpl.java index c541f932361b..ded190219e10 100644 --- a/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ContentletIndexAPIImpl.java +++ b/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ContentletIndexAPIImpl.java @@ -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()) { diff --git a/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ESContentletAPIImpl.java b/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ESContentletAPIImpl.java index a8bc97ab39b2..8f27e6eb9454 100644 --- a/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ESContentletAPIImpl.java +++ b/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ESContentletAPIImpl.java @@ -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; diff --git a/dotCMS/src/main/java/com/dotmarketing/common/reindex/ReindexThread.java b/dotCMS/src/main/java/com/dotmarketing/common/reindex/ReindexThread.java index c5992c26fe98..c2c7f958261c 100644 --- a/dotCMS/src/main/java/com/dotmarketing/common/reindex/ReindexThread.java +++ b/dotCMS/src/main/java/com/dotmarketing/common/reindex/ReindexThread.java @@ -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"); @@ -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); } } } diff --git a/dotCMS/src/main/java/com/dotmarketing/init/DotInitScheduler.java b/dotCMS/src/main/java/com/dotmarketing/init/DotInitScheduler.java index df6b1d9e8426..5b6ca319aecd 100644 --- a/dotCMS/src/main/java/com/dotmarketing/init/DotInitScheduler.java +++ b/dotCMS/src/main/java/com/dotmarketing/init/DotInitScheduler.java @@ -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) diff --git a/dotcms-integration/src/test/java/com/dotcms/content/elasticsearch/business/ESContentletAPIImplTest.java b/dotcms-integration/src/test/java/com/dotcms/content/elasticsearch/business/ESContentletAPIImplTest.java index 837d61a86980..f694254e4916 100644 --- a/dotcms-integration/src/test/java/com/dotcms/content/elasticsearch/business/ESContentletAPIImplTest.java +++ b/dotcms-integration/src/test/java/com/dotcms/content/elasticsearch/business/ESContentletAPIImplTest.java @@ -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