// Path: src/com/architecting/ch07/MapReduceIndexerTool.java
// static final class Options {
//   boolean goLive;
//   String collection;
//   String zkHost;
//   Integer goLiveThreads;
//   List<List<String>> shardUrls;
//   String inputTable;
//   Path outputDir;
//   int mappers;
//   int reducers;
//   int fanout;
//   Integer shards;
//   int maxSegments;
//   File solrHomeDir;
//   File log4jConfigFile;
// }


import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionService;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.fs.FileStatus;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrServer;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.architecting.ch07.MapReduceIndexerTool.Options;
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
 * agreements. See the NOTICE file distributed with this work for additional information regarding
 * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License. You may obtain a
 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
 * law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 * for the specific language governing permissions and limitations under the License.
 */
package com.architecting.ch07;





/**
 * The optional (parallel) GoLive phase merges the output shards of the previous phase into a set of
 * live customer facing Solr servers, typically a SolrCloud.
 */
class GoLive {

  private static final Logger LOG = LoggerFactory.getLogger(GoLive.class);

  // TODO: handle clusters with replicas
// Path: src/com/architecting/ch07/MapReduceIndexerTool.java
// static final class Options {
//   boolean goLive;
//   String collection;
//   String zkHost;
//   Integer goLiveThreads;
//   List<List<String>> shardUrls;
//   String inputTable;
//   Path outputDir;
//   int mappers;
//   int reducers;
//   int fanout;
//   Integer shards;
//   int maxSegments;
//   File solrHomeDir;
//   File log4jConfigFile;
// }


// Path: src/com/architecting/ch07/GoLive.java
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionService;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.fs.FileStatus;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrServer;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.architecting.ch07.MapReduceIndexerTool.Options;

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
 * agreements. See the NOTICE file distributed with this work for additional information regarding
 * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License. You may obtain a
 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
 * law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 * for the specific language governing permissions and limitations under the License.
 */
package com.architecting.ch07;





/**
 * The optional (parallel) GoLive phase merges the output shards of the previous phase into a set of
 * live customer facing Solr servers, typically a SolrCloud.
 */
class GoLive {

  private static final Logger LOG = LoggerFactory.getLogger(GoLive.class);

  // TODO: handle clusters with replicas
  public boolean goLive(Options options, FileStatus[] outDirs) {