Skip to content

Commit

Permalink
HSEARCH-4182 Remove CoordinationStrategyNames
Browse files Browse the repository at this point in the history
It doesn't make sense if the strategies require additional Maven
dependencies.
  • Loading branch information
yrodiere committed Oct 1, 2021
1 parent 541689e commit 0126ae8
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 82 deletions.
Expand Up @@ -20,7 +20,7 @@
import org.hibernate.SessionFactory;
import org.hibernate.search.engine.reporting.EntityIndexingFailureContext;
import org.hibernate.search.mapper.orm.common.EntityReference;
import org.hibernate.search.mapper.orm.coordination.CoordinationStrategyNames;
import org.hibernate.search.mapper.orm.coordination.databasepolling.cfg.HibernateOrmMapperDatabasePollingSettings;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
import org.hibernate.search.util.common.SearchException;
Expand All @@ -35,7 +35,7 @@
import org.awaitility.core.ThrowingRunnable;

/**
* Extensive tests of backend failures for automatic indexing with {@link CoordinationStrategyNames#DATABASE_POLLING}.
* Extensive tests of backend failures for automatic indexing with {@link HibernateOrmMapperDatabasePollingSettings#DATABASE_POLLING}.
*/
public class DatabasePollingAutomaticIndexingBackendFailureIT {

Expand Down
Expand Up @@ -6,7 +6,7 @@
*/
package org.hibernate.search.integrationtest.mapper.orm.automaticindexing.coordination.databasepolling;

import org.hibernate.search.mapper.orm.coordination.CoordinationStrategyNames;
import org.hibernate.search.mapper.orm.coordination.databasepolling.cfg.HibernateOrmMapperDatabasePollingSettings;
import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations;
import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper;

Expand All @@ -16,7 +16,7 @@
import org.junit.runner.RunWith;

/**
* Tests suite for automatic indexing with {@link CoordinationStrategyNames#DATABASE_POLLING}.
* Tests suite for automatic indexing with {@link HibernateOrmMapperDatabasePollingSettings#DATABASE_POLLING}.
*/
@RunWith(ClasspathSuite.class)
@ClasspathSuite.IncludeJars(true)
Expand Down
Expand Up @@ -14,7 +14,7 @@
import javax.persistence.Id;
import javax.persistence.OneToOne;

import org.hibernate.search.mapper.orm.coordination.CoordinationStrategyNames;
import org.hibernate.search.mapper.orm.coordination.databasepolling.cfg.HibernateOrmMapperDatabasePollingSettings;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField;
Expand All @@ -30,7 +30,7 @@
import org.junit.rules.MethodRule;

/**
* Extensive tests with edge cases for automatic indexing with {@link CoordinationStrategyNames#DATABASE_POLLING}.
* Extensive tests with edge cases for automatic indexing with {@link HibernateOrmMapperDatabasePollingSettings#DATABASE_POLLING}.
*/
public class DatabasePollingAutomaticIndexingEdgeCasesIT {

Expand Down
Expand Up @@ -7,7 +7,6 @@
package org.hibernate.search.mapper.orm.coordination.databasepolling.cfg;

import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings;
import org.hibernate.search.mapper.orm.coordination.CoordinationStrategyNames;

public final class HibernateOrmMapperDatabasePollingSettings {

Expand All @@ -20,6 +19,20 @@ private HibernateOrmMapperDatabasePollingSettings() {
*/
public static final String PREFIX = HibernateOrmMapperSettings.PREFIX;

/**
* The name of the database polling strategy,
* to be set on the {@link HibernateOrmMapperSettings#COORDINATION_STRATEGY}
* configuration property in order to use this strategy.
* <p>
* With database polling, one or multiple application nodes exist,
* and they coordinate with each other by pushing data to additional tables in the database
* and polling these tables.
* <p>
* See the reference documentation for a comparison of all available coordination strategies
* and possible architectures.
*/
public static final String COORDINATION_STRATEGY_NAME = "database-polling";

/**
* Whether shards are static, i.e. configured explicitly for each node, with a fixed number of shards/nodes.
* <p>
Expand All @@ -29,7 +42,7 @@ private HibernateOrmMapperDatabasePollingSettings() {
* resulting in errors and/or out-of-sync indexes.
* <p>
* Only available when {@link HibernateOrmMapperSettings#COORDINATION_STRATEGY} is
* {@link CoordinationStrategyNames#DATABASE_POLLING}.
* {@value #COORDINATION_STRATEGY_NAME}.
* <p>
* Expects a Boolean value such as {@code true} or {@code false},
* or a string that can be parsed to such Boolean value.
Expand All @@ -47,7 +60,7 @@ private HibernateOrmMapperDatabasePollingSettings() {
* resulting in errors and/or out-of-sync indexes.
* <p>
* Only available when {@link HibernateOrmMapperSettings#COORDINATION_STRATEGY} is
* {@link CoordinationStrategyNames#DATABASE_POLLING}
* {@value #COORDINATION_STRATEGY_NAME}
* and {@link #COORDINATION_SHARDS_STATIC} is {@code true}.
* <p>
* Expects an Integer value of at least {@code 2},
Expand All @@ -65,7 +78,7 @@ private HibernateOrmMapperDatabasePollingSettings() {
* resulting in errors and/or out-of-sync indexes.
* <p>
* Only available when {@link HibernateOrmMapperSettings#AUTOMATIC_INDEXING_STRATEGY} is
* {@link CoordinationStrategyNames#DATABASE_POLLING}
* {@value #COORDINATION_STRATEGY_NAME}
* and {@link #COORDINATION_SHARDS_STATIC} is {@code true}.
* <p>
* Expects a shard index, i.e. an Integer value between {@code 0} (inclusive) and the
Expand All @@ -82,7 +95,7 @@ private HibernateOrmMapperDatabasePollingSettings() {
* Whether the application will process entity change events.
* <p>
* Only available when {@link HibernateOrmMapperSettings#COORDINATION_STRATEGY} is
* {@link CoordinationStrategyNames#DATABASE_POLLING}.
* {@value #COORDINATION_STRATEGY_NAME}.
* <p>
* Expects a Boolean value such as {@code true} or {@code false},
* or a string that can be parsed to such Boolean value.
Expand All @@ -101,7 +114,7 @@ private HibernateOrmMapperDatabasePollingSettings() {
* after a query didn't return any event, in milliseconds.
* <p>
* Only available when {@link HibernateOrmMapperSettings#COORDINATION_STRATEGY} is
* {@link CoordinationStrategyNames#DATABASE_POLLING}.
* {@value #COORDINATION_STRATEGY_NAME}.
* <p>
* Hibernate Search will wait that long before polling again if the last polling didn't return any event:
* <ul>
Expand All @@ -121,7 +134,7 @@ private HibernateOrmMapperDatabasePollingSettings() {
* In the background indexing processor, how many outbox events, at most, are processed in a single transaction.
* <p>
* Only available when {@link HibernateOrmMapperSettings#COORDINATION_STRATEGY} is
* {@link CoordinationStrategyNames#DATABASE_POLLING}.
* {@value #COORDINATION_STRATEGY_NAME}.
* <p>
* Expects a positive Integer value, such as {@code 50},
* or a String that can be parsed into such Integer value.
Expand Down
Expand Up @@ -21,8 +21,8 @@
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.search.mapper.orm.coordination.CoordinationStrategyNames;
import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings;
import org.hibernate.search.mapper.orm.coordination.databasepolling.cfg.HibernateOrmMapperDatabasePollingSettings;
import org.hibernate.search.mapper.orm.coordination.databasepolling.logging.impl.Log;
import org.hibernate.search.util.common.logging.impl.LoggerFactory;
import org.hibernate.service.ServiceRegistry;
Expand Down Expand Up @@ -68,7 +68,7 @@ public Collection<MappingDocument> produceAdditionalMappings(final MetadataImple
ConfigurationService service = serviceRegistry.getService( ConfigurationService.class );

Object customIndexingStrategy = service.getSettings().get( HibernateOrmMapperSettings.COORDINATION_STRATEGY );
if ( !CoordinationStrategyNames.DATABASE_POLLING.equals( customIndexingStrategy ) ) {
if ( !HibernateOrmMapperDatabasePollingSettings.COORDINATION_STRATEGY_NAME.equals( customIndexingStrategy ) ) {
return Collections.emptyList();
}

Expand Down
Expand Up @@ -9,16 +9,16 @@
import org.hibernate.search.engine.environment.bean.BeanReference;
import org.hibernate.search.engine.environment.bean.spi.BeanConfigurationContext;
import org.hibernate.search.engine.environment.bean.spi.BeanConfigurer;
import org.hibernate.search.mapper.orm.coordination.CoordinationStrategyNames;
import org.hibernate.search.mapper.orm.coordination.common.spi.CooordinationStrategy;
import org.hibernate.search.mapper.orm.coordination.databasepolling.cfg.HibernateOrmMapperDatabasePollingSettings;

public class DatabasePollingBeanConfigurer implements BeanConfigurer {

@Override
public void configure(BeanConfigurationContext context) {
context.define(
CooordinationStrategy.class,
CoordinationStrategyNames.DATABASE_POLLING,
HibernateOrmMapperDatabasePollingSettings.COORDINATION_STRATEGY_NAME,
BeanReference.ofInstance( new DatabasePollingCooordinationStrategy() )
);
}
Expand Down
Expand Up @@ -8,9 +8,9 @@

import org.hibernate.search.engine.cfg.EngineSettings;
import org.hibernate.search.engine.environment.bean.BeanReference;
import org.hibernate.search.mapper.orm.coordination.CoordinationStrategyNames;
import org.hibernate.search.mapper.orm.automaticindexing.session.AutomaticIndexingSynchronizationStrategyNames;
import org.hibernate.search.mapper.orm.coordination.common.spi.CooordinationStrategy;
import org.hibernate.search.mapper.orm.coordination.impl.NoCoordinationStrategy;
import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer;
import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName;
import org.hibernate.search.mapper.orm.search.loading.EntityLoadingCacheLookupStrategy;
Expand Down Expand Up @@ -59,7 +59,6 @@ private HibernateOrmMapperSettings() {
* <p>
* Defaults to {@link Defaults#AUTOMATIC_INDEXING_STRATEGY}.
*
* @see CoordinationStrategyNames
* @deprecated Use {@link #AUTOMATIC_INDEXING_ENABLED} instead (caution: it expects a boolean value).
*/
@Deprecated
Expand Down Expand Up @@ -151,12 +150,11 @@ private HibernateOrmMapperSettings() {
/**
* The strategy for coordinating between nodes of a distributed application.
* <p>
* Expects one of the strings defined in {@link CoordinationStrategyNames},
* or a different string for a strategy provided by an external module.
* Expects a reference to a coordination strategy;
* see the reference documentation for available strategies
* and the relevant Maven dependencies.
* <p>
* Defaults to {@link Defaults#COORDINATION_STRATEGY}.
*
* @see CoordinationStrategyNames
*/
public static final String COORDINATION_STRATEGY = PREFIX + Radicals.COORDINATION_STRATEGY;

Expand Down Expand Up @@ -245,7 +243,7 @@ private Defaults() {
public static final boolean MAPPING_PROCESS_ANNOTATIONS = true;
public static final SchemaManagementStrategyName SCHEMA_MANAGEMENT_STRATEGY = SchemaManagementStrategyName.CREATE_OR_VALIDATE;
public static final BeanReference<CooordinationStrategy> COORDINATION_STRATEGY =
BeanReference.of( CooordinationStrategy.class, CoordinationStrategyNames.NONE );
BeanReference.of( CooordinationStrategy.class, NoCoordinationStrategy.NAME );
}

}

This file was deleted.

Expand Up @@ -14,6 +14,9 @@
import org.hibernate.search.mapper.orm.coordination.common.spi.CoordinationStrategyStartContext;

public class NoCoordinationStrategy implements CooordinationStrategy {

public static final String NAME = "none";

@Override
public CompletableFuture<?> start(CoordinationStrategyStartContext context) {
// Nothing to do
Expand Down
Expand Up @@ -9,7 +9,6 @@
import org.hibernate.search.engine.environment.bean.BeanReference;
import org.hibernate.search.engine.environment.bean.spi.BeanConfigurationContext;
import org.hibernate.search.engine.environment.bean.spi.BeanConfigurer;
import org.hibernate.search.mapper.orm.coordination.CoordinationStrategyNames;
import org.hibernate.search.mapper.orm.coordination.impl.NoCoordinationStrategy;
import org.hibernate.search.mapper.orm.automaticindexing.session.AutomaticIndexingSynchronizationStrategy;
import org.hibernate.search.mapper.orm.automaticindexing.session.AutomaticIndexingSynchronizationStrategyNames;
Expand All @@ -20,7 +19,7 @@ public class HibernateOrmBeanConfigurer implements BeanConfigurer {
public void configure(BeanConfigurationContext context) {
context.define(
CooordinationStrategy.class,
CoordinationStrategyNames.NONE,
NoCoordinationStrategy.NAME,
BeanReference.ofInstance( new NoCoordinationStrategy() )
);

Expand Down
Expand Up @@ -6,7 +6,6 @@
*/
package org.hibernate.search.util.impl.integrationtest.mapper.orm;

import org.hibernate.search.mapper.orm.coordination.CoordinationStrategyNames;
import org.hibernate.search.util.impl.integrationtest.common.rule.BackendIndexingWorkExpectations;
import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubDocumentWork;
import org.hibernate.search.util.impl.integrationtest.mapper.orm.coordination.localheap.LocalHeapQueueCooordinationStrategy;
Expand All @@ -22,7 +21,7 @@ public static CoordinationStrategyExpectations localHeapQueue() {
}

public static CoordinationStrategyExpectations outboxPolling() {
return async( CoordinationStrategyNames.DATABASE_POLLING, ".*Outbox event processor.*" );
return async( "database-polling", ".*Outbox event processor.*" );
}

private static CoordinationStrategyExpectations async(String strategyName, String threadNamePattern) {
Expand Down

0 comments on commit 0126ae8

Please sign in to comment.