You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by da...@apache.org on 2018/10/23 00:05:37 UTC

[16/52] [abbrv] [partial] lucene-solr:jira/gradle: Add gradle support for Solr

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/StreamHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/StreamHandler.java b/solr/core/src/java/org/apache/solr/handler/StreamHandler.java
deleted file mode 100644
index a447093..0000000
--- a/solr/core/src/java/org/apache/solr/handler/StreamHandler.java
+++ /dev/null
@@ -1,449 +0,0 @@
-/*
- * 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 org.apache.solr.handler;
-
-import java.io.IOException;
-import java.lang.invoke.MethodHandles;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.apache.solr.client.solrj.io.ModelCache;
-import org.apache.solr.client.solrj.io.SolrClientCache;
-import org.apache.solr.client.solrj.io.Tuple;
-import org.apache.solr.client.solrj.io.comp.StreamComparator;
-import org.apache.solr.client.solrj.io.stream.*;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
-import org.apache.solr.client.solrj.io.stream.expr.Expressible;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExplanation;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParser;
-import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.core.CloseHook;
-import org.apache.solr.core.CoreContainer;
-import org.apache.solr.core.PluginInfo;
-import org.apache.solr.core.SolrCore;
-import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.security.AuthorizationContext;
-import org.apache.solr.security.PermissionNameProvider;
-import org.apache.solr.util.plugin.SolrCoreAware;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.solr.common.params.CommonParams.ID;
-
-/**
- * @since 5.1.0
- */
-public class StreamHandler extends RequestHandlerBase implements SolrCoreAware, PermissionNameProvider {
-
-  static SolrClientCache clientCache = new SolrClientCache();
-  static ModelCache modelCache = null;
-  static ConcurrentMap objectCache = new ConcurrentHashMap();
-  private SolrDefaultStreamFactory streamFactory = new SolrDefaultStreamFactory();
-  private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-  private String coreName;
-  private Map<String,DaemonStream> daemons = Collections.synchronizedMap(new HashMap());
-
-  @Override
-  public PermissionNameProvider.Name getPermissionName(AuthorizationContext request) {
-    return PermissionNameProvider.Name.READ_PERM;
-  }
-
-  public static SolrClientCache getClientCache() {
-    return clientCache;
-  }
-
-  public void inform(SolrCore core) {
-
-    /*
-     * The stream factory will always contain the zkUrl for the given collection Adds default streams with their
-     * corresponding function names. These defaults can be overridden or added to in the solrConfig in the stream
-     * RequestHandler def. Example config override 
-     * <lst name="streamFunctions"> 
-     *  <str name="group">org.apache.solr.client.solrj.io.stream.ReducerStream</str> 
-     *  <str name="count">org.apache.solr.client.solrj.io.stream.RecordCountStream</str> 
-     * </lst>
-     */
-
-    String defaultCollection;
-    String defaultZkhost;
-    CoreContainer coreContainer = core.getCoreContainer();
-    this.coreName = core.getName();
-
-    if (coreContainer.isZooKeeperAware()) {
-      defaultCollection = core.getCoreDescriptor().getCollectionName();
-      defaultZkhost = core.getCoreContainer().getZkController().getZkServerAddress();
-      streamFactory.withCollectionZkHost(defaultCollection, defaultZkhost);
-      streamFactory.withDefaultZkHost(defaultZkhost);
-      modelCache = new ModelCache(250,
-          defaultZkhost,
-          clientCache);
-    }
-    streamFactory.withSolrResourceLoader(core.getResourceLoader());
-
-    // This pulls all the overrides and additions from the config
-    List<PluginInfo> pluginInfos = core.getSolrConfig().getPluginInfos(Expressible.class.getName());
-    for (PluginInfo pluginInfo : pluginInfos) {
-      Class<? extends Expressible> clazz = core.getMemClassLoader().findClass(pluginInfo.className, Expressible.class);
-      streamFactory.withFunctionName(pluginInfo.name, clazz);
-    }
-
-    core.addCloseHook(new CloseHook() {
-      @Override
-      public void preClose(SolrCore core) {
-        // To change body of implemented methods use File | Settings | File Templates.
-      }
-
-      @Override
-      public void postClose(SolrCore core) {
-        clientCache.close();
-      }
-    });
-  }
-
-  public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
-    SolrParams params = req.getParams();
-    params = adjustParams(params);
-    req.setParams(params);
-
-    if (params.get("action") != null) {
-      handleAdmin(req, rsp, params);
-      return;
-    }
-
-    TupleStream tupleStream;
-
-    try {
-      StreamExpression streamExpression = StreamExpressionParser.parse(params.get("expr"));
-      if (this.streamFactory.isEvaluator(streamExpression)) {
-        StreamExpression tupleExpression = new StreamExpression("tuple");
-        tupleExpression.addParameter(new StreamExpressionNamedParameter("return-value", streamExpression));
-        tupleStream = this.streamFactory.constructStream(tupleExpression);
-      } else {
-        tupleStream = this.streamFactory.constructStream(streamExpression);
-      }
-    } catch (Exception e) {
-      // Catch exceptions that occur while the stream is being created. This will include streaming expression parse
-      // rules.
-      SolrException.log(log, e);
-      rsp.add("result-set", new DummyErrorStream(e));
-
-      return;
-    }
-
-    int worker = params.getInt("workerID", 0);
-    int numWorkers = params.getInt("numWorkers", 1);
-    StreamContext context = new StreamContext();
-    context.put("shards", getCollectionShards(params));
-    context.workerID = worker;
-    context.numWorkers = numWorkers;
-    context.setSolrClientCache(clientCache);
-    context.setModelCache(modelCache);
-    context.setObjectCache(objectCache);
-    context.put("core", this.coreName);
-    context.put("solr-core", req.getCore());
-    tupleStream.setStreamContext(context);
-
-    // if asking for explanation then go get it
-    if (params.getBool("explain", false)) {
-      rsp.add("explanation", tupleStream.toExplanation(this.streamFactory));
-    }
-
-    if (tupleStream instanceof DaemonStream) {
-      DaemonStream daemonStream = (DaemonStream) tupleStream;
-      if (daemons.containsKey(daemonStream.getId())) {
-        daemons.remove(daemonStream.getId()).close();
-      }
-      daemonStream.setDaemons(daemons);
-      daemonStream.open(); // This will start the deamonStream
-      daemons.put(daemonStream.getId(), daemonStream);
-      rsp.add("result-set", new DaemonResponseStream("Deamon:" + daemonStream.getId() + " started on " + coreName));
-    } else {
-      rsp.add("result-set", new TimerStream(new ExceptionStream(tupleStream)));
-    }
-  }
-
-  private void handleAdmin(SolrQueryRequest req, SolrQueryResponse rsp, SolrParams params) {
-    String action = params.get("action");
-    if ("stop".equalsIgnoreCase(action)) {
-      String id = params.get(ID);
-      DaemonStream d = daemons.get(id);
-      if (d != null) {
-        d.close();
-        rsp.add("result-set", new DaemonResponseStream("Deamon:" + id + " stopped on " + coreName));
-      } else {
-        rsp.add("result-set", new DaemonResponseStream("Deamon:" + id + " not found on " + coreName));
-      }
-    } else {
-      if ("start".equalsIgnoreCase(action)) {
-        String id = params.get(ID);
-        DaemonStream d = daemons.get(id);
-        d.open();
-        rsp.add("result-set", new DaemonResponseStream("Deamon:" + id + " started on " + coreName));
-      } else if ("list".equalsIgnoreCase(action)) {
-        Collection<DaemonStream> vals = daemons.values();
-        rsp.add("result-set", new DaemonCollectionStream(vals));
-      } else if ("kill".equalsIgnoreCase(action)) {
-        String id = params.get("id");
-        DaemonStream d = daemons.remove(id);
-        if (d != null) {
-          d.close();
-        }
-        rsp.add("result-set", new DaemonResponseStream("Deamon:" + id + " killed on " + coreName));
-      }
-    }
-  }
-
-  private SolrParams adjustParams(SolrParams params) {
-    ModifiableSolrParams adjustedParams = new ModifiableSolrParams();
-    adjustedParams.add(params);
-    adjustedParams.add(CommonParams.OMIT_HEADER, "true");
-    return adjustedParams;
-  }
-
-  public String getDescription() {
-    return "StreamHandler";
-  }
-
-  public String getSource() {
-    return null;
-  }
-
-  public static class DummyErrorStream extends TupleStream {
-    private Exception e;
-
-    public DummyErrorStream(Exception e) {
-      this.e = e;
-    }
-
-    public StreamComparator getStreamSort() {
-      return null;
-    }
-
-    public void close() {}
-
-    public void open() {}
-
-    public void setStreamContext(StreamContext context) {}
-
-    public List<TupleStream> children() {
-      return null;
-    }
-
-    @Override
-    public Explanation toExplanation(StreamFactory factory) throws IOException {
-
-      return new StreamExplanation(getStreamNodeId().toString())
-          .withFunctionName("error")
-          .withImplementingClass(this.getClass().getName())
-          .withExpressionType(ExpressionType.STREAM_DECORATOR)
-          .withExpression("--non-expressible--");
-    }
-
-    public Tuple read() {
-      String msg = e.getMessage();
-
-      Throwable t = e.getCause();
-      while (t != null) {
-        msg = t.getMessage();
-        t = t.getCause();
-      }
-
-      Map m = new HashMap();
-      m.put("EOF", true);
-      m.put("EXCEPTION", msg);
-      return new Tuple(m);
-    }
-  }
-
-  public static class DaemonCollectionStream extends TupleStream {
-    private Iterator<DaemonStream> it;
-
-    public DaemonCollectionStream(Collection<DaemonStream> col) {
-      this.it = col.iterator();
-    }
-
-    public StreamComparator getStreamSort() {
-      return null;
-    }
-
-    public void close() {}
-
-    public void open() {}
-
-    public void setStreamContext(StreamContext context) {}
-
-    public List<TupleStream> children() {
-      return null;
-    }
-
-    @Override
-    public Explanation toExplanation(StreamFactory factory) throws IOException {
-
-      return new StreamExplanation(getStreamNodeId().toString())
-          .withFunctionName("daemon-collection")
-          .withImplementingClass(this.getClass().getName())
-          .withExpressionType(ExpressionType.STREAM_DECORATOR)
-          .withExpression("--non-expressible--");
-    }
-
-    public Tuple read() {
-      if (it.hasNext()) {
-        return it.next().getInfo();
-      } else {
-        Map m = new HashMap();
-        m.put("EOF", true);
-        return new Tuple(m);
-      }
-    }
-  }
-
-  public static class DaemonResponseStream extends TupleStream {
-    private String message;
-    private boolean sendEOF = false;
-
-    public DaemonResponseStream(String message) {
-      this.message = message;
-    }
-
-    public StreamComparator getStreamSort() {
-      return null;
-    }
-
-    public void close() {}
-
-    public void open() {}
-
-    public void setStreamContext(StreamContext context) {}
-
-    public List<TupleStream> children() {
-      return null;
-    }
-
-    @Override
-    public Explanation toExplanation(StreamFactory factory) throws IOException {
-
-      return new StreamExplanation(getStreamNodeId().toString())
-          .withFunctionName("daemon-response")
-          .withImplementingClass(this.getClass().getName())
-          .withExpressionType(ExpressionType.STREAM_DECORATOR)
-          .withExpression("--non-expressible--");
-    }
-
-    public Tuple read() {
-      if (sendEOF) {
-        Map m = new HashMap();
-        m.put("EOF", true);
-        return new Tuple(m);
-      } else {
-        sendEOF = true;
-        Map m = new HashMap();
-        m.put("DaemonOp", message);
-        return new Tuple(m);
-      }
-    }
-  }
-
-  public static class TimerStream extends TupleStream {
-
-    private long begin;
-    private TupleStream tupleStream;
-
-    public TimerStream(TupleStream tupleStream) {
-      this.tupleStream = tupleStream;
-    }
-
-    public StreamComparator getStreamSort() {
-      return this.tupleStream.getStreamSort();
-    }
-
-    public void close() throws IOException {
-      this.tupleStream.close();
-    }
-
-    public void open() throws IOException {
-      this.begin = System.nanoTime();
-      this.tupleStream.open();
-    }
-
-    public void setStreamContext(StreamContext context) {
-      this.tupleStream.setStreamContext(context);
-    }
-
-    public List<TupleStream> children() {
-      return this.tupleStream.children();
-    }
-
-    @Override
-    public Explanation toExplanation(StreamFactory factory) throws IOException {
-
-      return new StreamExplanation(getStreamNodeId().toString())
-          .withFunctionName("timer")
-          .withImplementingClass(this.getClass().getName())
-          .withExpressionType(ExpressionType.STREAM_DECORATOR)
-          .withExpression("--non-expressible--");
-    }
-
-    public Tuple read() throws IOException {
-      Tuple tuple = this.tupleStream.read();
-      if (tuple.EOF) {
-        long totalTime = (System.nanoTime() - begin) / 1000000;
-        tuple.fields.put("RESPONSE_TIME", totalTime);
-      }
-      return tuple;
-    }
-  }
-
-  private Map<String,List<String>> getCollectionShards(SolrParams params) {
-
-    Map<String,List<String>> collectionShards = new HashMap();
-    Iterator<String> paramsIt = params.getParameterNamesIterator();
-    while (paramsIt.hasNext()) {
-      String param = paramsIt.next();
-      if (param.indexOf(".shards") > -1) {
-        String collection = param.split("\\.")[0];
-        String shardString = params.get(param);
-        String[] shards = shardString.split(",");
-        List<String> shardList = new ArrayList();
-        for (String shard : shards) {
-          shardList.add(shard);
-        }
-        collectionShards.put(collection, shardList);
-      }
-    }
-
-    if (collectionShards.size() > 0) {
-      return collectionShards;
-    } else {
-      return null;
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandler.java
deleted file mode 100644
index cbe2cba..0000000
--- a/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandler.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * 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 org.apache.solr.handler;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrException.ErrorCode;
-import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.params.MapSolrParams;
-import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.common.params.UpdateParams;
-import org.apache.solr.common.util.ContentStream;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.handler.loader.CSVLoader;
-import org.apache.solr.handler.loader.ContentStreamLoader;
-import org.apache.solr.handler.loader.JavabinLoader;
-import org.apache.solr.handler.loader.JsonLoader;
-import org.apache.solr.handler.loader.XMLLoader;
-import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.security.AuthorizationContext;
-import org.apache.solr.security.PermissionNameProvider;
-import org.apache.solr.update.processor.UpdateRequestProcessor;
-
-import static org.apache.solr.common.params.CommonParams.PATH;
-import static org.apache.solr.security.PermissionNameProvider.Name.UPDATE_PERM;
-
-/**
- * UpdateHandler that uses content-type to pick the right Loader
- */
-public class UpdateRequestHandler extends ContentStreamHandlerBase implements PermissionNameProvider {
-
-  // XML Constants
-  public static final String ADD = "add";
-  public static final String DELETE = "delete";
-  public static final String OPTIMIZE = "optimize";
-  public static final String COMMIT = "commit";
-  public static final String ROLLBACK = "rollback";
-  public static final String WAIT_SEARCHER = "waitSearcher";
-  public static final String SOFT_COMMIT = "softCommit";
-
-  public static final String OVERWRITE = "overwrite";
-
-  public static final String VERSION = "version";
-
-  // NOTE: This constant is for use with the <add> XML tag, not the HTTP param with same name
-  public static final String COMMIT_WITHIN = "commitWithin";
-
-  Map<String,ContentStreamLoader> loaders = null;
-
-  ContentStreamLoader instance = new ContentStreamLoader() {
-    @Override
-    public void load(SolrQueryRequest req, SolrQueryResponse rsp,
-        ContentStream stream, UpdateRequestProcessor processor) throws Exception {
-
-      ContentStreamLoader loader = pathVsLoaders.get(req.getContext().get(PATH));
-      if(loader == null) {
-        String type = req.getParams().get(UpdateParams.ASSUME_CONTENT_TYPE);
-        if (type == null) {
-          type = stream.getContentType();
-        }
-        if (type == null) { // Normal requests will not get here.
-          throw new SolrException(ErrorCode.UNSUPPORTED_MEDIA_TYPE, "Missing ContentType");
-        }
-        int idx = type.indexOf(';');
-        if (idx > 0) {
-          type = type.substring(0, idx);
-        }
-        loader = loaders.get(type);
-        if (loader == null) {
-          throw new SolrException(ErrorCode.UNSUPPORTED_MEDIA_TYPE, "Unsupported ContentType: "
-              + type + "  Not in: " + loaders.keySet());
-        }
-      }
-
-      if(loader.getDefaultWT()!=null) {
-        setDefaultWT(req,loader);
-      }
-      loader.load(req, rsp, stream, processor);
-    }
-
-    private void setDefaultWT(SolrQueryRequest req, ContentStreamLoader loader) {
-      SolrParams params = req.getParams();
-      if( params.get(CommonParams.WT) == null ) {
-        String wt = loader.getDefaultWT();
-        // Make sure it is a valid writer
-        if(req.getCore().getQueryResponseWriter(wt)!=null) {
-          Map<String,String> map = new HashMap<>(1);
-          map.put(CommonParams.WT, wt);
-          req.setParams(SolrParams.wrapDefaults(params,
-              new MapSolrParams(map)));
-        }
-      }
-    }
-  };
-
-  @Override
-  public void init(NamedList args) {
-    super.init(args);
-
-    // Since backed by a non-thread safe Map, it should not be modifiable
-    loaders = Collections.unmodifiableMap(createDefaultLoaders(args));
-  }
-
-  protected void setAssumeContentType(String ct) {
-    if(invariants==null) {
-      Map<String,String> map = new HashMap<>();
-      map.put(UpdateParams.ASSUME_CONTENT_TYPE,ct);
-      invariants = new MapSolrParams(map);
-    }
-    else {
-      ModifiableSolrParams params = new ModifiableSolrParams(invariants);
-      params.set(UpdateParams.ASSUME_CONTENT_TYPE,ct);
-      invariants = params;
-    }
-  }
-  private Map<String ,ContentStreamLoader> pathVsLoaders = new HashMap<>();
-  protected Map<String,ContentStreamLoader> createDefaultLoaders(NamedList args) {
-    SolrParams p = null;
-    if(args!=null) {
-      p = args.toSolrParams();
-    }
-    Map<String,ContentStreamLoader> registry = new HashMap<>();
-    registry.put("application/xml", new XMLLoader().init(p) );
-    registry.put("application/json", new JsonLoader().init(p) );
-    registry.put("application/csv", new CSVLoader().init(p) );
-    registry.put("application/javabin", new JavabinLoader(instance).init(p) );
-    registry.put("text/csv", registry.get("application/csv") );
-    registry.put("text/xml", registry.get("application/xml") );
-    registry.put("text/json", registry.get("application/json"));
-
-    pathVsLoaders.put(JSON_PATH,registry.get("application/json"));
-    pathVsLoaders.put(DOC_PATH,registry.get("application/json"));
-    pathVsLoaders.put(CSV_PATH,registry.get("application/csv"));
-    pathVsLoaders.put(BIN_PATH,registry.get("application/javabin"));
-    return registry;
-  }
-
-  @Override
-  public PermissionNameProvider.Name getPermissionName(AuthorizationContext ctx) {
-    return UPDATE_PERM;
-  }
-
-  @Override
-  protected ContentStreamLoader newLoader(SolrQueryRequest req, final UpdateRequestProcessor processor) {
-    return instance;
-  }
-
-  //////////////////////// SolrInfoMBeans methods //////////////////////
-
-  @Override
-  public String getDescription() {
-    return "Add documents using XML (with XSLT), CSV, JSON, or javabin";
-  }
-
-  @Override
-  public Category getCategory() {
-    return Category.UPDATE;
-  }
-
-  public static final String DOC_PATH = "/update/json/docs";
-  public static final String JSON_PATH = "/update/json";
-  public static final String CSV_PATH = "/update/csv";
-  public static final String BIN_PATH = "/update/bin";
-
-}
-
-
-

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandlerApi.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandlerApi.java b/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandlerApi.java
deleted file mode 100644
index f7bc140..0000000
--- a/solr/core/src/java/org/apache/solr/handler/UpdateRequestHandlerApi.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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 org.apache.solr.handler;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
-import com.google.common.collect.ImmutableMap;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.api.Api;
-import org.apache.solr.common.util.Utils;
-import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.response.SolrQueryResponse;
-
-
-public class UpdateRequestHandlerApi extends UpdateRequestHandler  {
-
-
-  @Override
-  public Collection<Api> getApis() {
-    return Collections.singleton(getApiImpl());
-  }
-
-  private Api getApiImpl() {
-    return new Api(Utils.getSpec("core.Update")) {
-      @Override
-      public void call(SolrQueryRequest req, SolrQueryResponse rsp) {
-        String path = req.getPath();
-        String target =  mapping.get(path);
-        if(target != null) req.getContext().put("path", target);
-        try {
-          handleRequest(req, rsp);
-        } catch (RuntimeException e) {
-          throw e;
-        } catch (Exception e){
-          throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,e );
-        }
-      }
-    };
-  }
-
-  @Override
-  public Boolean registerV1() {
-    return Boolean.FALSE;
-  }
-
-  @Override
-  public Boolean registerV2() {
-    return Boolean.TRUE;
-  }
-
-  private static final Map<String, String> mapping = ImmutableMap.<String,String>builder()
-      .put("/update", DOC_PATH)
-      .put(JSON_PATH, DOC_PATH)
-      .put("/update/json/commands", JSON_PATH)
-      .build();
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/admin/AdminHandlersProxy.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/AdminHandlersProxy.java b/solr/core/src/java/org/apache/solr/handler/admin/AdminHandlersProxy.java
deleted file mode 100644
index ae3e01f..0000000
--- a/solr/core/src/java/org/apache/solr/handler/admin/AdminHandlersProxy.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * 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 org.apache.solr.handler.admin;
-
-import java.io.IOException;
-import java.lang.invoke.MethodHandles;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.impl.HttpSolrClient;
-import org.apache.solr.client.solrj.request.GenericSolrRequest;
-import org.apache.solr.cloud.ZkController;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.params.MapSolrParams;
-import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.Pair;
-import org.apache.solr.core.CoreContainer;
-import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.response.SolrQueryResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Static methods to proxy calls to an Admin (GET) API to other nodes in the cluster and return a combined response
- */
-public class AdminHandlersProxy {
-  private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-  private static final String PARAM_NODES = "nodes";
-
-  // Proxy this request to a different remote node if 'node' parameter is provided
-  public static boolean maybeProxyToNodes(SolrQueryRequest req, SolrQueryResponse rsp, CoreContainer container)
-      throws IOException, SolrServerException, InterruptedException {
-    String nodeNames = req.getParams().get(PARAM_NODES);
-    if (nodeNames == null || nodeNames.isEmpty()) {
-      return false; // local request
-    }
-
-    if (!container.isZooKeeperAware()) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Parameter " + PARAM_NODES + " only supported in Cloud mode");
-    }
-    
-    Set<String> nodes;
-    String pathStr = req.getPath();
-    
-    Map<String,String> paramsMap = req.getParams().toMap(new HashMap<>());
-    paramsMap.remove(PARAM_NODES);
-    SolrParams params = new MapSolrParams(paramsMap);
-    Set<String> liveNodes = container.getZkController().zkStateReader.getClusterState().getLiveNodes();
-    
-    if (nodeNames.equals("all")) {
-      nodes = liveNodes;
-      log.debug("All live nodes requested");
-    } else {
-      nodes = new HashSet<>(Arrays.asList(nodeNames.split(",")));
-      for (String nodeName : nodes) {
-        if (!nodeName.matches("^[^/:]+:\\d+_[\\w/]+$")) {
-          throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Parameter " + PARAM_NODES + " has wrong format");
-        }
-
-        if (!liveNodes.contains(nodeName)) {
-          throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Requested node " + nodeName + " is not part of cluster");
-        }
-      }       
-      log.debug("Nodes requested: {}", nodes);
-    }
-    log.debug(PARAM_NODES + " parameter {} specified on {} request", nodeNames, pathStr);
-    
-    Map<String, Pair<Future<NamedList<Object>>, SolrClient>> responses = new HashMap<>();
-    for (String node : nodes) {
-      responses.put(node, callRemoteNode(node, pathStr, params, container.getZkController()));
-    }
-    
-    for (Map.Entry<String, Pair<Future<NamedList<Object>>, SolrClient>> entry : responses.entrySet()) {
-      try {
-        NamedList<Object> resp = entry.getValue().first().get(10, TimeUnit.SECONDS);
-        entry.getValue().second().close();
-        rsp.add(entry.getKey(), resp);
-      } catch (ExecutionException ee) {
-        log.warn("Exception when fetching result from node {}", entry.getKey(), ee);
-      } catch (TimeoutException te) {
-        log.warn("Timeout when fetching result from node {}", entry.getKey(), te);
-      }
-    }
-    log.info("Fetched response from {} nodes: {}", responses.keySet().size(), responses.keySet());
-    return true;
-  } 
-
-  /**
-   * Makes a remote request and returns a future and the solr client. The caller is responsible for closing the client 
-   */
-  public static Pair<Future<NamedList<Object>>, SolrClient> callRemoteNode(String nodeName, String endpoint, 
-                                                                           SolrParams params, ZkController zkController) 
-      throws IOException, SolrServerException {
-    log.debug("Proxying {} request to node {}", endpoint, nodeName);
-    URL baseUrl = new URL(zkController.zkStateReader.getBaseUrlForNodeName(nodeName));
-    HttpSolrClient solr = new HttpSolrClient.Builder(baseUrl.toString()).build();
-    SolrRequest proxyReq = new GenericSolrRequest(SolrRequest.METHOD.GET, endpoint, params);
-    HttpSolrClient.HttpUriRequestResponse proxyResp = solr.httpUriRequest(proxyReq);
-    return new Pair<>(proxyResp.future, solr);
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/admin/AutoscalingHistoryHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/AutoscalingHistoryHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/AutoscalingHistoryHandler.java
deleted file mode 100644
index ae99453..0000000
--- a/solr/core/src/java/org/apache/solr/handler/admin/AutoscalingHistoryHandler.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * 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 org.apache.solr.handler.admin;
-
-import java.lang.invoke.MethodHandles;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Optional;
-
-import org.apache.solr.api.Api;
-import org.apache.solr.api.ApiBag;
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.cloud.autoscaling.SystemLogListener;
-import org.apache.solr.cloud.autoscaling.TriggerEvent;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.params.AutoScalingParams;
-import org.apache.solr.common.params.CollectionAdminParams;
-import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.core.CoreContainer;
-import org.apache.solr.handler.RequestHandlerBase;
-import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.security.AuthorizationContext;
-import org.apache.solr.security.PermissionNameProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This handler makes it easier to retrieve a history of autoscaling events from the .system
- * collection.
- */
-public class AutoscalingHistoryHandler extends RequestHandlerBase implements PermissionNameProvider {
-  private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
-  public static final String SYSTEM_COLLECTION_PARAM = "systemCollection";
-
-  public static final String ACTION_PARAM = "action";
-  public static final String MESSAGE_PARAM = "message";
-  public static final String TRIGGER_PARAM = AutoScalingParams.TRIGGER;
-  public static final String TYPE_PARAM = "eventType";
-  public static final String NODE_PARAM = "node";
-  public static final String COLLECTION_PARAM = CollectionAdminParams.COLLECTION;
-  public static final String STAGE_PARAM = AutoScalingParams.STAGE;
-  public static final String BEFORE_ACTION_PARAM = AutoScalingParams.BEFORE_ACTION;
-  public static final String AFTER_ACTION_PARAM = AutoScalingParams.AFTER_ACTION;
-
-  private static final String EVENTS_FQ = "{!term f=" + CommonParams.TYPE + "}" + SystemLogListener.DOC_TYPE;
-
-  private static final String ACTION_FQ_FORMAT = "{!term f=" + SystemLogListener.ACTION_FIELD + "}%s";
-  private static final String MESSAGE_FQ_FORMAT = "{!lucene}" + SystemLogListener.MESSAGE_FIELD + ":%s";
-  private static final String TRIGGER_FQ_FORMAT = "{!term f=" + SystemLogListener.EVENT_SOURCE_FIELD + "}%s";
-  private static final String STAGE_FQ_FORMAT = "{!term f=" + SystemLogListener.STAGE_FIELD + "}%s";
-  private static final String COLLECTION_FQ_FORMAT = "{!term f=" + SystemLogListener.COLLECTIONS_FIELD + "}%s";
-  private static final String TYPE_FQ_FORMAT = "{!term f=" + SystemLogListener.EVENT_TYPE_FIELD + "}%s";
-  private static final String NODE_FQ_FORMAT = "{!term f=event.property." + TriggerEvent.NODE_NAMES + "_ss}%s";
-  private static final String BEFORE_ACTION_FQ_FORMAT = "{!term f=" + SystemLogListener.BEFORE_ACTIONS_FIELD + "}%s";
-  private static final String AFTER_ACTION_FQ_FORMAT = "{!term f=" + SystemLogListener.AFTER_ACTIONS_FIELD + "}%s";
-
-  private static final Map<String, String> formats = new HashMap<String, String>() {{
-    put(ACTION_PARAM, ACTION_FQ_FORMAT);
-    put(MESSAGE_PARAM, MESSAGE_FQ_FORMAT);
-    put(TRIGGER_PARAM, TRIGGER_FQ_FORMAT);
-    put(TYPE_PARAM, TYPE_FQ_FORMAT);
-    put(STAGE_PARAM, STAGE_FQ_FORMAT);
-    put(NODE_PARAM, NODE_FQ_FORMAT);
-    put(COLLECTION_PARAM, COLLECTION_FQ_FORMAT);
-    put(BEFORE_ACTION_PARAM, BEFORE_ACTION_FQ_FORMAT);
-    put(AFTER_ACTION_PARAM, AFTER_ACTION_FQ_FORMAT);
-  }};
-
-  private final CoreContainer coreContainer;
-
-
-  public AutoscalingHistoryHandler(CoreContainer coreContainer) {
-    this.coreContainer = coreContainer;
-  }
-
-  @Override
-  public Name getPermissionName(AuthorizationContext request) {
-    return Name.AUTOSCALING_HISTORY_READ_PERM;
-  }
-
-  @Override
-  public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
-    ModifiableSolrParams params = new ModifiableSolrParams(req.getParams());
-    String collection = params.get(SYSTEM_COLLECTION_PARAM, CollectionAdminParams.SYSTEM_COLL);
-    params.remove(SYSTEM_COLLECTION_PARAM);
-    params.remove(CommonParams.QT);
-    // check that we have the main query, if not then use *:*
-    if (params.get(CommonParams.Q) == null) {
-      params.add(CommonParams.Q, "*:*");
-    }
-    // sort by doc id, which are time-based, unless specified otherwise
-    if (params.get(CommonParams.SORT) == null) {
-      params.add(CommonParams.SORT, "id asc");
-    }
-    // filter query to pick only autoscaling events
-    params.remove(CommonParams.FQ, EVENTS_FQ);
-    params.add(CommonParams.FQ, EVENTS_FQ);
-    // add filters translated from simplified parameters
-    for (Map.Entry<String, String> e : formats.entrySet()) {
-      String[] values = params.remove(e.getKey());
-      if (values != null) {
-        for (String value : values) {
-          params.add(CommonParams.FQ, String.format(Locale.ROOT, e.getValue(), value));
-        }
-      }
-    }
-    try (CloudSolrClient cloudSolrClient = new CloudSolrClient.Builder(Collections.singletonList(coreContainer.getZkController().getZkServerAddress()), Optional.empty())
-        .withHttpClient(coreContainer.getUpdateShardHandler().getDefaultHttpClient())
-        .build()) {
-      QueryResponse qr = cloudSolrClient.query(collection, params);
-      rsp.setAllValues(qr.getResponse());
-    } catch (Exception e) {
-      if ((e instanceof SolrException) && e.getMessage().contains("Collection not found")) {
-        // relatively benign
-        String msg = "Collection " + collection + " does not exist.";
-        log.info(msg);
-        rsp.getValues().add("error", msg);
-      } else {
-        throw e;
-      }
-    }
-  }
-
-  @Override
-  public String getDescription() {
-    return "A handler to return autoscaling event history";
-  }
-
-  @Override
-  public Category getCategory() {
-    return Category.ADMIN;
-  }
-
-  @Override
-  public Boolean registerV2() {
-    return Boolean.TRUE;
-  }
-
-  @Override
-  public Collection<Api> getApis() {
-    return ApiBag.wrapRequestHandlers(this, "autoscaling.history");
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/admin/BackupCoreOp.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/BackupCoreOp.java b/solr/core/src/java/org/apache/solr/handler/admin/BackupCoreOp.java
deleted file mode 100644
index 503eed0..0000000
--- a/solr/core/src/java/org/apache/solr/handler/admin/BackupCoreOp.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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 org.apache.solr.handler.admin;
-
-import java.net.URI;
-import java.util.Optional;
-
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.params.CoreAdminParams;
-import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.core.SolrCore;
-import org.apache.solr.core.backup.repository.BackupRepository;
-import org.apache.solr.handler.SnapShooter;
-
-import static org.apache.solr.common.params.CommonParams.NAME;
-
-
-class BackupCoreOp implements CoreAdminHandler.CoreAdminOp {
-  @Override
-  public void execute(CoreAdminHandler.CallInfo it) throws Exception {
-    final SolrParams params = it.req.getParams();
-
-    String cname = params.required().get(CoreAdminParams.CORE);
-    String name = params.required().get(NAME);
-
-    String repoName = params.get(CoreAdminParams.BACKUP_REPOSITORY);
-    BackupRepository repository = it.handler.coreContainer.newBackupRepository(Optional.ofNullable(repoName));
-
-    String location = repository.getBackupLocation(params.get(CoreAdminParams.BACKUP_LOCATION));
-    if (location == null) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "'location' is not specified as a query"
-          + " parameter or as a default repository property");
-    }
-
-    // An optional parameter to describe the snapshot to be backed-up. If this
-    // parameter is not supplied, the latest index commit is backed-up.
-    String commitName = params.get(CoreAdminParams.COMMIT_NAME);
-
-    URI locationUri = repository.createURI(location);
-    try (SolrCore core = it.handler.coreContainer.getCore(cname)) {
-      SnapShooter snapShooter = new SnapShooter(repository, core, locationUri, name, commitName);
-      // validateCreateSnapshot will create parent dirs instead of throw; that choice is dubious.
-      //  But we want to throw. One reason is that
-      //  this dir really should, in fact must, already exist here if triggered via a collection backup on a shared
-      //  file system. Otherwise, perhaps the FS location isn't shared -- we want an error.
-      if (!snapShooter.getBackupRepository().exists(snapShooter.getLocation())) {
-        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
-            "Directory to contain snapshots doesn't exist: " + snapShooter.getLocation() + ". " +
-            "Note that Backup/Restore of a SolrCloud collection " +
-            "requires a shared file system mounted at the same path on all nodes!");
-      }
-      snapShooter.validateCreateSnapshot();
-      snapShooter.createSnapshot();
-    } catch (Exception e) {
-      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
-          "Failed to backup core=" + cname + " because " + e, e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java b/solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java
deleted file mode 100644
index 90a2dd2..0000000
--- a/solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * 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 org.apache.solr.handler.admin;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-import com.google.common.collect.ImmutableList;
-import org.apache.solr.api.Api;
-import org.apache.solr.api.ApiSupport;
-import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.request.CollectionApiMapping.CommandMeta;
-import org.apache.solr.client.solrj.request.CollectionApiMapping.V2EndPoint;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.common.util.CommandOperation;
-import org.apache.solr.common.util.Utils;
-import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.response.SolrQueryResponse;
-
-import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;
-import static org.apache.solr.common.SolrException.ErrorCode.BAD_REQUEST;
-import static org.apache.solr.common.util.StrUtils.splitSmart;
-
-/**
- * This is a utility class to provide an easy mapping of request handlers which support multiple commands
- * to the V2 API format (core admin api, collections api). This helps in automatically mapping paths
- * to actions and old parameter names to new parameter names
- */
-public abstract class BaseHandlerApiSupport implements ApiSupport {
-  protected final Map<SolrRequest.METHOD, Map<V2EndPoint, List<ApiCommand>>> commandsMapping;
-
-  protected BaseHandlerApiSupport() {
-    commandsMapping = new HashMap<>();
-    for (ApiCommand cmd : getCommands()) {
-      Map<V2EndPoint, List<ApiCommand>> m = commandsMapping.get(cmd.meta().getHttpMethod());
-      if (m == null) commandsMapping.put(cmd.meta().getHttpMethod(), m = new HashMap<>());
-      List<ApiCommand> list = m.get(cmd.meta().getEndPoint());
-      if (list == null) m.put(cmd.meta().getEndPoint(), list = new ArrayList<>());
-      list.add(cmd);
-    }
-  }
-
-  @Override
-  public synchronized Collection<Api> getApis() {
-    ImmutableList.Builder<Api> l = ImmutableList.builder();
-    for (V2EndPoint op : getEndPoints()) l.add(getApi(op));
-    return l.build();
-  }
-
-
-  private Api getApi(final V2EndPoint op) {
-    final BaseHandlerApiSupport apiHandler = this;
-    return new Api(Utils.getSpec(op.getSpecName())) {
-      @Override
-      public void call(SolrQueryRequest req, SolrQueryResponse rsp) {
-        SolrParams params = req.getParams();
-        SolrRequest.METHOD method = SolrRequest.METHOD.valueOf(req.getHttpMethod());
-        List<ApiCommand> commands = commandsMapping.get(method).get(op);
-        try {
-          if (method == POST) {
-            List<CommandOperation> cmds = req.getCommands(true);
-            if (cmds.size() > 1)
-              throw new SolrException(BAD_REQUEST, "Only one command is allowed");
-            CommandOperation c = cmds.size() == 0 ? null : cmds.get(0);
-            ApiCommand command = null;
-            String commandName = c == null ? null : c.name;
-            for (ApiCommand cmd : commands) {
-              if (Objects.equals(cmd.meta().getName(), commandName)) {
-                command = cmd;
-                break;
-              }
-            }
-
-            if (command == null) {
-              throw new SolrException(BAD_REQUEST, " no such command " + c);
-            }
-            wrapParams(req, c, command, false);
-            command.invoke(req, rsp, apiHandler);
-
-          } else {
-            if (commands == null || commands.isEmpty()) {
-              rsp.add("error", "No support for : " + method + " at :" + req.getPath());
-              return;
-            }
-            if (commands.size() > 1) {
-              for (ApiCommand command : commands) {
-                if (command.meta().getName().equals(req.getPath())) {
-                  commands = Collections.singletonList(command);
-                  break;
-                }
-              }
-            }
-            wrapParams(req, new CommandOperation("", Collections.EMPTY_MAP), commands.get(0), true);
-            commands.get(0).invoke(req, rsp, apiHandler);
-          }
-
-        } catch (SolrException e) {
-          throw e;
-        } catch (Exception e) {
-          throw new SolrException(BAD_REQUEST, e); //TODO BAD_REQUEST is a wild guess; should we flip the default?  fail here to investigate how this happens in tests
-        } finally {
-          req.setParams(params);
-        }
-
-      }
-    };
-
-  }
-
-  /**
-   * Wrapper for SolrParams that wraps V2 params and exposes them as V1 params.
-   */
-  private static void wrapParams(final SolrQueryRequest req, final CommandOperation co, final ApiCommand cmd, final boolean useRequestParams) {
-    final Map<String, String> pathValues = req.getPathTemplateValues();
-    final Map<String, Object> map = co == null || !(co.getCommandData() instanceof Map) ?
-        Collections.singletonMap("", co.getCommandData()) : co.getDataMap();
-    final SolrParams origParams = req.getParams();
-
-    req.setParams(
-        new SolrParams() {
-          @Override
-          public String get(String param) {
-            Object vals = getParams0(param);
-            if (vals == null) return null;
-            if (vals instanceof String) return (String) vals;
-            if (vals instanceof Boolean || vals instanceof Number) return String.valueOf(vals);
-            if (vals instanceof String[] && ((String[]) vals).length > 0) return ((String[]) vals)[0];
-            return null;
-          }
-
-          private Object getParams0(String param) {
-            param = cmd.meta().getParamSubstitute(param); // v1 -> v2, possibly dotted path
-            Object o = param.indexOf('.') > 0 ?
-                Utils.getObjectByPath(map, true, splitSmart(param, '.')) :
-                map.get(param);
-            if (o == null) o = pathValues.get(param);
-            if (o == null && useRequestParams) o = origParams.getParams(param);
-            if (o instanceof List) {
-              List l = (List) o;
-              return l.toArray(new String[l.size()]);
-            }
-
-            return o;
-          }
-
-          @Override
-          public String[] getParams(String param) {
-            Object vals = getParams0(param);
-            return vals == null || vals instanceof String[] ?
-                (String[]) vals :
-                new String[]{vals.toString()};
-          }
-
-          @Override
-          public Iterator<String> getParameterNamesIterator() {
-            return cmd.meta().getParamNamesIterator(co);
-          }
-
-        });
-
-  }
-
-  protected abstract Collection<ApiCommand> getCommands();
-
-  protected abstract Collection<V2EndPoint> getEndPoints();
-
-
-  public interface ApiCommand  {
-    CommandMeta meta();
-
-    void invoke(SolrQueryRequest req, SolrQueryResponse rsp, BaseHandlerApiSupport apiHandler) throws Exception;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java b/solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java
deleted file mode 100644
index 9ebac77..0000000
--- a/solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * 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 org.apache.solr.handler.admin;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.cloud.Aliases;
-import org.apache.solr.common.cloud.ClusterState;
-import org.apache.solr.common.cloud.DocCollection;
-import org.apache.solr.common.cloud.DocRouter;
-import org.apache.solr.common.cloud.Replica;
-import org.apache.solr.common.cloud.Slice;
-import org.apache.solr.common.cloud.ZkNodeProps;
-import org.apache.solr.common.cloud.ZkStateReader;
-import org.apache.solr.common.params.ShardParams;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SimpleOrderedMap;
-import org.apache.solr.common.util.Utils;
-import org.apache.zookeeper.KeeperException;
-
-public class ClusterStatus {
-  private final ZkStateReader zkStateReader;
-  private final ZkNodeProps message;
-  private final String collection; // maybe null
-
-  public ClusterStatus(ZkStateReader zkStateReader, ZkNodeProps props) {
-    this.zkStateReader = zkStateReader;
-    this.message = props;
-    collection = props.getStr(ZkStateReader.COLLECTION_PROP);
-  }
-
-  @SuppressWarnings("unchecked")
-  public void getClusterStatus(NamedList results)
-      throws KeeperException, InterruptedException {
-    // read aliases
-    Aliases aliases = zkStateReader.getAliases();
-    Map<String, List<String>> collectionVsAliases = new HashMap<>();
-    Map<String, List<String>> aliasVsCollections = aliases.getCollectionAliasListMap();
-    for (Map.Entry<String, List<String>> entry : aliasVsCollections.entrySet()) {
-      String alias = entry.getKey();
-      List<String> colls = entry.getValue();
-      for (String coll : colls) {
-        if (collection == null || collection.equals(coll))  {
-          List<String> list = collectionVsAliases.computeIfAbsent(coll, k -> new ArrayList<>());
-          list.add(alias);
-        }
-      }
-    }
-
-    Map roles = null;
-    if (zkStateReader.getZkClient().exists(ZkStateReader.ROLES, true)) {
-      roles = (Map) Utils.fromJSON(zkStateReader.getZkClient().getData(ZkStateReader.ROLES, null, null, true));
-    }
-
-    ClusterState clusterState = zkStateReader.getClusterState();
-
-    // convert cluster state into a map of writable types
-    byte[] bytes = Utils.toJSON(clusterState);
-    Map<String, Object> stateMap = (Map<String,Object>) Utils.fromJSON(bytes);
-
-    String routeKey = message.getStr(ShardParams._ROUTE_);
-    String shard = message.getStr(ZkStateReader.SHARD_ID_PROP);
-
-    Map<String, DocCollection> collectionsMap = null;
-    if (collection == null) {
-      collectionsMap = clusterState.getCollectionsMap();
-    } else  {
-      collectionsMap = Collections.singletonMap(collection, clusterState.getCollectionOrNull(collection));
-    }
-
-    NamedList<Object> collectionProps = new SimpleOrderedMap<>();
-
-    for (Map.Entry<String, DocCollection> entry : collectionsMap.entrySet()) {
-      Map<String, Object> collectionStatus;
-      String name = entry.getKey();
-      DocCollection clusterStateCollection = entry.getValue();
-      if (clusterStateCollection == null) {
-        if (collection != null) {
-          throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Collection: " + name + " not found");
-        } else {
-          //collection might have got deleted at the same time
-          continue;
-        }
-      }
-
-      Set<String> requestedShards = new HashSet<>();
-      if (routeKey != null) {
-        DocRouter router = clusterStateCollection.getRouter();
-        Collection<Slice> slices = router.getSearchSlices(routeKey, null, clusterStateCollection);
-        for (Slice slice : slices) {
-          requestedShards.add(slice.getName());
-        }
-      }
-      if (shard != null) {
-        String[] paramShards = shard.split(",");
-        requestedShards.addAll(Arrays.asList(paramShards));
-      }
-
-      if (clusterStateCollection.getStateFormat() > 1) {
-        bytes = Utils.toJSON(clusterStateCollection);
-        Map<String, Object> docCollection = (Map<String, Object>) Utils.fromJSON(bytes);
-        collectionStatus = getCollectionStatus(docCollection, name, requestedShards);
-      } else {
-        collectionStatus = getCollectionStatus((Map<String, Object>) stateMap.get(name), name, requestedShards);
-      }
-
-      collectionStatus.put("znodeVersion", clusterStateCollection.getZNodeVersion());
-      if (collectionVsAliases.containsKey(name) && !collectionVsAliases.get(name).isEmpty()) {
-        collectionStatus.put("aliases", collectionVsAliases.get(name));
-      }
-      try {
-        String configName = zkStateReader.readConfigName(name);
-        collectionStatus.put("configName", configName);
-        collectionProps.add(name, collectionStatus);
-      } catch (SolrException e) {
-        if (e.getCause() instanceof KeeperException.NoNodeException)  {
-          // skip this collection because the collection's znode has been deleted
-          // which can happen during aggressive collection removal, see SOLR-10720
-        } else throw e;
-      }
-    }
-
-    List<String> liveNodes = zkStateReader.getZkClient().getChildren(ZkStateReader.LIVE_NODES_ZKNODE, null, true);
-
-    // now we need to walk the collectionProps tree to cross-check replica state with live nodes
-    crossCheckReplicaStateWithLiveNodes(liveNodes, collectionProps);
-
-    NamedList<Object> clusterStatus = new SimpleOrderedMap<>();
-    clusterStatus.add("collections", collectionProps);
-
-    // read cluster properties
-    Map clusterProps = zkStateReader.getClusterProperties();
-    if (clusterProps != null && !clusterProps.isEmpty())  {
-      clusterStatus.add("properties", clusterProps);
-    }
-
-    // add the alias map too
-    Map<String, String> collectionAliasMap = aliases.getCollectionAliasMap(); // comma delim
-    if (!collectionAliasMap.isEmpty())  {
-      clusterStatus.add("aliases", collectionAliasMap);
-    }
-
-    // add the roles map
-    if (roles != null)  {
-      clusterStatus.add("roles", roles);
-    }
-
-    // add live_nodes
-    clusterStatus.add("live_nodes", liveNodes);
-
-    results.add("cluster", clusterStatus);
-  }
-
-  /**
-   * Get collection status from cluster state.
-   * Can return collection status by given shard name.
-   *
-   *
-   * @param collection collection map parsed from JSON-serialized {@link ClusterState}
-   * @param name  collection name
-   * @param requestedShards a set of shards to be returned in the status.
-   *                        An empty or null values indicates <b>all</b> shards.
-   * @return map of collection properties
-   */
-  @SuppressWarnings("unchecked")
-  private Map<String, Object> getCollectionStatus(Map<String, Object> collection, String name, Set<String> requestedShards) {
-    if (collection == null)  {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Collection: " + name + " not found");
-    }
-    if (requestedShards == null || requestedShards.isEmpty()) {
-      return collection;
-    } else {
-      Map<String, Object> shards = (Map<String, Object>) collection.get("shards");
-      Map<String, Object>  selected = new HashMap<>();
-      for (String selectedShard : requestedShards) {
-        if (!shards.containsKey(selectedShard)) {
-          throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Collection: " + name + " shard: " + selectedShard + " not found");
-        }
-        selected.put(selectedShard, shards.get(selectedShard));
-        collection.put("shards", selected);
-      }
-      return collection;
-    }
-  }
-
-
-
-  /**
-   * Walks the tree of collection status to verify that any replicas not reporting a "down" status is
-   * on a live node, if any replicas reporting their status as "active" but the node is not live is
-   * marked as "down"; used by CLUSTERSTATUS.
-   * @param liveNodes List of currently live node names.
-   * @param collectionProps Map of collection status information pulled directly from ZooKeeper.
-   */
-
-  @SuppressWarnings("unchecked")
-  protected void crossCheckReplicaStateWithLiveNodes(List<String> liveNodes, NamedList<Object> collectionProps) {
-    Iterator<Map.Entry<String,Object>> colls = collectionProps.iterator();
-    while (colls.hasNext()) {
-      Map.Entry<String,Object> next = colls.next();
-      Map<String,Object> collMap = (Map<String,Object>)next.getValue();
-      Map<String,Object> shards = (Map<String,Object>)collMap.get("shards");
-      for (Object nextShard : shards.values()) {
-        Map<String,Object> shardMap = (Map<String,Object>)nextShard;
-        Map<String,Object> replicas = (Map<String,Object>)shardMap.get("replicas");
-        for (Object nextReplica : replicas.values()) {
-          Map<String,Object> replicaMap = (Map<String,Object>)nextReplica;
-          if (Replica.State.getState((String) replicaMap.get(ZkStateReader.STATE_PROP)) != Replica.State.DOWN) {
-            // not down, so verify the node is live
-            String node_name = (String)replicaMap.get(ZkStateReader.NODE_NAME_PROP);
-            if (!liveNodes.contains(node_name)) {
-              // node is not live, so this replica is actually down
-              replicaMap.put(ZkStateReader.STATE_PROP, Replica.State.DOWN.toString());
-            }
-          }
-        }
-      }
-    }
-  }
-
-
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/admin/CollectionHandlerApi.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CollectionHandlerApi.java b/solr/core/src/java/org/apache/solr/handler/admin/CollectionHandlerApi.java
deleted file mode 100644
index d7d179a..0000000
--- a/solr/core/src/java/org/apache/solr/handler/admin/CollectionHandlerApi.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * 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 org.apache.solr.handler.admin;
-
-import java.lang.invoke.MethodHandles;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.EnumMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.solr.client.solrj.request.CollectionApiMapping;
-import org.apache.solr.client.solrj.request.CollectionApiMapping.CommandMeta;
-import org.apache.solr.client.solrj.request.CollectionApiMapping.Meta;
-import org.apache.solr.client.solrj.request.CollectionApiMapping.V2EndPoint;
-import org.apache.solr.common.Callable;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.cloud.ClusterProperties;
-import org.apache.solr.common.util.CommandOperation;
-import org.apache.solr.handler.admin.CollectionsHandler.CollectionOperation;
-import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.response.SolrQueryResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class CollectionHandlerApi extends BaseHandlerApiSupport {
-  private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
-  final CollectionsHandler handler;
-  static Collection<ApiCommand> apiCommands = createCollMapping();
-
-  private static Collection<ApiCommand> createCollMapping() {
-    Map<Meta, ApiCommand> result = new EnumMap<>(Meta.class);
-
-    for (Meta meta : Meta.values()) {
-      for (CollectionOperation op : CollectionOperation.values()) {
-        if (op.action == meta.action) {
-          result.put(meta, new ApiCommand() {
-            @Override
-            public CommandMeta meta() {
-              return meta;
-            }
-
-            @Override
-            public void invoke(SolrQueryRequest req, SolrQueryResponse rsp, BaseHandlerApiSupport apiHandler) throws Exception {
-              ((CollectionHandlerApi) apiHandler).handler.invokeAction(req, rsp, ((CollectionHandlerApi) apiHandler).handler.coreContainer, op.action, op);
-            }
-          });
-        }
-      }
-    }
-    //The following APIs have only V2 implementations
-    addApi(result, Meta.GET_NODES, params -> params.rsp.add("nodes", ((CollectionHandlerApi) params.apiHandler).handler.coreContainer.getZkController().getClusterState().getLiveNodes()));
-    addApi(result, Meta.SET_CLUSTER_PROPERTY_OBJ, params -> {
-      List<CommandOperation> commands = params.req.getCommands(true);
-      if (commands == null || commands.isEmpty()) throw new RuntimeException("Empty commands");
-      ClusterProperties clusterProperties = new ClusterProperties(((CollectionHandlerApi) params.apiHandler).handler.coreContainer.getZkController().getZkClient());
-
-      try {
-        clusterProperties.setClusterProperties(commands.get(0).getDataMap());
-      } catch (Exception e) {
-        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error in API", e);
-      }
-    });
-
-    for (Meta meta : Meta.values()) {
-      if (result.get(meta) == null) {
-        log.error("ERROR_INIT. No corresponding API implementation for : " + meta.commandName);
-      }
-    }
-
-    return result.values();
-  }
-
-  private static void addApi(Map<Meta, ApiCommand> result, Meta metaInfo, Callable<ApiParams> fun) {
-    result.put(metaInfo, new ApiCommand() {
-      @Override
-      public CommandMeta meta() {
-        return metaInfo;
-      }
-
-      @Override
-      public void invoke(SolrQueryRequest req, SolrQueryResponse rsp, BaseHandlerApiSupport apiHandler) throws Exception {
-        fun.call(new ApiParams(req, rsp, apiHandler));
-      }
-    });
-  }
-
-  static class ApiParams {
-    final SolrQueryRequest req;
-    final SolrQueryResponse rsp;
-    final BaseHandlerApiSupport apiHandler;
-
-    ApiParams(SolrQueryRequest req, SolrQueryResponse rsp, BaseHandlerApiSupport apiHandler) {
-      this.req = req;
-      this.rsp = rsp;
-      this.apiHandler = apiHandler;
-    }
-  }
-
-  public CollectionHandlerApi(CollectionsHandler handler) {
-    this.handler = handler;
-  }
-
-  @Override
-  protected Collection<ApiCommand> getCommands() {
-    return apiCommands;
-  }
-
-  @Override
-  protected List<V2EndPoint> getEndPoints() {
-    return Arrays.asList(CollectionApiMapping.EndPoint.values());
-  }
-
-}