You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2015/09/11 04:20:21 UTC
[1/2] curator git commit: wip
Repository: curator
Updated Branches:
refs/heads/CURATOR-261 fad270861 -> f8f13c25d
wip
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/0603e958
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/0603e958
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/0603e958
Branch: refs/heads/CURATOR-261
Commit: 0603e95834d8596d2397620cd29235d5a62da700
Parents: fad2708
Author: randgalt <ra...@apache.org>
Authored: Thu Sep 10 20:43:37 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Thu Sep 10 20:43:37 2015 -0500
----------------------------------------------------------------------
.../curator/framework/imps/TestFramework.java | 4 +--
.../framework/imps/TestReconfiguration.java | 3 +-
.../locks/TestInterProcessMutexBase.java | 4 +--
.../curator/test/QuorumConfigBuilder.java | 36 ++++++++++++++++++--
.../curator/test/TestingZooKeeperMain.java | 18 +++++++++-
.../curator/test/TestingZooKeeperServer.java | 2 ++
pom.xml | 3 +-
7 files changed, 61 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/0603e958/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
index 811631c..472e0fc 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
@@ -59,7 +59,7 @@ public class TestFramework extends BaseClassForTests
@Override
public void setup() throws Exception
{
- System.setProperty("container.checkIntervalMs", "1000");
+ System.setProperty("znode.container.checkIntervalMs", "1000");
super.setup();
}
@@ -67,7 +67,7 @@ public class TestFramework extends BaseClassForTests
@Override
public void teardown() throws Exception
{
- System.clearProperty("container.checkIntervalMs");
+ System.clearProperty("znode.container.checkIntervalMs");
super.teardown();
}
http://git-wip-us.apache.org/repos/asf/curator/blob/0603e958/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java
index 2438ef8..a99617b 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java
@@ -27,6 +27,7 @@ import org.apache.curator.framework.api.BackgroundCallback;
import org.apache.curator.framework.api.CuratorEvent;
import org.apache.curator.framework.ensemble.EnsembleTracker;
import org.apache.curator.retry.RetryOneTime;
+import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.test.InstanceSpec;
import org.apache.curator.test.TestingCluster;
import org.apache.curator.test.Timing;
@@ -47,7 +48,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
-public class TestReconfiguration
+public class TestReconfiguration extends BaseClassForTests
{
private static final Timing timing = new Timing();
private TestingCluster cluster;
http://git-wip-us.apache.org/repos/asf/curator/blob/0603e958/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutexBase.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutexBase.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutexBase.java
index 5a8168e..0cf8d45 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutexBase.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutexBase.java
@@ -211,7 +211,7 @@ public abstract class TestInterProcessMutexBase extends BaseClassForTests
server.close();
- System.setProperty("container.checkIntervalMs", "10");
+ System.setProperty("znode.container.checkIntervalMs", "10");
try
{
server = new TestingServer();
@@ -272,7 +272,7 @@ public abstract class TestInterProcessMutexBase extends BaseClassForTests
}
finally
{
- System.clearProperty("container.checkIntervalMs");
+ System.clearProperty("znode.container.checkIntervalMs");
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/0603e958/curator-test/src/main/java/org/apache/curator/test/QuorumConfigBuilder.java
----------------------------------------------------------------------
diff --git a/curator-test/src/main/java/org/apache/curator/test/QuorumConfigBuilder.java b/curator-test/src/main/java/org/apache/curator/test/QuorumConfigBuilder.java
index 02979ee..17bb185 100644
--- a/curator-test/src/main/java/org/apache/curator/test/QuorumConfigBuilder.java
+++ b/curator-test/src/main/java/org/apache/curator/test/QuorumConfigBuilder.java
@@ -19,19 +19,23 @@
package org.apache.curator.test;
+import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.io.Files;
import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
+import java.io.Closeable;
import java.io.File;
+import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
@SuppressWarnings("UnusedDeclaration")
-public class QuorumConfigBuilder
+public class QuorumConfigBuilder implements Closeable
{
private final ImmutableList<InstanceSpec> instanceSpecs;
private final boolean fromRandom;
+ private final File fakeConfigFile;
public QuorumConfigBuilder(Collection<InstanceSpec> specs)
{
@@ -42,6 +46,16 @@ public class QuorumConfigBuilder
{
fromRandom = (specs == null) || (specs.length == 0);
instanceSpecs = fromRandom ? ImmutableList.of(InstanceSpec.newInstanceSpec()) : ImmutableList.copyOf(specs);
+ File fakeConfigFile = null;
+ try
+ {
+ fakeConfigFile = File.createTempFile("temp", "temp");
+ }
+ catch ( IOException e )
+ {
+ Throwables.propagate(e);
+ }
+ this.fakeConfigFile = fakeConfigFile;
}
public boolean isFromRandom()
@@ -69,6 +83,16 @@ public class QuorumConfigBuilder
return instanceSpecs.size();
}
+ @Override
+ public void close()
+ {
+ if ( fakeConfigFile != null )
+ {
+ //noinspection ResultOfMethodCallIgnored
+ fakeConfigFile.delete();
+ }
+ }
+
public QuorumPeerConfig buildConfig(int instanceIndex) throws Exception
{
boolean isCluster = (instanceSpecs.size() > 1);
@@ -103,7 +127,15 @@ public class QuorumConfigBuilder
}
}
- QuorumPeerConfig config = new QuorumPeerConfig();
+ QuorumPeerConfig config = new QuorumPeerConfig()
+ {
+ {
+ if ( fakeConfigFile != null )
+ {
+ configFileStr = fakeConfigFile.getPath();
+ }
+ }
+ };
config.parseProperties(properties);
return config;
}
http://git-wip-us.apache.org/repos/asf/curator/blob/0603e958/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
----------------------------------------------------------------------
diff --git a/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java b/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
index a4cca8e..82bcd9b 100644
--- a/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
+++ b/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
@@ -21,6 +21,8 @@ package org.apache.curator.test;
import org.apache.zookeeper.jmx.MBeanRegistry;
import org.apache.zookeeper.jmx.ZKMBeanInfo;
+import org.apache.zookeeper.server.ContainerManager;
+import org.apache.zookeeper.server.RequestProcessor;
import org.apache.zookeeper.server.ServerCnxnFactory;
import org.apache.zookeeper.server.ServerConfig;
import org.apache.zookeeper.server.ZKDatabase;
@@ -37,6 +39,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.channels.ServerSocketChannel;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
@@ -48,7 +51,8 @@ public class TestingZooKeeperMain implements ZooKeeperMainFace
private final AtomicReference<Exception> startingException = new AtomicReference<Exception>(null);
private volatile ServerCnxnFactory cnxnFactory;
- private volatile ZooKeeperServer zkServer;
+ private volatile TestZooKeeperServer zkServer;
+ private volatile ContainerManager containerManager;
private static final Timing timing = new Timing();
@@ -169,6 +173,11 @@ public class TestingZooKeeperMain implements ZooKeeperMainFace
cnxnFactory = null;
}
+ if ( containerManager != null ) {
+ containerManager.stop();
+ containerManager = null;
+ }
+
try
{
if ( zkServer != null )
@@ -217,6 +226,8 @@ public class TestingZooKeeperMain implements ZooKeeperMainFace
timing.sleepABit();
}
cnxnFactory.startup(zkServer);
+ containerManager = new ContainerManager(zkServer.getZKDatabase(), zkServer.getFirstProcessor(), Integer.getInteger("znode.container.checkIntervalMs", (int)TimeUnit.MINUTES.toMillis(1L)).intValue(), Integer.getInteger("znode.container.maxPerMinute", 10000).intValue());
+ containerManager.start();
latch.countDown();
cnxnFactory.join();
if ( zkServer.isRunning()) {
@@ -242,6 +253,11 @@ public class TestingZooKeeperMain implements ZooKeeperMainFace
private final AtomicBoolean isRunning = new AtomicBoolean(false);
+ public RequestProcessor getFirstProcessor()
+ {
+ return firstProcessor;
+ }
+
protected void registerJMX()
{
// NOP
http://git-wip-us.apache.org/repos/asf/curator/blob/0603e958/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperServer.java
----------------------------------------------------------------------
diff --git a/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperServer.java b/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperServer.java
index eeec877..c14e3e4 100644
--- a/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperServer.java
+++ b/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperServer.java
@@ -123,6 +123,8 @@ public class TestingZooKeeperServer extends QuorumPeerMain implements Closeable
if ( state.compareAndSet(State.STOPPED, State.CLOSED) )
{
+ configBuilder.close();
+
InstanceSpec spec = getInstanceSpec();
if ( spec.deleteDataDirectoryOnClose() )
{
http://git-wip-us.apache.org/repos/asf/curator/blob/0603e958/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 567eb8f..0e7a732 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
- <version>16</version>
+ <version>17</version>
</parent>
<groupId>org.apache.curator</groupId>
@@ -622,6 +622,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
+ <reuseForks>false</reuseForks>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
</plugin>
[2/2] curator git commit: oops - forgot to try again on bind exception
Posted by ra...@apache.org.
oops - forgot to try again on bind exception
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/f8f13c25
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/f8f13c25
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/f8f13c25
Branch: refs/heads/CURATOR-261
Commit: f8f13c25d65e96efa6a0718515e8e035d72de7e9
Parents: 0603e95
Author: randgalt <ra...@apache.org>
Authored: Thu Sep 10 21:20:14 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Thu Sep 10 21:20:14 2015 -0500
----------------------------------------------------------------------
.../main/java/org/apache/curator/test/TestingZooKeeperMain.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/f8f13c25/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
----------------------------------------------------------------------
diff --git a/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java b/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
index 82bcd9b..795e5d0 100644
--- a/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
+++ b/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
@@ -224,6 +224,9 @@ public class TestingZooKeeperMain implements ZooKeeperMainFace
{
log.info("Could not server. Waiting and trying one more time.", e);
timing.sleepABit();
+ cnxnFactory = ServerCnxnFactory.createFactory();
+ cnxnFactory.configure(config.getClientPortAddress(),
+ config.getMaxClientCnxns());
}
cnxnFactory.startup(zkServer);
containerManager = new ContainerManager(zkServer.getZKDatabase(), zkServer.getFirstProcessor(), Integer.getInteger("znode.container.checkIntervalMs", (int)TimeUnit.MINUTES.toMillis(1L)).intValue(), Integer.getInteger("znode.container.maxPerMinute", 10000).intValue());