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:
Mark Robert Miller 2013-11-02 14:12:24 +00:00
parent 9990a2eab9
commit 1d12507774
3 changed files with 149 additions and 111 deletions

View File

@ -1,5 +1,9 @@
package org.apache.solr.cloud; 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;
import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.cloud.ClusterState; 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.common.cloud.ZkStateReader;
import org.apache.solr.core.CoreContainer; import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore; import org.apache.solr.core.SolrCore;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.update.UpdateLog; import org.apache.solr.update.UpdateLog;
import org.apache.solr.util.RefCounted;
import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.NoNodeException; import org.apache.zookeeper.KeeperException.NoNodeException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Map;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -223,20 +226,23 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase {
} }
// solrcloud_debug // solrcloud_debug
// try { if (Boolean.getBoolean("solr.cloud.debug")) {
// RefCounted<SolrIndexSearcher> searchHolder = try {
// core.getNewestSearcher(false); RefCounted<SolrIndexSearcher> searchHolder = core
// SolrIndexSearcher searcher = searchHolder.get(); .getNewestSearcher(false);
// try { SolrIndexSearcher searcher = searchHolder.get();
// System.out.println(core.getCoreDescriptor().getCoreContainer().getZkController().getNodeName() try {
// + " synched " System.err.println(core.getCoreDescriptor().getCoreContainer()
// + searcher.search(new MatchAllDocsQuery(), 1).totalHits); .getZkController().getNodeName()
// } finally { + " synched "
// searchHolder.decref(); + searcher.search(new MatchAllDocsQuery(), 1).totalHits);
// } } finally {
// } catch (Exception e) { searchHolder.decref();
// }
// } } catch (Exception e) {
throw new SolrException(ErrorCode.SERVER_ERROR, null, e);
}
}
if (!success) { if (!success) {
rejoinLeaderElection(leaderSeqPath, core); rejoinLeaderElection(leaderSeqPath, core);
return; return;

View File

@ -24,6 +24,7 @@ import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrServer; import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest; 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.SolrRequestHandler;
import org.apache.solr.request.SolrRequestInfo; import org.apache.solr.request.SolrRequestInfo;
import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.update.CommitUpdateCommand; import org.apache.solr.update.CommitUpdateCommand;
import org.apache.solr.update.PeerSync; import org.apache.solr.update.PeerSync;
import org.apache.solr.update.UpdateLog; import org.apache.solr.update.UpdateLog;
import org.apache.solr.update.UpdateLog.RecoveryInfo; import org.apache.solr.update.UpdateLog.RecoveryInfo;
import org.apache.solr.update.processor.DistributedUpdateProcessor; import org.apache.solr.update.processor.DistributedUpdateProcessor;
import org.apache.solr.util.RefCounted;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -151,21 +154,31 @@ public class RecoveryStrategy extends Thread implements ClosableThread {
throw new SolrException(ErrorCode.SERVER_ERROR, throw new SolrException(ErrorCode.SERVER_ERROR,
"Replication for recovery failed."); "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, 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); log.info("PeerSync Recovery was successful - registering as Active. core=" + coreName);
// solrcloud_debug // solrcloud_debug
// try { if (Boolean.getBoolean("solr.cloud.debug")) {
// RefCounted<SolrIndexSearcher> searchHolder = try {
// core.getNewestSearcher(false); RefCounted<SolrIndexSearcher> searchHolder = core
// SolrIndexSearcher searcher = searchHolder.get(); .getNewestSearcher(false);
// try { SolrIndexSearcher searcher = searchHolder.get();
// System.out.println(core.getCoreDescriptor().getCoreContainer().getZkController().getNodeName() try {
// + " synched " System.out.println(core.getCoreDescriptor()
// + searcher.search(new MatchAllDocsQuery(), 1).totalHits); .getCoreContainer().getZkController().getNodeName()
// } finally { + " synched "
// searchHolder.decref(); + searcher.search(new MatchAllDocsQuery(), 1).totalHits);
// } } finally {
// } catch (Exception e) { searchHolder.decref();
// }
// } } catch (Exception e) {
throw new SolrException(ErrorCode.SERVER_ERROR, null, e);
}
}
// sync success - register as active and return // sync success - register as active and return
zkController.publish(core.getCoreDescriptor(), zkController.publish(core.getCoreDescriptor(),
@ -410,7 +426,7 @@ public class RecoveryStrategy extends Thread implements ClosableThread {
replicate(zkController.getNodeName(), core, leaderprops); replicate(zkController.getNodeName(), core, leaderprops);
replay(ulog); replay(core);
replayed = true; replayed = true;
log.info("Replication Recovery was successful - registering as Active. core=" + coreName); 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); log.info("Finished recovery process. core=" + coreName);
} }
private Future<RecoveryInfo> replay(UpdateLog ulog) private Future<RecoveryInfo> replay(SolrCore core)
throws InterruptedException, ExecutionException { throws InterruptedException, ExecutionException {
Future<RecoveryInfo> future = ulog.applyBufferedUpdates(); Future<RecoveryInfo> future = core.getUpdateHandler().getUpdateLog().applyBufferedUpdates();
if (future == null) { if (future == null) {
// no replay needed\ // no replay needed\
log.info("No replay needed. core=" + coreName); log.info("No replay needed. core=" + coreName);
@ -519,18 +536,23 @@ public class RecoveryStrategy extends Thread implements ClosableThread {
} }
// solrcloud_debug // solrcloud_debug
// try { if (Boolean.getBoolean("solr.cloud.debug")) {
// RefCounted<SolrIndexSearcher> searchHolder = core.getNewestSearcher(false); try {
// SolrIndexSearcher searcher = searchHolder.get(); RefCounted<SolrIndexSearcher> searchHolder = core
// try { .getNewestSearcher(false);
// System.out.println(core.getCoreDescriptor().getCoreContainer().getZkController().getNodeName() + " replayed " SolrIndexSearcher searcher = searchHolder.get();
// + searcher.search(new MatchAllDocsQuery(), 1).totalHits); try {
// } finally { System.out.println(core.getCoreDescriptor().getCoreContainer()
// searchHolder.decref(); .getZkController().getNodeName()
// } + " replayed "
// } catch (Exception e) { + searcher.search(new MatchAllDocsQuery(), 1).totalHits);
// } finally {
// } searchHolder.decref();
}
} catch (Exception e) {
throw new SolrException(ErrorCode.SERVER_ERROR, null, e);
}
}
return future; return future;
} }

View File

@ -17,12 +17,25 @@
package org.apache.solr.handler.admin; package org.apache.solr.handler.admin;
import com.google.common.collect.ImmutableMap; import static org.apache.solr.common.cloud.DocCollection.DOC_ROUTER;
import com.google.common.collect.Lists;
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.io.FileUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.store.Directory; import org.apache.lucene.store.Directory;
import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.IOUtils;
import org.apache.solr.cloud.CloudDescriptor; 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.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.search.SolrIndexSearcher; import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.update.CommitUpdateCommand;
import org.apache.solr.update.MergeIndexesCommand; import org.apache.solr.update.MergeIndexesCommand;
import org.apache.solr.update.SplitIndexCommand; import org.apache.solr.update.SplitIndexCommand;
import org.apache.solr.update.UpdateLog; import org.apache.solr.update.UpdateLog;
@ -66,20 +80,8 @@ import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import com.google.common.collect.ImmutableMap;
import java.io.IOException; import com.google.common.collect.Lists;
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;
/** /**
* *
@ -794,20 +796,23 @@ public class CoreAdminHandler extends RequestHandlerBase {
boolean success = syncStrategy.sync(zkController, core, new ZkNodeProps(props)); boolean success = syncStrategy.sync(zkController, core, new ZkNodeProps(props));
// solrcloud_debug // solrcloud_debug
// try { if (Boolean.getBoolean("solr.cloud.debug")) {
// RefCounted<SolrIndexSearcher> searchHolder = try {
// core.getNewestSearcher(false); RefCounted<SolrIndexSearcher> searchHolder = core
// SolrIndexSearcher searcher = searchHolder.get(); .getNewestSearcher(false);
// try { SolrIndexSearcher searcher = searchHolder.get();
// System.out.println(core.getCoreDescriptor().getCoreContainer().getZkController().getNodeName() try {
// + " synched " System.out.println(core.getCoreDescriptor().getCoreContainer()
// + searcher.search(new MatchAllDocsQuery(), 1).totalHits); .getZkController().getNodeName()
// } finally { + " synched "
// searchHolder.decref(); + searcher.search(new MatchAllDocsQuery(), 1).totalHits);
// } } finally {
// } catch (Exception e) { searchHolder.decref();
// }
// } } catch (Exception e) {
throw new SolrException(ErrorCode.SERVER_ERROR, null, e);
}
}
if (!success) { if (!success) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Sync Failed"); throw new SolrException(ErrorCode.SERVER_ERROR, "Sync Failed");
} }
@ -910,27 +915,32 @@ public class CoreAdminHandler extends RequestHandlerBase {
} }
// solrcloud_debug // solrcloud_debug
// try {; if (Boolean.getBoolean("solr.cloud.debug")) {
// LocalSolrQueryRequest r = new LocalSolrQueryRequest(core, new try {
// ModifiableSolrParams()); ;
// CommitUpdateCommand commitCmd = new CommitUpdateCommand(r, false); LocalSolrQueryRequest r = new LocalSolrQueryRequest(core,
// commitCmd.softCommit = true; new ModifiableSolrParams());
// core.getUpdateHandler().commit(commitCmd); CommitUpdateCommand commitCmd = new CommitUpdateCommand(r, false);
// RefCounted<SolrIndexSearcher> searchHolder = commitCmd.softCommit = true;
// core.getNewestSearcher(false); core.getUpdateHandler().commit(commitCmd);
// SolrIndexSearcher searcher = searchHolder.get(); RefCounted<SolrIndexSearcher> searchHolder = core
// try { .getNewestSearcher(false);
// System.out.println(core.getCoreDescriptor().getCoreContainer().getZkController().getNodeName() SolrIndexSearcher searcher = searchHolder.get();
// + " to replicate " try {
// + searcher.search(new MatchAllDocsQuery(), 1).totalHits + " gen:" + System.out.println(core.getCoreDescriptor().getCoreContainer()
// core.getDeletionPolicy().getLatestCommit().getGeneration() + " data:" + .getZkController().getNodeName()
// core.getDataDir()); + " to replicate "
// } finally { + searcher.search(new MatchAllDocsQuery(), 1).totalHits
// searchHolder.decref(); + " gen:"
// } + core.getDeletionPolicy().getLatestCommit().getGeneration()
// } catch (Exception e) { + " data:" + core.getDataDir());
// } finally {
// } searchHolder.decref();
}
} catch (Exception e) {
throw new SolrException(ErrorCode.SERVER_ERROR, null, e);
}
}
} finally { } finally {
if (core != null) { if (core != null) {
core.close(); core.close();