Package org.apache.sling.discovery

Examples of org.apache.sling.discovery.ClusterView


        pw.println("</tr>");
        pw.println("</thead>");
        pw.println("<tbody>");

        Set<ClusterView> clusters = topology.getClusterViews();
        ClusterView myCluster = topology.getLocalInstance().getClusterView();
        boolean odd = true;
        renderCluster(pw, myCluster, myCluster, odd);

        for (Iterator<ClusterView> it = clusters.iterator(); it.hasNext();) {
            ClusterView clusterView = it.next();
            if (clusterView.equals(myCluster)) {
                // skip - I already rendered that
                continue;
            }
            odd = !odd;
            renderCluster(pw, clusterView, myCluster, odd);
View Full Code Here


        }
        pw.println();
        pw.println();

        final Set<ClusterView> clusters = topology.getClusterViews();
        final ClusterView myCluster = topology.getLocalInstance().getClusterView();
        printCluster(pw, myCluster, myCluster);

        for (Iterator<ClusterView> it = clusters.iterator(); it.hasNext();) {
            ClusterView clusterView = it.next();
            if (clusterView.equals(myCluster)) {
                // skip - I already rendered that
                continue;
            }
            printCluster(pw, clusterView, myCluster);
        }
View Full Code Here

        return ann;
    }
   
    @Test
    public void testExpiry() throws InterruptedException, NoSuchFieldException {
        ClusterView cluster1 = createCluster(4);
        ClusterView cluster2 = createCluster(3);
        ClusterView cluster3 = createCluster(5);
       
        ClusterView myCluster = createCluster(slingId);
       
        Announcement ann1 = createAnnouncement(cluster1, 0, true);
        Announcement ann2 = createAnnouncement(cluster2, 1, true);
        Announcement ann3 = createAnnouncement(cluster3, 1, false);
       
View Full Code Here

       
    }
   
    @Test
    public void testCluster() throws Exception {
        ClusterView cluster1 = createCluster(2);
        ClusterView cluster2 = createCluster(4);
        ClusterView cluster3 = createCluster(7);
       
        Announcement ann1 = createAnnouncement(cluster1, 1, true);
        Announcement ann2 = createAnnouncement(cluster2, 2, true);
        Announcement ann3 = createAnnouncement(cluster3, 3, false);
       
        final String instance1 = UUID.randomUUID().toString();
        final String instance2 = UUID.randomUUID().toString();
        final String instance3 = UUID.randomUUID().toString();
        ClusterView myCluster = createCluster(instance1, instance2, instance3);

        AnnouncementRegistryImpl registry1 = (AnnouncementRegistryImpl) OSGiFactory.createITopologyAnnouncementRegistry(
                resourceResolverFactory, config, instance1);
        AnnouncementRegistryImpl registry2 = (AnnouncementRegistryImpl) OSGiFactory.createITopologyAnnouncementRegistry(
                resourceResolverFactory, config, instance2);
View Full Code Here

        logger.info("testGetters: start");
        assertNotNull(instance);
        logger.info("sling id=" + instance.getSlingId());
        assertNotNull(instance.getClusterViewService().getClusterView());

        ClusterView cv = instance.getClusterViewService().getClusterView();
        logger.info("cluster view: id=" + cv.getId());
        assertNotNull(cv.getId());
        assertNotSame(cv.getId(), "");

        List<InstanceDescription> instances = cv.getInstances();
        assertNotNull(instances);
        assertTrue(instances.size() == 1);

        InstanceDescription myInstance = instances.get(0);
        assertNotNull(myInstance);
View Full Code Here

    }

    @Test
    public void testBootstrap() throws Throwable {
        logger.info("testBootstrap: start");
        ClusterView initialClusterView = instance.getClusterViewService()
                .getClusterView();
        assertNotNull(initialClusterView);

        AssertingTopologyEventListener ada = new AssertingTopologyEventListener();
        ada.addExpected(Type.TOPOLOGY_INIT);
        instance.bindTopologyEventListener(ada);
        assertEquals(1, ada.getEvents().size());
        TopologyEvent initEvent = ada.getEvents().remove(0);
        assertNotNull(initEvent);

        assertEquals(initialClusterView.getId(), initEvent.getNewView()
                .getClusterViews().iterator().next().getId());
        assertEquals(initialClusterView.getInstances().get(0).getSlingId(),
                initEvent.getNewView().getLocalInstance().getSlingId());

        // hard assumption that the class we get is an
        // IsolatedInstanceDescription
        // this is because we dont have any established clusterview yet - hence
        // still entirely isolated
        assertEquals(IsolatedInstanceDescription.class, initialClusterView
                .getInstances().get(0).getClass());
        assertEquals(IsolatedInstanceDescription.class, instance
                .getClusterViewService().getClusterView().getInstances().get(0)
                .getClass());
        instance.runHeartbeatOnce();
View Full Code Here

                    "DiscoveryService not yet initialized with IClusterViewService");
        }
        // create a new topology view
        final TopologyViewImpl topology = new TopologyViewImpl();

        final ClusterView localClusterView = clusterViewService.getClusterView();

        final List<InstanceDescription> localInstances = localClusterView.getInstances();
        topology.addInstances(localInstances);

        Collection<InstanceDescription> attachedInstances = announcementRegistry
                .listInstances(localClusterView);
        topology.addInstances(attachedInstances);
View Full Code Here

            }

            Announcement topologyAnnouncement = new Announcement(
                    clusterViewService.getSlingId());
            topologyAnnouncement.setServerInfo(serverInfo);
            final ClusterView clusterView = clusterViewService
                    .getClusterView();
            topologyAnnouncement.setLocalCluster(clusterView);
            if (force) {
                logger.debug("ping: sending a resetBackoff");
                topologyAnnouncement.setResetBackoff(true);
View Full Code Here

            result.setLoop(true);
            return result;
        }
        final String localClusterViewJSON = announcement
                .getString("localClusterView");
        final ClusterView localClusterView = asClusterView(localClusterViewJSON);
        final JSONArray subAnnouncements = announcement
                .getJSONArray("topologyAnnouncements");

        if (announcement.has("inherited")) {
            final Boolean inherited = announcement.getBoolean("inherited");
View Full Code Here

    private static JSONObject asJSON(final InstanceDescription instanceDescription)
            throws JSONException {
        JSONObject obj = new JSONObject();
        obj.put("slingId", instanceDescription.getSlingId());
        obj.put("isLeader", instanceDescription.isLeader());
        ClusterView cluster = instanceDescription.getClusterView();
        if (cluster != null) {
            obj.put("cluster", cluster.getId());
        }
        JSONObject propertiesObj = new JSONObject();
        Map<String, String> propertiesMap = instanceDescription.getProperties();
        for (Iterator<Entry<String, String>> it = propertiesMap.entrySet()
                .iterator(); it.hasNext();) {
View Full Code Here

TOP

Related Classes of org.apache.sling.discovery.ClusterView

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.