use of org.apache.sling.discovery.base.its.setup.VirtualInstanceBuilder in project sling by apache.
the class LargeTopologyWithHubTest method setup.
@Before
public void setup() throws Throwable {
instances = new LinkedList<VirtualInstance>();
// 1 hour should be enough, really
final int defaultHeartbeatTimeout = 3600;
final int heartbeatTimeout = TimeoutsProvider.getInstance().getTimeout(defaultHeartbeatTimeout);
VirtualInstanceBuilder hubBuilder = newBuilder().newRepository("/var/discovery/impl/", true).setDebugName("hub").setConnectorPingInterval(5).setConnectorPingTimeout(heartbeatTimeout);
hub = hubBuilder.build();
instances.add(hub);
hub.getConfig().setViewCheckTimeout(heartbeatTimeout);
// hub.installVotingOnHeartbeatHandler();
hub.heartbeatsAndCheckView();
hub.heartbeatsAndCheckView();
assertNotNull(hub.getClusterViewService().getLocalClusterView());
hub.startViewChecker(1);
hub.dumpRepo();
slingIds = new LinkedList<String>();
slingIds.add(hub.getSlingId());
logger.info("setUp: using heartbeatTimeout of " + heartbeatTimeout + "sec " + "(default: " + defaultHeartbeatTimeout + ")");
for (int i = 0; i < TEST_SIZE; i++) {
logger.info("setUp: creating instance" + i);
VirtualInstanceBuilder builder2 = newBuilder().newRepository("/var/discovery/impl/", false).setDebugName("instance" + i).setConnectorPingInterval(5).setConnectorPingTimeout(heartbeatTimeout);
VirtualInstance instance = builder2.build();
instances.add(instance);
instance.getConfig().setViewCheckTimeout(heartbeatTimeout);
// instance.installVotingOnHeartbeatHandler();
instance.heartbeatsAndCheckView();
instance.heartbeatsAndCheckView();
ClusterView clusterView = instance.getClusterViewService().getLocalClusterView();
assertNotNull(clusterView);
new VirtualConnector(instance, hub);
slingIds.add(instance.getSlingId());
}
}
use of org.apache.sling.discovery.base.its.setup.VirtualInstanceBuilder in project sling by apache.
the class AbstractDiscoveryServiceTest method newInstance.
Tester newInstance(String debugName, int interval, int timeout, long pollingSleep, VirtualInstance base) throws Throwable {
VirtualInstanceBuilder builder = newBuilder();
builder.setDebugName(debugName);
if (base == null) {
builder.newRepository("/var/discovery/testing/", true);
} else {
builder.useRepositoryOf(base);
}
builder.setConnectorPingInterval(interval);
builder.setConnectorPingTimeout(timeout);
builder.setMinEventDelay(1);
VirtualInstance instance = builder.build();
Tester t = new Tester(instance, pollingSleep);
testers.add(t);
instance.startViewChecker(interval);
return t;
}
use of org.apache.sling.discovery.base.its.setup.VirtualInstanceBuilder in project sling by apache.
the class AbstractClusterLoadTest method testFramework.
@Test
public void testFramework() throws Exception {
logger.info("testFramework: building 1st instance..");
VirtualInstanceBuilder builder = newBuilder().newRepository("/var/discovery/impl/ClusterLoadTest/testFramework/", true).setDebugName("firstInstance").setConnectorPingTimeout(3).setConnectorPingInterval(20).setMinEventDelay(0);
VirtualInstance firstInstance = builder.build();
instances.add(firstInstance);
Thread.sleep(2000);
// in so called 'isolated' mode - lets test for that
try {
firstInstance.getClusterViewService().getLocalClusterView();
fail("should complain");
} catch (UndefinedClusterViewException e) {
// SLING-5030:
}
firstInstance.startViewChecker(1);
Thread.sleep(4000);
// after a heartbeat and letting it settle, the discovery service must have
// established a view - test for that
firstInstance.dumpRepo();
firstInstance.assertEstablishedView();
VirtualInstanceBuilder builder2 = newBuilder().useRepositoryOf(builder).setDebugName("secondInstance").setConnectorPingTimeout(3).setConnectorPingInterval(20).setMinEventDelay(0);
firstInstance.dumpRepo();
logger.info("testFramework: building 2nd instance..");
VirtualInstance secondInstance = builder2.build();
instances.add(secondInstance);
secondInstance.startViewChecker(1);
Thread.sleep(4000);
firstInstance.dumpRepo();
assertEquals(firstInstance.getClusterViewService().getLocalClusterView().getInstances().size(), 2);
assertEquals(secondInstance.getClusterViewService().getLocalClusterView().getInstances().size(), 2);
}
Aggregations