mirror of https://github.com/apache/lucene.git
tests: add sys prop for enabling solrcloud debug logging
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1538196 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9990a2eab9
commit
1d12507774
|
@ -1,5 +1,9 @@
|
|||
package org.apache.solr.cloud;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.SolrException.ErrorCode;
|
||||
import org.apache.solr.common.cloud.ClusterState;
|
||||
|
@ -11,16 +15,15 @@ import org.apache.solr.common.cloud.ZkNodeProps;
|
|||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.apache.solr.core.CoreContainer;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.search.SolrIndexSearcher;
|
||||
import org.apache.solr.update.UpdateLog;
|
||||
import org.apache.solr.util.RefCounted;
|
||||
import org.apache.zookeeper.CreateMode;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
import org.apache.zookeeper.KeeperException.NoNodeException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -223,20 +226,23 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase {
|
|||
}
|
||||
|
||||
// solrcloud_debug
|
||||
// try {
|
||||
// RefCounted<SolrIndexSearcher> searchHolder =
|
||||
// core.getNewestSearcher(false);
|
||||
// SolrIndexSearcher searcher = searchHolder.get();
|
||||
// try {
|
||||
// System.out.println(core.getCoreDescriptor().getCoreContainer().getZkController().getNodeName()
|
||||
// + " synched "
|
||||
// + searcher.search(new MatchAllDocsQuery(), 1).totalHits);
|
||||
// } finally {
|
||||
// searchHolder.decref();
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
//
|
||||
// }
|
||||
if (Boolean.getBoolean("solr.cloud.debug")) {
|
||||
try {
|
||||
RefCounted<SolrIndexSearcher> searchHolder = core
|
||||
.getNewestSearcher(false);
|
||||
SolrIndexSearcher searcher = searchHolder.get();
|
||||
try {
|
||||
System.err.println(core.getCoreDescriptor().getCoreContainer()
|
||||
.getZkController().getNodeName()
|
||||
+ " synched "
|
||||
+ searcher.search(new MatchAllDocsQuery(), 1).totalHits);
|
||||
} finally {
|
||||
searchHolder.decref();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new SolrException(ErrorCode.SERVER_ERROR, null, e);
|
||||
}
|
||||
}
|
||||
if (!success) {
|
||||
rejoinLeaderElection(leaderSeqPath, core);
|
||||
return;
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrServer;
|
||||
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
|
||||
|
@ -48,11 +49,13 @@ import org.apache.solr.request.SolrQueryRequest;
|
|||
import org.apache.solr.request.SolrRequestHandler;
|
||||
import org.apache.solr.request.SolrRequestInfo;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.apache.solr.search.SolrIndexSearcher;
|
||||
import org.apache.solr.update.CommitUpdateCommand;
|
||||
import org.apache.solr.update.PeerSync;
|
||||
import org.apache.solr.update.UpdateLog;
|
||||
import org.apache.solr.update.UpdateLog.RecoveryInfo;
|
||||
import org.apache.solr.update.processor.DistributedUpdateProcessor;
|
||||
import org.apache.solr.util.RefCounted;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -151,21 +154,31 @@ public class RecoveryStrategy extends Thread implements ClosableThread {
|
|||
throw new SolrException(ErrorCode.SERVER_ERROR,
|
||||
"Replication for recovery failed.");
|
||||
}
|
||||
|
||||
// solrcloud_debug
|
||||
// try {
|
||||
// RefCounted<SolrIndexSearcher> searchHolder = core.getNewestSearcher(false);
|
||||
// SolrIndexSearcher searcher = searchHolder.get();
|
||||
// try {
|
||||
// System.out.println(core.getCoreDescriptor().getCoreContainer().getZkController().getNodeName() + " replicated "
|
||||
// + searcher.search(new MatchAllDocsQuery(), 1).totalHits + " from " + leaderUrl + " gen:" + core.getDeletionPolicy().getLatestCommit().getGeneration() + " data:" + core.getDataDir());
|
||||
// } finally {
|
||||
// searchHolder.decref();
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
//
|
||||
// }
|
||||
|
||||
// solrcloud_debug
|
||||
if (Boolean.getBoolean("solr.cloud.debug")) {
|
||||
try {
|
||||
RefCounted<SolrIndexSearcher> searchHolder = core
|
||||
.getNewestSearcher(false);
|
||||
SolrIndexSearcher searcher = searchHolder.get();
|
||||
try {
|
||||
System.err.println(core.getCoreDescriptor().getCoreContainer()
|
||||
.getZkController().getNodeName()
|
||||
+ " replicated "
|
||||
+ searcher.search(new MatchAllDocsQuery(), 1).totalHits
|
||||
+ " from "
|
||||
+ leaderUrl
|
||||
+ " gen:"
|
||||
+ core.getDeletionPolicy().getLatestCommit().getGeneration()
|
||||
+ " data:" + core.getDataDir());
|
||||
} finally {
|
||||
searchHolder.decref();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new SolrException(ErrorCode.SERVER_ERROR, null, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void commitOnLeader(String leaderUrl) throws SolrServerException,
|
||||
|
@ -374,20 +387,23 @@ public class RecoveryStrategy extends Thread implements ClosableThread {
|
|||
log.info("PeerSync Recovery was successful - registering as Active. core=" + coreName);
|
||||
|
||||
// solrcloud_debug
|
||||
// try {
|
||||
// RefCounted<SolrIndexSearcher> searchHolder =
|
||||
// core.getNewestSearcher(false);
|
||||
// SolrIndexSearcher searcher = searchHolder.get();
|
||||
// try {
|
||||
// System.out.println(core.getCoreDescriptor().getCoreContainer().getZkController().getNodeName()
|
||||
// + " synched "
|
||||
// + searcher.search(new MatchAllDocsQuery(), 1).totalHits);
|
||||
// } finally {
|
||||
// searchHolder.decref();
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
//
|
||||
// }
|
||||
if (Boolean.getBoolean("solr.cloud.debug")) {
|
||||
try {
|
||||
RefCounted<SolrIndexSearcher> searchHolder = core
|
||||
.getNewestSearcher(false);
|
||||
SolrIndexSearcher searcher = searchHolder.get();
|
||||
try {
|
||||
System.out.println(core.getCoreDescriptor()
|
||||
.getCoreContainer().getZkController().getNodeName()
|
||||
+ " synched "
|
||||
+ searcher.search(new MatchAllDocsQuery(), 1).totalHits);
|
||||
} finally {
|
||||
searchHolder.decref();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new SolrException(ErrorCode.SERVER_ERROR, null, e);
|
||||
}
|
||||
}
|
||||
|
||||
// sync success - register as active and return
|
||||
zkController.publish(core.getCoreDescriptor(),
|
||||
|
@ -410,7 +426,7 @@ public class RecoveryStrategy extends Thread implements ClosableThread {
|
|||
|
||||
replicate(zkController.getNodeName(), core, leaderprops);
|
||||
|
||||
replay(ulog);
|
||||
replay(core);
|
||||
replayed = true;
|
||||
|
||||
log.info("Replication Recovery was successful - registering as Active. core=" + coreName);
|
||||
|
@ -500,11 +516,12 @@ public class RecoveryStrategy extends Thread implements ClosableThread {
|
|||
}
|
||||
log.info("Finished recovery process. core=" + coreName);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private Future<RecoveryInfo> replay(UpdateLog ulog)
|
||||
private Future<RecoveryInfo> replay(SolrCore core)
|
||||
throws InterruptedException, ExecutionException {
|
||||
Future<RecoveryInfo> future = ulog.applyBufferedUpdates();
|
||||
Future<RecoveryInfo> future = core.getUpdateHandler().getUpdateLog().applyBufferedUpdates();
|
||||
if (future == null) {
|
||||
// no replay needed\
|
||||
log.info("No replay needed. core=" + coreName);
|
||||
|
@ -519,18 +536,23 @@ public class RecoveryStrategy extends Thread implements ClosableThread {
|
|||
}
|
||||
|
||||
// solrcloud_debug
|
||||
// try {
|
||||
// RefCounted<SolrIndexSearcher> searchHolder = core.getNewestSearcher(false);
|
||||
// SolrIndexSearcher searcher = searchHolder.get();
|
||||
// try {
|
||||
// System.out.println(core.getCoreDescriptor().getCoreContainer().getZkController().getNodeName() + " replayed "
|
||||
// + searcher.search(new MatchAllDocsQuery(), 1).totalHits);
|
||||
// } finally {
|
||||
// searchHolder.decref();
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
//
|
||||
// }
|
||||
if (Boolean.getBoolean("solr.cloud.debug")) {
|
||||
try {
|
||||
RefCounted<SolrIndexSearcher> searchHolder = core
|
||||
.getNewestSearcher(false);
|
||||
SolrIndexSearcher searcher = searchHolder.get();
|
||||
try {
|
||||
System.out.println(core.getCoreDescriptor().getCoreContainer()
|
||||
.getZkController().getNodeName()
|
||||
+ " replayed "
|
||||
+ searcher.search(new MatchAllDocsQuery(), 1).totalHits);
|
||||
} finally {
|
||||
searchHolder.decref();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new SolrException(ErrorCode.SERVER_ERROR, null, e);
|
||||
}
|
||||
}
|
||||
|
||||
return future;
|
||||
}
|
||||
|
|
|
@ -17,12 +17,25 @@
|
|||
|
||||
package org.apache.solr.handler.admin;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import static org.apache.solr.common.cloud.DocCollection.DOC_ROUTER;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.apache.solr.cloud.CloudDescriptor;
|
||||
|
@ -55,6 +68,7 @@ import org.apache.solr.request.LocalSolrQueryRequest;
|
|||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.apache.solr.search.SolrIndexSearcher;
|
||||
import org.apache.solr.update.CommitUpdateCommand;
|
||||
import org.apache.solr.update.MergeIndexesCommand;
|
||||
import org.apache.solr.update.SplitIndexCommand;
|
||||
import org.apache.solr.update.UpdateLog;
|
||||
|
@ -66,20 +80,8 @@ import org.apache.zookeeper.KeeperException;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import static org.apache.solr.common.cloud.DocCollection.DOC_ROUTER;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -794,20 +796,23 @@ public class CoreAdminHandler extends RequestHandlerBase {
|
|||
|
||||
boolean success = syncStrategy.sync(zkController, core, new ZkNodeProps(props));
|
||||
// solrcloud_debug
|
||||
// try {
|
||||
// RefCounted<SolrIndexSearcher> searchHolder =
|
||||
// core.getNewestSearcher(false);
|
||||
// SolrIndexSearcher searcher = searchHolder.get();
|
||||
// try {
|
||||
// System.out.println(core.getCoreDescriptor().getCoreContainer().getZkController().getNodeName()
|
||||
// + " synched "
|
||||
// + searcher.search(new MatchAllDocsQuery(), 1).totalHits);
|
||||
// } finally {
|
||||
// searchHolder.decref();
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
//
|
||||
// }
|
||||
if (Boolean.getBoolean("solr.cloud.debug")) {
|
||||
try {
|
||||
RefCounted<SolrIndexSearcher> searchHolder = core
|
||||
.getNewestSearcher(false);
|
||||
SolrIndexSearcher searcher = searchHolder.get();
|
||||
try {
|
||||
System.out.println(core.getCoreDescriptor().getCoreContainer()
|
||||
.getZkController().getNodeName()
|
||||
+ " synched "
|
||||
+ searcher.search(new MatchAllDocsQuery(), 1).totalHits);
|
||||
} finally {
|
||||
searchHolder.decref();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new SolrException(ErrorCode.SERVER_ERROR, null, e);
|
||||
}
|
||||
}
|
||||
if (!success) {
|
||||
throw new SolrException(ErrorCode.SERVER_ERROR, "Sync Failed");
|
||||
}
|
||||
|
@ -910,27 +915,32 @@ public class CoreAdminHandler extends RequestHandlerBase {
|
|||
}
|
||||
|
||||
// solrcloud_debug
|
||||
// try {;
|
||||
// LocalSolrQueryRequest r = new LocalSolrQueryRequest(core, new
|
||||
// ModifiableSolrParams());
|
||||
// CommitUpdateCommand commitCmd = new CommitUpdateCommand(r, false);
|
||||
// commitCmd.softCommit = true;
|
||||
// core.getUpdateHandler().commit(commitCmd);
|
||||
// RefCounted<SolrIndexSearcher> searchHolder =
|
||||
// core.getNewestSearcher(false);
|
||||
// SolrIndexSearcher searcher = searchHolder.get();
|
||||
// try {
|
||||
// System.out.println(core.getCoreDescriptor().getCoreContainer().getZkController().getNodeName()
|
||||
// + " to replicate "
|
||||
// + searcher.search(new MatchAllDocsQuery(), 1).totalHits + " gen:" +
|
||||
// core.getDeletionPolicy().getLatestCommit().getGeneration() + " data:" +
|
||||
// core.getDataDir());
|
||||
// } finally {
|
||||
// searchHolder.decref();
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
//
|
||||
// }
|
||||
if (Boolean.getBoolean("solr.cloud.debug")) {
|
||||
try {
|
||||
;
|
||||
LocalSolrQueryRequest r = new LocalSolrQueryRequest(core,
|
||||
new ModifiableSolrParams());
|
||||
CommitUpdateCommand commitCmd = new CommitUpdateCommand(r, false);
|
||||
commitCmd.softCommit = true;
|
||||
core.getUpdateHandler().commit(commitCmd);
|
||||
RefCounted<SolrIndexSearcher> searchHolder = core
|
||||
.getNewestSearcher(false);
|
||||
SolrIndexSearcher searcher = searchHolder.get();
|
||||
try {
|
||||
System.out.println(core.getCoreDescriptor().getCoreContainer()
|
||||
.getZkController().getNodeName()
|
||||
+ " to replicate "
|
||||
+ searcher.search(new MatchAllDocsQuery(), 1).totalHits
|
||||
+ " gen:"
|
||||
+ core.getDeletionPolicy().getLatestCommit().getGeneration()
|
||||
+ " data:" + core.getDataDir());
|
||||
} finally {
|
||||
searchHolder.decref();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new SolrException(ErrorCode.SERVER_ERROR, null, e);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (core != null) {
|
||||
core.close();
|
||||
|
|
Loading…
Reference in New Issue