Search in sources :

Example 1 with FullJR2VirtualInstanceBuilder

use of org.apache.sling.discovery.impl.setup.FullJR2VirtualInstanceBuilder in project sling by apache.

the class RepositoryDelaysTest method testOldView.

/**
     * Tests whether the not-current view returned by getTopology()
     * matches what listeners get in TOPOLOGY_CHANGING - it should
     * basically be the same.
     */
@Test
public void testOldView() throws Throwable {
    final org.apache.log4j.Logger discoveryLogger = RootLogger.getLogger("org.apache.sling.discovery");
    // info should do
    discoveryLogger.setLevel(Level.INFO);
    FullJR2VirtualInstanceBuilder builder = newBuilder();
    builder.setDebugName("firstInstanceA").newRepository("/var/discovery/impl/", true).setConnectorPingTimeout(3).setMinEventDelay(3);
    instance1 = builder.fullBuild();
    instance1.stopVoting();
    TopologyView t1 = instance1.getDiscoveryService().getTopology();
    // current it should not be
    assertFalse(t1.isCurrent());
    // but it can as well contain the local instance
    assertEquals(1, t1.getInstances().size());
    AssertingTopologyEventListener l1 = new AssertingTopologyEventListener("instance1.l1");
    l1.addExpected(Type.TOPOLOGY_INIT);
    instance1.bindTopologyEventListener(l1);
    logger.info("testOldView: instance1 created, no events expected yet. slingId=" + instance1.slingId);
    instance1.heartbeatsAndCheckView();
    Thread.sleep(200);
    instance1.heartbeatsAndCheckView();
    Thread.sleep(200);
    instance1.heartbeatsAndCheckView();
    Thread.sleep(200);
    logger.info("testOldView: 2nd/3rd heartbeat sent - now expecting a TOPOLOGY_INIT");
    instance1.dumpRepo();
    // one event
    assertEquals(1, l1.getEvents().size());
    // the expected one
    assertEquals(0, l1.getRemainingExpectedCount());
    assertEquals(0, l1.getUnexpectedCount());
    t1 = instance1.getDiscoveryService().getTopology();
    // current it should now be
    assertTrue(t1.isCurrent());
    // and it must contain the local instance
    assertEquals(1, t1.getInstances().size());
    logger.info("testOldView: creating instance2");
    l1.addExpected(Type.TOPOLOGY_CHANGING);
    FullJR2VirtualInstanceBuilder builder2 = newBuilder();
    builder2.setDebugName("secondInstanceB").useRepositoryOf(instance1).setConnectorPingTimeout(3).setMinEventDelay(3);
    instance2 = builder2.fullBuild();
    instance2.stopVoting();
    logger.info("testOldView: instance2 created, now issuing one heartbeat with instance2 first, so that instance1 can take note of it");
    instance2.heartbeatsAndCheckView();
    logger.info("testOldView: now instance1 is also doing a heartbeat and should see that a new instance is there");
    instance1.heartbeatsAndCheckView();
    logger.info("testOldView: 500ms sleep...");
    // allow some time for CHANGING to be sent
    Thread.sleep(500);
    logger.info("testOldView: 500ms sleep done.");
    // INIT and CHANGING
    assertEquals(2, l1.getEvents().size());
    // no remaining expected
    assertEquals(0, l1.getRemainingExpectedCount());
    // and no unexpected
    assertEquals(0, l1.getUnexpectedCount());
    t1 = instance1.getDiscoveryService().getTopology();
    // current it should not be
    assertFalse(t1.isCurrent());
    // but it should still contain the local instance from before
    assertEquals(1, t1.getInstances().size());
    l1.addExpected(Type.TOPOLOGY_CHANGED);
    logger.info("testOldView: now issuing 3 rounds of heartbeats/checks and expecting a TOPOLOGY_CHANGED then");
    instance2.heartbeatsAndCheckView();
    //        instance2.analyzeVotings();
    instance1.heartbeatsAndCheckView();
    //        instance1.analyzeVotings();
    Thread.sleep(1200);
    instance2.heartbeatsAndCheckView();
    instance1.heartbeatsAndCheckView();
    Thread.sleep(1200);
    instance2.heartbeatsAndCheckView();
    instance1.heartbeatsAndCheckView();
    Thread.sleep(1200);
    // INIT, CHANGING and CHANGED
    assertEquals(3, l1.getEvents().size());
    // no remaining expected
    assertEquals(0, l1.getRemainingExpectedCount());
    // and no unexpected
    assertEquals(0, l1.getUnexpectedCount());
    t1 = instance1.getDiscoveryService().getTopology();
    // and we should be current again
    assertTrue(t1.isCurrent());
    // and contain both instances now
    assertEquals(2, t1.getInstances().size());
    // timeout is set to 3sec, so we now do heartbeats for 4sec with only instance1
    // to let instance2 crash
    // force instance1 to no longer analyze the votings
    // since stopVoting() only deactivates the listener, we also
    // have to set votingHandler of heartbeatHandler to null
    PrivateAccessor.setField(instance1.getHeartbeatHandler(), "votingHandler", null);
    l1.addExpected(Type.TOPOLOGY_CHANGING);
    for (int i = 0; i < 8; i++) {
        instance1.getHeartbeatHandler().heartbeatAndCheckView();
        Thread.sleep(500);
    }
    // INIT, CHANGING, CHANGED and CHANGED
    assertEquals(4, l1.getEvents().size());
    // no remaining expected
    assertEquals(0, l1.getRemainingExpectedCount());
    // and no unexpected
    assertEquals(0, l1.getUnexpectedCount());
    t1 = instance1.getDiscoveryService().getTopology();
    // we should still be !current
    assertFalse(t1.isCurrent());
    // and contain both instances
    assertEquals(2, t1.getInstances().size());
}
Also used : FullJR2VirtualInstanceBuilder(org.apache.sling.discovery.impl.setup.FullJR2VirtualInstanceBuilder) AssertingTopologyEventListener(org.apache.sling.discovery.base.its.setup.mock.AssertingTopologyEventListener) TopologyView(org.apache.sling.discovery.TopologyView) Test(org.junit.Test)

Example 2 with FullJR2VirtualInstanceBuilder

use of org.apache.sling.discovery.impl.setup.FullJR2VirtualInstanceBuilder in project sling by apache.

the class DiscoveryWithSyncTokenTest method testTwoNodes.

@Test
public void testTwoNodes() throws Throwable {
    logger.info("testTwoNodes: start");
    FullJR2VirtualInstanceBuilder b1 = new FullJR2VirtualInstanceBuilder();
    b1.setDebugName("i1").newRepository("/var/twon/", true);
    b1.setConnectorPingInterval(1).setMinEventDelay(1).setConnectorPingTimeout(60);
    VirtualInstance i1 = b1.build();
    instances.add(i1);
    i1.bindTopologyEventListener(new TopologyEventListener() {

        @Override
        public void handleTopologyEvent(TopologyEvent event) {
            logger.info("GOT EVENT: " + event);
        }
    });
    FullJR2VirtualInstanceBuilder b2 = new FullJR2VirtualInstanceBuilder();
    b2.setDebugName("i2").useRepositoryOf(i1);
    b2.setConnectorPingInterval(1).setMinEventDelay(1).setConnectorPingTimeout(60);
    VirtualInstance i2 = b2.build();
    instances.add(i2);
    i1.heartbeatsAndCheckView();
    i2.heartbeatsAndCheckView();
    i1.heartbeatsAndCheckView();
    i2.heartbeatsAndCheckView();
    Thread.sleep(999);
//TODO: finalize test
}
Also used : FullJR2VirtualInstanceBuilder(org.apache.sling.discovery.impl.setup.FullJR2VirtualInstanceBuilder) TopologyEvent(org.apache.sling.discovery.TopologyEvent) TopologyEventListener(org.apache.sling.discovery.TopologyEventListener) VirtualInstance(org.apache.sling.discovery.base.its.setup.VirtualInstance) Test(org.junit.Test)

Example 3 with FullJR2VirtualInstanceBuilder

use of org.apache.sling.discovery.impl.setup.FullJR2VirtualInstanceBuilder in project sling by apache.

the class HeartbeatTest method testVotingLoop.

/**
     * SLING-5027 : test to reproduce the voting loop
     * (and verify that it's fixed)
     */
@Test
public void testVotingLoop() throws Throwable {
    logger.info("testVotingLoop: creating slowMachine1...");
    FullJR2VirtualInstanceBuilder slowBuilder1 = newBuilder();
    slowBuilder1.setDebugName("slow1").newRepository("/var/discovery/impl/", true).setConnectorPingTimeout(600).setConnectorPingInterval(999).setMinEventDelay(0);
    FullJR2VirtualInstance slowMachine1 = slowBuilder1.fullBuild();
    instances.add(slowMachine1);
    SimpleTopologyEventListener slowListener1 = new SimpleTopologyEventListener("slow1");
    slowMachine1.bindTopologyEventListener(slowListener1);
    logger.info("testVotingLoop: creating slowMachine2...");
    FullJR2VirtualInstanceBuilder slowBuilder2 = newBuilder();
    slowBuilder2.setDebugName("slow2").useRepositoryOf(slowMachine1).setConnectorPingTimeout(600).setConnectorPingInterval(999).setMinEventDelay(0);
    FullJR2VirtualInstance slowMachine2 = slowBuilder2.fullBuild();
    instances.add(slowMachine2);
    SimpleTopologyEventListener slowListener2 = new SimpleTopologyEventListener("slow2");
    slowMachine2.bindTopologyEventListener(slowListener2);
    logger.info("testVotingLoop: creating fastMachine...");
    FullJR2VirtualInstanceBuilder fastBuilder = newBuilder();
    fastBuilder.setDebugName("fast").useRepositoryOf(slowMachine1).setConnectorPingTimeout(600).setConnectorPingInterval(999).setMinEventDelay(0);
    FullJR2VirtualInstance fastMachine = fastBuilder.fullBuild();
    instances.add(fastMachine);
    SimpleTopologyEventListener fastListener = new SimpleTopologyEventListener("fast");
    fastMachine.bindTopologyEventListener(fastListener);
    HeartbeatHandler hhSlow1 = slowMachine1.getHeartbeatHandler();
    HeartbeatHandler hhSlow2 = slowMachine2.getHeartbeatHandler();
    HeartbeatHandler hhFast = fastMachine.getHeartbeatHandler();
    Thread.sleep(1000);
    logger.info("testVotingLoop: after some initial 1sec sleep no event should yet have been sent");
    assertFalse(fastMachine.getDiscoveryService().getTopology().isCurrent());
    assertFalse(slowMachine1.getDiscoveryService().getTopology().isCurrent());
    assertFalse(slowMachine2.getDiscoveryService().getTopology().isCurrent());
    assertNull(fastListener.getLastEvent());
    assertNull(slowListener1.getLastEvent());
    assertNull(slowListener2.getLastEvent());
    // prevent the slow machine from voting
    logger.info("testVotingLoop: stopping voting of slowMachine1...");
    slowMachine1.stopVoting();
    // now let all issue a heartbeat
    logger.info("testVotingLoop: letting slow1, slow2 and fast all issue 1 heartbeat");
    hhSlow1.issueHeartbeat();
    hhSlow2.issueHeartbeat();
    hhFast.issueHeartbeat();
    // now let the fast one start a new voting, to which
    // only the fast one will vote, the slow one doesn't.
    // that will cause a voting loop
    logger.info("testVotingLoop: let the fast one do a checkView, thus initiate a voting");
    hhFast.doCheckView();
    Calendar previousVotedAt = null;
    for (int i = 0; i < 5; i++) {
        logger.info("testVotingLoop: sleeping 1sec...");
        Thread.sleep(1000);
        logger.info("testVotingLoop: check to see that there is no voting loop...");
        // now check the ongoing votings
        ResourceResolverFactory factory = fastMachine.getResourceResolverFactory();
        ResourceResolver resourceResolver = factory.getServiceResourceResolver(null);
        try {
            List<VotingView> ongoingVotings = VotingHelper.listOpenNonWinningVotings(resourceResolver, fastMachine.getFullConfig());
            assertNotNull(ongoingVotings);
            assertEquals(1, ongoingVotings.size());
            VotingView ongoingVote = ongoingVotings.get(0);
            assertFalse(ongoingVote.isWinning());
            assertFalse(ongoingVote.hasVotedYes(slowMachine1.getSlingId()));
            assertTrue(ongoingVote.hasVotedYes(slowMachine2.getSlingId()));
            final Resource memberResource = ongoingVote.getResource().getChild("members").getChild(slowMachine2.getSlingId());
            final ModifiableValueMap memberMap = memberResource.adaptTo(ModifiableValueMap.class);
            Property vote = (Property) memberMap.get("vote");
            assertEquals(Boolean.TRUE, vote.getBoolean());
            Property votedAt = (Property) memberMap.get("votedAt");
            if (previousVotedAt == null) {
                previousVotedAt = votedAt.getDate();
            } else {
                assertEquals(previousVotedAt, votedAt.getDate());
            }
        } catch (Exception e) {
            resourceResolver.close();
            fail("Exception: " + e);
        }
    }
}
Also used : FullJR2VirtualInstance(org.apache.sling.discovery.impl.setup.FullJR2VirtualInstance) Calendar(java.util.Calendar) Resource(org.apache.sling.api.resource.Resource) ModifiableValueMap(org.apache.sling.api.resource.ModifiableValueMap) FullJR2VirtualInstanceBuilder(org.apache.sling.discovery.impl.setup.FullJR2VirtualInstanceBuilder) ResourceResolverFactory(org.apache.sling.api.resource.ResourceResolverFactory) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) VotingView(org.apache.sling.discovery.impl.cluster.voting.VotingView) Property(javax.jcr.Property) Test(org.junit.Test)

Example 4 with FullJR2VirtualInstanceBuilder

use of org.apache.sling.discovery.impl.setup.FullJR2VirtualInstanceBuilder in project sling by apache.

the class HeartbeatTest method doTestSlowAndFastMachine.

public void doTestSlowAndFastMachine(boolean withFailingScheduler) throws Throwable {
    logger.info("doTestSlowAndFastMachine: creating slowMachine... (w/o heartbeat runner)");
    FullJR2VirtualInstanceBuilder slowBuilder = newBuilder();
    slowBuilder.setDebugName("slow").newRepository("/var/discovery/impl/", true).setConnectorPingTimeout(5).setConnectorPingInterval(999).setMinEventDelay(0).withFailingScheduler(withFailingScheduler);
    FullJR2VirtualInstance slowMachine = slowBuilder.fullBuild();
    instances.add(slowMachine);
    SimpleTopologyEventListener slowListener = new SimpleTopologyEventListener("slow");
    slowMachine.bindTopologyEventListener(slowListener);
    logger.info("doTestSlowAndFastMachine: creating fastMachine... (w/o heartbeat runner)");
    FullJR2VirtualInstanceBuilder fastBuilder = newBuilder();
    fastBuilder.setDebugName("fast").useRepositoryOf(slowMachine).setConnectorPingTimeout(5).setConnectorPingInterval(999).setMinEventDelay(0).withFailingScheduler(withFailingScheduler);
    FullJR2VirtualInstance fastMachine = fastBuilder.fullBuild();
    instances.add(fastMachine);
    SimpleTopologyEventListener fastListener = new SimpleTopologyEventListener("fast");
    fastMachine.bindTopologyEventListener(fastListener);
    HeartbeatHandler hhSlow = slowMachine.getHeartbeatHandler();
    HeartbeatHandler hhFast = fastMachine.getHeartbeatHandler();
    Thread.sleep(1000);
    logger.info("doTestSlowAndFastMachine: no event should have been triggered yet");
    assertFalse(fastMachine.getDiscoveryService().getTopology().isCurrent());
    assertFalse(slowMachine.getDiscoveryService().getTopology().isCurrent());
    assertNull(fastListener.getLastEvent());
    assertNull(slowListener.getLastEvent());
    // make few rounds of heartbeats so that the two instances see each other
    logger.info("doTestSlowAndFastMachine: send a couple of heartbeats to connect the two..");
    for (int i = 0; i < 5; i++) {
        synchronized (lock(hhSlow)) {
            hhSlow.issueHeartbeat();
            hhSlow.doCheckView();
        }
        synchronized (lock(hhFast)) {
            hhFast.issueHeartbeat();
            hhFast.doCheckView();
        }
        Thread.sleep(100);
    }
    logger.info("doTestSlowAndFastMachine: now the two instances should be connected.");
    slowMachine.dumpRepo();
    assertEquals(2, slowMachine.getDiscoveryService().getTopology().getInstances().size());
    assertEquals(2, fastMachine.getDiscoveryService().getTopology().getInstances().size());
    assertEquals(TopologyEvent.Type.TOPOLOGY_INIT, fastListener.getLastEvent().getType());
    assertEquals(1, fastListener.getEventCount());
    assertEquals(TopologyEvent.Type.TOPOLOGY_INIT, slowListener.getLastEvent().getType());
    assertEquals(1, slowListener.getEventCount());
    // now let the slow machine be slow while the fast one updates as expected
    logger.info("doTestSlowAndFastMachine: last heartbeat of slowMachine.");
    synchronized (lock(hhSlow)) {
        hhSlow.issueHeartbeat();
    }
    logger.info("doTestSlowAndFastMachine: while the fastMachine still sends heartbeats...");
    for (int i = 0; i < 6; i++) {
        Thread.sleep(1500);
        synchronized (lock(hhFast)) {
            hhFast.issueHeartbeat();
            hhFast.doCheckView();
        }
    }
    logger.info("doTestSlowAndFastMachine: now the fastMachine should have decoupled the slow one");
    fastMachine.dumpRepo();
    // one more for the start of the vote
    hhFast.doCheckView();
    fastMachine.dumpRepo();
    // and one for the promotion
    hhFast.doCheckView();
    // after 9 sec hhSlow's heartbeat will have timed out, so hhFast will not see hhSlow anymore
    fastMachine.dumpRepo();
    assertEquals(TopologyEvent.Type.TOPOLOGY_CHANGED, fastListener.getLastEvent().getType());
    assertEquals(3, fastListener.getEventCount());
    assertEquals(1, fastMachine.getDiscoveryService().getTopology().getInstances().size());
    TopologyView topo = slowMachine.getDiscoveryService().getTopology();
    assertFalse(topo.isCurrent());
    // after those 6 sec, hhSlow does the check (6sec between heartbeat and check)
    logger.info("doTestSlowAndFastMachine: slowMachine is going to do a checkView next - and will detect being decoupled");
    hhSlow.doCheckView();
    slowMachine.dumpRepo();
    logger.info("doTestSlowAndFastMachine: slowMachine is going to also do a heartbeat next");
    synchronized (lock(hhSlow)) {
        hhSlow.issueHeartbeat();
    }
    assertEquals(TopologyEvent.Type.TOPOLOGY_CHANGED, fastListener.getLastEvent().getType());
    assertEquals(3, fastListener.getEventCount());
    assertEquals(TopologyEvent.Type.TOPOLOGY_CHANGING, slowListener.getLastEvent().getType());
    assertEquals(2, slowListener.getEventCount());
    Thread.sleep(8000);
    // even after 8 sec the slow lsitener did not send a TOPOLOGY_CHANGED yet
    logger.info("doTestSlowAndFastMachine: after another 8 sec of silence from slowMachine, it should still remain in CHANGING state");
    assertEquals(TopologyEvent.Type.TOPOLOGY_CHANGING, slowListener.getLastEvent().getType());
    assertFalse(slowMachine.getDiscoveryService().getTopology().isCurrent());
    assertEquals(2, slowListener.getEventCount());
    assertEquals(TopologyEvent.Type.TOPOLOGY_CHANGED, fastListener.getLastEvent().getType());
    assertEquals(1, fastMachine.getDiscoveryService().getTopology().getInstances().size());
    assertEquals(3, fastListener.getEventCount());
    // make few rounds of heartbeats so that the two instances see each other again
    logger.info("doTestSlowAndFastMachine: now let both fast and slow issue heartbeats...");
    for (int i = 0; i < 4; i++) {
        synchronized (lock(hhFast)) {
            hhFast.issueHeartbeat();
            hhFast.doCheckView();
        }
        synchronized (lock(hhSlow)) {
            hhSlow.issueHeartbeat();
            hhSlow.doCheckView();
        }
        Thread.sleep(1000);
    }
    logger.info("doTestSlowAndFastMachine: by now the two should have joined");
    // this should have put the two together again
    // even after 8 sec the slow lsitener did not send a TOPOLOGY_CHANGED yet
    assertEquals(TopologyEvent.Type.TOPOLOGY_CHANGED, fastListener.getLastEvent().getType());
    assertTrue(fastMachine.getDiscoveryService().getTopology().isCurrent());
    assertEquals(2, fastMachine.getDiscoveryService().getTopology().getInstances().size());
    assertEquals(5, fastListener.getEventCount());
    assertEquals(TopologyEvent.Type.TOPOLOGY_CHANGED, slowListener.getLastEvent().getType());
    assertTrue(slowMachine.getDiscoveryService().getTopology().isCurrent());
    assertEquals(2, slowMachine.getDiscoveryService().getTopology().getInstances().size());
    assertEquals(3, slowListener.getEventCount());
}
Also used : FullJR2VirtualInstanceBuilder(org.apache.sling.discovery.impl.setup.FullJR2VirtualInstanceBuilder) FullJR2VirtualInstance(org.apache.sling.discovery.impl.setup.FullJR2VirtualInstance) TopologyView(org.apache.sling.discovery.TopologyView)

Example 5 with FullJR2VirtualInstanceBuilder

use of org.apache.sling.discovery.impl.setup.FullJR2VirtualInstanceBuilder in project sling by apache.

the class DiscoveryServiceImplTest method testLocalClusterSyncTokenIdChange.

@Test
public void testLocalClusterSyncTokenIdChange() throws Exception {
    logger.info("testLocalClusterSyncTokenIdChange: start");
    logger.info("testLocalClusterSyncTokenIdChange: creating instance1...");
    FullJR2VirtualInstanceBuilder builder1 = (FullJR2VirtualInstanceBuilder) new FullJR2VirtualInstanceBuilder().setDebugName("instance1").newRepository("/var/testLocalClusterSyncTokenIdChange/", true).setConnectorPingInterval(999).setConnectorPingTimeout(999).setMinEventDelay(0);
    VirtualInstance instance1 = builder1.build();
    logger.info("testLocalClusterSyncTokenIdChange: creating instance2...");
    FullJR2VirtualInstanceBuilder builder2 = (FullJR2VirtualInstanceBuilder) new FullJR2VirtualInstanceBuilder().setDebugName("instance2").useRepositoryOf(instance1).setConnectorPingInterval(999).setConnectorPingTimeout(999).setMinEventDelay(0);
    VirtualInstance instance2 = builder2.build();
    logger.info("testLocalClusterSyncTokenIdChange: registering listener...");
    DummyListener listener = new DummyListener();
    DiscoveryServiceImpl discoveryService = (DiscoveryServiceImpl) instance1.getDiscoveryService();
    discoveryService.bindTopologyEventListener(listener);
    assertEquals(0, discoveryService.getViewStateManager().waitForAsyncEvents(2000));
    assertEquals(0, listener.countEvents());
    logger.info("testLocalClusterSyncTokenIdChange: doing some heartbeating...");
    instance1.heartbeatsAndCheckView();
    instance2.heartbeatsAndCheckView();
    Thread.sleep(1000);
    instance1.heartbeatsAndCheckView();
    instance2.heartbeatsAndCheckView();
    Thread.sleep(2000);
    logger.info("testLocalClusterSyncTokenIdChange: expecting to have received the INIT...");
    assertEquals(0, discoveryService.getViewStateManager().waitForAsyncEvents(2000));
    assertEquals(1, listener.countEvents());
    ResourceResolverFactory factory = instance1.getResourceResolverFactory();
    ResourceResolver resolver = factory.getServiceResourceResolver(null);
    instance1.heartbeatsAndCheckView();
    instance2.heartbeatsAndCheckView();
    Thread.sleep(1000);
    logger.info("testLocalClusterSyncTokenIdChange: after another heartbeat nothing more should have been triggered...");
    assertEquals(0, discoveryService.getViewStateManager().waitForAsyncEvents(2000));
    assertEquals(1, listener.countEvents());
    // simulate a change in the establishedView's viewId - which can be
    // achieved by triggering a revoting - which should result with the
    // same view cos the instances have not changed
    HeartbeatHandler heartbeatHandler = (HeartbeatHandler) instance1.getViewChecker();
    logger.info("testLocalClusterSyncTokenIdChange: forcing a new voting to start...");
    heartbeatHandler.startNewVoting();
    logger.info("testLocalClusterSyncTokenIdChange: doing some heartbeats to finish the voting...");
    instance1.heartbeatsAndCheckView();
    instance2.heartbeatsAndCheckView();
    Thread.sleep(1000);
    instance1.heartbeatsAndCheckView();
    instance2.heartbeatsAndCheckView();
    Thread.sleep(3000);
    logger.info("testLocalClusterSyncTokenIdChange: now we should have gotten a CHANGING/CHANGED pair additionally...");
    assertEquals(0, discoveryService.getViewStateManager().waitForAsyncEvents(2000));
    assertEquals(3, listener.countEvents());
}
Also used : FullJR2VirtualInstanceBuilder(org.apache.sling.discovery.impl.setup.FullJR2VirtualInstanceBuilder) ResourceResolverFactory(org.apache.sling.api.resource.ResourceResolverFactory) HeartbeatHandler(org.apache.sling.discovery.impl.common.heartbeat.HeartbeatHandler) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) VirtualInstance(org.apache.sling.discovery.base.its.setup.VirtualInstance) DummyListener(org.apache.sling.discovery.commons.providers.base.DummyListener) Test(org.junit.Test) AbstractDiscoveryServiceTest(org.apache.sling.discovery.base.its.AbstractDiscoveryServiceTest)

Aggregations

FullJR2VirtualInstanceBuilder (org.apache.sling.discovery.impl.setup.FullJR2VirtualInstanceBuilder)6 Test (org.junit.Test)4 TopologyView (org.apache.sling.discovery.TopologyView)3 FullJR2VirtualInstance (org.apache.sling.discovery.impl.setup.FullJR2VirtualInstance)3 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)2 ResourceResolverFactory (org.apache.sling.api.resource.ResourceResolverFactory)2 VirtualInstance (org.apache.sling.discovery.base.its.setup.VirtualInstance)2 Calendar (java.util.Calendar)1 Property (javax.jcr.Property)1 ModifiableValueMap (org.apache.sling.api.resource.ModifiableValueMap)1 Resource (org.apache.sling.api.resource.Resource)1 TopologyEvent (org.apache.sling.discovery.TopologyEvent)1 TopologyEventListener (org.apache.sling.discovery.TopologyEventListener)1 AbstractDiscoveryServiceTest (org.apache.sling.discovery.base.its.AbstractDiscoveryServiceTest)1 AssertingTopologyEventListener (org.apache.sling.discovery.base.its.setup.mock.AssertingTopologyEventListener)1 DummyListener (org.apache.sling.discovery.commons.providers.base.DummyListener)1 DiscoveryServiceImpl (org.apache.sling.discovery.impl.DiscoveryServiceImpl)1 VotingView (org.apache.sling.discovery.impl.cluster.voting.VotingView)1 HeartbeatHandler (org.apache.sling.discovery.impl.common.heartbeat.HeartbeatHandler)1