} else {
Set<String> docIds = new HashSet<String>();
// Check for work: all un-indexed date intervals
{
CouchQuery query = new CouchQuery();
query.setViewName("date-index");
query.setReduce(false);
JSONArray keys = new JSONArray();
keys.put(JSONObject.NULL);
query.setKeys(keys);
CouchQueryResults results = atlasDesign.performQuery(query);
synchronized(this) { // protect docIdsToSkip
for(JSONObject row : results.getRows()) {
String id = row.optString("id");
if( null != id
&& false == docIdsToSkip.contains(id) ) {
// Found some work
docIds.add(id);
}
}
}
}
// Check for work: all legacy nodes
{
List<TreeNode> legacyNodes = clusterTree.getLegacyNodes();
if( legacyNodes.size() > 0 ){
JSONArray keys = new JSONArray();
for(TreeNode legacyNode : legacyNodes){
keys.put(legacyNode.getClusterId());
}
CouchQuery query = new CouchQuery();
query.setViewName("date-index");
query.setReduce(false);
query.setReduce(false);
query.setKeys(keys);
CouchQueryResults results = atlasDesign.performQuery(query);
synchronized(this) { // protect docIdsToSkip
for(JSONObject row : results.getRows()) {
String id = row.optString("id");