You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2013/08/07 12:49:24 UTC
svn commit: r1511245 -
/sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/cluster/ClusterLoadTest.java
Author: cziegeler
Date: Wed Aug 7 10:49:23 2013
New Revision: 1511245
URL: http://svn.apache.org/r1511245
Log:
Add missing licence header
Modified:
sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/cluster/ClusterLoadTest.java
Modified: sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/cluster/ClusterLoadTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/cluster/ClusterLoadTest.java?rev=1511245&r1=1511244&r2=1511245&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/cluster/ClusterLoadTest.java (original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/cluster/ClusterLoadTest.java Wed Aug 7 10:49:23 2013
@@ -17,8 +17,25 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The SF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
public class ClusterLoadTest {
-
+
// wait up to 4 heartbeat intervals
private static final int INSTANCE_VIEW_WAIT_TIME_MILLIS = 5000;
private static final int INSTANCE_VIEW_POLL_INTERVAL_MILLIS = 500;
@@ -28,7 +45,7 @@ public class ClusterLoadTest {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
List<Instance> instances = new LinkedList<Instance>();
-
+
@After
public void tearDown() throws Exception {
if (instances==null || instances.size()==0) {
@@ -40,7 +57,7 @@ public class ClusterLoadTest {
it.remove();
}
}
-
+
@Test
public void testFramework() throws Exception {
Instance firstInstance = Instance.newStandaloneInstance("/var/discovery/impl/ClusterLoadTest/testFramework/", "firstInstance", false, 2, 0);
@@ -58,7 +75,7 @@ public class ClusterLoadTest {
assertEquals(EstablishedInstanceDescription.class, firstInstance
.getClusterViewService().getClusterView().getInstances().get(0)
.getClass());
-
+
Instance secondInstance = Instance.newClusterInstance("/var/discovery/impl/ClusterLoadTest/testFramework/", "secondInstance", firstInstance, false, 2, 0);
instances.add(secondInstance);
secondInstance.startHeartbeats(1);
@@ -81,7 +98,7 @@ public class ClusterLoadTest {
public void testFourInstances() throws Throwable {
doTest(4, 7);
}
-
+
@Test
public void testFiveInstances() throws Throwable {
doTest(5, 8);
@@ -109,12 +126,12 @@ public class ClusterLoadTest {
instances.add(subsequentInstance);
subsequentInstance.startHeartbeats(1);
}
-
+
for(int i=0; i<loopCnt; i++) {
logger.info("=====================");
logger.info(" START of LOOP "+i);
logger.info("=====================");
-
+
// count how many instances had heartbeats running in the first place
int aliveCnt = 0;
for (Iterator<Instance> it = instances.iterator(); it.hasNext();) {
@@ -130,7 +147,7 @@ public class ClusterLoadTest {
// if no one is sending heartbeats, all instances go back to isolated mode
aliveCnt=1;
}
-
+
final int aliveCntFinal = aliveCnt;
for (Iterator<Instance> it = instances.iterator(); it.hasNext();) {
@@ -154,7 +171,7 @@ public class ClusterLoadTest {
INSTANCE_VIEW_POLL_INTERVAL_MILLIS);
}
}
-
+
// start/stop heartbeats accordingly
logger.info("Starting/Stopping heartbeats with count="+instances.size());
for (Iterator<Instance> it = instances.iterator(); it.hasNext();) {
@@ -169,7 +186,7 @@ public class ClusterLoadTest {
logger.info("Stopped heartbeats with "+instance.slingId);
}
}
-
+
}
}