Search in sources :

Example 6 with VirtualInstanceBuilder

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());
    }
}
Also used : VirtualInstanceBuilder(org.apache.sling.discovery.base.its.setup.VirtualInstanceBuilder) ClusterView(org.apache.sling.discovery.ClusterView) VirtualConnector(org.apache.sling.discovery.base.its.setup.VirtualConnector) VirtualInstance(org.apache.sling.discovery.base.its.setup.VirtualInstance) Before(org.junit.Before)

Example 7 with VirtualInstanceBuilder

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;
}
Also used : VirtualInstanceBuilder(org.apache.sling.discovery.base.its.setup.VirtualInstanceBuilder) VirtualInstance(org.apache.sling.discovery.base.its.setup.VirtualInstance)

Example 8 with VirtualInstanceBuilder

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);
}
Also used : VirtualInstanceBuilder(org.apache.sling.discovery.base.its.setup.VirtualInstanceBuilder) UndefinedClusterViewException(org.apache.sling.discovery.base.commons.UndefinedClusterViewException) VirtualInstance(org.apache.sling.discovery.base.its.setup.VirtualInstance) Test(org.junit.Test)

Aggregations

VirtualInstanceBuilder (org.apache.sling.discovery.base.its.setup.VirtualInstanceBuilder)8 VirtualInstance (org.apache.sling.discovery.base.its.setup.VirtualInstance)5 Test (org.junit.Test)4 TopologyView (org.apache.sling.discovery.TopologyView)2 UndefinedClusterViewException (org.apache.sling.discovery.base.commons.UndefinedClusterViewException)2 DummyVirtualInstanceBuilder (org.apache.sling.discovery.base.connectors.DummyVirtualInstanceBuilder)2 VirtualConnector (org.apache.sling.discovery.base.its.setup.VirtualConnector)2 Before (org.junit.Before)2 ClusterView (org.apache.sling.discovery.ClusterView)1 InstanceDescription (org.apache.sling.discovery.InstanceDescription)1 Announcement (org.apache.sling.discovery.base.connectors.announcement.Announcement)1 AbstractDiscoveryServiceTest (org.apache.sling.discovery.base.its.AbstractDiscoveryServiceTest)1 AssertingTopologyEventListener (org.apache.sling.discovery.base.its.setup.mock.AssertingTopologyEventListener)1 FullJR2VirtualInstanceBuilder (org.apache.sling.discovery.impl.setup.FullJR2VirtualInstanceBuilder)1 OakDiscoveryService (org.apache.sling.discovery.oak.OakDiscoveryService)1 OakVirtualInstanceBuilder (org.apache.sling.discovery.oak.its.setup.OakVirtualInstanceBuilder)1 RetryLoop (org.apache.sling.testing.tools.retry.RetryLoop)1 Category (org.junit.experimental.categories.Category)1