You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2012/10/25 15:10:51 UTC
svn commit: r1402140 [14/17] - in /lucene/dev/branches/LUCENE-2878: ./
dev-tools/ dev-tools/eclipse/ dev-tools/eclipse/dot.settings/
dev-tools/idea/.idea/libraries/ dev-tools/idea/lucene/classification/
dev-tools/maven/ dev-tools/maven/lucene/classific...
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java Thu Oct 25 13:10:25 2012
@@ -35,6 +35,7 @@ import org.eclipse.jetty.server.Connecto
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.bio.SocketConnector;
import org.eclipse.jetty.server.handler.GzipHandler;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.eclipse.jetty.server.session.HashSessionIdManager;
import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.servlet.ServletContextHandler;
@@ -92,6 +93,7 @@ public class JettySolrRunner {
private void init(String solrHome, String context, int port, boolean stopAtShutdown) {
this.context = context;
server = new Server(port);
+
this.solrHome = solrHome;
this.stopAtShutdown = stopAtShutdown;
server.setStopAtShutdown(stopAtShutdown);
@@ -100,32 +102,45 @@ public class JettySolrRunner {
}
System.setProperty("solr.solr.home", solrHome);
if (System.getProperty("jetty.testMode") != null) {
- // SelectChannelConnector connector = new SelectChannelConnector();
- // Normal SocketConnector is what solr's example server uses by default
- SocketConnector connector = new SocketConnector();
+ SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(port);
connector.setReuseAddress(true);
- if (!stopAtShutdown) {
- QueuedThreadPool threadPool = (QueuedThreadPool) connector
- .getThreadPool();
- if (threadPool != null) {
+ connector.setLowResourcesMaxIdleTime(1500);
+ QueuedThreadPool threadPool = (QueuedThreadPool) connector
+ .getThreadPool();
+ if (threadPool != null) {
+ threadPool.setMaxThreads(10000);
+ threadPool.setMaxIdleTimeMs(5000);
+ if (!stopAtShutdown) {
threadPool.setMaxStopTimeMs(100);
}
}
+
server.setConnectors(new Connector[] {connector});
server.setSessionIdManager(new HashSessionIdManager(new Random()));
} else {
- if (!stopAtShutdown) {
- for (Connector connector : server.getConnectors()) {
- if (connector instanceof SocketConnector) {
- QueuedThreadPool threadPool = (QueuedThreadPool) ((SocketConnector) connector)
- .getThreadPool();
- if (threadPool != null) {
- threadPool.setMaxStopTimeMs(100);
- }
+
+ for (Connector connector : server.getConnectors()) {
+ QueuedThreadPool threadPool = null;
+ if (connector instanceof SocketConnector) {
+ threadPool = (QueuedThreadPool) ((SocketConnector) connector)
+ .getThreadPool();
+ }
+ if (connector instanceof SelectChannelConnector) {
+ threadPool = (QueuedThreadPool) ((SelectChannelConnector) connector)
+ .getThreadPool();
+ }
+
+ if (threadPool != null) {
+ threadPool.setMaxThreads(10000);
+ threadPool.setMaxIdleTimeMs(5000);
+ if (!stopAtShutdown) {
+ threadPool.setMaxStopTimeMs(100);
}
}
+
}
+
}
// Initialize the servlets
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/AssignShard.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/AssignShard.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/AssignShard.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/AssignShard.java Thu Oct 25 13:10:25 2012
@@ -32,8 +32,6 @@ public class AssignShard {
/**
* Assign a new unique id up to slices count - then add replicas evenly.
*
- * @param collection
- * @param state
* @return the assigned shard id
*/
public static String assignShard(String collection, ClusterState state, Integer numShards) {
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/DistributedQueue.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/DistributedQueue.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/DistributedQueue.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/DistributedQueue.java Thu Oct 25 13:10:25 2012
@@ -98,9 +98,6 @@ public class DistributedQueue {
* Return the head of the queue without modifying the queue.
*
* @return the data at the head of the queue.
- * @throws NoSuchElementException
- * @throws KeeperException
- * @throws InterruptedException
*/
public byte[] element() throws NoSuchElementException, KeeperException,
InterruptedException {
@@ -137,9 +134,6 @@ public class DistributedQueue {
* Attempts to remove the head of the queue and return it.
*
* @return The former head of the queue
- * @throws NoSuchElementException
- * @throws KeeperException
- * @throws InterruptedException
*/
public byte[] remove() throws NoSuchElementException, KeeperException,
InterruptedException {
@@ -190,9 +184,6 @@ public class DistributedQueue {
* Removes the head of the queue and returns it, blocks until it succeeds.
*
* @return The former head of the queue
- * @throws NoSuchElementException
- * @throws KeeperException
- * @throws InterruptedException
*/
public byte[] take() throws KeeperException, InterruptedException {
TreeMap<Long,String> orderedChildren;
@@ -226,7 +217,6 @@ public class DistributedQueue {
/**
* Inserts data into queue.
*
- * @param data
* @return true if data was successfully added
*/
public boolean offer(byte[] data) throws KeeperException,
@@ -254,8 +244,6 @@ public class DistributedQueue {
* empty.
*
* @return data at the first element of the queue, or null.
- * @throws KeeperException
- * @throws InterruptedException
*/
public byte[] peek() throws KeeperException, InterruptedException {
try {
@@ -270,8 +258,6 @@ public class DistributedQueue {
* empty.
*
* @return data at the first element of the queue, or null.
- * @throws KeeperException
- * @throws InterruptedException
*/
public byte[] peek(boolean block) throws KeeperException, InterruptedException {
if (!block) {
@@ -309,8 +295,6 @@ public class DistributedQueue {
* queue is empty.
*
* @return Head of the queue or null.
- * @throws KeeperException
- * @throws InterruptedException
*/
public byte[] poll() throws KeeperException, InterruptedException {
try {
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java Thu Oct 25 13:10:25 2012
@@ -14,6 +14,7 @@ import org.apache.solr.common.cloud.ZkNo
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;
+import org.apache.solr.update.UpdateLog;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger;
@@ -122,6 +123,7 @@ final class ShardLeaderElectionContext e
@Override
public void close() {
this.isClosed = true;
+ syncStrategy.close();
}
@Override
@@ -161,6 +163,10 @@ final class ShardLeaderElectionContext e
}
log.info("I may be the new leader - try and sync");
+
+ UpdateLog ulog = core.getUpdateHandler().getUpdateLog();
+
+
// we are going to attempt to be the leader
// first cancel any current recovery
core.getUpdateHandler().getSolrCoreState().cancelRecovery();
@@ -172,6 +178,14 @@ final class ShardLeaderElectionContext e
success = false;
}
+ if (!success && ulog.getRecentUpdates().getVersions(1).isEmpty()) {
+ // we failed sync, but we have no versions - we can't sync in that case
+ // - we were active
+ // before, so become leader anyway
+ log.info("We failed sync, but we have no versions - we can't sync in that case - we were active before, so become leader anyway");
+ success = true;
+ }
+
// if !success but no one else is in active mode,
// we are the leader anyway
// TODO: should we also be leader if there is only one other active?
@@ -307,13 +321,7 @@ final class ShardLeaderElectionContext e
return;
}
- log.info("There is a better leader candidate than us - going back into recovery");
-
- try {
- zkController.publish(core.getCoreDescriptor(), ZkStateReader.DOWN);
- } catch (Throwable t) {
- SolrException.log(log, "Error trying to publish down state", t);
- }
+ log.info("There may be a better leader candidate than us - going back into recovery");
cancelElection();
@@ -323,7 +331,7 @@ final class ShardLeaderElectionContext e
SolrException.log(log, "Error trying to start recovery", t);
}
- leaderElector.joinElection(this);
+ leaderElector.joinElection(this, true);
}
private boolean shouldIBeLeader(ZkNodeProps leaderProps, SolrCore core) {
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java Thu Oct 25 13:10:25 2012
@@ -18,7 +18,6 @@ package org.apache.solr.cloud;
*/
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -43,7 +42,7 @@ import org.slf4j.LoggerFactory;
* Leader Election process. This class contains the logic by which a
* leader is chosen. First call * {@link #setup(ElectionContext)} to ensure
* the election process is init'd. Next call
- * {@link #joinElection(ElectionContext)} to start the leader election.
+ * {@link #joinElection(ElectionContext, boolean)} to start the leader election.
*
* The implementation follows the classic ZooKeeper recipe of creating an
* ephemeral, sequential node for each candidate and then looking at the set
@@ -75,13 +74,7 @@ public class LeaderElector {
* watching the candidate that is in line before this one - if it goes down, check
* if this candidate is the leader again.
*
- * @param seq
- * @param context
* @param replacement has someone else been the leader already?
- * @throws KeeperException
- * @throws InterruptedException
- * @throws IOException
- * @throws UnsupportedEncodingException
*/
private void checkIfIamLeader(final int seq, final ElectionContext context, boolean replacement) throws KeeperException,
InterruptedException, IOException {
@@ -161,7 +154,6 @@ public class LeaderElector {
/**
* Returns int given String of form n_0000000001 or n_0000000003, etc.
*
- * @param nStringSequence
* @return sequence number
*/
private int getSeq(String nStringSequence) {
@@ -208,14 +200,9 @@ public class LeaderElector {
* node that is watched goes down, check if we are the new lowest node, else
* watch the next lowest numbered node.
*
- * @param context
* @return sequential node number
- * @throws KeeperException
- * @throws InterruptedException
- * @throws IOException
- * @throws UnsupportedEncodingException
*/
- public int joinElection(ElectionContext context) throws KeeperException, InterruptedException, IOException {
+ public int joinElection(ElectionContext context, boolean replacement) throws KeeperException, InterruptedException, IOException {
final String shardsElectZkPath = context.electionPath + LeaderElector.ELECTION_NODE;
long sessionId = zkClient.getSolrZooKeeper().getSessionId();
@@ -271,17 +258,13 @@ public class LeaderElector {
}
}
int seq = getSeq(leaderSeqPath);
- checkIfIamLeader(seq, context, false);
+ checkIfIamLeader(seq, context, replacement);
return seq;
}
/**
* Set up any ZooKeeper nodes needed for leader election.
- *
- * @param context
- * @throws InterruptedException
- * @throws KeeperException
*/
public void setup(final ElectionContext context) throws InterruptedException,
KeeperException {
@@ -292,8 +275,6 @@ public class LeaderElector {
/**
* Sort n string sequence list.
- *
- * @param seqs
*/
private void sortSeqs(List<String> seqs) {
Collections.sort(seqs, new Comparator<String>() {
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/Overseer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/Overseer.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/Overseer.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/Overseer.java Thu Oct 25 13:10:25 2012
@@ -17,14 +17,11 @@ package org.apache.solr.cloud;
* the License.
*/
-import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
-import org.apache.noggit.JSONUtil;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.cloud.ClusterState;
import org.apache.solr.common.cloud.ClosableThread;
@@ -210,11 +207,11 @@ public class Overseer {
private ClusterState updateState(ClusterState state, final ZkNodeProps message) {
final String collection = message.getStr(ZkStateReader.COLLECTION_PROP);
final String zkCoreNodeName = message.getStr(ZkStateReader.NODE_NAME_PROP) + "_" + message.getStr(ZkStateReader.CORE_NAME_PROP);
- final Integer numShards = message.getStr(ZkStateReader.NUM_SHARDS_PROP)!=null?Integer.parseInt(message.getStr(ZkStateReader.NUM_SHARDS_PROP)):null;
-
+ Integer numShards = message.getStr(ZkStateReader.NUM_SHARDS_PROP)!=null?Integer.parseInt(message.getStr(ZkStateReader.NUM_SHARDS_PROP)):null;
+ log.info("Update state numShards={} message={}", numShards, message);
//collection does not yet exist, create placeholders if num shards is specified
- if (!state.getCollections().contains(collection)
- && numShards!=null) {
+ boolean collectionExists = state.getCollections().contains(collection);
+ if (!collectionExists && numShards!=null) {
state = createCollection(state, collection, numShards);
}
@@ -227,6 +224,10 @@ public class Overseer {
}
if(sliceName == null) {
//request new shardId
+ if (collectionExists) {
+ // use existing numShards
+ numShards = state.getCollectionStates().get(collection).size();
+ }
sliceName = AssignShard.assignShard(collection, state, numShards);
}
@@ -269,6 +270,8 @@ public class Overseer {
}
private ClusterState createCollection(ClusterState state, String collectionName, int numShards) {
+ log.info("Create collection {} with numShards {}", collectionName, numShards);
+
HashPartitioner hp = new HashPartitioner();
List<HashPartitioner.Range> ranges = hp.partitionRange(numShards, hp.fullRange());
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java Thu Oct 25 13:10:25 2012
@@ -37,6 +37,7 @@ import org.apache.solr.common.cloud.ZkNo
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.cloud.ZooKeeperException;
import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.UpdateParams;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.core.RequestHandlers.LazyRequestHandlerWrapper;
@@ -177,6 +178,7 @@ public class RecoveryStrategy extends Th
UpdateRequest ureq = new UpdateRequest();
ureq.setParams(new ModifiableSolrParams());
ureq.getParams().set(DistributedUpdateProcessor.COMMIT_END_POINT, true);
+ ureq.getParams().set(UpdateParams.OPEN_SEARCHER, false);
ureq.setAction(AbstractUpdateRequest.ACTION.COMMIT, false, true).process(
server);
server.shutdown();
@@ -346,7 +348,7 @@ public class RecoveryStrategy extends Th
// System.out.println("Attempting to PeerSync from " + leaderUrl
// + " i am:" + zkController.getNodeName());
PeerSync peerSync = new PeerSync(core,
- Collections.singletonList(leaderUrl), ulog.numRecordsToKeep);
+ Collections.singletonList(leaderUrl), ulog.numRecordsToKeep, false, false);
peerSync.setStartingVersions(recentVersions);
boolean syncSuccess = peerSync.sync();
if (syncSuccess) {
@@ -441,7 +443,7 @@ public class RecoveryStrategy extends Th
// Or do a fall off retry...
try {
- log.error("Recovery failed - trying again... core=" + coreName);
+ log.error("Recovery failed - trying again... (" + retries + ") core=" + coreName);
if (isClosed()) {
retries = INTERRUPTED;
@@ -449,7 +451,7 @@ public class RecoveryStrategy extends Th
retries++;
if (retries >= MAX_RETRIES) {
- if (retries == INTERRUPTED) {
+ if (retries >= INTERRUPTED) {
SolrException.log(log, "Recovery failed - interrupted. core="
+ coreName);
try {
@@ -461,7 +463,7 @@ public class RecoveryStrategy extends Th
}
} else {
SolrException.log(log,
- "Recovery failed - max retries exceeded. core=" + coreName);
+ "Recovery failed - max retries exceeded (" + retries + "). core=" + coreName);
try {
recoveryFailed(core, zkController, baseUrl, coreZkNodeName,
core.getCoreDescriptor());
@@ -480,6 +482,7 @@ public class RecoveryStrategy extends Th
try {
// start at 1 sec and work up to a couple min
double loopCount = Math.min(Math.pow(2, retries), 600);
+ log.info("Wait {} seconds before trying to recover again ({})", loopCount, retries);
for (int i = 0; i < loopCount; i++) {
if (isClosed()) break; // check if someone closed us
Thread.sleep(STARTING_RECOVERY_DELAY);
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/SolrZkServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/SolrZkServer.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/SolrZkServer.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/SolrZkServer.java Thu Oct 25 13:10:25 2012
@@ -321,8 +321,6 @@ class SolrZkServerProps extends QuorumPe
/**
* Parse config from a Properties.
* @param zkProp Properties to parse from.
- * @throws java.io.IOException
- * @throws ConfigException
*/
@Override
public void parseProperties(Properties zkProp)
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java Thu Oct 25 13:10:25 2012
@@ -20,6 +20,9 @@ package org.apache.solr.cloud;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
import org.apache.http.client.HttpClient;
import org.apache.solr.client.solrj.SolrServerException;
@@ -32,6 +35,7 @@ import org.apache.solr.common.cloud.ZkNo
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction;
import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.ExecutorUtil;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrCore;
import org.apache.solr.handler.component.HttpShardHandlerFactory;
@@ -39,6 +43,7 @@ import org.apache.solr.handler.component
import org.apache.solr.handler.component.ShardRequest;
import org.apache.solr.handler.component.ShardResponse;
import org.apache.solr.update.PeerSync;
+import org.apache.solr.util.DefaultSolrThreadFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,6 +54,13 @@ public class SyncStrategy {
private final ShardHandler shardHandler;
+ private ThreadPoolExecutor recoveryCmdExecutor = new ThreadPoolExecutor(
+ 0, Integer.MAX_VALUE, 5, TimeUnit.SECONDS,
+ new SynchronousQueue<Runnable>(), new DefaultSolrThreadFactory(
+ "recoveryCmdExecutor"));
+
+ private volatile boolean isClosed;
+
private final static HttpClient client;
static {
ModifiableSolrParams params = new ModifiableSolrParams();
@@ -95,6 +107,10 @@ public class SyncStrategy {
String collection = cloudDesc.getCollectionName();
String shardId = cloudDesc.getShardId();
+ if (isClosed) {
+ log.info("We have been closed, won't sync with replicas");
+ return false;
+ }
// if no one that is up is active, we are willing to wait...
// we don't want a recovering node to become leader and then
// a better candidate pops up a second later.
@@ -118,7 +134,11 @@ public class SyncStrategy {
SolrException.log(log, "Sync Failed", e);
}
try {
-
+ if (isClosed) {
+ log.info("We have been closed, won't attempt to sync replicas back to leader");
+ return false;
+ }
+
if (success) {
log.info("Sync Success - now sync replicas to me");
@@ -156,7 +176,7 @@ public class SyncStrategy {
// if we can't reach a replica for sync, we still consider the overall sync a success
// TODO: as an assurance, we should still try and tell the sync nodes that we couldn't reach
// to recover once more?
- PeerSync peerSync = new PeerSync(core, syncWith, core.getUpdateHandler().getUpdateLog().numRecordsToKeep, true);
+ PeerSync peerSync = new PeerSync(core, syncWith, core.getUpdateHandler().getUpdateLog().numRecordsToKeep, true, true);
return peerSync.sync();
}
@@ -199,9 +219,11 @@ public class SyncStrategy {
if (!success) {
try {
log.info(ZkCoreNodeProps.getCoreUrl(leaderProps) + ": Sync failed - asking replica (" + srsp.getShardAddress() + ") to recover.");
-
- requestRecovery(leaderProps, ((ShardCoreRequest)srsp.getShardRequest()).baseUrl, ((ShardCoreRequest)srsp.getShardRequest()).coreName);
-
+ if (isClosed) {
+ log.info("We have been closed, don't request that a replica recover");
+ } else {
+ requestRecovery(leaderProps, ((ShardCoreRequest)srsp.getShardRequest()).baseUrl, ((ShardCoreRequest)srsp.getShardRequest()).coreName);
+ }
} catch (Throwable t) {
SolrException.log(log, ZkCoreNodeProps.getCoreUrl(leaderProps) + ": Could not tell a replica to recover", t);
}
@@ -247,6 +269,11 @@ public class SyncStrategy {
shardHandler.submit(sreq, replica, sreq.params);
}
+ public void close() {
+ this.isClosed = true;
+ ExecutorUtil.shutdownNowAndAwaitTermination(recoveryCmdExecutor);
+ }
+
private void requestRecovery(final ZkNodeProps leaderProps, final String baseUrl, final String coreName) throws SolrServerException, IOException {
// TODO: do this in background threads
Thread thread = new Thread() {
@@ -269,7 +296,7 @@ public class SyncStrategy {
}
}
};
- thread.run();
+ recoveryCmdExecutor.execute(thread);
}
public static ModifiableSolrParams params(String... params) {
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java Thu Oct 25 13:10:25 2012
@@ -73,14 +73,6 @@ public class ZkCLI {
*
* If you also pass a solrPort, it will be used to start an embedded zk useful
* for single machine, multi node tests.
- *
- * @param args
- * @throws IOException
- * @throws TimeoutException
- * @throws InterruptedException
- * @throws SAXException
- * @throws ParserConfigurationException
- * @throws KeeperException
*/
public static void main(String[] args) throws InterruptedException,
TimeoutException, IOException, ParserConfigurationException,
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/ZkController.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/ZkController.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/ZkController.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/cloud/ZkController.java Thu Oct 25 13:10:25 2012
@@ -138,19 +138,6 @@ public final class ZkController {
private int clientTimeout;
- /**
- * @param cc
- * @param zkServerAddress
- * @param zkClientTimeout
- * @param zkClientConnectTimeout
- * @param localHost
- * @param locaHostPort
- * @param localHostContext
- * @param registerOnReconnect
- * @throws InterruptedException
- * @throws TimeoutException
- * @throws IOException
- */
public ZkController(final CoreContainer cc, String zkServerAddress, int zkClientTimeout, int zkClientConnectTimeout, String localHost, String locaHostPort,
String localHostContext, final CurrentCoreDescriptorProvider registerOnReconnect) throws InterruptedException,
TimeoutException, IOException {
@@ -158,20 +145,6 @@ public final class ZkController {
}
- /**
- * @param cc
- * @param zkServerAddress
- * @param zkClientTimeout
- * @param zkClientConnectTimeout
- * @param localHost
- * @param locaHostPort
- * @param localHostContext
- * @param leaderVoteWait
- * @param registerOnReconnect
- * @throws InterruptedException
- * @throws TimeoutException
- * @throws IOException
- */
public ZkController(final CoreContainer cc, String zkServerAddress, int zkClientTimeout, int zkClientConnectTimeout, String localHost, String locaHostPort,
String localHostContext, String leaderVoteWait, final CurrentCoreDescriptorProvider registerOnReconnect) throws InterruptedException,
TimeoutException, IOException {
@@ -218,7 +191,7 @@ public final class ZkController {
ZkController.this.overseer = new Overseer(shardHandler, adminPath, zkStateReader);
ElectionContext context = new OverseerElectionContext(zkClient, overseer, getNodeName());
- overseerElector.joinElection(context);
+ overseerElector.joinElection(context, true);
zkStateReader.createClusterStateWatchersAndUpdate();
// cc.newCmdDistribExecutor();
@@ -347,11 +320,7 @@ public final class ZkController {
}
/**
- * @param collection
- * @param fileName
- * @return true if config file exists
- * @throws KeeperException
- * @throws InterruptedException
+ * Returns true if config file exists
*/
public boolean configFileExists(String collection, String fileName)
throws KeeperException, InterruptedException {
@@ -367,11 +336,7 @@ public final class ZkController {
}
/**
- * @param zkConfigName
- * @param fileName
- * @return config file data (in bytes)
- * @throws KeeperException
- * @throws InterruptedException
+ * Returns config file data (in bytes)
*/
public byte[] getConfigFileData(String zkConfigName, String fileName)
throws KeeperException, InterruptedException {
@@ -457,7 +422,7 @@ public final class ZkController {
this.overseer = new Overseer(shardHandler, adminPath, zkStateReader);
ElectionContext context = new OverseerElectionContext(zkClient, overseer, getNodeName());
overseerElector.setup(context);
- overseerElector.joinElection(context);
+ overseerElector.joinElection(context, false);
zkStateReader.createClusterStateWatchersAndUpdate();
} catch (IOException e) {
@@ -521,10 +486,7 @@ public final class ZkController {
}
/**
- * @param path
- * @return true if the path exists
- * @throws KeeperException
- * @throws InterruptedException
+ * Returns true if the path exists
*/
public boolean pathExists(String path) throws KeeperException,
InterruptedException {
@@ -532,10 +494,7 @@ public final class ZkController {
}
/**
- * @param collection
- * @return config value
- * @throws KeeperException
- * @throws InterruptedException
+ * Returns config value
*/
public String readConfigName(String collection) throws KeeperException,
InterruptedException {
@@ -567,10 +526,7 @@ public final class ZkController {
/**
* Register shard with ZooKeeper.
*
- * @param coreName
- * @param desc
* @return the shardId for the SolrCore
- * @throws Exception
*/
public String register(String coreName, final CoreDescriptor desc) throws Exception {
return register(coreName, desc, false, false);
@@ -580,12 +536,7 @@ public final class ZkController {
/**
* Register shard with ZooKeeper.
*
- * @param coreName
- * @param desc
- * @param recoverReloadedCores
- * @param afterExpiration
* @return the shardId for the SolrCore
- * @throws Exception
*/
public String register(String coreName, final CoreDescriptor desc, boolean recoverReloadedCores, boolean afterExpiration) throws Exception {
final String baseUrl = getBaseUrl();
@@ -725,10 +676,7 @@ public final class ZkController {
/**
* Get leader props directly from zk nodes.
*
- * @param collection
- * @param slice
* @return leader props
- * @throws InterruptedException
*/
public ZkCoreNodeProps getLeaderProps(final String collection,
final String slice, boolean failImmediatelyOnExpiration) throws InterruptedException {
@@ -782,23 +730,12 @@ public final class ZkController {
leaderElector.setup(context);
electionContexts.put(coreZkNodeName, context);
- leaderElector.joinElection(context);
+ leaderElector.joinElection(context, false);
}
/**
- * @param coreName
- * @param desc
- * @param recoverReloadedCores
- * @param isLeader
- * @param cloudDesc
- * @param collection
- * @param shardZkNodeName
- * @param shardId
- * @param leaderProps
- * @param core
- * @param cc
- * @return whether or not a recovery was started
+ * Returns whether or not a recovery was started
*/
private boolean checkRecovery(String coreName, final CoreDescriptor desc,
boolean recoverReloadedCores, final boolean isLeader,
@@ -839,15 +776,12 @@ public final class ZkController {
/**
* Publish core state to overseer.
- * @param cd
- * @param state
- * @throws KeeperException
- * @throws InterruptedException
*/
public void publish(final CoreDescriptor cd, final String state, boolean updateLastState) throws KeeperException, InterruptedException {
//System.out.println(Thread.currentThread().getStackTrace()[3]);
Integer numShards = cd.getCloudDescriptor().getNumShards();
if (numShards == null) { //XXX sys prop hack
+ log.info("numShards not found on descriptor - reading it from system property");
numShards = Integer.getInteger(ZkStateReader.NUM_SHARDS_PROP);
}
@@ -880,12 +814,6 @@ public final class ZkController {
return true;
}
- /**
- * @param coreName
- * @param cloudDesc
- * @throws KeeperException
- * @throws InterruptedException
- */
public void unregister(String coreName, CloudDescriptor cloudDesc)
throws InterruptedException, KeeperException {
ZkNodeProps m = new ZkNodeProps(Overseer.QUEUE_OPERATION,
@@ -909,24 +837,10 @@ public final class ZkController {
overseerJobQueue.offer(ZkStateReader.toJSON(m));
}
- /**
- * @param dir
- * @param zkPath
- * @throws IOException
- * @throws KeeperException
- * @throws InterruptedException
- */
public void uploadToZK(File dir, String zkPath) throws IOException, KeeperException, InterruptedException {
uploadToZK(zkClient, dir, zkPath);
}
- /**
- * @param dir
- * @param configName
- * @throws IOException
- * @throws KeeperException
- * @throws InterruptedException
- */
public void uploadConfigDir(File dir, String configName) throws IOException, KeeperException, InterruptedException {
uploadToZK(zkClient, dir, ZkController.CONFIGS_ZKNODE + "/" + configName);
}
@@ -1258,10 +1172,6 @@ public final class ZkController {
/**
* If in SolrCloud mode, upload config sets for each SolrCore in solr.xml.
- *
- * @throws IOException
- * @throws KeeperException
- * @throws InterruptedException
*/
public static void bootstrapConf(SolrZkClient zkClient, Config cfg, String solrHome) throws IOException,
KeeperException, InterruptedException {
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java Thu Oct 25 13:10:25 2012
@@ -42,9 +42,9 @@ import org.slf4j.LoggerFactory;
*
*/
public abstract class CachingDirectoryFactory extends DirectoryFactory {
- class CacheValue {
- Directory directory;
- int refCnt = 1;
+ protected class CacheValue {
+ public Directory directory;
+ public int refCnt = 1;
public String path;
public boolean doneWithDir = false;
public String toString() {
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/CloseHook.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/CloseHook.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/CloseHook.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/CloseHook.java Thu Oct 25 13:10:25 2012
@@ -50,8 +50,6 @@ public abstract class CloseHook {
* <b>Important:</b> Keep the method implementation as short as possible. If it were to use any heavy i/o , network connections -
* it might be a better idea to launch in a separate Thread so as to not to block the process of
* shutting down a given SolrCore instance.
- *
- * @param core
*/
public abstract void postClose(SolrCore core);
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/Config.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/Config.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/Config.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/Config.java Thu Oct 25 13:10:25 2012
@@ -61,11 +61,6 @@ public class Config {
/**
* Builds a config from a resource name with no xpath prefix.
- * @param loader
- * @param name
- * @throws javax.xml.parsers.ParserConfigurationException
- * @throws java.io.IOException
- * @throws org.xml.sax.SAXException
*/
public Config(SolrResourceLoader loader, String name) throws ParserConfigurationException, IOException, SAXException
{
@@ -92,9 +87,6 @@ public class Config {
* @param name the resource name used if the input stream 'is' is null
* @param is the resource as a SAX InputSource
* @param prefix an optional prefix that will be preprended to all non-absolute xpath expressions
- * @throws javax.xml.parsers.ParserConfigurationException
- * @throws java.io.IOException
- * @throws org.xml.sax.SAXException
*/
public Config(SolrResourceLoader loader, String name, InputSource is, String prefix, boolean subProps) throws ParserConfigurationException, IOException, SAXException
{
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/CoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/CoreContainer.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/CoreContainer.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/CoreContainer.java Thu Oct 25 13:10:25 2012
@@ -162,12 +162,6 @@ public class CoreContainer
/**
* Initalize CoreContainer directly from the constructor
- *
- * @param dir
- * @param configFile
- * @throws ParserConfigurationException
- * @throws IOException
- * @throws SAXException
*/
public CoreContainer(String dir, File configFile) throws ParserConfigurationException, IOException, SAXException
{
@@ -356,9 +350,6 @@ public class CoreContainer
* Load a config file listing the available solr cores.
* @param dir the home directory of all resources.
* @param configFile the configuration file
- * @throws javax.xml.parsers.ParserConfigurationException
- * @throws java.io.IOException
- * @throws org.xml.sax.SAXException
*/
public void load(String dir, File configFile ) throws ParserConfigurationException, IOException, SAXException {
this.configFile = configFile;
@@ -370,9 +361,6 @@ public class CoreContainer
*
* @param dir the home directory of all resources.
* @param cfgis the configuration file InputStream
- * @throws ParserConfigurationException
- * @throws IOException
- * @throws SAXException
*/
public void load(String dir, InputSource cfgis)
throws ParserConfigurationException, IOException, SAXException {
@@ -761,9 +749,6 @@ public class CoreContainer
*
* @param dcore a core descriptor
* @return the newly created core
- * @throws javax.xml.parsers.ParserConfigurationException
- * @throws java.io.IOException
- * @throws org.xml.sax.SAXException
*/
public SolrCore create(CoreDescriptor dcore) throws ParserConfigurationException, IOException, SAXException {
@@ -969,9 +954,6 @@ public class CoreContainer
* and processed by the old core
*
* @param name the name of the SolrCore to reload
- * @throws ParserConfigurationException
- * @throws IOException
- * @throws SAXException
*/
public void reload(String name) throws ParserConfigurationException, IOException, SAXException {
@@ -1068,8 +1050,6 @@ public class CoreContainer
/**
* Swaps two SolrCore descriptors.
- * @param n0
- * @param n1
*/
public void swap(String n0, String n1) {
if( n0 == null || n1 == null ) {
@@ -1197,7 +1177,6 @@ public class CoreContainer
* declare an alternate way of accessing named cores.
* This can also be used in a pseudo single-core environment so admins can prepare
* a new version before swapping.
- * @param path
*/
public void setManagementPath(String path) {
this.managementPath = path;
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java Thu Oct 25 13:10:25 2012
@@ -176,8 +176,6 @@ public class CoreDescriptor {
* Properties instance passed into this method. This means that the Properties instance
* set to this method will have different (less) key/value pairs than the Properties
* instance returned by #getCoreProperties method.
- *
- * @param coreProperties
*/
public void setCoreProperties(Properties coreProperties) {
if (this.coreProperties == null) {
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java Thu Oct 25 13:10:25 2012
@@ -36,30 +36,26 @@ public abstract class DirectoryFactory i
* hits 0, it can be closed. On shutdown all directories will be closed
* whether this has been called or not. This is simply to allow early cleanup.
*
- * @param directory
- * @throws IOException
+ * @throws IOException If there is a low-level I/O error.
*/
public abstract void doneWithDirectory(Directory directory) throws IOException;
/**
* Adds a close listener for a Directory.
- *
- * @param dir
- * @param closeListener
*/
public abstract void addCloseListener(Directory dir, CloseListener closeListener);
/**
* Close the this and all of the Directories it contains.
*
- * @throws IOException
+ * @throws IOException If there is a low-level I/O error.
*/
public abstract void close() throws IOException;
/**
* Creates a new Directory for a given path.
*
- * @throws IOException
+ * @throws IOException If there is a low-level I/O error.
*/
protected abstract Directory create(String path) throws IOException;
@@ -73,7 +69,7 @@ public abstract class DirectoryFactory i
* Returns the Directory for a given path, using the specified rawLockType.
* Will return the same Directory instance for the same path.
*
- * @throws IOException
+ * @throws IOException If there is a low-level I/O error.
*/
public abstract Directory get(String path, String rawLockType)
throws IOException;
@@ -85,7 +81,7 @@ public abstract class DirectoryFactory i
* {@link #doneWithDirectory(Directory)} in this case - the old Directory
* will be closed when it's ref count hits 0.
*
- * @throws IOException
+ * @throws IOException If there is a low-level I/O error.
*/
public abstract Directory get(String path, String rawLockType,
boolean forceNew) throws IOException;
@@ -101,7 +97,7 @@ public abstract class DirectoryFactory i
* Releases the Directory so that it may be closed when it is no longer
* referenced.
*
- * @throws IOException
+ * @throws IOException If there is a low-level I/O error.
*/
public abstract void release(Directory directory) throws IOException;
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/IndexReaderFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/IndexReaderFactory.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/IndexReaderFactory.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/IndexReaderFactory.java Thu Oct 25 13:10:25 2012
@@ -63,7 +63,7 @@ public abstract class IndexReaderFactory
* {@link SolrCore#getCoreDescriptor()}, {@link SolrCore#getSchema()} and
* {@link SolrCore#getSolrConfig()} are valid.
* @return An IndexReader instance
- * @throws IOException
+ * @throws IOException If there is a low-level I/O error.
*/
public abstract DirectoryReader newReader(Directory indexDir, SolrCore core)
throws IOException;
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/RAMDirectoryFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/RAMDirectoryFactory.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/RAMDirectoryFactory.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/RAMDirectoryFactory.java Thu Oct 25 13:10:25 2012
@@ -36,7 +36,7 @@ public class RAMDirectoryFactory extends
@Override
public boolean exists(String path) {
String fullPath = new File(path).getAbsolutePath();
- synchronized (DirectoryFactory.class) {
+ synchronized (this) {
CacheValue cacheValue = byPathCache.get(fullPath);
Directory directory = null;
if (cacheValue != null) {
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/RequestHandlers.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/RequestHandlers.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/RequestHandlers.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/RequestHandlers.java Thu Oct 25 13:10:25 2012
@@ -189,8 +189,8 @@ public final class RequestHandlers {
/**
- * The <code>LazyRequestHandlerWrapper</core> wraps any {@link SolrRequestHandler}.
- * Rather then instanciate and initalize the handler on startup, this wrapper waits
+ * The <code>LazyRequestHandlerWrapper</code> wraps any {@link SolrRequestHandler}.
+ * Rather then instantiate and initialize the handler on startup, this wrapper waits
* until it is actually called. This should only be used for handlers that are
* unlikely to be used in the normal lifecycle.
*
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SchemaCodecFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SchemaCodecFactory.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SchemaCodecFactory.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SchemaCodecFactory.java Thu Oct 25 13:10:25 2012
@@ -2,7 +2,7 @@ package org.apache.solr.core;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.PostingsFormat;
-import org.apache.lucene.codecs.lucene40.Lucene40Codec;
+import org.apache.lucene.codecs.lucene41.Lucene41Codec;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.SchemaAware;
import org.apache.solr.schema.SchemaField;
@@ -42,7 +42,7 @@ public class SchemaCodecFactory extends
@Override
public void inform(final IndexSchema schema) {
- codec = new Lucene40Codec() {
+ codec = new Lucene41Codec() {
@Override
public PostingsFormat getPostingsFormatForField(String field) {
final SchemaField fieldOrNull = schema.getFieldOrNull(field);
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SolrConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SolrConfig.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SolrConfig.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SolrConfig.java Thu Oct 25 13:10:25 2012
@@ -404,7 +404,6 @@ public class SolrConfig extends Config {
public final boolean openSearcher; // is opening a new searcher part of hard autocommit?
/**
- * @param className
* @param autoCommmitMaxDocs set -1 as default
* @param autoCommmitMaxTime set -1 as default
* @param commitIntervalLowerBound set -1 as default
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SolrCore.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SolrCore.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SolrCore.java Thu Oct 25 13:10:25 2012
@@ -62,10 +62,13 @@ import org.apache.solr.search.QParserPlu
import org.apache.solr.search.SolrFieldCacheMBean;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.search.ValueSourceParser;
+import org.apache.solr.update.DefaultSolrCoreState;
import org.apache.solr.update.DirectUpdateHandler2;
+import org.apache.solr.update.SolrCoreState;
import org.apache.solr.update.SolrIndexWriter;
import org.apache.solr.update.UpdateHandler;
import org.apache.solr.update.VersionInfo;
+import org.apache.solr.update.SolrCoreState.IndexWriterCloser;
import org.apache.solr.update.processor.DistributedUpdateProcessorFactory;
import org.apache.solr.update.processor.LogUpdateProcessorFactory;
import org.apache.solr.update.processor.RunUpdateProcessorFactory;
@@ -140,6 +143,9 @@ public final class SolrCore implements S
private final IndexSchema schema;
private final String dataDir;
private final UpdateHandler updateHandler;
+ private final SolrCoreState solrCoreState;
+ private int solrCoreStateRefCnt = 1;
+
private final long startTime;
private final RequestHandlers reqHandlers;
private final Map<String,SearchComponent> searchComponents;
@@ -248,7 +254,7 @@ public final class SolrCore implements S
}
}
if (!result.equals(lastNewIndexDir)) {
- log.warn("New index directory detected: old="+lastNewIndexDir + " new=" + result);
+ log.info("New index directory detected: old="+lastNewIndexDir + " new=" + result);
}
lastNewIndexDir = result;
return result;
@@ -369,7 +375,8 @@ public final class SolrCore implements S
IndexSchema schema = new IndexSchema(config,
getSchema().getResourceName(), null);
- updateHandler.incref();
+ increfSolrCoreState();
+
SolrCore core = new SolrCore(getName(), getDataDir(), config,
schema, coreDescriptor, updateHandler, prev);
return core;
@@ -556,7 +563,6 @@ public final class SolrCore implements S
* Creates a new core and register it in the list of cores.
* If a core with the same name already exists, it will be stopped and replaced by this one.
*
- * @param name
* @param dataDir the index directory
* @param config a solr config instance
* @param schema a solr schema instance
@@ -573,7 +579,6 @@ public final class SolrCore implements S
*@param dataDir the index directory
*@param config a solr config instance
*@param schema a solr schema instance
- *@param updateHandler
*
*@since solr 1.3
*/
@@ -639,8 +644,10 @@ public final class SolrCore implements S
if (updateHandler == null) {
initDirectoryFactory();
+ solrCoreState = new DefaultSolrCoreState(getDirectoryFactory());
} else {
- directoryFactory = updateHandler.getSolrCoreState().getDirectoryFactory();
+ solrCoreState = updateHandler.getSolrCoreState();
+ directoryFactory = solrCoreState.getDirectoryFactory();
this.isReloaded = true;
}
@@ -792,6 +799,36 @@ public final class SolrCore implements S
map.put("", def);
return map;
}
+
+ public SolrCoreState getSolrCoreState() {
+ return solrCoreState;
+ }
+
+ private void increfSolrCoreState() {
+ synchronized (solrCoreState) {
+ if (solrCoreStateRefCnt == 0) {
+ throw new IllegalStateException("IndexWriter has been closed");
+ }
+ solrCoreStateRefCnt++;
+ }
+ }
+
+ private void decrefSolrCoreState(IndexWriterCloser closer) {
+ synchronized (solrCoreState) {
+
+ solrCoreStateRefCnt--;
+ if (solrCoreStateRefCnt == 0) {
+
+ try {
+ log.info("Closing SolrCoreState");
+ solrCoreState.close(closer);
+ } catch (Throwable t) {
+ log.error("Error closing SolrCoreState", t);
+ }
+
+ }
+ }
+ }
/**
* @return an update processor registered to the given name. Throw an exception if this chain is undefined
@@ -867,6 +904,21 @@ public final class SolrCore implements S
}
try {
+ if (null != updateHandler) {
+ updateHandler.close();
+ }
+ } catch (Throwable e) {
+ SolrException.log(log,e);
+ }
+
+
+ if (updateHandler instanceof IndexWriterCloser) {
+ decrefSolrCoreState((IndexWriterCloser)updateHandler);
+ } else {
+ decrefSolrCoreState(null);
+ }
+
+ try {
searcherExecutor.shutdown();
if (!searcherExecutor.awaitTermination(60, TimeUnit.SECONDS)) {
log.error("Timeout waiting for searchExecutor to terminate");
@@ -895,20 +947,17 @@ public final class SolrCore implements S
} catch (Throwable e) {
SolrException.log(log,e);
}
-
- try {
- if (null != updateHandler) {
- updateHandler.close();
- } else {
- if (null != directoryFactory) {
- // :HACK: normally we rely on updateHandler to do this,
- // but what if updateHandler failed to init?
+
+ synchronized (solrCoreState) {
+ if (solrCoreStateRefCnt == 0) {
+ try {
directoryFactory.close();
+ } catch (Throwable t) {
+ SolrException.log(log, t);
}
}
- } catch (Throwable e) {
- SolrException.log(log,e);
}
+
if( closeHooks != null ) {
for( CloseHook hook : closeHooks ) {
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java Thu Oct 25 13:10:25 2012
@@ -324,10 +324,9 @@ public class SolrResourceLoader implemen
* A comment line is any line that starts with the character "#"
* </p>
*
- * @param resource
* @return a list of non-blank non-comment lines with whitespace trimmed
* from front and back.
- * @throws IOException
+ * @throws IOException If there is a low-level I/O error.
*/
public List<String> getLines(String resource) throws IOException {
return getLines(resource, UTF_8);
@@ -342,9 +341,8 @@ public class SolrResourceLoader implemen
* </p>
*
* @param resource the file to be read
- * @param encoding
* @return a list of non-blank non-comment lines with whitespace trimmed
- * @throws IOException
+ * @throws IOException If there is a low-level I/O error.
*/
public List<String> getLines(String resource,
String encoding) throws IOException {
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SolrXMLSerializer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SolrXMLSerializer.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SolrXMLSerializer.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/core/SolrXMLSerializer.java Thu Oct 25 13:10:25 2012
@@ -45,7 +45,7 @@ public class SolrXMLSerializer {
/**
* @param w
* Writer to use
- * @throws IOException
+ * @throws IOException If there is a low-level I/O error.
*/
void persist(Writer w, SolrXMLDef solrXMLDef) throws IOException {
w.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java Thu Oct 25 13:10:25 2012
@@ -119,7 +119,7 @@ import org.slf4j.LoggerFactory;
* </li>
* <li><code>http://.../ping?action=status</code>
* - returns a status code indicating if the healthcheck file exists
- * ("<code>enabled</code>") or not ("<code>disabled<code>")
+ * ("<code>enabled</code>") or not ("<code>disabled</code>")
* </li>
* </ul>
*
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java Thu Oct 25 13:10:25 2012
@@ -568,8 +568,6 @@ public class ReplicationHandler extends
/**
* Used for showing statistics and progress information.
- *
- * @param showSlaveDetails
*/
private NamedList<Object> getReplicationDetails(boolean showSlaveDetails) {
NamedList<Object> details = new SimpleOrderedMap<Object>();
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/SnapPuller.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/SnapPuller.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/SnapPuller.java Thu Oct 25 13:10:25 2012
@@ -422,8 +422,6 @@ public class SnapPuller {
/**
* terminate the fsync service and wait for all the tasks to complete. If it is already terminated
- *
- * @throws Exception
*/
private void terminateAndWaitFsyncService() throws Exception {
if (fsyncService.isTerminated()) return;
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java Thu Oct 25 13:10:25 2012
@@ -433,9 +433,6 @@ public class CoreAdminHandler extends Re
/**
* Handle 'CREATE' action.
*
- * @param req
- * @param rsp
- *
* @return true if a modification has resulted that requires persistance
* of the CoreContainer configuration.
*
@@ -530,13 +527,8 @@ public class CoreAdminHandler extends Re
/**
* Handle "RENAME" Action
*
- * @param req
- * @param rsp
- *
- * @return true if a modification has resulted that requires persistance
+ * @return true if a modification has resulted that requires persistence
* of the CoreContainer configuration.
- *
- * @throws SolrException
*/
protected boolean handleRenameAction(SolrQueryRequest req, SolrQueryResponse rsp) throws SolrException {
SolrParams params = req.getParams();
@@ -556,9 +548,6 @@ public class CoreAdminHandler extends Re
/**
* Handle "ALIAS" action
*
- * @param req
- * @param rsp
- *
* @return true if a modification has resulted that requires persistance
* of the CoreContainer configuration.
*/
@@ -584,9 +573,6 @@ public class CoreAdminHandler extends Re
/**
* Handle "UNLOAD" Action
*
- * @param req
- * @param rsp
- *
* @return true if a modification has resulted that requires persistance
* of the CoreContainer configuration.
*/
@@ -691,9 +677,6 @@ public class CoreAdminHandler extends Re
/**
* Handle "STATUS" action
*
- * @param req
- * @param rsp
- *
* @return true if a modification has resulted that requires persistance
* of the CoreContainer configuration.
*/
@@ -731,13 +714,8 @@ public class CoreAdminHandler extends Re
/**
* Handler "PERSIST" action
*
- * @param req
- * @param rsp
- *
- * @return true if a modification has resulted that requires persistance
+ * @return true if a modification has resulted that requires persistence
* of the CoreContainer configuration.
- *
- * @throws SolrException
*/
protected boolean handlePersistAction(SolrQueryRequest req, SolrQueryResponse rsp)
throws SolrException {
@@ -760,10 +738,7 @@ public class CoreAdminHandler extends Re
/**
* Handler "RELOAD" action
*
- * @param req
- * @param rsp
- *
- * @return true if a modification has resulted that requires persistance
+ * @return true if a modification has resulted that requires persistence
* of the CoreContainer configuration.
*/
protected boolean handleReloadAction(SolrQueryRequest req, SolrQueryResponse rsp) {
@@ -780,10 +755,7 @@ public class CoreAdminHandler extends Re
/**
* Handle "SWAP" action
*
- * @param req
- * @param rsp
- *
- * @return true if a modification has resulted that requires persistance
+ * @return true if a modification has resulted that requires persistence
* of the CoreContainer configuration.
*/
protected boolean handleSwapAction(SolrQueryRequest req, SolrQueryResponse rsp) {
@@ -846,11 +818,12 @@ public class CoreAdminHandler extends Re
throw new IllegalArgumentException(CoreAdminParams.CORE + " is required");
}
SolrCore core = null;
+ SyncStrategy syncStrategy = null;
try {
core = coreContainer.getCore(cname);
if (core != null) {
- SyncStrategy syncStrategy = new SyncStrategy();
-
+ syncStrategy = new SyncStrategy();
+
Map<String,Object> props = new HashMap<String,Object>();
props.put(ZkStateReader.BASE_URL_PROP, zkController.getBaseUrl());
props.put(ZkStateReader.CORE_NAME_PROP, cname);
@@ -883,6 +856,9 @@ public class CoreAdminHandler extends Re
if (core != null) {
core.close();
}
+ if (syncStrategy != null) {
+ syncStrategy.close();
+ }
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java Thu Oct 25 13:10:25 2012
@@ -53,14 +53,6 @@ public class FacetComponent extends Sear
static final String PIVOT_KEY = "facet_pivot";
- PivotFacetHelper pivotHelper;
-
- @Override
- public void init( NamedList args )
- {
- pivotHelper = new PivotFacetHelper(); // Maybe this would configurable?
- }
-
@Override
public void prepare(ResponseBuilder rb) throws IOException
{
@@ -72,7 +64,6 @@ public class FacetComponent extends Sear
/**
* Actually run the query
- * @param rb
*/
@Override
public void process(ResponseBuilder rb) throws IOException
@@ -87,7 +78,11 @@ public class FacetComponent extends Sear
NamedList<Object> counts = f.getFacetCounts();
String[] pivots = params.getParams( FacetParams.FACET_PIVOT );
if( pivots != null && pivots.length > 0 ) {
- NamedList v = pivotHelper.process(rb, params, pivots);
+ PivotFacetHelper pivotHelper = new PivotFacetHelper(rb.req,
+ rb.getResults().docSet,
+ params,
+ rb );
+ NamedList v = pivotHelper.process(pivots);
if( v != null ) {
counts.add( PIVOT_KEY, v );
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/PivotFacetHelper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/PivotFacetHelper.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/PivotFacetHelper.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/PivotFacetHelper.java Thu Oct 25 13:10:25 2012
@@ -17,6 +17,7 @@
package org.apache.solr.handler.component;
+import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.util.BytesRef;
import org.apache.solr.schema.SchemaField;
import org.apache.solr.search.SolrIndexSearcher;
@@ -43,55 +44,60 @@ import java.util.List;
import java.util.Map;
/**
- * This is thread safe
* @since solr 4.0
*/
-public class PivotFacetHelper
+public class PivotFacetHelper extends SimpleFacets
{
- /**
- * Designed to be overridden by subclasses that provide different faceting implementations.
- * TODO: Currently this is returning a SimpleFacets object, but those capabilities would
- * be better as an extracted abstract class or interface.
- */
- protected SimpleFacets getFacetImplementation(SolrQueryRequest req, DocSet docs, SolrParams params) {
- return new SimpleFacets(req, docs, params);
+
+ protected int minMatch;
+
+ public PivotFacetHelper(SolrQueryRequest req, DocSet docs, SolrParams params, ResponseBuilder rb) {
+ super(req, docs, params, rb);
+ minMatch = params.getInt( FacetParams.FACET_PIVOT_MINCOUNT, 1 );
}
- public SimpleOrderedMap<List<NamedList<Object>>> process(ResponseBuilder rb, SolrParams params, String[] pivots) throws IOException {
+ public SimpleOrderedMap<List<NamedList<Object>>> process(String[] pivots) throws IOException {
if (!rb.doFacets || pivots == null)
return null;
-
- int minMatch = params.getInt( FacetParams.FACET_PIVOT_MINCOUNT, 1 );
-
+
SimpleOrderedMap<List<NamedList<Object>>> pivotResponse = new SimpleOrderedMap<List<NamedList<Object>>>();
for (String pivot : pivots) {
- String[] fields = pivot.split(","); // only support two levels for now
-
+ //ex: pivot == "features,cat" or even "{!ex=mytag}features,cat"
+ try {
+ this.parseParams(FacetParams.FACET_PIVOT, pivot);
+ } catch (ParseException e) {
+ throw new SolrException(ErrorCode.BAD_REQUEST, e);
+ }
+ pivot = facetValue;//facetValue potentially modified from parseParams()
+
+ String[] fields = pivot.split(",");
+
if( fields.length < 2 ) {
- throw new SolrException( ErrorCode.BAD_REQUEST,
+ throw new SolrException( ErrorCode.BAD_REQUEST,
"Pivot Facet needs at least two fields: "+pivot );
}
-
- DocSet docs = rb.getResults().docSet;
+
String field = fields[0];
String subField = fields[1];
Deque<String> fnames = new LinkedList<String>();
for( int i=fields.length-1; i>1; i-- ) {
fnames.push( fields[i] );
}
-
- SimpleFacets sf = getFacetImplementation(rb.req, rb.getResults().docSet, rb.req.getParams());
- NamedList<Integer> superFacets = sf.getTermCounts(field);
-
- pivotResponse.add(pivot, doPivots(superFacets, field, subField, fnames, rb, docs, minMatch));
+
+ NamedList<Integer> superFacets = this.getTermCounts(field);
+
+ //super.key usually == pivot unless local-param 'key' used
+ pivotResponse.add(key, doPivots(superFacets, field, subField, fnames, docs));
}
return pivotResponse;
}
-
+
/**
* Recursive function to do all the pivots
*/
- protected List<NamedList<Object>> doPivots( NamedList<Integer> superFacets, String field, String subField, Deque<String> fnames, ResponseBuilder rb, DocSet docs, int minMatch ) throws IOException
+ protected List<NamedList<Object>> doPivots(NamedList<Integer> superFacets,
+ String field, String subField, Deque<String> fnames,
+ DocSet docs) throws IOException
{
SolrIndexSearcher searcher = rb.req.getSearcher();
// TODO: optimize to avoid converting to an external string and then having to convert back to internal below
@@ -103,7 +109,7 @@ public class PivotFacetHelper
List<NamedList<Object>> values = new ArrayList<NamedList<Object>>( superFacets.size() );
for (Map.Entry<String, Integer> kv : superFacets) {
// Only sub-facet if parent facet has positive count - still may not be any values for the sub-field though
- if (kv.getValue() >= minMatch ) {
+ if (kv.getValue() >= minMatch) {
// may be null when using facet.missing
final String fieldValue = kv.getKey();
@@ -136,11 +142,11 @@ public class PivotFacetHelper
Query query = new TermQuery(new Term(field, termval));
subset = searcher.getDocSet(query, docs);
}
- SimpleFacets sf = getFacetImplementation(rb.req, subset, rb.req.getParams());
-
- NamedList<Integer> nl = sf.getTermCounts(subField);
- if (nl.size() >= minMatch ) {
- pivot.add( "pivot", doPivots( nl, subField, nextField, fnames, rb, subset, minMatch ) );
+ super.docs = subset;//used by getTermCounts()
+
+ NamedList<Integer> nl = this.getTermCounts(subField);
+ if (nl.size() >= minMatch) {
+ pivot.add( "pivot", doPivots( nl, subField, nextField, fnames, subset) );
values.add( pivot ); // only add response if there are some counts
}
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java Thu Oct 25 13:10:25 2012
@@ -296,7 +296,7 @@ public class QueryElevationComponent ext
/**
* Helpful for testing without loading config.xml
*
- * @throws IOException
+ * @throws IOException If there is a low-level I/O error.
*/
void setTopQueryResults(IndexReader reader, String query, String[] ids, String[] ex) throws IOException {
if (ids == null) {
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java Thu Oct 25 13:10:25 2012
@@ -525,7 +525,7 @@ public class RealTimeGetComponent extend
boolean cantReachIsSuccess = rb.req.getParams().getBool("cantReachIsSuccess", false);
- PeerSync peerSync = new PeerSync(rb.req.getCore(), replicas, nVersions, cantReachIsSuccess);
+ PeerSync peerSync = new PeerSync(rb.req.getCore(), replicas, nVersions, cantReachIsSuccess, true);
boolean success = peerSync.sync();
// TODO: more complex response?
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/SearchComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/SearchComponent.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/SearchComponent.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/component/SearchComponent.java Thu Oct 25 13:10:25 2012
@@ -39,14 +39,14 @@ public abstract class SearchComponent im
*
* The place to do initialization that is request dependent.
* @param rb The {@link org.apache.solr.handler.component.ResponseBuilder}
- * @throws IOException
+ * @throws IOException If there is a low-level I/O error.
*/
public abstract void prepare(ResponseBuilder rb) throws IOException;
/**
* Process the request for this component
* @param rb The {@link ResponseBuilder}
- * @throws IOException
+ * @throws IOException If there is a low-level I/O error.
*/
public abstract void process(ResponseBuilder rb) throws IOException;
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java Thu Oct 25 13:10:25 2012
@@ -37,10 +37,12 @@ import org.apache.solr.common.params.Upd
import org.apache.solr.core.SolrConfig;
import org.apache.solr.handler.RequestHandlerUtils;
import org.apache.solr.handler.UpdateRequestHandler;
+import org.apache.solr.util.EmptyEntityResolver;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamException;
@@ -52,6 +54,7 @@ import javax.xml.transform.TransformerEx
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
+import javax.xml.parsers.SAXParserFactory;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@@ -72,10 +75,14 @@ public class XMLLoader extends ContentSt
int xsltCacheLifetimeSeconds;
XMLInputFactory inputFactory;
+ SAXParserFactory saxFactory;
@Override
public XMLLoader init(SolrParams args) {
+ // Init StAX parser:
inputFactory = XMLInputFactory.newInstance();
+ EmptyEntityResolver.configureXMLInputFactory(inputFactory);
+ inputFactory.setXMLReporter(xmllog);
try {
// The java 1.6 bundled stax parser (sjsxp) does not currently have a thread-safe
// XMLInputFactory, as that implementation tries to cache and reuse the
@@ -84,13 +91,16 @@ public class XMLLoader extends ContentSt
// All other known open-source stax parsers (and the bea ref impl)
// have thread-safe factories.
inputFactory.setProperty("reuse-instance", Boolean.FALSE);
- }
- catch (IllegalArgumentException ex) {
+ } catch (IllegalArgumentException ex) {
// Other implementations will likely throw this exception since "reuse-instance"
// isimplementation specific.
log.debug("Unable to set the 'reuse-instance' property for the input chain: " + inputFactory);
}
- inputFactory.setXMLReporter(xmllog);
+
+ // Init SAX parser (for XSL):
+ saxFactory = SAXParserFactory.newInstance();
+ saxFactory.setNamespaceAware(true); // XSL needs this!
+ EmptyEntityResolver.configureSAXParserFactory(saxFactory);
xsltCacheLifetimeSeconds = XSLT_CACHE_DEFAULT;
if(args != null) {
@@ -113,7 +123,7 @@ public class XMLLoader extends ContentSt
String tr = req.getParams().get(CommonParams.TR,null);
if(tr!=null) {
- Transformer t = getTransformer(tr,req);
+ final Transformer t = getTransformer(tr,req);
final DOMResult result = new DOMResult();
// first step: read XML and build DOM using Transformer (this is no overhead, as XSL always produces
@@ -122,14 +132,17 @@ public class XMLLoader extends ContentSt
is = stream.getStream();
final InputSource isrc = new InputSource(is);
isrc.setEncoding(charset);
- final SAXSource source = new SAXSource(isrc);
+ final XMLReader xmlr = saxFactory.newSAXParser().getXMLReader();
+ xmlr.setErrorHandler(xmllog);
+ xmlr.setEntityResolver(EmptyEntityResolver.SAX_INSTANCE);
+ final SAXSource source = new SAXSource(xmlr, isrc);
t.transform(source, result);
} catch(TransformerException te) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, te.getMessage(), te);
} finally {
IOUtils.closeQuietly(is);
}
- // second step feed the intermediate DOM tree into StAX parser:
+ // second step: feed the intermediate DOM tree into StAX parser:
try {
parser = inputFactory.createXMLStreamReader(new DOMSource(result.getNode()));
this.processUpdate(req, processor, parser);