Examples of InstanceDescription


Examples of org.apache.sling.discovery.InstanceDescription

    private InstanceDescription getInstance(Instance instance, String slingId) {
        Iterator<InstanceDescription> it = instance.getClusterViewService()
                .getClusterView().getInstances().iterator();
        while (it.hasNext()) {
            InstanceDescription id = it.next();
            if (id.getSlingId().equals(slingId)) {
                return id;
            }
        }
        throw new IllegalStateException("instance not found: instance="
                + instance + ", slingId=" + slingId);
View Full Code Here

Examples of org.apache.sling.discovery.InstanceDescription

        for(int i=0; i<slingIds.length; i++) {
            final String aSlingId = slingIds[i];
            final Set<?> instances = topology.getInstances();
            boolean found = false;
            for (Iterator<?> it = instances.iterator(); it.hasNext();) {
                InstanceDescription anInstance = (InstanceDescription) it.next();
                if (anInstance.getSlingId().equals(aSlingId)) {
                    found = true;
                    break;
                }
            }
            assertTrue(found);
View Full Code Here

Examples of org.apache.sling.discovery.InstanceDescription

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

        InstanceDescription myInstance = instances.get(0);
        assertNotNull(myInstance);
        assertTrue(myInstance.getClusterView() == cv);
        logger.info("instance id: " + myInstance.getSlingId());
        assertEquals(instance.getSlingId(), myInstance.getSlingId());

        Map<String, String> properties = myInstance.getProperties();
        assertNotNull(properties);

        assertNull(myInstance.getProperty("foo"));

        assertTrue(myInstance.isLeader());

        assertTrue(myInstance.isLocal());
        logger.info("testGetters: end");
    }
View Full Code Here

Examples of org.apache.sling.discovery.InstanceDescription

                    // filter out announcements that are of old cluster instances
                    // which I dont really have in my cluster view at the moment
                    final Iterator<InstanceDescription> it =
                            clusterViewService.getClusterView().getInstances().iterator();
                    while(it.hasNext()) {
                        final InstanceDescription instance = it.next();
                        if (instance.getSlingId().equals(receivingSlingId)) {
                            // then I have the receiving instance in my cluster view
                            // all fine then
                            return true;
                        }
                    }
View Full Code Here

Examples of org.apache.sling.discovery.InstanceDescription

            if (instances==null || instances.size()==0) {
                return false;
            }
            boolean isOwnerMemberOfLocalCluster = false;
            for (Iterator<InstanceDescription> it = instances.iterator(); it.hasNext();) {
                InstanceDescription instanceDescription = it.next();
                if (instanceDescription.getSlingId().equals(ownerId)) {
                    isOwnerMemberOfLocalCluster = true;
                }
            }
            if (!isOwnerMemberOfLocalCluster) {
                return false;
View Full Code Here

Examples of org.apache.sling.discovery.InstanceDescription

        obj.put("id", clusterView.getId());
        JSONArray instancesObj = new JSONArray();
        List<InstanceDescription> instances = clusterView.getInstances();
        for (Iterator<InstanceDescription> it = instances.iterator(); it
                .hasNext();) {
            InstanceDescription instanceDescription = it.next();
            instancesObj.put(asJSON(instanceDescription));
        }
        obj.put("instances", instancesObj);
        return obj;
    }
View Full Code Here

Examples of org.apache.sling.discovery.InstanceDescription

        }
        boolean propertiesChanged = false;
        for(final InstanceDescription instance : this.instances) {

            final Iterator<InstanceDescription> it2 = other.instances.iterator();
            InstanceDescription matchingInstance = null;
            while (it2.hasNext()) {
                final InstanceDescription otherInstance = it2.next();
                if (instance.getSlingId().equals(otherInstance.getSlingId())) {
                    matchingInstance = otherInstance;
                    break;
                }
            }
            if (matchingInstance == null) {
View Full Code Here

Examples of org.apache.sling.discovery.InstanceDescription

    @Override
    public int hashCode() {
        int code = 0;
        for (Iterator<InstanceDescription> it = instances.iterator(); it
                .hasNext();) {
            InstanceDescription instance = it.next();
            code += instance.hashCode();
        }
        return code;
    }
View Full Code Here

Examples of org.apache.sling.discovery.InstanceDescription

     * @see org.apache.sling.discovery.TopologyView#getLocalInstance()
     */
    public InstanceDescription getLocalInstance() {
        for (Iterator<InstanceDescription> it = instances.iterator(); it
                .hasNext();) {
            InstanceDescription instance = it.next();
            if (instance.isLocal()) {
                return instance;
            }
        }
        return null;
    }
View Full Code Here

Examples of org.apache.sling.discovery.InstanceDescription

        if (instances == null) {
            return;
        }
        outerLoop: for (Iterator<InstanceDescription> it = instances.iterator(); it
                .hasNext();) {
            InstanceDescription instanceDescription = it.next();
            for (Iterator<InstanceDescription> it2 = this.instances.iterator(); it2.hasNext();) {
                InstanceDescription existingInstance = it2.next();
                if (existingInstance.getSlingId().equals(instanceDescription.getSlingId())) {
                    logger.info("addInstance: cannot add same instance twice: "
                            + instanceDescription);
                    continue outerLoop;
                }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.