public RoutingRule(String routeKey, Map<String, Object> propMap) { super(propMap); this.routeRangesStr = (String) propMap.get("routeRanges"); String[] rangesArr = this.routeRangesStr.split(","); if (rangesArr != null && rangesArr.length > 0) { this.routeRanges = new ArrayList<>(); for (String r : rangesArr) { routeRanges.add(DocRouter.DEFAULT.fromString(r)); } } else { this.routeRanges = null; } this.targetCollectionName = (String) propMap.get("targetCollection"); this.expireAt = Long.parseLong((String) propMap.get("expireAt")); }
private static DocCollection collectionFromObjects(String name, Map<String, Object> objs, Integer version, String znode) { Map<String,Object> props; Map<String,Slice> slices; Map<String,Object> sliceObjs = (Map<String,Object>)objs.get(DocCollection.SHARDS); if (sliceObjs == null) { // legacy format from 4.0... there was no separate "shards" level to contain the collection shards. slices = makeSlices(objs); props = Collections.emptyMap(); } else { slices = makeSlices(sliceObjs); props = new HashMap<>(objs); objs.remove(DocCollection.SHARDS); } Object routerObj = props.get(DocCollection.DOC_ROUTER); DocRouter router; if (routerObj == null) { router = DocRouter.DEFAULT; } else if (routerObj instanceof String) { // back compat with Solr4.4 router = DocRouter.getDocRouter((String)routerObj); } else { Map routerProps = (Map)routerObj; router = DocRouter.getDocRouter((String) routerProps.get("name")); } return new DocCollection(name, slices, props, router, version, znode); }
/** This method is consulted to determine what slices should be queried for a request when * an explicit shards parameter was not used. * This method accepts a multi-valued shardKeys parameter (normally comma separated from the shard.keys request parameter) * and aggregates the slices returned by getSearchSlicesSingle for each shardKey. **/ public Collection<Slice> getSearchSlices(String shardKeys, SolrParams params, DocCollection collection) { if (shardKeys == null || shardKeys.indexOf(',') < 0) { return getSearchSlicesSingle(shardKeys, params, collection); } List<String> shardKeyList = StrUtils.splitSmart(shardKeys, ",", true); HashSet<Slice> allSlices = new HashSet<>(); for (String shardKey : shardKeyList) { allSlices.addAll( getSearchSlicesSingle(shardKey, params, collection) ); } return allSlices; }
Slice slice = docRouter.getTargetSlice(keyStr, doc, null, emptySolrParams, docCollection);
throw new SolrException(ErrorCode.BAD_REQUEST, "Collection not found: " + collectionName); Collection<Slice> routeSlices = col.getRouter().getSearchSlices(shardKeys, reqParams , col); ClientUtils.addSlices(slices, collectionName, routeSlices, true);
Slice slice = docRouter.getTargetSlice(keyStr, doc, emptySolrParams, docCollection);
for (String collectionName : collectionNames) { DocCollection col = getDocCollection(clusterState, collectionName, null); Collection<Slice> routeSlices = col.getRouter().getSearchSlices(shardKeys, reqParams , col); ClientUtils.addSlices(slices, collectionName, routeSlices, true);
return null; Slice slice = router.getTargetSlice(id .toString(), doc, null, null, col); if (slice == null) { version = (Long) map.get(VER); Slice slice = router.getTargetSlice(deleteId, null, null, null, col); if (slice == null) { return null;
public RoutingRule(String routeKey, Map<String, Object> propMap) { super(propMap); this.routeRangesStr = (String) propMap.get("routeRanges"); String[] rangesArr = this.routeRangesStr.split(","); if (rangesArr != null && rangesArr.length > 0) { this.routeRanges = new ArrayList<>(); for (String r : rangesArr) { routeRanges.add(DocRouter.DEFAULT.fromString(r)); } } else { this.routeRanges = null; } this.targetCollectionName = (String) propMap.get("targetCollection"); this.expireAt = Long.parseLong((String) propMap.get("expireAt")); }
/** This method is consulted to determine what slices should be queried for a request when * an explicit shards parameter was not used. * This method accepts a multi-valued shardKeys parameter (normally comma separated from the shard.keys request parameter) * and aggregates the slices returned by getSearchSlicesSingle for each shardKey. **/ public Collection<Slice> getSearchSlices(String shardKeys, SolrParams params, DocCollection collection) { if (shardKeys == null || shardKeys.indexOf(',') < 0) { return getSearchSlicesSingle(shardKeys, params, collection); } List<String> shardKeyList = StrUtils.splitSmart(shardKeys, ",", true); HashSet<Slice> allSlices = new HashSet<>(); for (String shardKey : shardKeyList) { allSlices.addAll( getSearchSlicesSingle(shardKey, params, collection) ); } return allSlices; }
private static DocCollection collectionFromObjects(String name, Map<String, Object> objs, Integer version, String znode) { Map<String,Object> props; Map<String,Slice> slices; Map<String,Object> sliceObjs = (Map<String,Object>)objs.get(DocCollection.SHARDS); if (sliceObjs == null) { // legacy format from 4.0... there was no separate "shards" level to contain the collection shards. slices = Slice.loadAllFromMap(objs); props = Collections.emptyMap(); } else { slices = Slice.loadAllFromMap(sliceObjs); props = new HashMap<>(objs); objs.remove(DocCollection.SHARDS); } Object routerObj = props.get(DocCollection.DOC_ROUTER); DocRouter router; if (routerObj == null) { router = DocRouter.DEFAULT; } else if (routerObj instanceof String) { // back compat with Solr4.4 router = DocRouter.getDocRouter((String)routerObj); } else { Map routerProps = (Map)routerObj; router = DocRouter.getDocRouter((String) routerProps.get("name")); } return new DocCollection(name, slices, props, router, version, znode); }
return null; Slice slice = router.getTargetSlice(id .toString(), doc, null, null, col); if (slice == null) { version = (Long) map.get(VER); Slice slice = router.getTargetSlice(deleteId, null, null, null, col); if (slice == null) { return null;
} else if (rangeObj != null) { tmpRange = DocRouter.DEFAULT.fromString(rangeObj.toString());
} else if (rangeObj != null) { tmpRange = DocRouter.DEFAULT.fromString(rangeObj.toString());