SEARCH-403: Fully integrated DB_ID_RANGE shard method

This commit is contained in:
Joel
2017-06-01 13:36:25 -04:00
parent 47b5caf506
commit 2fc641f92c
3 changed files with 29 additions and 17 deletions
@@ -21,6 +21,7 @@ package org.alfresco.solr.tracker;
import org.alfresco.repo.index.shard.ShardMethodEnum;
import java.util.Properties;
import java.util.Set;
/*
* @author Joel
@@ -29,9 +30,16 @@ import java.util.Properties;
public class DocRouterFactory
{
public static DocRouter getRouter(Properties properties, ShardMethodEnum method) {
switch(method) {
case DB_ID:
return new DBIDRouter();
case DB_ID_RANGE:
String range = properties.getProperty("shard.range");
String[] rangeParts = range.split("-");
long startRange = Long.parseLong(rangeParts[0].trim());
long endRange = Long.parseLong(rangeParts[1].trim());
return new DBIDRangeRouter(startRange, endRange);
case ACL_ID:
return new ACLIDMurmurRouter();
case MOD_ACL_ID:
@@ -41,15 +49,8 @@ public class DocRouterFactory
case PROPERTY:
return new PropertyRouter(properties.getProperty("shard.regex", ""));
default:
if(properties.containsKey("shard.range")) {
String range = properties.getProperty("shard.range");
String[] rangeParts = range.split("-");
long startRange = Long.parseLong(rangeParts[0].trim());
long endRange = Long.parseLong(rangeParts[1].trim());
return new DBIDRangeRouter(startRange, endRange);
} else {
return new DBIDRouter();
}
return new DBIDRouter();
}
}
}
@@ -589,9 +589,16 @@ public abstract class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
JettySolrRunner jsr = createJetty(jettyKey);
jettyContainers.put(jettyKey, jsr);
Properties properties = new Properties();
if(additionalProperties != null) {
properties.putAll(additionalProperties);
properties.remove("shard.method");
}
for (int i = 0; i < coreNames.length; i++)
{
addCoreToJetty(jettyKey, coreNames[i], coreNames[i], additionalProperties);
addCoreToJetty(jettyKey, coreNames[i], coreNames[i], properties);
}
//Now start jetty
@@ -608,25 +615,30 @@ public abstract class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
shardsArr = new String[numShards];
StringBuilder sb = new StringBuilder();
if (additionalProperties == null) {
additionalProperties = new Properties();
}
String[] ranges = {"0-100", "100-200", "200-300", "300-400"};
for (int i = 0; i < numShards; i++)
{
Properties props = new Properties();
props.putAll(additionalProperties);
if (sb.length() > 0) sb.append(',');
final String shardname = "shard" + i;
if (additionalProperties == null) additionalProperties = new Properties();
additionalProperties.put("shard.instance", Integer.toString(i));
additionalProperties.put("shard.count", Integer.toString(numShards));
props.put("shard.instance", Integer.toString(i));
props.put("shard.count", Integer.toString(numShards));
if(additionalProperties.getProperty("shard.method").equals("DB_ID_RANGE")) {
if("DB_ID_RANGE".equalsIgnoreCase(props.getProperty("shard.method"))) {
//Add
additionalProperties.put("shard.range", ranges[i]);
props.put("shard.range", ranges[i]);
}
String shardKey = jettyKey+"_shard_"+i;
JettySolrRunner j = createJetty(shardKey);
//use the first corename specified as the Share template
addCoreToJetty(shardKey, coreNames[0], shardname, additionalProperties);
addCoreToJetty(shardKey, coreNames[0], shardname, props);
jettyShards.add(j);
startJetty(j);
String shardStr = buildUrl(j.getLocalPort()) + "/" + shardname;
@@ -65,7 +65,6 @@ public class DistributedDbidRangeAlfrescoSolrTrackerTest extends AbstractAlfresc
@Test
public void testDbIdRange() throws Exception
{
Thread.sleep(25000);
putHandleDefaults();
int numAcls = 250;