diff --git a/src/main/java/org/alfresco/repo/domain/node/Node.java b/src/main/java/org/alfresco/repo/domain/node/Node.java index 7eea53f676..b034651ff7 100644 --- a/src/main/java/org/alfresco/repo/domain/node/Node.java +++ b/src/main/java/org/alfresco/repo/domain/node/Node.java @@ -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 . - * #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 . + * #L% + */ package org.alfresco.repo.domain.node; import org.alfresco.model.ContentModel; @@ -40,42 +40,40 @@ public interface Node extends NodeIdAndAclId /** * Helper method to get a key that includes the node and its current version number */ - NodeVersionKey getNodeVersionKey(); + public NodeVersionKey getNodeVersionKey(); /** * Helper method to force the instance to be read-only */ - void lock(); + public void lock(); - NodeRef getNodeRef(); + public abstract NodeRef getNodeRef(); - NodeRef.Status getNodeStatus(QNameDAO qnameDAO); + public NodeRef.Status getNodeStatus(QNameDAO qnameDAO); - Pair getNodePair(); + public abstract Pair 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 true if the node is {@link ContentModel#TYPE_DELETED} */ - boolean getDeleted(QNameDAO qnameDAO); + public abstract boolean getDeleted(QNameDAO qnameDAO); - Long getVersion(); + public abstract Long getVersion(); - StoreEntity getStore(); + public abstract StoreEntity getStore(); - String getUuid(); + public abstract String getUuid(); - Long getTypeQNameId(); + public abstract Long getTypeQNameId(); - Long getLocaleId(); + public abstract Long getLocaleId(); - TransactionEntity getTransaction(); + public abstract TransactionEntity getTransaction(); - AuditablePropertiesEntity getAuditableProperties(); - - String getShardKey(); - - Integer getExplicitShardId(); + public abstract AuditablePropertiesEntity getAuditableProperties(); + + public abstract String getShardKey(); } \ No newline at end of file diff --git a/src/main/java/org/alfresco/repo/domain/node/NodeEntity.java b/src/main/java/org/alfresco/repo/domain/node/NodeEntity.java index afdc9c2a51..eb12b0c25d 100644 --- a/src/main/java/org/alfresco/repo/domain/node/NodeEntity.java +++ b/src/main/java/org/alfresco/repo/domain/node/NodeEntity.java @@ -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 . - * #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 . + * #L% + */ package org.alfresco.repo.domain.node; import java.io.Serializable; @@ -54,9 +54,8 @@ 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 @@ -91,7 +90,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(); } @@ -140,7 +139,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(); @@ -335,30 +334,18 @@ public class NodeEntity implements Node, PermissionCheckValue, Serializable, Clo { checkLock(); this.auditableProperties = auditableProperties; - } - - @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; - } - - - + } + + @Override + public String getShardKey() + { + return this.shardKey; + } + + public synchronized void setShardKey(String shardKey) + { + this.shardKey = shardKey; + } + + } diff --git a/src/main/java/org/alfresco/repo/index/shard/ShardRegistry.java b/src/main/java/org/alfresco/repo/index/shard/ShardRegistry.java index 6e8295e795..04034074c2 100644 --- a/src/main/java/org/alfresco/repo/index/shard/ShardRegistry.java +++ b/src/main/java/org/alfresco/repo/index/shard/ShardRegistry.java @@ -1,68 +1,52 @@ -/* - * #%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 . - * #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 . + * #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; /** - * A registry which collects all the active shard subscriptions. - * * @author Andy - * @author agazzarini - * @author eporciani + * */ public interface ShardRegistry { - /** - * 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 void registerShardState(ShardState shardState); - List getIndexSlice(SearchParameters searchParameters); + public List getIndexSlice(SearchParameters searchParameters); - void purge(); + public void purge(); - Map>> getFlocs(); + public HashMap>> getFlocs(); - 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); + public void purgeAgedOutShards(); } diff --git a/src/main/java/org/alfresco/repo/solr/NodeParameters.java b/src/main/java/org/alfresco/repo/solr/NodeParameters.java index f78c69d012..e01c0b753d 100644 --- a/src/main/java/org/alfresco/repo/solr/NodeParameters.java +++ b/src/main/java/org/alfresco/repo/solr/NodeParameters.java @@ -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 . - * #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 . + * #L% + */ package org.alfresco.repo.solr; import java.util.List; @@ -54,11 +54,10 @@ public class NodeParameters private Set excludeNodeTypes; private Set includeAspects; - private Set excludeAspects; - + private Set excludeAspects; + private String shardProperty; - private String coreName; - + public int getMaxResults() { return maxResults; @@ -182,25 +181,15 @@ public class NodeParameters public void setExcludeAspects(Set 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; - } - - } diff --git a/src/main/java/org/alfresco/repo/solr/SOLRTrackingComponentImpl.java b/src/main/java/org/alfresco/repo/solr/SOLRTrackingComponentImpl.java index fe1041a5ba..ac845a5685 100644 --- a/src/main/java/org/alfresco/repo/solr/SOLRTrackingComponentImpl.java +++ b/src/main/java/org/alfresco/repo/solr/SOLRTrackingComponentImpl.java @@ -36,7 +36,6 @@ 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; @@ -47,7 +46,6 @@ 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; @@ -377,15 +375,6 @@ 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); } } diff --git a/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/solr-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/solr-common-SqlMap.xml index c7744bc5fc..07d33988f4 100644 --- a/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/solr-common-SqlMap.xml +++ b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/solr-common-SqlMap.xml @@ -26,7 +26,6 @@ - @@ -116,13 +115,12 @@