lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwe...@apache.org
Subject svn commit: r1584603 [9/12] - in /lucene/dev/branches/solr5914: ./ dev-tools/ dev-tools/idea/solr/core/src/test/ lucene/ lucene/analysis/ lucene/analysis/common/ lucene/analysis/common/src/java/org/apache/lucene/analysis/br/ lucene/analysis/common/src/...
Date Fri, 04 Apr 2014 10:27:14 GMT
Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/analytics/statistics/MinMaxStatsCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/analytics/statistics/MinMaxStatsCollector.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/analytics/statistics/MinMaxStatsCollector.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/analytics/statistics/MinMaxStatsCollector.java Fri Apr  4 10:27:05 2014
@@ -74,7 +74,7 @@ public class MinMaxStatsCollector implem
     if (stat.equals("min")&&min!=null) {
       return (Comparable)min.toObject();
     }
-    if (stat.equals("max")&&min!=null) {
+    if (stat.equals("max")&&max!=null) {
       return (Comparable)max.toObject();
     }
     if (stat.equals("count")) {
@@ -83,7 +83,9 @@ public class MinMaxStatsCollector implem
     if (stat.equals("missing")) {
       return new Long(missingCount);
     }
+
     return null;
+//    throw new IllegalArgumentException("No stat named '"+stat+"' in this collector " + this);
   }
   
   public Set<String> getStatsList() {

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/analytics/statistics/StatsCollectorSupplierFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/analytics/statistics/StatsCollectorSupplierFactory.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/analytics/statistics/StatsCollectorSupplierFactory.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/analytics/statistics/StatsCollectorSupplierFactory.java Fri Apr  4 10:27:05 2014
@@ -21,9 +21,11 @@ import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.TreeMap;
 
 import org.apache.lucene.queries.function.ValueSource;
 import org.apache.lucene.queries.function.valuesource.BytesRefFieldSource;
@@ -33,7 +35,6 @@ import org.apache.lucene.queries.functio
 import org.apache.lucene.queries.function.valuesource.LongFieldSource;
 import org.apache.lucene.search.FieldCache;
 import org.apache.solr.analytics.expression.ExpressionFactory;
-import org.apache.solr.analytics.request.AnalyticsRequest;
 import org.apache.solr.analytics.request.ExpressionRequest;
 import org.apache.solr.analytics.util.AnalyticsParams;
 import org.apache.solr.analytics.util.AnalyticsParsers;
@@ -67,10 +68,13 @@ import org.apache.solr.schema.TrieDouble
 import org.apache.solr.schema.TrieFloatField;
 import org.apache.solr.schema.TrieIntField;
 import org.apache.solr.schema.TrieLongField;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Supplier;
 
 public class StatsCollectorSupplierFactory {
+  private static final Logger log = LoggerFactory.getLogger(StatsCollectorSupplierFactory.class);
   
   // FunctionTypes
   final static int NUMBER_TYPE = 0;
@@ -83,18 +87,18 @@ public class StatsCollectorSupplierFacto
    * Builds a Supplier that will generate identical arrays of new StatsCollectors.
    * 
    * @param schema The Schema being used.
-   * @param request The AnalyticsRequest to generate a StatsCollector[] from.
+   * @param exRequests The expression requests to generate a StatsCollector[] from.
    * @return A Supplier that will return an array of new StatsCollector.
    */
   @SuppressWarnings("unchecked")
-  public static Supplier<StatsCollector[]> create(IndexSchema schema, AnalyticsRequest request) {
-    final Map<String, Set<String>> collectorStats =  new HashMap<>();
-    final Map<String, Set<Integer>> collectorPercs =  new HashMap<>();
-    final Map<String, ValueSource> collectorSources =  new HashMap<>();
+  public static Supplier<StatsCollector[]> create(IndexSchema schema, List<ExpressionRequest> exRequests ) {
+    final Map<String, Set<String>> collectorStats =  new TreeMap<>();
+    final Map<String, Set<Integer>> collectorPercs =  new TreeMap<>();
+    final Map<String, ValueSource> collectorSources =  new TreeMap<>();
     
     // Iterate through all expression request to make a list of ValueSource strings
     // and statistics that need to be calculated on those ValueSources.
-    for (ExpressionRequest expRequest : request.getExpressions()) {
+    for (ExpressionRequest expRequest : exRequests) {
       String statExpression = expRequest.getExpressionString();
       Set<String> statistics = getStatistics(statExpression);
       if (statistics == null) {
@@ -146,7 +150,11 @@ public class StatsCollectorSupplierFacto
           stats = new HashSet<>();
           collectorStats.put(source, stats);
         }
-        stats.add(stat);
+        if(AnalyticsParams.STAT_PERCENTILE.equals(stat)) {
+          stats.add(stat + "_"+ arguments[0]);
+        } else {
+          stats.add(stat);
+        }
       }
     }
     String[] keys = collectorStats.keySet().toArray(new String[0]);
@@ -168,7 +176,7 @@ public class StatsCollectorSupplierFacto
         if (percs!=null) {
           collectorPercs.put(builtString, percs);
         }
-        for (ExpressionRequest er : request.getExpressions()) {
+        for (ExpressionRequest er : exRequests) {
           er.setExpressionString(er.getExpressionString().replace(sourceStr, builtString));
         }
       }
@@ -182,6 +190,8 @@ public class StatsCollectorSupplierFacto
       };
     }
     
+    log.info("Stats objects: "+collectorStats.size()+" sr="+collectorSources.size()+" pr="+collectorPercs.size() );
+    
     // All information is stored in final arrays so that nothing 
     // has to be computed when the Supplier's get() method is called.
     final Set<String>[] statsArr = collectorStats.values().toArray(new Set[0]);

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java Fri Apr  4 10:27:05 2014
@@ -68,10 +68,11 @@ public abstract class ElectionContext {
   
   public void cancelElection() throws InterruptedException, KeeperException {
     try {
+      log.info("canceling election {}",leaderSeqPath );
       zkClient.delete(leaderSeqPath, -1, true);
     } catch (NoNodeException e) {
       // fine
-      log.warn("cancelElection did not find election node to remove");
+      log.warn("cancelElection did not find election node to remove",e);
     }
   }
 

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java Fri Apr  4 10:27:05 2014
@@ -67,6 +67,8 @@ public  class LeaderElector {
 
   private volatile ElectionContext context;
 
+  private ElectionWatcher watcher;
+
   public LeaderElector(SolrZkClient zkClient) {
     this.zkClient = zkClient;
     zkCmdExecutor = new ZkCmdExecutor(zkClient.getZkClientTimeout());
@@ -90,7 +92,7 @@ public  class LeaderElector {
     // get all other numbers...
     final String holdElectionPath = context.electionPath + ELECTION_NODE;
     List<String> seqs = zkClient.getChildren(holdElectionPath, null, true);
-    
+
     sortSeqs(seqs);
     List<Integer> intSeqs = getSeqs(seqs);
     if (intSeqs.size() == 0) {
@@ -122,31 +124,7 @@ public  class LeaderElector {
         return;
       }
       try {
-        zkClient.getData(holdElectionPath + "/" + seqs.get(index),
-            new Watcher() {
-              
-              @Override
-              public void process(WatchedEvent event) {
-                // session events are not change events,
-                // and do not remove the watcher
-                if (EventType.None.equals(event.getType())) {
-                  return;
-                }
-                // am I the next leader?
-                try {
-                  checkIfIamLeader(seq, context, true);
-                } catch (InterruptedException e) {
-                  // Restore the interrupted status
-                  Thread.currentThread().interrupt();
-                  log.warn("", e);
-                } catch (IOException e) {
-                  log.warn("", e);
-                } catch (Exception e) {
-                  log.warn("", e);
-                }
-              }
-              
-            }, null, true);
+        zkClient.getData(holdElectionPath + "/" + seqs.get(index), watcher = new ElectionWatcher(context.leaderSeqPath , seq, context) , null, true);
       } catch (KeeperException.SessionExpiredException e) {
         throw e;
       } catch (KeeperException e) {
@@ -290,6 +268,50 @@ public  class LeaderElector {
     
     return seq;
   }
+
+  private class ElectionWatcher implements Watcher {
+    final String leaderSeqPath;
+    final int seq;
+    final ElectionContext context;
+
+    private boolean canceled = false;
+
+    private ElectionWatcher(String leaderSeqPath, int seq, ElectionContext context) {
+      this.leaderSeqPath = leaderSeqPath;
+      this.seq = seq;
+      this.context = context;
+    }
+
+    void cancel(String leaderSeqPath){
+      canceled = true;
+
+    }
+
+    @Override
+    public void process(WatchedEvent event) {
+      // session events are not change events,
+      // and do not remove the watcher
+      if (EventType.None.equals(event.getType())) {
+        return;
+      }
+      if(canceled) {
+        log.info("This watcher is not active anymore {}", leaderSeqPath);
+        return;
+      }
+      try {
+        // am I the next leader?
+        checkIfIamLeader(seq, context, true);
+      } catch (InterruptedException e) {
+        // Restore the interrupted status
+        Thread.currentThread().interrupt();
+        log.warn("", e);
+      } catch (IOException e) {
+        log.warn("", e);
+      } catch (Exception e) {
+        log.warn("", e);
+      }
+    }
+  }
   
   /**
    * Set up any ZooKeeper nodes needed for leader election.
@@ -317,6 +339,8 @@ public  class LeaderElector {
   }
   void retryElection() throws KeeperException, InterruptedException, IOException {
     context.cancelElection();
+    ElectionWatcher watcher = this.watcher;
+    if(watcher!= null) watcher.cancel(context.leaderSeqPath);
     joinElection(context, true);
   }
 }

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/Overseer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/Overseer.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/Overseer.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/Overseer.java Fri Apr  4 10:27:05 2014
@@ -70,6 +70,7 @@ public class Overseer {
   public static final String ADD_ROUTING_RULE = "addroutingrule";
   public static final String REMOVE_ROUTING_RULE = "removeroutingrule";
   public static final String STATE = "state";
+  public static final String QUIT = "quit";
 
   public static final int STATE_UPDATE_DELAY = 1500;  // delay between cloud state updates
   public static final String CREATESHARD = "createshard";
@@ -200,85 +201,132 @@ public class Overseer {
       }
       
       log.info("Starting to work on the main queue");
-      while (!this.isClosed) {
-        isLeader = amILeader();
-        if (LeaderStatus.NO == isLeader) {
-          break;
-        }
-        else if (LeaderStatus.YES != isLeader) {
-          log.debug("am_i_leader unclear {}", isLeader);
-          continue; // not a no, not a yes, try ask again
-        }
-        DistributedQueue.QueueEvent head = null;
-        try {
-          head = stateUpdateQueue.peek(true);
-        } catch (KeeperException e) {
-          if (e.code() == KeeperException.Code.SESSIONEXPIRED) {
-            log.warn(
-                "Solr cannot talk to ZK, exiting Overseer main queue loop", e);
-            return;
+      try {
+        while (!this.isClosed) {
+          isLeader = amILeader();
+          if (LeaderStatus.NO == isLeader) {
+            break;
+          }
+          else if (LeaderStatus.YES != isLeader) {
+            log.debug("am_i_leader unclear {}", isLeader);
+            continue; // not a no, not a yes, try ask again
           }
-          log.error("Exception in Overseer main queue loop", e);
-        } catch (InterruptedException e) {
-          Thread.currentThread().interrupt();
-          return;
-          
-        } catch (Exception e) {
-          log.error("Exception in Overseer main queue loop", e);
-        }
-        synchronized (reader.getUpdateLock()) {
+          DistributedQueue.QueueEvent head = null;
           try {
-            reader.updateClusterState(true);
-            ClusterState clusterState = reader.getClusterState();
-
-            while (head != null) {
-              final ZkNodeProps message = ZkNodeProps.load(head.getBytes());
-              final String operation = message.getStr(QUEUE_OPERATION);
-              final TimerContext timerContext = stats.time(operation);
-              try {
-                clusterState = processMessage(clusterState, message, operation);
-                stats.success(operation);
-              } catch (Exception e) {
-                // generally there is nothing we can do - in most cases, we have
-                // an issue that will fail again on retry or we cannot communicate with
-                // ZooKeeper in which case another Overseer should take over
-                // TODO: if ordering for the message is not important, we could
-                // track retries and put it back on the end of the queue
-                log.error("Overseer could not process the current clusterstate state update message, skipping the message.", e);
-                stats.error(operation);
-              } finally {
-                timerContext.stop();
-              }
-              workQueue.offer(head.getBytes());
-
-              stateUpdateQueue.poll();
-
-              if (System.nanoTime() - lastUpdatedTime > TimeUnit.NANOSECONDS.convert(STATE_UPDATE_DELAY, TimeUnit.MILLISECONDS)) break;
-              
-              // if an event comes in the next 100ms batch it together
-              head = stateUpdateQueue.peek(100); 
-            }
-            lastUpdatedTime = System.nanoTime();
-            zkClient.setData(ZkStateReader.CLUSTER_STATE,
-                ZkStateReader.toJSON(clusterState), true);
-            // clean work queue
-            while (workQueue.poll() != null) ;
-
+            head = stateUpdateQueue.peek(true);
           } catch (KeeperException e) {
             if (e.code() == KeeperException.Code.SESSIONEXPIRED) {
-              log.warn("Solr cannot talk to ZK, exiting Overseer main queue loop", e);
+              log.warn(
+                  "Solr cannot talk to ZK, exiting Overseer main queue loop", e);
               return;
             }
             log.error("Exception in Overseer main queue loop", e);
           } catch (InterruptedException e) {
             Thread.currentThread().interrupt();
             return;
-            
+
           } catch (Exception e) {
             log.error("Exception in Overseer main queue loop", e);
           }
+          synchronized (reader.getUpdateLock()) {
+            try {
+              reader.updateClusterState(true);
+              ClusterState clusterState = reader.getClusterState();
+
+              while (head != null) {
+                final ZkNodeProps message = ZkNodeProps.load(head.getBytes());
+                final String operation = message.getStr(QUEUE_OPERATION);
+                final TimerContext timerContext = stats.time(operation);
+                try {
+                  clusterState = processMessage(clusterState, message, operation);
+                  stats.success(operation);
+                } catch (Exception e) {
+                  // generally there is nothing we can do - in most cases, we have
+                  // an issue that will fail again on retry or we cannot communicate with
+                  // ZooKeeper in which case another Overseer should take over
+                  // TODO: if ordering for the message is not important, we could
+                  // track retries and put it back on the end of the queue
+                  log.error("Overseer could not process the current clusterstate state update message, skipping the message.", e);
+                  stats.error(operation);
+                } finally {
+                  timerContext.stop();
+                }
+                workQueue.offer(head.getBytes());
+
+                stateUpdateQueue.poll();
+
+                if (isClosed || System.nanoTime() - lastUpdatedTime > TimeUnit.NANOSECONDS.convert(STATE_UPDATE_DELAY, TimeUnit.MILLISECONDS)) break;
+
+                // if an event comes in the next 100ms batch it together
+                head = stateUpdateQueue.peek(100);
+              }
+              lastUpdatedTime = System.nanoTime();
+              zkClient.setData(ZkStateReader.CLUSTER_STATE,
+                  ZkStateReader.toJSON(clusterState), true);
+              // clean work queue
+              while (workQueue.poll() != null) ;
+
+            } catch (KeeperException e) {
+              if (e.code() == KeeperException.Code.SESSIONEXPIRED) {
+                log.warn("Solr cannot talk to ZK, exiting Overseer main queue loop", e);
+                return;
+              }
+              log.error("Exception in Overseer main queue loop", e);
+            } catch (InterruptedException e) {
+              Thread.currentThread().interrupt();
+              return;
+
+            } catch (Exception e) {
+              log.error("Exception in Overseer main queue loop", e);
+            }
+          }
+
         }
-        
+      } finally {
+        log.info("Overseer Loop exiting : {}", LeaderElector.getNodeName(myId));
+        new Thread("OverseerExitThread"){
+          //do this in a separate thread because any wait is interrupted in this main thread
+          @Override
+          public void run() {
+            checkIfIamStillLeader();
+          }
+        }.start();
+      }
+    }
+
+    private void checkIfIamStillLeader() {
+      org.apache.zookeeper.data.Stat stat = new org.apache.zookeeper.data.Stat();
+      String path = "/overseer_elect/leader";
+      byte[] data = null;
+      try {
+        data = zkClient.getData(path, null, stat, true);
+      } catch (Exception e) {
+        log.error("could not read the data" ,e);
+        return;
+      }
+      Map m = (Map) ZkStateReader.fromJSON(data);
+      String id = (String) m.get("id");
+      if(overseerCollectionProcessor.getId().equals(id)){
+        try {
+          log.info("I'm exiting , but I'm still the leader");
+          zkClient.delete(path,stat.getVersion(),true);
+        } catch (KeeperException.BadVersionException e) {
+          //no problem ignore it some other Overseer has already taken over
+        } catch (Exception e) {
+          log.error("Could not delete my leader node ", e);
+        } finally {
+          try {
+            if(zkController !=null && !zkController.getCoreContainer().isShutDown()){
+              zkController.rejoinOverseerElection();
+            }
+
+          } catch (Exception e) {
+            log.error("error canceling overseer election election  ",e);
+          }
+        }
+
+      } else{
+        log.info("somebody else has already taken up the overseer position");
       }
     }
 
@@ -324,7 +372,11 @@ public class Overseer {
         clusterState = removeRoutingRule(clusterState, message);
       } else if(CLUSTERPROP.isEqual(operation)){
            handleProp(message);
-      } else {
+      } else if( QUIT.equals(operation)){
+        log.info("Quit command received {}", LeaderElector.getNodeName(myId));
+        overseerCollectionProcessor.close();
+        close();
+      } else{
         throw new RuntimeException("unknown operation:" + operation
             + " contents:" + message.getProperties());
       }
@@ -1107,15 +1159,18 @@ public class Overseer {
 
   private String adminPath;
 
-  private OverseerCollectionProcessor ocp;
+  private OverseerCollectionProcessor overseerCollectionProcessor;
+
+  private ZkController zkController;
 
   private Stats stats;
 
   // overseer not responsible for closing reader
-  public Overseer(ShardHandler shardHandler, String adminPath, final ZkStateReader reader) throws KeeperException, InterruptedException {
+  public Overseer(ShardHandler shardHandler, String adminPath, final ZkStateReader reader, ZkController zkController) throws KeeperException, InterruptedException {
     this.reader = reader;
     this.shardHandler = shardHandler;
     this.adminPath = adminPath;
+    this.zkController = zkController;
     this.stats = new Stats();
   }
   
@@ -1130,8 +1185,8 @@ public class Overseer {
 
     ThreadGroup ccTg = new ThreadGroup("Overseer collection creation process.");
 
-    ocp = new OverseerCollectionProcessor(reader, id, shardHandler, adminPath, stats);
-    ccThread = new OverseerThread(ccTg, ocp, "Overseer-" + id);
+    overseerCollectionProcessor = new OverseerCollectionProcessor(reader, id, shardHandler, adminPath, stats);
+    ccThread = new OverseerThread(ccTg, overseerCollectionProcessor, "Overseer-" + id);
     ccThread.setDaemon(true);
     
     updaterThread.start();

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java Fri Apr  4 10:27:05 2014
@@ -88,6 +88,8 @@ import static org.apache.solr.common.clo
 import static org.apache.solr.common.cloud.ZkStateReader.SHARD_ID_PROP;
 import static org.apache.solr.common.params.CollectionParams.CollectionAction.ADDREPLICA;
 import static org.apache.solr.common.params.CollectionParams.CollectionAction.ADDROLE;
+import static org.apache.solr.common.params.CollectionParams.CollectionAction.CLUSTERSTATUS;
+import static org.apache.solr.common.params.CollectionParams.CollectionAction.LIST;
 import static org.apache.solr.common.params.CollectionParams.CollectionAction.OVERSEERSTATUS;
 import static org.apache.solr.common.params.CollectionParams.CollectionAction.REMOVEROLE;
 
@@ -136,7 +138,6 @@ public class OverseerCollectionProcessor
 
   public static final String COLL_PROP_PREFIX = "property.";
 
-
   public static final Set<String> KNOWN_CLUSTER_PROPS = ImmutableSet.of(ZkStateReader.LEGACY_CLOUD, ZkStateReader.URL_SCHEME);
 
   public static final Map<String,Object> COLL_PROPS = ZkNodeProps.makeMap(
@@ -220,6 +221,7 @@ public class OverseerCollectionProcessor
            }
            
            QueueEvent head = workQueue.peek(true);
+           if(isClosed) break;
            final ZkNodeProps message = ZkNodeProps.load(head.getBytes());
 
            final String asyncId = (message.containsKey(ASYNC) && message.get(ASYNC) != null) ? (String) message.get(ASYNC) : null;
@@ -287,7 +289,7 @@ public class OverseerCollectionProcessor
   }
 
   private void prioritizeOverseerNodes() throws KeeperException, InterruptedException {
-    log.info("prioritizing overseer nodes");
+    log.info("prioritizing overseer nodes at {}", LeaderElector.getNodeName(myId));
     SolrZkClient zk = zkStateReader.getZkClient();
     if(!zk.exists(ZkStateReader.ROLES,true))return;
     Map m = (Map) ZkStateReader.fromJSON(zk.getData(ZkStateReader.ROLES, null, new Stat(), true));
@@ -299,6 +301,7 @@ public class OverseerCollectionProcessor
 
     List<String> nodeNames = getSortedOverseerNodeNames(zk);
     if(nodeNames.size()<2) return;
+    boolean designateIsInFront = overseerDesignates.contains( nodeNames.get(0));
 
 //
     ArrayList<String> nodesTobePushedBack =  new ArrayList<>();
@@ -306,25 +309,25 @@ public class OverseerCollectionProcessor
     List<String> availableDesignates = new ArrayList<>();
 
     log.info("sorted nodes {}", nodeNames);//TODO to be removed
-    for (int i = 0; i < nodeNames.size(); i++) {
+    for (int i = 1; i < nodeNames.size(); i++) {
       String s = nodeNames.get(i);
 
       if (overseerDesignates.contains(s)) {
         availableDesignates.add(s);
 
-        for(int j=0;j<i;j++){
-          if(!overseerDesignates.contains(nodeNames.get(j))) {
-            if(!nodesTobePushedBack.contains(nodeNames.get(j))) nodesTobePushedBack.add(nodeNames.get(j));
+        for(int j=1;j<i;j++){
+          String n = nodeNames.get(j);
+          if(!overseerDesignates.contains(n)) {
+            if(!nodesTobePushedBack.contains(n)) nodesTobePushedBack.add(n);
           }
         }
 
       }
-      if(availableDesignates.size()>1) break;
+      if(availableDesignates.size()>1) break;//we don't need to line up more than 2 designates
     }
 
     if(!availableDesignates.isEmpty()){
-      for (int i = nodesTobePushedBack.size() - 1; i >= 0; i--) {
-         String s = nodesTobePushedBack.get(i);
+      for (String s : nodesTobePushedBack) {
         log.info("pushing back {} ", s);
         invokeOverseerOp(s, "rejoin");
       }
@@ -358,18 +361,22 @@ public class OverseerCollectionProcessor
         log.warn("available designates and current state {} {} ", availableDesignates, getSortedOverseerNodeNames(zk));
       }
 
-    } else {
+    } else if(!designateIsInFront) {
       log.warn("No overseer designates are available, overseerDesignates: {}, live nodes : {}",overseerDesignates,nodeNames);
       return;
     }
 
     String leaderNode = getLeaderNode(zkStateReader.getZkClient());
     if(leaderNode ==null) return;
-    if(!overseerDesignates.contains(leaderNode) && !availableDesignates.isEmpty()){
-      //this means there are designated Overseer nodes and I am not one of them , kill myself
-      String newLeader = availableDesignates.get(0);
-      log.info("I am not an overseerdesignate , forcing a new leader {} ", newLeader);
-      invokeOverseerOp(newLeader, "leader");
+    if(!overseerDesignates.contains(leaderNode) ){
+      List<String> sortedNodes = getSortedOverseerNodeNames(zk);
+
+      if(leaderNode.equals(sortedNodes.get(0))  ||         // I am leader and I am in front of the queue
+          overseerDesignates.contains(sortedNodes.get(0))) {// I am leader but somebody else is in the front , Screwed up leader election
+        //this means there are I am not a designate and the next guy is lined up to become the leader, kill myself
+        log.info("I am not an overseer designate , forcing myself out {} ", leaderNode);
+        Overseer.getInQueue(zkStateReader.getZkClient()).offer(ZkStateReader.toJSON(new ZkNodeProps(Overseer.QUEUE_OPERATION, Overseer.QUIT)));
+      }
     }
 
   }
@@ -470,13 +477,13 @@ public class OverseerCollectionProcessor
         processRoleCommand(message, operation);
       } else if (ADDREPLICA.isEqual(operation))  {
         addReplica(zkStateReader.getClusterState(), message, results);
-      } else if (REQUESTSTATUS.equals(operation)) {
-        requestStatus(message, results);
       } else if (OVERSEERSTATUS.isEqual(operation)) {
         getOverseerStatus(message, results);
-      }
-
-      else {
+      } else if(LIST.isEqual(operation)) {
+        listCollections(zkStateReader.getClusterState(), results);
+      } else if (CLUSTERSTATUS.isEqual(operation)) {
+         getClusterStatus(zkStateReader.getClusterState(), message, results);
+      } else {
         throw new SolrException(ErrorCode.BAD_REQUEST, "Unknown operation:"
             + operation);
       }
@@ -567,6 +574,131 @@ public class OverseerCollectionProcessor
 
   }
 
+  private void getClusterStatus(ClusterState clusterState, ZkNodeProps message, NamedList results) {
+    String collection = message.getStr(ZkStateReader.COLLECTION_PROP);
+
+    // read aliases
+    Aliases aliases = zkStateReader.getAliases();
+    Map<String, List<String>> collectionVsAliases = new HashMap<>();
+    Map<String, String> aliasVsCollections = aliases.getCollectionAliasMap();
+    if (aliasVsCollections != null) {
+      for (Map.Entry<String, String> entry : aliasVsCollections.entrySet()) {
+        List<String> colls = StrUtils.splitSmart(entry.getValue(), ',');
+        String alias = entry.getKey();
+        for (String coll : colls) {
+          if (collection == null || collection.equals(coll))  {
+            List<String> list = collectionVsAliases.get(coll);
+            if (list == null) {
+              list = new ArrayList<>();
+              collectionVsAliases.put(coll, list);
+            }
+            list.add(alias);
+          }
+        }
+      }
+    }
+
+    // convert cluster state into a map of writable types
+    byte[] bytes = ZkStateReader.toJSON(clusterState);
+    Map<String, Object> stateMap = (Map<String, Object>) ZkStateReader.fromJSON(bytes);
+
+    String shard = message.getStr(ZkStateReader.SHARD_ID_PROP);
+    NamedList<Object> collectionProps = new SimpleOrderedMap<Object>();
+    if (collection == null) {
+      Set<String> collections = clusterState.getCollections();
+      for (String name : collections) {
+        Map<String, Object> collectionStatus = getCollectionStatus(stateMap, name, shard);
+        if (collectionVsAliases.containsKey(name) && !collectionVsAliases.get(name).isEmpty())  {
+          collectionStatus.put("aliases", collectionVsAliases.get(name));
+        }
+        collectionProps.add(name, collectionStatus);
+      }
+    } else {
+      String routeKey = message.getStr(ShardParams._ROUTE_);
+      if (routeKey == null) {
+        Map<String, Object> collectionStatus = getCollectionStatus(stateMap, collection, shard);
+        if (collectionVsAliases.containsKey(collection) && !collectionVsAliases.get(collection).isEmpty())  {
+          collectionStatus.put("aliases", collectionVsAliases.get(collection));
+        }
+        collectionProps.add(collection, collectionStatus);
+      } else {
+        DocCollection docCollection = clusterState.getCollection(collection);
+        DocRouter router = docCollection.getRouter();
+        Collection<Slice> slices = router.getSearchSlices(routeKey, null, docCollection);
+        String s = "";
+        for (Slice slice : slices) {
+          s += slice.getName() + ",";
+        }
+        if (shard != null)  {
+          s += shard;
+        }
+        Map<String, Object> collectionStatus = getCollectionStatus(stateMap, collection, s);
+        if (collectionVsAliases.containsKey(collection) && !collectionVsAliases.get(collection).isEmpty())  {
+          collectionStatus.put("aliases", collectionVsAliases.get(collection));
+        }
+        collectionProps.add(collection, collectionStatus);
+      }
+    }
+
+
+    NamedList<Object> clusterStatus = new SimpleOrderedMap<>();
+    clusterStatus.add("collections", collectionProps);
+
+    // read cluster properties
+    Map clusterProps = zkStateReader.getClusterProps();
+    if (clusterProps != null && !clusterProps.isEmpty())  {
+      clusterStatus.add("properties", clusterProps);
+    }
+
+    // add the alias map too
+    if (aliasVsCollections != null && !aliasVsCollections.isEmpty())  {
+      clusterStatus.add("aliases", aliasVsCollections);
+    }
+
+    results.add("cluster", clusterStatus);
+  }
+
+  /**
+   * Get collection status from cluster state.
+   * Can return collection status by given shard name.
+   *
+   *
+   * @param clusterState cloud state map parsed from JSON-serialized {@link ClusterState}
+   * @param name  collection name
+   * @param shardStr comma separated shard names
+   * @return map of collection properties
+   */
+  private Map<String, Object> getCollectionStatus(Map<String, Object> clusterState, String name, String shardStr) {
+    Map<String, Object> docCollection = (Map<String, Object>) clusterState.get(name);
+    if (docCollection == null)  {
+      throw new SolrException(ErrorCode.BAD_REQUEST, "Collection: " + name + " not found");
+    }
+    if (shardStr == null) {
+      return docCollection;
+    } else {
+      Map<String, Object> shards = (Map<String, Object>) docCollection.get("shards");
+      Map<String, Object>  selected = new HashMap<>();
+      List<String> selectedShards = Arrays.asList(shardStr.split(","));
+      for (String selectedShard : selectedShards) {
+        if (!shards.containsKey(selectedShard)) {
+          throw new SolrException(ErrorCode.BAD_REQUEST, "Collection: " + name + " shard: " + selectedShard + " not found");
+        }
+        selected.put(selectedShard, shards.get(selectedShard));
+        docCollection.put("shards", selected);
+      }
+      return docCollection;
+    }
+  }
+
+  private void listCollections(ClusterState clusterState, NamedList results) {
+    Set<String> collections = clusterState.getCollections();
+    List<String> collectionList = new ArrayList<String>();
+    for (String collection : collections) {
+      collectionList.add(collection);
+    }
+    results.add("collections", collectionList);
+  }
+
   private void processRoleCommand(ZkNodeProps message, String operation) throws KeeperException, InterruptedException {
     SolrZkClient zkClient = zkStateReader.getZkClient();
     Map roles = null;
@@ -1372,40 +1504,6 @@ public class OverseerCollectionProcessor
     } while (srsp != null);
   }
 
-  private void requestStatus(ZkNodeProps message, NamedList results) throws KeeperException, InterruptedException {
-    log.info("Request status invoked");
-    String requestId = message.getStr(REQUESTID);
-
-    // Special taskId (-1), clears up the request state maps.
-    if(requestId.equals("-1")) {
-      completedMap.clear();
-      failureMap.clear();
-      return;
-    }
-
-    if(completedMap.contains(requestId)) {
-      SimpleOrderedMap success = new SimpleOrderedMap();
-      success.add("state", "completed");
-      success.add("msg", "found " + requestId + " in completed tasks");
-      results.add("status", success);
-    } else if (runningMap.contains(requestId)) {
-      SimpleOrderedMap success = new SimpleOrderedMap();
-      success.add("state", "running");
-      success.add("msg", "found " + requestId + " in submitted tasks");
-      results.add("status", success);
-    } else if (failureMap.contains(requestId)) {
-      SimpleOrderedMap success = new SimpleOrderedMap();
-      success.add("state", "failed");
-      success.add("msg", "found " + requestId + " in failed tasks");
-      results.add("status", success);
-    } else {
-      SimpleOrderedMap failure = new SimpleOrderedMap();
-      failure.add("state", "notfound");
-      failure.add("msg", "Did not find taskid [" + requestId + "] in any tasks queue");
-      results.add("status", failure);
-    }
-  }
-
   private void deleteShard(ClusterState clusterState, ZkNodeProps message, NamedList results) {
     log.info("Delete shard invoked");
     String collection = message.getStr(ZkStateReader.COLLECTION_PROP);
@@ -2277,5 +2375,9 @@ public class OverseerCollectionProcessor
       } while (srsp != null);
     } while(true);
   }
+  String getId(){
+    return myId;
+  }
+
 
 }

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/SolrZkServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/SolrZkServer.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/SolrZkServer.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/SolrZkServer.java Fri Apr  4 10:27:05 2014
@@ -25,11 +25,11 @@ import java.io.InputStreamReader;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
+import java.nio.charset.StandardCharsets;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Map.Entry;
 
-import org.apache.lucene.util.IOUtils;
 import org.apache.solr.common.SolrException;
 import org.apache.zookeeper.server.ServerConfig;
 import org.apache.zookeeper.server.ZooKeeperServerMain;
@@ -179,7 +179,7 @@ class SolrZkServerProps extends QuorumPe
       Properties cfg = new Properties();
       FileInputStream in = new FileInputStream(configFile);
       try {
-        cfg.load(new InputStreamReader(in, IOUtils.CHARSET_UTF_8));
+        cfg.load(new InputStreamReader(in, StandardCharsets.UTF_8));
       } finally {
         in.close();
       }
@@ -461,7 +461,7 @@ class SolrZkServerProps extends QuorumPe
             + " file is missing");
       }
 
-      BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(myIdFile), IOUtils.CHARSET_UTF_8));
+      BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(myIdFile), StandardCharsets.UTF_8));
       String myIdString;
       try {
         myIdString = br.readLine();

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java Fri Apr  4 10:27:05 2014
@@ -20,10 +20,12 @@ import org.apache.zookeeper.data.ACL;
 import org.xml.sax.SAXException;
 
 import javax.xml.parsers.ParserConfigurationException;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.concurrent.TimeoutException;
 
@@ -253,7 +255,7 @@ public class ZkCLI {
             System.out.println("-" + PUT + " requires two args - the path to create and the data string");
             System.exit(1);
           }
-          zkClient.create(arglist.get(0).toString(), arglist.get(1).toString().getBytes("UTF-8"),
+          zkClient.create(arglist.get(0).toString(), arglist.get(1).toString().getBytes(StandardCharsets.UTF_8),
                           acl, CreateMode.PERSISTENT, true);
         } else if (line.getOptionValue(CMD).equals(PUT_FILE)) {
           List arglist = line.getArgList();
@@ -276,7 +278,7 @@ public class ZkCLI {
             System.exit(1);
           }
           byte [] data = zkClient.getData(arglist.get(0).toString(), null, null, true);
-          System.out.println(new String(data, "UTF-8"));
+          System.out.println(new String(data, StandardCharsets.UTF_8));
         } else if (line.getOptionValue(CMD).equals(GET_FILE)) {
           List arglist = line.getArgList();
           if (arglist.size() != 2) {

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/ZkController.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/ZkController.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/ZkController.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/cloud/ZkController.java Fri Apr  4 10:27:05 2014
@@ -304,18 +304,6 @@ public final class ZkController {
     return leaderConflictResolveWait;
   }
 
-  public void forceOverSeer(){
-    try {
-      zkClient.delete("/overseer_elect/leader",-1, true);
-      log.info("Forcing me to be leader  {} ", getBaseUrl());
-      overseerElector.getContext().runLeaderProcess(true, Overseer.STATE_UPDATE_DELAY + 100);
-    } catch (Exception e) {
-      throw new SolrException(ErrorCode.SERVER_ERROR, " Error becoming overseer ",e);
-
-    }
-
-  }
-
   private void registerAllCoresAsDown(
       final CurrentCoreDescriptorProvider registerOnReconnect, boolean updateLastPublished) {
     List<CoreDescriptor> descriptors = registerOnReconnect
@@ -558,7 +546,7 @@ public final class ZkController {
       adminPath = cc.getAdminPath();
       
       overseerElector = new LeaderElector(zkClient);
-      this.overseer = new Overseer(shardHandler, adminPath, zkStateReader);
+      this.overseer = new Overseer(shardHandler, adminPath, zkStateReader,this);
       ElectionContext context = new OverseerElectionContext(zkClient, overseer, getNodeName());
       overseerElector.setup(context);
       overseerElector.joinElection(context, false);
@@ -1626,7 +1614,7 @@ public final class ZkController {
       return hostName + ':' + hostPort + '_' + 
         URLEncoder.encode(trimLeadingAndTrailingSlashes(hostContext), "UTF-8");
     } catch (UnsupportedEncodingException e) {
-      throw new IllegalStateException("JVM Does not seem to support UTF-8", e);
+      throw new Error("JVM Does not seem to support UTF-8", e);
     }
   }
   
@@ -1679,4 +1667,8 @@ public final class ZkController {
     }
   }
 
+  CoreContainer getCoreContainer(){
+    return cc;
+  }
+
 }

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/ConfigSolr.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/ConfigSolr.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/ConfigSolr.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/ConfigSolr.java Fri Apr  4 10:27:05 2014
@@ -17,7 +17,6 @@ package org.apache.solr.core;
  * limitations under the License.
  */
 
-import com.google.common.base.Charsets;
 import com.google.common.io.ByteStreams;
 
 import org.apache.commons.io.IOUtils;
@@ -42,6 +41,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
@@ -77,19 +77,17 @@ public abstract class ConfigSolr {
   }
 
   public static ConfigSolr fromString(SolrResourceLoader loader, String xml) {
-    return fromInputStream(loader, new ByteArrayInputStream(xml.getBytes(Charsets.UTF_8)));
+    return fromInputStream(loader, new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)));
   }
 
   public static ConfigSolr fromInputStream(SolrResourceLoader loader, InputStream is) {
     try {
-      ByteArrayOutputStream baos = new ByteArrayOutputStream();
-      ByteStreams.copy(is, baos);
-      String originalXml = IOUtils.toString(new ByteArrayInputStream(baos.toByteArray()), "UTF-8");
-      ByteArrayInputStream dup = new ByteArrayInputStream(baos.toByteArray());
+      byte[] buf = IOUtils.toByteArray(is);
+      String originalXml = new String(buf, StandardCharsets.UTF_8);
+      ByteArrayInputStream dup = new ByteArrayInputStream(buf);
       Config config = new Config(loader, null, new InputSource(dup), null, false);
       return fromConfig(config, originalXml);
-    }
-    catch (Exception e) {
+    } catch (Exception e) {
       throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
     }
   }
@@ -241,7 +239,7 @@ public abstract class ConfigSolr {
   }
 
   public ConfigSetService createCoreConfigService(SolrResourceLoader loader, ZkController zkController) {
-    if (getZkHost() != null)
+    if (getZkHost() != null || System.getProperty("zkRun") != null)
       return new CloudConfigSetService(loader, zkController);
     if (hasSchemaCache())
       return new ConfigSetService.SchemaCaching(loader, getConfigSetBaseDirectory());

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java Fri Apr  4 10:27:05 2014
@@ -31,6 +31,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
 import java.util.Locale;
 import java.util.Properties;
 
@@ -213,7 +214,7 @@ public class CoreDescriptor {
       try {
         in = new FileInputStream(propertiesFile);
         Properties externalProps = new Properties();
-        externalProps.load(new InputStreamReader(in, "UTF-8"));
+        externalProps.load(new InputStreamReader(in, StandardCharsets.UTF_8));
         coreProperties.putAll(externalProps);
       } catch (IOException e) {
         String message = String.format(Locale.ROOT, "Could not load properties from %s: %s:",

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/CorePropertiesLocator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/CorePropertiesLocator.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/CorePropertiesLocator.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/CorePropertiesLocator.java Fri Apr  4 10:27:05 2014
@@ -17,7 +17,6 @@ package org.apache.solr.core;
  * limitations under the License.
  */
 
-import com.google.common.base.Charsets;
 import com.google.common.collect.Lists;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.util.IOUtils;
@@ -31,6 +30,7 @@ import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Properties;
 
@@ -79,7 +79,7 @@ public class CorePropertiesLocator imple
     Writer os = null;
     try {
       propfile.getParentFile().mkdirs();
-      os = new OutputStreamWriter(new FileOutputStream(propfile), Charsets.UTF_8);
+      os = new OutputStreamWriter(new FileOutputStream(propfile), StandardCharsets.UTF_8);
       p.store(os, "Written by CorePropertiesLocator");
     }
     catch (IOException e) {
@@ -147,7 +147,7 @@ public class CorePropertiesLocator imple
       File instanceDir = propertiesFile.getParentFile();
       Properties coreProperties = new Properties();
       fis = new FileInputStream(propertiesFile);
-      coreProperties.load(new InputStreamReader(fis, Charsets.UTF_8));
+      coreProperties.load(new InputStreamReader(fis, StandardCharsets.UTF_8));
       String name = createName(coreProperties, instanceDir);
       return new CoreDescriptor(cc, name, instanceDir.getAbsolutePath(), coreProperties);
     }

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/SolrCore.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/SolrCore.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/SolrCore.java Fri Apr  4 10:27:05 2014
@@ -99,6 +99,7 @@ import org.slf4j.LoggerFactory;
 import org.xml.sax.SAXException;
 
 import javax.xml.parsers.ParserConfigurationException;
+
 import java.io.Closeable;
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -108,6 +109,7 @@ import java.io.InputStreamReader;
 import java.io.Writer;
 import java.lang.reflect.Constructor;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 import java.nio.file.NoSuchFileException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -274,7 +276,7 @@ public final class SolrCore implements S
       if (input != null) {
         final InputStream is = new PropertiesInputStream(input);
         try {
-          p.load(new InputStreamReader(is, "UTF-8"));
+          p.load(new InputStreamReader(is, StandardCharsets.UTF_8));
           
           String s = p.getProperty("index");
           if (s != null && s.trim().length() > 0) {

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java Fri Apr  4 10:27:05 2014
@@ -48,6 +48,7 @@ import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import javax.naming.NoInitialContextException;
+
 import java.io.Closeable;
 import java.io.File;
 import java.io.FileFilter;
@@ -61,6 +62,7 @@ import java.net.URL;
 import java.net.URLClassLoader;
 import java.nio.charset.CharacterCodingException;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -93,7 +95,7 @@ public class SolrResourceLoader implemen
   private final List<SolrCoreAware> waitingForCore = Collections.synchronizedList(new ArrayList<SolrCoreAware>());
   private final List<SolrInfoMBean> infoMBeans = Collections.synchronizedList(new ArrayList<SolrInfoMBean>());
   private final List<ResourceLoaderAware> waitingForResources = Collections.synchronizedList(new ArrayList<ResourceLoaderAware>());
-  private static final Charset UTF_8 = Charset.forName("UTF-8");
+  private static final Charset UTF_8 = StandardCharsets.UTF_8;
 
   //TODO: Solr5. Remove this completely when you obsolete putting <core> tags in solr.xml (See Solr-4196)
   private final Properties coreProperties;

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/SolrXMLCoresLocator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/SolrXMLCoresLocator.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/SolrXMLCoresLocator.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/SolrXMLCoresLocator.java Fri Apr  4 10:27:05 2014
@@ -17,7 +17,6 @@ package org.apache.solr.core;
  * limitations under the License.
  */
 
-import com.google.common.base.Charsets;
 import com.google.common.collect.ImmutableList;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
@@ -29,6 +28,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -157,7 +157,7 @@ public class SolrXMLCoresLocator impleme
     FileOutputStream fos = null;
     try {
       fos = new FileOutputStream(file);
-      writer = new OutputStreamWriter(fos, Charsets.UTF_8);
+      writer = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
       writer.write(xml);
       writer.close();
       logger.info("Persisted core descriptions to {}", file.getAbsolutePath());

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/SolrXMLSerializer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/SolrXMLSerializer.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/SolrXMLSerializer.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/core/SolrXMLSerializer.java Fri Apr  4 10:27:05 2014
@@ -28,6 +28,7 @@ import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
+
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileInputStream;
@@ -37,6 +38,7 @@ import java.io.OutputStreamWriter;
 import java.io.StringWriter;
 import java.io.Writer;
 import java.nio.channels.FileChannel;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -169,7 +171,7 @@ public class SolrXMLSerializer {
       tmpFile = File.createTempFile("solr", ".xml", file.getParentFile());
       
       java.io.FileOutputStream out = new java.io.FileOutputStream(tmpFile);
-      Writer writer = new BufferedWriter(new OutputStreamWriter(out, "UTF-8"));
+      Writer writer = new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8));
       try {
         persist(writer, solrXMLDef);
       } finally {

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java Fri Apr  4 10:27:05 2014
@@ -26,6 +26,7 @@ import java.io.OutputStream;
 import java.io.Writer;
 import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
+import java.nio.charset.StandardCharsets;
 import java.nio.file.NoSuchFileException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -81,8 +82,6 @@ import org.apache.solr.util.plugin.SolrC
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.lucene.util.IOUtils.CHARSET_UTF_8;
-
 /**
  * <p> A Handler which provides a REST API for replication and serves replication requests from Slaves. <p/> </p>
  * <p>When running on the master, it provides the following commands <ol> <li>Get the current replicable index version
@@ -823,7 +822,7 @@ public class ReplicationHandler extends 
         try {
           final InputStream is = new PropertiesInputStream(input);
           Properties props = new Properties();
-          props.load(new InputStreamReader(is, CHARSET_UTF_8));
+          props.load(new InputStreamReader(is, StandardCharsets.UTF_8));
           return props;
         } finally {
           input.close();

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/SnapPuller.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/SnapPuller.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/SnapPuller.java Fri Apr  4 10:27:05 2014
@@ -26,6 +26,7 @@ import java.io.OutputStreamWriter;
 import java.io.Writer;
 import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
+import java.nio.charset.StandardCharsets;
 import java.nio.file.NoSuchFileException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -90,7 +91,6 @@ import org.eclipse.jetty.util.log.Log;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.lucene.util.IOUtils.CHARSET_UTF_8;
 import static org.apache.solr.handler.ReplicationHandler.ALIAS;
 import static org.apache.solr.handler.ReplicationHandler.CHECKSUM;
 import static org.apache.solr.handler.ReplicationHandler.CMD_DETAILS;
@@ -604,7 +604,7 @@ public class SnapPuller {
       }
 
       final IndexOutput out = dir.createOutput(REPLICATION_PROPERTIES, DirectoryFactory.IOCONTEXT_NO_CACHE);
-      Writer outFile = new OutputStreamWriter(new PropertiesOutputStream(out), CHARSET_UTF_8);
+      Writer outFile = new OutputStreamWriter(new PropertiesOutputStream(out), StandardCharsets.UTF_8);
       try {
         props.store(outFile, "Replication details");
         dir.sync(Collections.singleton(REPLICATION_PROPERTIES));
@@ -945,7 +945,7 @@ public class SnapPuller {
   
         final InputStream is = new PropertiesInputStream(input);
         try {
-          p.load(new InputStreamReader(is, CHARSET_UTF_8));
+          p.load(new InputStreamReader(is, StandardCharsets.UTF_8));
         } catch (Exception e) {
           LOG.error("Unable to load " + SnapPuller.INDEX_PROPERTIES, e);
         } finally {
@@ -961,7 +961,7 @@ public class SnapPuller {
       p.put("index", tmpIdxDirName);
       Writer os = null;
       try {
-        os = new OutputStreamWriter(new PropertiesOutputStream(out), CHARSET_UTF_8);
+        os = new OutputStreamWriter(new PropertiesOutputStream(out), StandardCharsets.UTF_8);
         p.store(os, SnapPuller.INDEX_PROPERTIES);
         dir.sync(Collections.singleton(INDEX_PROPERTIES));
       } catch (Exception e) {

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java Fri Apr  4 10:27:05 2014
@@ -211,6 +211,14 @@ public class CollectionsHandler extends 
         this.handleOverseerStatus(req, rsp);
         break;
       }
+      case LIST: {
+        this.handleListAction(req, rsp);
+        break;
+      }
+      case CLUSTERSTATUS:  {
+        this.handleClusterStatus(req, rsp);
+        break;
+      }
       default: {
           throw new RuntimeException("Unknown action: " + action);
       }
@@ -257,11 +265,43 @@ public class CollectionsHandler extends 
   private void handleRequestStatus(SolrQueryRequest req, SolrQueryResponse rsp) throws KeeperException, InterruptedException {
     log.debug("REQUESTSTATUS action invoked: " + req.getParamString());
     req.getParams().required().check(REQUESTID);
-    Map<String, Object> props = new HashMap<String, Object>();
-    props.put(Overseer.QUEUE_OPERATION, OverseerCollectionProcessor.REQUESTSTATUS);
-    props.put(REQUESTID, req.getParams().get(REQUESTID));
-    ZkNodeProps m = new ZkNodeProps(props);
-    handleResponse(OverseerCollectionProcessor.REQUESTSTATUS, m, rsp);
+
+    String requestId = req.getParams().get(REQUESTID);
+
+    if (requestId.equals("-1")) {
+      // Special taskId (-1), clears up the request state maps.
+      if(requestId.equals("-1")) {
+        coreContainer.getZkController().getOverseerCompletedMap().clear();
+        coreContainer.getZkController().getOverseerFailureMap().clear();
+        return;
+      }
+    } else {
+      NamedList<Object> results = new NamedList<>();
+      if (coreContainer.getZkController().getOverseerCompletedMap().contains(requestId)) {
+        SimpleOrderedMap success = new SimpleOrderedMap();
+        success.add("state", "completed");
+        success.add("msg", "found " + requestId + " in completed tasks");
+        results.add("status", success);
+      } else if (coreContainer.getZkController().getOverseerRunningMap().contains(requestId)) {
+        SimpleOrderedMap success = new SimpleOrderedMap();
+        success.add("state", "running");
+        success.add("msg", "found " + requestId + " in submitted tasks");
+        results.add("status", success);
+      } else if (coreContainer.getZkController().getOverseerFailureMap().contains(requestId)) {
+        SimpleOrderedMap success = new SimpleOrderedMap();
+        success.add("state", "failed");
+        success.add("msg", "found " + requestId + " in failed tasks");
+        results.add("status", success);
+      } else {
+        SimpleOrderedMap failure = new SimpleOrderedMap();
+        failure.add("state", "notfound");
+        failure.add("msg", "Did not find taskid [" + requestId + "] in any tasks queue");
+        results.add("status", failure);
+      }
+      SolrResponse response = new OverseerSolrResponse(results);
+
+      rsp.getValues().addAll(response.getResponse());
+    }
   }
 
   private void handleResponse(String operation, ZkNodeProps m,
@@ -574,6 +614,36 @@ public class CollectionsHandler extends 
     handleResponse(CollectionAction.ADDREPLICA.toString(), m, rsp);
   }
 
+  /**
+   * Handle cluster status request.
+   * Can return status per specific collection/shard or per all collections.
+   *
+   * @param req solr request
+   * @param rsp solr response
+   */
+  private void handleClusterStatus(SolrQueryRequest req, SolrQueryResponse rsp) throws KeeperException, InterruptedException {
+    Map<String,Object> props = new HashMap<>();
+    props.put(Overseer.QUEUE_OPERATION, CollectionAction.CLUSTERSTATUS.toLower());
+    copyIfNotNull(req.getParams(), props, COLLECTION_PROP, SHARD_ID_PROP, ShardParams._ROUTE_);
+    handleResponse(CollectionAction.CLUSTERSTATUS.toString(), new ZkNodeProps(props), rsp);
+  }
+
+  /**
+   * Handled list collection request.
+   * Do list collection request to zk host
+   *
+   * @param req solr request
+   * @param rsp solr response
+   * @throws KeeperException      zk connection failed
+   * @throws InterruptedException connection interrupted
+   */
+  private void handleListAction(SolrQueryRequest req, SolrQueryResponse rsp) throws KeeperException, InterruptedException {
+    Map<String, Object> props = ZkNodeProps.makeMap(
+        Overseer.QUEUE_OPERATION, CollectionAction.LIST.toString().toLowerCase(Locale.ROOT));
+    handleResponse(CollectionAction.LIST.toString(), new ZkNodeProps(props), rsp);
+  }
+
+
   public static ModifiableSolrParams params(String... params) {
     ModifiableSolrParams msp = new ModifiableSolrParams();
     for (int i=0; i<params.length; i+=2) {

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java Fri Apr  4 10:27:05 2014
@@ -273,10 +273,8 @@ public class CoreAdminHandler extends Re
         case OVERSEEROP:{
           ZkController zkController = coreContainer.getZkController();
           if(zkController != null){
-            String op = req.getParams().get("op");
-            if("leader".equals(op)){
-              zkController.forceOverSeer();
-            } else if ("rejoin".equals(op)) zkController.rejoinOverseerElection();
+           String op = req.getParams().get("op");
+           if ("rejoin".equals(op)) zkController.rejoinOverseerElection();
           }
           break;
         }

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/admin/EditFileRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/admin/EditFileRequestHandler.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/admin/EditFileRequestHandler.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/admin/EditFileRequestHandler.java Fri Apr  4 10:27:05 2014
@@ -43,10 +43,7 @@ import org.xml.sax.InputSource;
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.HashSet;
 import java.util.Iterator;
-import java.util.Locale;
 import java.util.Set;
 
 /**
@@ -152,7 +149,7 @@ public class EditFileRequestHandler exte
           return; // Error already in rsp.
         }
 
-        data = IOUtils.toByteArray(new InputStreamReader(stream.getStream(), "UTF-8"), "UTF-8");
+        data = IOUtils.toByteArray(stream.getStream());
 
         // If it's "solrconfig.xml", try parsing it as that object. Otherwise, if it ends in '.xml',
         // see if it at least parses.

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java Fri Apr  4 10:27:05 2014
@@ -39,6 +39,7 @@ import org.apache.solr.common.params.Sha
 import org.apache.solr.search.CollapsingQParserPlugin;
 import org.apache.solr.search.DocIterator;
 import org.apache.solr.search.DocList;
+import org.apache.solr.search.QParser;
 import org.apache.solr.search.QueryParsing;
 import org.apache.solr.schema.FieldType;
 import org.apache.solr.common.params.SolrParams;
@@ -51,11 +52,9 @@ import org.apache.solr.util.plugin.Plugi
 import org.apache.solr.util.plugin.SolrCoreAware;
 import org.apache.solr.core.PluginInfo;
 import org.apache.solr.core.SolrCore;
-
 import com.carrotsearch.hppc.IntObjectOpenHashMap;
 import com.carrotsearch.hppc.IntOpenHashSet;
 import com.carrotsearch.hppc.cursors.IntObjectCursor;
-
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -64,7 +63,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.Vector;
 
 /**
   * The ExpandComponent is designed to work with the CollapsingPostFilter.
@@ -75,9 +73,11 @@ import java.util.Vector;
   * http parameters:
   * <p/>
   * expand=true <br/>
-  * expand.rows=5 </br>
-  * expand.sort=field asc|desc
-  *
+  * expand.rows=5 <br/>
+  * expand.sort=field asc|desc<br/>
+  * expand.q=*:* (optional, overrides the main query)<br/>
+  * expand.fq=type:child (optional, overrides the main filter queries)<br/>
+  * expand.field=field (mandatory if the not used with the CollapsingQParserPlugin)<br/>
   **/
     
 public class ExpandComponent extends SearchComponent implements PluginInfoInitialized, SolrCoreAware {
@@ -117,8 +117,26 @@ public class ExpandComponent extends Sea
       return;
     }
 
-    String field = null;
+    String field = params.get(ExpandParams.EXPAND_FIELD);
+    if(field == null) {
+      List<Query> filters = rb.getFilters();
+      if(filters != null) {
+        for(Query q : filters) {
+          if(q instanceof CollapsingQParserPlugin.CollapsingPostFilter) {
+              CollapsingQParserPlugin.CollapsingPostFilter cp = (CollapsingQParserPlugin.CollapsingPostFilter)q;
+              field = cp.getField();
+          }
+        }
+      }
+    }
+
+    if(field == null) {
+      throw new IOException("Expand field is null.");
+    }
+
     String sortParam = params.get(ExpandParams.EXPAND_SORT);
+    String[] fqs = params.getParams(ExpandParams.EXPAND_FQ);
+    String qs = params.get(ExpandParams.EXPAND_Q);
     int limit = params.getInt(ExpandParams.EXPAND_ROWS, 5);
 
     Sort sort = null;
@@ -127,20 +145,40 @@ public class ExpandComponent extends Sea
       sort = QueryParsing.parseSortSpec(sortParam, rb.req).getSort();
     }
 
-    Query query = rb.getQuery();
-    List<Query> filters = rb.getFilters();
-    List<Query> newFilters = new ArrayList();
-    for(Query q : filters) {
-      if(!(q instanceof CollapsingQParserPlugin.CollapsingPostFilter)) {
-        newFilters.add(q);
-      } else {
-        CollapsingQParserPlugin.CollapsingPostFilter cp = (CollapsingQParserPlugin.CollapsingPostFilter)q;
-        field = cp.getField();
+    Query query = null;
+    if(qs == null) {
+      query = rb.getQuery();
+    } else {
+      try {
+        QParser parser = QParser.getParser(qs, null, req);
+        query = parser.getQuery();
+      } catch(Exception e) {
+        throw new IOException(e);
       }
     }
 
-    if(field == null) {
-      throw new IOException("Expand field is null.");
+    List<Query> newFilters = new ArrayList();
+
+    if(fqs == null) {
+      List<Query> filters = rb.getFilters();
+      if(filters != null) {
+        for(Query q : filters) {
+          if(!(q instanceof CollapsingQParserPlugin.CollapsingPostFilter)) {
+            newFilters.add(q);
+          }
+        }
+      }
+    } else {
+      try {
+        for (String fq : fqs) {
+          if (fq != null && fq.trim().length()!=0 && !fq.equals("*:*")) {
+            QParser fqp = QParser.getParser(fq, null, req);
+            newFilters.add(fqp.getQuery());
+          }
+        }
+      } catch(Exception e) {
+        throw new IOException(e);
+      }
     }
 
     SolrIndexSearcher searcher = req.getSearcher();

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/internal/csv/writer/CSVConfigGuesser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/internal/csv/writer/CSVConfigGuesser.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/internal/csv/writer/CSVConfigGuesser.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/internal/csv/writer/CSVConfigGuesser.java Fri Apr  4 10:27:05 2014
@@ -21,8 +21,7 @@ package org.apache.solr.internal.csv.wri
 import java.io.BufferedReader;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-
-import org.apache.lucene.util.IOUtils;
+import java.nio.charset.StandardCharsets;
 
 /**
  * Tries to guess a config based on an InputStream.
@@ -76,7 +75,7 @@ public class CSVConfigGuesser {
     public CSVConfig guess() {
         try {
             // tralalal
-            BufferedReader bIn = new BufferedReader(new InputStreamReader(getInputStream(), IOUtils.CHARSET_UTF_8));
+            BufferedReader bIn = new BufferedReader(new InputStreamReader(getInputStream(), StandardCharsets.UTF_8));
             String[] lines = new String[10];
             String line = null;
             int counter = 0;

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/rest/BaseSolrResource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/rest/BaseSolrResource.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/rest/BaseSolrResource.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/rest/BaseSolrResource.java Fri Apr  4 10:27:05 2014
@@ -45,13 +45,14 @@ import java.io.UnsupportedEncodingExcept
 import java.io.Writer;
 import java.net.URLDecoder;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 
 /**
  * Base class of all Solr Restlet server resource classes.
  */
 public abstract class BaseSolrResource extends ServerResource {
-  protected static final Charset UTF8 = Charset.forName("UTF-8");
+  protected static final Charset UTF8 = StandardCharsets.UTF_8;
   protected static final String SHOW_DEFAULTS = "showDefaults";
 
   private SolrCore solrCore;
@@ -161,7 +162,7 @@ public abstract class BaseSolrResource e
           binWriter.write(outputStream, solrRequest, solrResponse);
         } else {
           String charset = ContentStreamBase.getCharsetFromContentType(contentType);
-          Writer out = (charset == null || charset.equalsIgnoreCase("UTF-8"))
+          Writer out = (charset == null)
               ? new OutputStreamWriter(outputStream, UTF8)
               : new OutputStreamWriter(outputStream, charset);
           out = new FastWriter(out);

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java Fri Apr  4 10:27:05 2014
@@ -29,6 +29,7 @@ import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Reader;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
@@ -419,7 +420,7 @@ public abstract class ManagedResourceSto
   
   public static final Logger log = LoggerFactory.getLogger(ManagedResourceStorage.class);
   
-  public static final Charset UTF_8 = Charset.forName("UTF-8");
+  public static final Charset UTF_8 = StandardCharsets.UTF_8;
   
   protected StorageIO storageIO;
   protected SolrResourceLoader loader;

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/BCDIntField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/BCDIntField.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/BCDIntField.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/BCDIntField.java Fri Apr  4 10:27:05 2014
@@ -66,6 +66,16 @@ public class BCDIntField extends Primiti
   public void write(TextResponseWriter writer, String name, StorableField f) throws IOException {
     writer.writeInt(name,toExternal(f));
   }
+
+  @Override
+  public Object marshalSortValue(Object value) {
+    return marshalStringSortValue(value);
+  }
+
+  @Override
+  public Object unmarshalSortValue(Object value) {
+    return unmarshalStringSortValue(value);
+  }
 }
 
 

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/BoolField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/BoolField.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/BoolField.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/BoolField.java Fri Apr  4 10:27:05 2014
@@ -151,6 +151,16 @@ public class BoolField extends Primitive
   public void write(TextResponseWriter writer, String name, StorableField f) throws IOException {
     writer.writeBool(name, f.stringValue().charAt(0) == 'T');
   }
+
+  @Override
+  public Object marshalSortValue(Object value) {
+    return marshalStringSortValue(value);
+  }
+
+  @Override
+  public Object unmarshalSortValue(Object value) {
+    return unmarshalStringSortValue(value);
+  }
 }
 
 // TODO - this can be much more efficient - use OpenBitSet or Bits

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/CollationField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/CollationField.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/CollationField.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/CollationField.java Fri Apr  4 10:27:05 2014
@@ -47,7 +47,6 @@ import org.apache.lucene.util.Version;
 import org.apache.lucene.analysis.util.ResourceLoader;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
-import org.apache.solr.common.util.Base64;
 import org.apache.solr.response.TextResponseWriter;
 import org.apache.solr.search.QParser;
 
@@ -278,20 +277,11 @@ public class CollationField extends Fiel
 
   @Override
   public Object marshalSortValue(Object value) {
-    if (null == value) {
-      return null;
-    }
-    final BytesRef val = (BytesRef)value;
-    return Base64.byteArrayToBase64(val.bytes, val.offset, val.length);
+    return marshalBase64SortValue(value);
   }
 
   @Override
   public Object unmarshalSortValue(Object value) {
-    if (null == value) {
-      return null;
-    }
-    final String val = (String)value;
-    final byte[] bytes = Base64.base64ToByteArray(val);
-    return new BytesRef(bytes);
+    return unmarshalBase64SortValue(value);
   }
 }

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/DateField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/DateField.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/DateField.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/DateField.java Fri Apr  4 10:27:05 2014
@@ -248,6 +248,16 @@ public class DateField extends Primitive
   }
 
   @Override
+  public Object marshalSortValue(Object value) {
+    return marshalStringSortValue(value);
+  }
+
+  @Override
+  public Object unmarshalSortValue(Object value) {
+    return unmarshalStringSortValue(value);
+  }
+
+  @Override
   public void write(TextResponseWriter writer, String name, StorableField f) throws IOException {
     writer.writeDate(name, toExternal(f));
   }

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/FieldType.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/FieldType.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/FieldType.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/FieldType.java Fri Apr  4 10:27:05 2014
@@ -48,6 +48,7 @@ import org.apache.solr.analysis.SolrAnal
 import org.apache.solr.analysis.TokenizerChain;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
+import org.apache.solr.common.util.Base64;
 import org.apache.solr.common.util.SimpleOrderedMap;
 import org.apache.solr.common.util.StrUtils;
 import org.apache.solr.response.TextResponseWriter;
@@ -968,4 +969,52 @@ public abstract class FieldType extends 
   public Object unmarshalSortValue(Object value) {
     return value;
   }
+
+  /**
+   * Marshals a string-based field value.
+   */
+  protected static Object marshalStringSortValue(Object value) {
+    if (null == value) {
+      return null;
+    }
+    CharsRef spare = new CharsRef();
+    UnicodeUtil.UTF8toUTF16((BytesRef)value, spare);
+    return spare.toString();
+  }
+
+  /**
+   * Unmarshals a string-based field value.
+   */
+  protected static Object unmarshalStringSortValue(Object value) {
+    if (null == value) {
+      return null;
+    }
+    BytesRef spare = new BytesRef();
+    String stringVal = (String)value;
+    UnicodeUtil.UTF16toUTF8(stringVal, 0, stringVal.length(), spare);
+    return spare;
+  }
+
+  /**
+   * Marshals a binary field value.
+   */
+  protected static Object marshalBase64SortValue(Object value) {
+    if (null == value) {
+      return null;
+    }
+    final BytesRef val = (BytesRef)value;
+    return Base64.byteArrayToBase64(val.bytes, val.offset, val.length);
+  }
+
+  /**
+   * Unmarshals a binary field value.
+   */
+  protected static Object unmarshalBase64SortValue(Object value) {
+    if (null == value) {
+      return null;
+    }
+    final String val = (String)value;
+    final byte[] bytes = Base64.base64ToByteArray(val);
+    return new BytesRef(bytes);
+  }
 }

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/FloatField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/FloatField.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/FloatField.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/FloatField.java Fri Apr  4 10:27:05 2014
@@ -70,7 +70,7 @@ public class FloatField extends Primitiv
   @Override
   public SortField getSortField(SchemaField field,boolean reverse) {
     field.checkSortability();
-    return new SortField(field.name,SortField.Type.FLOAT, reverse);
+    return new SortField(field.name, PARSER, reverse);
   }
 
   @Override

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java Fri Apr  4 10:27:05 2014
@@ -33,11 +33,13 @@ import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
 
 import javax.xml.xpath.XPath;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -92,7 +94,7 @@ public final class ManagedIndexSchema ex
         }
       }
       final FileOutputStream out = new FileOutputStream(managedSchemaFile);
-      writer = new OutputStreamWriter(out, "UTF-8");
+      writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
       persist(writer);
       log.info("Upgraded to managed schema at " + managedSchemaFile.getPath());
     } catch (IOException e) {
@@ -132,7 +134,7 @@ public final class ManagedIndexSchema ex
       StringWriter writer = new StringWriter();
       persist(writer);
 
-      final byte[] data = writer.toString().getBytes("UTF-8");
+      final byte[] data = writer.toString().getBytes(StandardCharsets.UTF_8);
       if (createOnly) {
         try {
           zkClient.create(managedSchemaPath, data, CreateMode.PERSISTENT, true);

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/OpenExchangeRatesOrgProvider.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/OpenExchangeRatesOrgProvider.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/OpenExchangeRatesOrgProvider.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/OpenExchangeRatesOrgProvider.java Fri Apr  4 10:27:05 2014
@@ -20,13 +20,13 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
 import org.noggit.JSONParser;
 import org.apache.lucene.analysis.util.ResourceLoader;
-import org.apache.lucene.util.IOUtils;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
 import org.slf4j.Logger;
@@ -202,7 +202,7 @@ public class OpenExchangeRatesOrgProvide
     private JSONParser parser;
     
     public OpenExchangeRates(InputStream ratesStream) throws IOException {
-      parser = new JSONParser(new InputStreamReader(ratesStream, IOUtils.CHARSET_UTF_8));
+      parser = new JSONParser(new InputStreamReader(ratesStream, StandardCharsets.UTF_8));
       rates = new HashMap<>();
       
       int ev;

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/PreAnalyzedField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/PreAnalyzedField.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/PreAnalyzedField.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/PreAnalyzedField.java Fri Apr  4 10:27:05 2014
@@ -78,6 +78,7 @@ public class PreAnalyzedField extends Fi
           parser = new JsonPreAnalyzedParser();
         }
       }
+      args.remove(PARSER_IMPL);
     }
   }
 

Modified: lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/StrField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/StrField.java?rev=1584603&r1=1584602&r2=1584603&view=diff
==============================================================================
--- lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/StrField.java (original)
+++ lucene/dev/branches/solr5914/solr/core/src/java/org/apache/solr/schema/StrField.java Fri Apr  4 10:27:05 2014
@@ -29,8 +29,6 @@ import org.apache.lucene.index.StorableF
 import org.apache.lucene.queries.function.ValueSource;
 import org.apache.lucene.search.SortField;
 import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.CharsRef;
-import org.apache.lucene.util.UnicodeUtil;
 import org.apache.solr.response.TextResponseWriter;
 import org.apache.solr.search.QParser;
 
@@ -86,23 +84,12 @@ public class StrField extends PrimitiveF
 
   @Override
   public Object marshalSortValue(Object value) {
-    if (null == value) {
-      return null;
-    }
-    CharsRef spare = new CharsRef();
-    UnicodeUtil.UTF8toUTF16((BytesRef)value, spare);
-    return spare.toString();
+    return marshalStringSortValue(value);
   }
 
   @Override
   public Object unmarshalSortValue(Object value) {
-    if (null == value) {
-      return null;
-    }
-    BytesRef spare = new BytesRef();
-    String stringVal = (String)value;
-    UnicodeUtil.UTF16toUTF8(stringVal, 0, stringVal.length(), spare);
-    return spare;
+    return unmarshalStringSortValue(value);
   }
 }
 



Mime
View raw message