Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-1886 Introduce Backends, instantiated right when an index man…
…ager group is created This will allow to start background services, such as JMS/JGroups message consumers on the master nodes, even if there is no index manager yet (as is the case with dynamic sharding when a *slave* triggers the creation of a shard).
- Loading branch information
Showing
23 changed files
with
766 additions
and
207 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
backends/jgroups/src/main/java/org/hibernate/search/backend/jgroups/impl/JGroupsBackend.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.backend.jgroups.impl; | ||
|
||
import java.util.Properties; | ||
|
||
import org.hibernate.search.backend.spi.Backend; | ||
import org.hibernate.search.backend.spi.BackendQueueProcessor; | ||
import org.hibernate.search.indexes.spi.IndexManager; | ||
import org.hibernate.search.spi.WorkerBuildContext; | ||
|
||
|
||
/** | ||
* @author Yoann Rodiere | ||
*/ | ||
public class JGroupsBackend implements Backend { | ||
|
||
private Properties properties; | ||
|
||
@Override | ||
public void initialize(Properties properties, WorkerBuildContext context) { | ||
this.properties = properties; | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("deprecation") | ||
public BackendQueueProcessor createQueueProcessor(IndexManager indexManager, WorkerBuildContext context) { | ||
NodeSelectorStrategy nodeSelectorStrategy = createNodeSelectorStrategy( indexManager ); | ||
BackendQueueProcessor queueProcessor = new JGroupsBackendQueueProcessor( nodeSelectorStrategy ); | ||
queueProcessor.initialize( properties, context, indexManager ); | ||
return queueProcessor; | ||
} | ||
|
||
protected NodeSelectorStrategy createNodeSelectorStrategy(IndexManager indexManager) { | ||
return new AutoNodeSelector( indexManager.getIndexName() ); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
...jgroups/src/main/java/org/hibernate/search/backend/jgroups/impl/JGroupsMasterBackend.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.backend.jgroups.impl; | ||
|
||
import org.hibernate.search.indexes.spi.IndexManager; | ||
|
||
/** | ||
* @author Yoann Rodiere | ||
*/ | ||
public class JGroupsMasterBackend extends JGroupsBackend { | ||
|
||
@Override | ||
protected NodeSelectorStrategy createNodeSelectorStrategy(IndexManager indexManager) { | ||
return new MasterNodeSelector(); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
.../jgroups/src/main/java/org/hibernate/search/backend/jgroups/impl/JGroupsSlaveBackend.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.backend.jgroups.impl; | ||
|
||
import org.hibernate.search.indexes.spi.IndexManager; | ||
|
||
/** | ||
* @author Yoann Rodiere | ||
*/ | ||
public class JGroupsSlaveBackend extends JGroupsBackend { | ||
|
||
@Override | ||
protected NodeSelectorStrategy createNodeSelectorStrategy(IndexManager indexManager) { | ||
return new SlaveNodeSelector(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
backends/jms/src/main/java/org/hibernate/search/backend/jms/impl/JndiJMSBackend.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.backend.jms.impl; | ||
|
||
import java.util.Properties; | ||
|
||
import org.hibernate.search.backend.spi.Backend; | ||
import org.hibernate.search.backend.spi.BackendQueueProcessor; | ||
import org.hibernate.search.indexes.spi.IndexManager; | ||
import org.hibernate.search.spi.WorkerBuildContext; | ||
|
||
|
||
/** | ||
* @author Yoann Rodiere | ||
*/ | ||
public class JndiJMSBackend implements Backend { | ||
|
||
private Properties properties; | ||
|
||
@Override | ||
public void initialize(Properties properties, WorkerBuildContext context) { | ||
this.properties = properties; | ||
} | ||
|
||
@Override | ||
public boolean isTransactional() { | ||
return true; | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("deprecation") | ||
public BackendQueueProcessor createQueueProcessor(IndexManager indexManager, WorkerBuildContext context) { | ||
BackendQueueProcessor queueProcessor = new JndiJMSBackendQueueProcessor(); | ||
queueProcessor.initialize( properties, context, indexManager ); | ||
return queueProcessor; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.