You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2012/01/21 20:33:02 UTC
svn commit: r1234403 - in
/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr:
cloud/ElectionContext.java cloud/RecoveryStrategy.java
cloud/SyncStrategy.java handler/ReplicationHandler.java update/PeerSync.java
Author: markrmiller
Date: Sat Jan 21 19:33:01 2012
New Revision: 1234403
URL: http://svn.apache.org/viewvc?rev=1234403&view=rev
Log:
clean up nocommits
Modified:
lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java
lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/PeerSync.java
Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java?rev=1234403&r1=1234402&r2=1234403&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java Sat Jan 21 19:33:01 2012
@@ -131,9 +131,14 @@ final class ShardLeaderElectionContext e
+ " - I need to try and sync");
boolean success = syncStrategy.sync(zkController, core, leaderProps);
if (!success) {
+ // TODO: what if no one can be the leader in a loop?
+ // perhaps we look down the list and if no one is active, we
+ // accept leader role anyhow
+ core.getUpdateHandler().getSolrCoreState().doRecovery(core);
+
rejoinLeaderElection(leaderSeqPath, core);
return;
- }
+ }
}
// If I am going to be the leader I have to be active
Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java?rev=1234403&r1=1234402&r2=1234403&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java Sat Jan 21 19:33:01 2012
@@ -173,7 +173,7 @@ public class RecoveryStrategy extends Th
ZkNodeProps leaderprops = zkStateReader.getLeaderProps(
cloudDesc.getCollectionName(), cloudDesc.getShardId());
- // nocommit
+
// System.out.println("recover " + shardZkNodeName + " against " +
// leaderprops);
replicate(zkController.getNodeName(), core, coreZkNodeName,
@@ -223,10 +223,6 @@ public class RecoveryStrategy extends Th
break;
}
- // nocommit:
-// zkController.publishAsDown(baseUrl, cloudDesc, coreZkNodeName,
-// core.getName());
-
} catch (Exception e) {
SolrException.log(log, "", e);
}
@@ -253,7 +249,7 @@ public class RecoveryStrategy extends Th
log.info("No replay needed");
} else {
// wait for replay
- future.get(5, TimeUnit.MINUTES); // nocommit
+ future.get();
}
// nocommit
Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java?rev=1234403&r1=1234402&r2=1234403&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java Sat Jan 21 19:33:01 2012
@@ -27,6 +27,7 @@ import org.apache.solr.client.solrj.Solr
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.apache.solr.client.solrj.request.CoreAdminRequest.RequestRecovery;
import org.apache.solr.client.solrj.request.QueryRequest;
+import org.apache.solr.common.SolrException;
import org.apache.solr.common.cloud.CloudState;
import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.cloud.ZkCoreNodeProps;
@@ -59,21 +60,19 @@ public class SyncStrategy {
CloudDescriptor cloudDesc = core.getCoreDescriptor().getCloudDescriptor();
String collection = cloudDesc.getCollectionName();
String shardId = cloudDesc.getShardId();
+
+ // first sync ourselves - we are the potential leader after all
+ try {
+ success = syncWithReplicas(zkController, core, leaderProps, collection,
+ shardId);
+ } catch (Exception e) {
+ SolrException.log(log, "Sync Failed", e);
+ }
try {
- // nocommit
-
- // first sync ourselves - we are the potential leader after all
- try {
- success = syncWithReplicas(zkController, core, leaderProps, collection, shardId);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
// if !success but no one else is in active mode,
// we are the leader anyway
- // nocommit: should we also be leader if there is only one other active?
- // if we couldnt sync with it, it shouldnt be able to sync with us
-
+ // TODO: should we also be leader if there is only one other active?
+ // if we couldn't sync with it, it shouldn't be able to sync with us
if (!success
&& !areAnyOtherReplicasActive(zkController, leaderProps, collection,
shardId)) {
@@ -91,18 +90,13 @@ public class SyncStrategy {
syncToMe(zkController, collection, shardId, leaderProps);
} else {
- // nocommit: we cannot be the leader - go into recovery
- // but what if no one can be the leader in a loop?
- // perhaps we look down the list and if no one is active, we
- // accept leader role anyhow
// nocommit
System.out.println("Sync failure");
}
} catch (Exception e) {
- // nocommit
- e.printStackTrace();
+ SolrException.log(log, "Sync Failed", e);
}
return success;
@@ -220,8 +214,7 @@ public class SyncStrategy {
}
}
} catch (Exception e) {
- // nocommit
- e.printStackTrace();
+ SolrException.log(log, "Error syncing replica to leader", e);
}
}
}
Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java?rev=1234403&r1=1234402&r2=1234403&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java Sat Jan 21 19:33:01 2012
@@ -130,7 +130,7 @@ public class ReplicationHandler extends
// It gives the current 'replicateable' index version
if (command.equals(CMD_INDEX_VERSION)) {
IndexCommit commitPoint = indexCommitPoint; // make a copy so it won't change
- // nocommit
+
//System.out.println("The latest index gen is:" + commitPoint.getGeneration() + " " + core.getCoreDescriptor().getCoreContainer().getZkController().getNodeName());
if (commitPoint != null && replicationEnabled.get()) {
//
@@ -339,7 +339,7 @@ public class ReplicationHandler extends
}
long version = Long.parseLong(v);
IndexCommit commit = core.getDeletionPolicy().getCommitPoint(version);
- //nocommit
+
//System.out.println("ask for files for gen:" + commit.getGeneration() + core.getCoreDescriptor().getCoreContainer().getZkController().getNodeName());
if (commit == null) {
rsp.add("status", "invalid indexversion");
Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/PeerSync.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/PeerSync.java?rev=1234403&r1=1234402&r2=1234403&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/PeerSync.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/PeerSync.java Sat Jan 21 19:33:01 2012
@@ -54,7 +54,6 @@ public class PeerSync {
public static Logger log = LoggerFactory.getLogger(PeerSync.class);
public boolean debug = log.isDebugEnabled();
- private SolrCore core;
private List<String> replicas;
private int nUpdates;
@@ -91,7 +90,6 @@ public class PeerSync {
public PeerSync(SolrCore core, List<String> replicas, int nUpdates) {
- this.core = core;
this.replicas = replicas;
this.nUpdates = nUpdates;
@@ -166,7 +164,9 @@ public class PeerSync {
private boolean handleResponse(ShardResponse srsp) {
if (srsp.getException() != null) {
- // nocommit
+ // TODO: look at this more thoroughly - we don't want
+ // to fail on connection exceptions, but it may make sense
+ // to determine this based on the number of fails
if (srsp.getException() instanceof SolrServerException) {
Throwable solrException = ((SolrServerException) srsp.getException())
.getRootCause();
@@ -176,7 +176,7 @@ public class PeerSync {
}
}
// TODO: at least log???
- srsp.getException().printStackTrace(System.out);
+ // srsp.getException().printStackTrace(System.out);
return false;
}