Fix for ACE-4089 SOLR 4 - sharded - Remove the requirement for shard configuration on the Alfresco One Platform

- vanilla support - currently not enterprise only and does not support slave shards

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@111382 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrew Hind
2015-09-03 10:37:33 +00:00
parent 54c5962983
commit a57feb95b4
2 changed files with 50 additions and 3 deletions

View File

@@ -5,7 +5,8 @@
<format default="json">argument</format>
<!-- Solr api is protected by a solr-specific authentication mechanism -->
<authentication>none</authentication>
<transaction allow="readonly">required</transaction>
<!-- Must be readwrite as it updates shard state -->
<transaction allow="readwrite">required</transaction>
<lifecycle>internal</lifecycle>
<family>SOLR</family>
</webscript>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
* Copyright (C) 2005-2015 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -22,8 +22,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.repo.index.shard.ShardMethodEnum;
import org.alfresco.repo.index.shard.ShardState;
import org.alfresco.repo.index.shard.ShardStateBuilder;
import org.alfresco.repo.solr.SOLRTrackingComponent;
import org.alfresco.repo.solr.Transaction;
import org.alfresco.service.cmr.repository.StoreRef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
@@ -54,6 +58,49 @@ public class TransactionsGet extends DeclarativeWebScript
String toCommitTimeParam = req.getParameter("toCommitTime");
String maxResultsParam = req.getParameter("maxResults");
String baseUrl = req.getParameter("baseUrl");
String hostName = req.getParameter("hostName");
String template = req.getParameter("template");
String instance = req.getParameter("instance");
String numberOfShards = req.getParameter("numberOfShards");
String port = req.getParameter("port");
String stores = req.getParameter("stores");
String isMaster = req.getParameter("isMaster");
String hasContent = req.getParameter("hasContent");
String shardMethod = req.getParameter("shardMethod");
if(baseUrl != null)
{
ShardState shardState = ShardStateBuilder.shardState()
.withMaster(Boolean.valueOf(isMaster))
.withShardInstance()
.withBaseUrl(baseUrl)
.withPort(Integer.valueOf(port))
.withHostName(hostName)
.withShard()
.withInstance(Integer.valueOf(instance))
.withFloc()
.withNumberOfShards(Integer.valueOf(numberOfShards))
.withTemplate(template)
.withHasContent(Boolean.valueOf(hasContent))
.withShardMethod(ShardMethodEnum.getShardMethod(shardMethod))
.endFloc()
.endShard()
.endShardInstance()
.build();
for(String store : stores.split(","))
{
shardState.getShardInstance().getShard().getFloc().getStoreRefs().add(new StoreRef(store));
}
solrTrackingComponent.registerShardState(shardState);
}
Long minTxnId = (minTxnIdParam == null ? null : Long.valueOf(minTxnIdParam));
Long fromCommitTime = (fromCommitTimeParam == null ? null : Long.valueOf(fromCommitTimeParam));
Long maxTxnId = (maxTxnIdParam == null ? null : Long.valueOf(maxTxnIdParam));
@@ -84,5 +131,4 @@ public class TransactionsGet extends DeclarativeWebScript
return model;
}
}