Package org.apache.sling.discovery.impl.common

Examples of org.apache.sling.discovery.impl.common.DefaultClusterViewImpl


public class TopologyTestHelper {

    public static TopologyViewImpl createTopologyView(String clusterViewId,
            String slingId) {
        TopologyViewImpl t = new TopologyViewImpl();
        DefaultClusterViewImpl c = new DefaultClusterViewImpl(clusterViewId);
        DefaultInstanceDescriptionImpl i = new DefaultInstanceDescriptionImpl(
                c, true, false, slingId, new HashMap<String, String>());
        Collection<InstanceDescription> instances = new LinkedList<InstanceDescription>();
        instances.add(i);
        t.addInstances(instances);
View Full Code Here


    public static TopologyViewImpl cloneTopologyView(TopologyViewImpl original) {
        TopologyViewImpl t = new TopologyViewImpl();
        Iterator<ClusterView> it = original.getClusterViews().iterator();
        while (it.hasNext()) {
            DefaultClusterViewImpl c = (DefaultClusterViewImpl) it.next();
            t.addInstances(clone(c).getInstances());
        }
        return t;
    }
View Full Code Here

        }
        return t;
    }

    public static DefaultClusterViewImpl clone(DefaultClusterViewImpl original) {
        DefaultClusterViewImpl c = new DefaultClusterViewImpl(original.getId());
        Iterator<InstanceDescription> it = original.getInstances().iterator();
        while (it.hasNext()) {
            DefaultInstanceDescriptionImpl id = (DefaultInstanceDescriptionImpl) it
                    .next();
            c.addInstanceDescription(cloneWOClusterView(id));
        }
        return c;
    }
View Full Code Here

       
        Announcement ann = new Announcement(slingId);
        assertFalse(ann.isValid());
        assertFalse(registry.registerAnnouncement(ann)!=-1);
       
        DefaultClusterViewImpl localCluster = new DefaultClusterViewImpl(UUID.randomUUID().toString());
        ann.setLocalCluster(localCluster);
        assertFalse(ann.isValid());
        assertFalse(registry.registerAnnouncement(ann)!=-1);

        try{
View Full Code Here

        } catch(IllegalArgumentException iae) {
            // ok
        }
        assertEquals(0, registry.listLocalAnnouncements().size());
        assertEquals(0, registry.listLocalIncomingAnnouncements().size());
        DefaultClusterViewImpl localCluster = new DefaultClusterViewImpl(UUID.randomUUID().toString());
        DefaultInstanceDescriptionImpl instance = TopologyTestHelper.createInstanceDescription(slingId, true, localCluster);       
        assertEquals(0, registry.listAnnouncementsInSameCluster(localCluster).size());
        assertEquals(0, registry.listLocalAnnouncements().size());
        assertEquals(0, registry.listLocalIncomingAnnouncements().size());
       
View Full Code Here

        registry.registerAnnouncement(ann);
        assertEquals(2, registry.listAnnouncementsInSameCluster(localCluster).size());
    }
   
    private ClusterView createCluster(int numInstances) {
        DefaultClusterViewImpl localCluster = new DefaultClusterViewImpl(UUID.randomUUID().toString());
        for (int i = 0; i < numInstances; i++) {
            DefaultInstanceDescriptionImpl instance = TopologyTestHelper.createInstanceDescription(UUID.randomUUID().toString(), (i==0 ? true : false), localCluster);       
        }
        return localCluster;
    }
View Full Code Here

        }
        return localCluster;
    }
   
    private ClusterView createCluster(String... instanceIds) {
        DefaultClusterViewImpl localCluster = new DefaultClusterViewImpl(UUID.randomUUID().toString());
        for (int i = 0; i < instanceIds.length; i++) {
            DefaultInstanceDescriptionImpl instance = TopologyTestHelper.createInstanceDescription(instanceIds[i], (i==0 ? true : false), localCluster);       
        }
        return localCluster;
    }
View Full Code Here

    /** create a clusterview from json **/
    private static ClusterView asClusterView(final String localClusterViewJSON)
            throws JSONException {
        JSONObject obj = new JSONObject(localClusterViewJSON);
        DefaultClusterViewImpl clusterView = new DefaultClusterViewImpl(
                obj.getString("id"));
        JSONArray instancesObj = obj.getJSONArray("instances");

        for (int i = 0; i < instancesObj.length(); i++) {
            JSONObject anInstance = instancesObj.getJSONObject(i);
            clusterView.addInstanceDescription(asInstance(anInstance));
        }

        return clusterView;
    }
View Full Code Here

        assertNotNull(firstInstance);
        DefaultInstanceDescriptionImpl secondInstance = (DefaultInstanceDescriptionImpl) it.next();
        assertNotNull(secondInstance);
        TopologyTestHelper.getWriteableProperties(
                firstInstance).put("c", "d");
        DefaultClusterViewImpl cluster = new DefaultClusterViewImpl(UUID.randomUUID().toString());
        PrivateAccessor.setField(secondInstance, "clusterView", null);
        cluster.addInstanceDescription(secondInstance);
        assertEquals(Type.TOPOLOGY_CHANGED, newView.compareTopology(oldView));
    }
View Full Code Here

    public IsolatedInstanceDescription(final Resource res, final String clusterViewId,
            final String slingId) {
        super(null, res, slingId, true, true);

        DefaultClusterViewImpl clusterView = new DefaultClusterViewImpl(
                clusterViewId);
        clusterView.addInstanceDescription(this);
    }
View Full Code Here

TOP

Related Classes of org.apache.sling.discovery.impl.common.DefaultClusterViewImpl

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.