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:
Alan Davis
2019-06-01 10:46:41 +01:00
parent 1e276f1889
commit e381052539
7 changed files with 253 additions and 192 deletions

View File

@@ -1,28 +1,28 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.domain.node;
import org.alfresco.model.ContentModel;
@@ -40,40 +40,42 @@ public interface Node extends NodeIdAndAclId
/**
* 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
*/
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
* @param qnameDAO DAO to work out type IDs
* @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();
public abstract String getShardKey();
AuditablePropertiesEntity getAuditableProperties();
String getShardKey();
Integer getExplicitShardId();
}

View File

@@ -1,28 +1,28 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.domain.node;
import java.io.Serializable;
@@ -54,8 +54,9 @@ public class NodeEntity implements Node, PermissionCheckValue, Serializable, Clo
private Long localeId;
private Long aclId;
private TransactionEntity transaction;
private AuditablePropertiesEntity auditableProperties;
private AuditablePropertiesEntity auditableProperties;
private String shardKey;
private Integer explicitShardId;
/**
* Required default constructor
@@ -90,7 +91,7 @@ public class NodeEntity implements Node, PermissionCheckValue, Serializable, Clo
this.localeId = node.getLocaleId();
this.aclId = node.getAclId();
this.transaction = node.getTransaction();
this.auditableProperties = node.getAuditableProperties();
this.auditableProperties = node.getAuditableProperties();
this.shardKey = node.getShardKey();
}
@@ -139,7 +140,7 @@ public class NodeEntity implements Node, PermissionCheckValue, Serializable, Clo
.append(", localeId=").append(localeId)
.append(", aclId=").append(aclId)
.append(", transaction=").append(transaction)
.append(", auditProps=").append(auditableProperties)
.append(", auditProps=").append(auditableProperties)
.append(", shardKey=").append(shardKey)
.append("]");
return sb.toString();
@@ -334,18 +335,30 @@ public class NodeEntity implements Node, PermissionCheckValue, Serializable, Clo
{
checkLock();
this.auditableProperties = auditableProperties;
}
@Override
public String getShardKey()
{
return this.shardKey;
}
public synchronized void setShardKey(String shardKey)
{
this.shardKey = shardKey;
}
}
@Override
public String getShardKey()
{
return this.shardKey;
}
@Override
public Integer getExplicitShardId()
{
return this.explicitShardId;
}
public synchronized void setShardKey(String shardKey)
{
this.shardKey = shardKey;
}
public synchronized void setExplicitShardId(Integer explicitShardId)
{
this.explicitShardId = explicitShardId;
}
}

View File

@@ -1,52 +1,68 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
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.Map;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.Set;
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 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);
}

View File

@@ -1,28 +1,28 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.solr;
import java.util.List;
@@ -54,10 +54,11 @@ public class NodeParameters
private Set<QName> excludeNodeTypes;
private Set<QName> includeAspects;
private Set<QName> excludeAspects;
private String shardProperty;
private Set<QName> excludeAspects;
private String shardProperty;
private String coreName;
public int getMaxResults()
{
return maxResults;
@@ -181,15 +182,25 @@ public class NodeParameters
public void setExcludeAspects(Set<QName> excludeAspects)
{
this.excludeAspects = excludeAspects;
}
public String getShardProperty()
{
return this.shardProperty;
}
public void setShardProperty(String shardProperty)
{
this.shardProperty = shardProperty;
}
public String getShardProperty()
{
return this.shardProperty;
}
public void setShardProperty(String shardProperty)
{
this.shardProperty = shardProperty;
}
public String getCoreName() {
return this.coreName;
}
public void setCoreName(String coreName){
this.coreName = coreName;
}
}

View File

@@ -36,6 +36,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.OptionalInt;
import java.util.Set;
import java.util.TreeSet;
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.NodeDAO;
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.qname.QNameDAO;
import org.alfresco.repo.domain.solr.SOLRDAO;
@@ -375,6 +377,15 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
for (Node node : nodes)
{
if (shardRegistry != null){
shardRegistry.getShardInstanceByTransactionTimestamp(
nodeParameters.getCoreName(),
node.getTransaction().getCommitTimeMs()).ifPresent(
shardId -> ((NodeEntity) node).setExplicitShardId(shardId));
}
callback.handleNode(node);
}
}

View File

@@ -26,6 +26,7 @@
<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="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="store.protocol" column="protocol" 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
COALESCE(np.long_value, node.id) as id,
node.type_qname_id as type_qname_id,
node.transaction_id as txn_id,
node.uuid as uuid,
node.acl_id as acl_id,
store.protocol as protocol,
store.identifier as identifier,
node.type_qname_id as type_qname_id,
node.transaction_id as txn_id,
txn.commit_time_ms as txn_commit_time_ms,
node.uuid as uuid,
node.acl_id as acl_id,
store.protocol as protocol,
store.identifier as identifier,
<choose>
<when test="shardPropertyQNameId == null">
null as shard_key

View File

@@ -1,28 +1,28 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.search.impl.solr;
import org.alfresco.repo.domain.node.AuditablePropertiesEntity;
@@ -131,12 +131,18 @@ class TestNode implements Node
public AuditablePropertiesEntity getAuditableProperties()
{
return null;
}
@Override
public String getShardKey()
{
return null;
}
@Override
public String getShardKey()
{
return null;
}
@Override
public Integer getExplicitShardId()
{
return null;
}
}