Search in sources :

Example 11 with VirtualInstance

use of org.apache.sling.discovery.base.its.setup.VirtualInstance 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 12 with VirtualInstance

use of org.apache.sling.discovery.base.its.setup.VirtualInstance 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 13 with VirtualInstance

use of org.apache.sling.discovery.base.its.setup.VirtualInstance in project sling by apache.

the class AbstractClusterLoadTest method tearDown.

@After
public void tearDown() throws Exception {
    if (instances == null || instances.size() == 0) {
        return;
    }
    for (Iterator<VirtualInstance> it = instances.iterator(); it.hasNext(); ) {
        VirtualInstance i = it.next();
        i.stop();
        it.remove();
    }
}
Also used : VirtualInstance(org.apache.sling.discovery.base.its.setup.VirtualInstance) After(org.junit.After)

Example 14 with VirtualInstance

use of org.apache.sling.discovery.base.its.setup.VirtualInstance 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)

Example 15 with VirtualInstance

use of org.apache.sling.discovery.base.its.setup.VirtualInstance in project sling by apache.

the class TopologyTest method tearDown.

@After
public void tearDown() throws Exception {
    for (Iterator<VirtualInstance> it = instances.iterator(); it.hasNext(); ) {
        final VirtualInstance instance = it.next();
        instance.stop();
    }
}
Also used : VirtualInstance(org.apache.sling.discovery.base.its.setup.VirtualInstance) After(org.junit.After)

Aggregations

VirtualInstance (org.apache.sling.discovery.base.its.setup.VirtualInstance)15 VirtualInstanceBuilder (org.apache.sling.discovery.base.its.setup.VirtualInstanceBuilder)5 After (org.junit.After)5 Test (org.junit.Test)5 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)2 ResourceResolverFactory (org.apache.sling.api.resource.ResourceResolverFactory)2 UndefinedClusterViewException (org.apache.sling.discovery.base.commons.UndefinedClusterViewException)2 VirtualConnector (org.apache.sling.discovery.base.its.setup.VirtualConnector)2 DummyListener (org.apache.sling.discovery.commons.providers.base.DummyListener)2 FullJR2VirtualInstanceBuilder (org.apache.sling.discovery.impl.setup.FullJR2VirtualInstanceBuilder)2 ClusterView (org.apache.sling.discovery.ClusterView)1 InstanceDescription (org.apache.sling.discovery.InstanceDescription)1 TopologyEvent (org.apache.sling.discovery.TopologyEvent)1 TopologyEventListener (org.apache.sling.discovery.TopologyEventListener)1 DummyVirtualInstanceBuilder (org.apache.sling.discovery.base.connectors.DummyVirtualInstanceBuilder)1 Announcement (org.apache.sling.discovery.base.connectors.announcement.Announcement)1 AbstractDiscoveryServiceTest (org.apache.sling.discovery.base.its.AbstractDiscoveryServiceTest)1 HeartbeatHandler (org.apache.sling.discovery.impl.common.heartbeat.HeartbeatHandler)1 FullJR2VirtualInstance (org.apache.sling.discovery.impl.setup.FullJR2VirtualInstance)1 OakVirtualInstanceBuilder (org.apache.sling.discovery.oak.its.setup.OakVirtualInstanceBuilder)1