mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Revert "Revert "Feature/search 1654 (#463)""
This reverts commit 418db22fb8
.
This is putting back a previously committed change that broke alfresco-enterprise-repository
This commit is contained in:
@@ -40,40 +40,42 @@ public interface Node extends NodeIdAndAclId
|
|||||||
/**
|
/**
|
||||||
* Helper method to get a key that includes the node and its current version number
|
* Helper method to get a key that includes the node and its current version number
|
||||||
*/
|
*/
|
||||||
public NodeVersionKey getNodeVersionKey();
|
NodeVersionKey getNodeVersionKey();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to force the instance to be read-only
|
* Helper method to force the instance to be read-only
|
||||||
*/
|
*/
|
||||||
public void lock();
|
void lock();
|
||||||
|
|
||||||
public abstract NodeRef getNodeRef();
|
NodeRef getNodeRef();
|
||||||
|
|
||||||
public NodeRef.Status getNodeStatus(QNameDAO qnameDAO);
|
NodeRef.Status getNodeStatus(QNameDAO qnameDAO);
|
||||||
|
|
||||||
public abstract Pair<Long, NodeRef> getNodePair();
|
Pair<Long, NodeRef> getNodePair();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the {@link #getTypeQNameId() type} of the node to determine if the node is deleted
|
* Checks the {@link #getTypeQNameId() type} of the node to determine if the node is deleted
|
||||||
* @param qnameDAO DAO to work out type IDs
|
* @param qnameDAO DAO to work out type IDs
|
||||||
* @return <tt>true</tt> if the node is {@link ContentModel#TYPE_DELETED}
|
* @return <tt>true</tt> if the node is {@link ContentModel#TYPE_DELETED}
|
||||||
*/
|
*/
|
||||||
public abstract boolean getDeleted(QNameDAO qnameDAO);
|
boolean getDeleted(QNameDAO qnameDAO);
|
||||||
|
|
||||||
public abstract Long getVersion();
|
Long getVersion();
|
||||||
|
|
||||||
public abstract StoreEntity getStore();
|
StoreEntity getStore();
|
||||||
|
|
||||||
public abstract String getUuid();
|
String getUuid();
|
||||||
|
|
||||||
public abstract Long getTypeQNameId();
|
Long getTypeQNameId();
|
||||||
|
|
||||||
public abstract Long getLocaleId();
|
Long getLocaleId();
|
||||||
|
|
||||||
public abstract TransactionEntity getTransaction();
|
TransactionEntity getTransaction();
|
||||||
|
|
||||||
public abstract AuditablePropertiesEntity getAuditableProperties();
|
AuditablePropertiesEntity getAuditableProperties();
|
||||||
|
|
||||||
public abstract String getShardKey();
|
String getShardKey();
|
||||||
|
|
||||||
|
Integer getExplicitShardId();
|
||||||
|
|
||||||
}
|
}
|
@@ -56,6 +56,7 @@ public class NodeEntity implements Node, PermissionCheckValue, Serializable, Clo
|
|||||||
private TransactionEntity transaction;
|
private TransactionEntity transaction;
|
||||||
private AuditablePropertiesEntity auditableProperties;
|
private AuditablePropertiesEntity auditableProperties;
|
||||||
private String shardKey;
|
private String shardKey;
|
||||||
|
private Integer explicitShardId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required default constructor
|
* Required default constructor
|
||||||
@@ -342,10 +343,22 @@ public class NodeEntity implements Node, PermissionCheckValue, Serializable, Clo
|
|||||||
return this.shardKey;
|
return this.shardKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getExplicitShardId()
|
||||||
|
{
|
||||||
|
return this.explicitShardId;
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void setShardKey(String shardKey)
|
public synchronized void setShardKey(String shardKey)
|
||||||
{
|
{
|
||||||
this.shardKey = shardKey;
|
this.shardKey = shardKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized void setExplicitShardId(Integer explicitShardId)
|
||||||
|
{
|
||||||
|
this.explicitShardId = explicitShardId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -25,28 +25,44 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.index.shard;
|
package org.alfresco.repo.index.shard;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.OptionalInt;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.search.SearchParameters;
|
import org.alfresco.service.cmr.search.SearchParameters;
|
||||||
import org.alfresco.util.Pair;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andy
|
* A registry which collects all the active shard subscriptions.
|
||||||
*
|
*
|
||||||
|
* @author Andy
|
||||||
|
* @author agazzarini
|
||||||
|
* @author eporciani
|
||||||
*/
|
*/
|
||||||
public interface ShardRegistry
|
public interface ShardRegistry
|
||||||
{
|
{
|
||||||
public void registerShardState(ShardState shardState);
|
/**
|
||||||
|
* Registers (or updates the existing subscription) of a shard.
|
||||||
|
*
|
||||||
|
* @param shardState the shard state, which contains the information about the shard that wants to subscribe/register.
|
||||||
|
*/
|
||||||
|
void registerShardState(ShardState shardState);
|
||||||
|
|
||||||
public List<ShardInstance> getIndexSlice(SearchParameters searchParameters);
|
List<ShardInstance> getIndexSlice(SearchParameters searchParameters);
|
||||||
|
|
||||||
public void purge();
|
void purge();
|
||||||
|
|
||||||
public HashMap<Floc, HashMap<Shard, HashSet<ShardState>>> getFlocs();
|
Map<Floc, Map<Shard, Set<ShardState>>> getFlocs();
|
||||||
|
|
||||||
public void purgeAgedOutShards();
|
void purgeAgedOutShards();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the shard instance (i.e. shard number) which owns (or should own) the transaction associated with the given timestamp.
|
||||||
|
*
|
||||||
|
* @param coreId an identifier (e.g. core name, base url) of the core / collection whose requested shard belongs to.
|
||||||
|
* @param txnTimestamp the transaction timestamp used as search criteria.
|
||||||
|
* @return the shard instance (i.e. shard number) which owns (or should own) the transaction associated with the given timestamp.
|
||||||
|
*/
|
||||||
|
OptionalInt getShardInstanceByTransactionTimestamp(String coreId, long txnTimestamp);
|
||||||
}
|
}
|
||||||
|
@@ -57,6 +57,7 @@ public class NodeParameters
|
|||||||
private Set<QName> excludeAspects;
|
private Set<QName> excludeAspects;
|
||||||
|
|
||||||
private String shardProperty;
|
private String shardProperty;
|
||||||
|
private String coreName;
|
||||||
|
|
||||||
public int getMaxResults()
|
public int getMaxResults()
|
||||||
{
|
{
|
||||||
@@ -192,4 +193,14 @@ public class NodeParameters
|
|||||||
{
|
{
|
||||||
this.shardProperty = shardProperty;
|
this.shardProperty = shardProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCoreName() {
|
||||||
|
return this.coreName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCoreName(String coreName){
|
||||||
|
this.coreName = coreName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -36,6 +36,7 @@ import java.util.Iterator;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.OptionalInt;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.zip.CRC32;
|
import java.util.zip.CRC32;
|
||||||
@@ -46,6 +47,7 @@ import org.alfresco.repo.dictionary.DictionaryDAO;
|
|||||||
import org.alfresco.repo.domain.node.Node;
|
import org.alfresco.repo.domain.node.Node;
|
||||||
import org.alfresco.repo.domain.node.NodeDAO;
|
import org.alfresco.repo.domain.node.NodeDAO;
|
||||||
import org.alfresco.repo.domain.node.NodeDAO.ChildAssocRefQueryCallback;
|
import org.alfresco.repo.domain.node.NodeDAO.ChildAssocRefQueryCallback;
|
||||||
|
import org.alfresco.repo.domain.node.NodeEntity;
|
||||||
import org.alfresco.repo.domain.permissions.AclDAO;
|
import org.alfresco.repo.domain.permissions.AclDAO;
|
||||||
import org.alfresco.repo.domain.qname.QNameDAO;
|
import org.alfresco.repo.domain.qname.QNameDAO;
|
||||||
import org.alfresco.repo.domain.solr.SOLRDAO;
|
import org.alfresco.repo.domain.solr.SOLRDAO;
|
||||||
@@ -375,6 +377,15 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
|
|||||||
|
|
||||||
for (Node node : nodes)
|
for (Node node : nodes)
|
||||||
{
|
{
|
||||||
|
if (shardRegistry != null){
|
||||||
|
shardRegistry.getShardInstanceByTransactionTimestamp(
|
||||||
|
nodeParameters.getCoreName(),
|
||||||
|
node.getTransaction().getCommitTimeMs()).ifPresent(
|
||||||
|
shardId -> ((NodeEntity) node).setExplicitShardId(shardId));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
callback.handleNode(node);
|
callback.handleNode(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
<result property="id" column="id" jdbcType="BIGINT" javaType="java.lang.Long"/>
|
<result property="id" column="id" jdbcType="BIGINT" javaType="java.lang.Long"/>
|
||||||
<result property="typeQNameId" column="type_qname_id" jdbcType="BIGINT" javaType="java.lang.Long" />
|
<result property="typeQNameId" column="type_qname_id" jdbcType="BIGINT" javaType="java.lang.Long" />
|
||||||
<result property="transaction.id" column="txn_id" jdbcType="BIGINT" javaType="java.lang.Long"/>
|
<result property="transaction.id" column="txn_id" jdbcType="BIGINT" javaType="java.lang.Long"/>
|
||||||
|
<result property="transaction.commitTimeMs" column="txn_commit_time_ms" jdbcType="BIGINT" javaType="java.lang.Long"/>
|
||||||
<result property="aclId" column="acl_id" jdbcType="BIGINT" javaType="java.lang.Long"/>
|
<result property="aclId" column="acl_id" jdbcType="BIGINT" javaType="java.lang.Long"/>
|
||||||
<result property="store.protocol" column="protocol" jdbcType="VARCHAR" javaType="java.lang.String"/>
|
<result property="store.protocol" column="protocol" jdbcType="VARCHAR" javaType="java.lang.String"/>
|
||||||
<result property="store.identifier" column="identifier" jdbcType="VARCHAR" javaType="java.lang.String"/>
|
<result property="store.identifier" column="identifier" jdbcType="VARCHAR" javaType="java.lang.String"/>
|
||||||
@@ -115,12 +116,13 @@
|
|||||||
<select id="select_Txn_Nodes" parameterType="SOLRNodeParameters" resultMap="result_Node">
|
<select id="select_Txn_Nodes" parameterType="SOLRNodeParameters" resultMap="result_Node">
|
||||||
select
|
select
|
||||||
COALESCE(np.long_value, node.id) as id,
|
COALESCE(np.long_value, node.id) as id,
|
||||||
node.type_qname_id as type_qname_id,
|
node.type_qname_id as type_qname_id,
|
||||||
node.transaction_id as txn_id,
|
node.transaction_id as txn_id,
|
||||||
node.uuid as uuid,
|
txn.commit_time_ms as txn_commit_time_ms,
|
||||||
node.acl_id as acl_id,
|
node.uuid as uuid,
|
||||||
store.protocol as protocol,
|
node.acl_id as acl_id,
|
||||||
store.identifier as identifier,
|
store.protocol as protocol,
|
||||||
|
store.identifier as identifier,
|
||||||
<choose>
|
<choose>
|
||||||
<when test="shardPropertyQNameId == null">
|
<when test="shardPropertyQNameId == null">
|
||||||
null as shard_key
|
null as shard_key
|
||||||
|
@@ -139,4 +139,10 @@ class TestNode implements Node
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getExplicitShardId()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user