Examples of InstanceDescription


Examples of org.apache.sling.discovery.InstanceDescription

            throw new IllegalArgumentException("picker must not be null");
        }
        Set<InstanceDescription> result = new HashSet<InstanceDescription>();
        for (Iterator<InstanceDescription> it = instances.iterator(); it
                .hasNext();) {
            InstanceDescription instance = it.next();
            if (picker.accept(instance)) {
                result.add(instance);
            }
        }
        return result;
View Full Code Here

Examples of org.apache.sling.discovery.InstanceDescription

     */
    public Set<ClusterView> getClusterViews() {
        Set<ClusterView> result = new HashSet<ClusterView>();
        for (Iterator<InstanceDescription> it = instances.iterator(); it
                .hasNext();) {
            InstanceDescription instance = it.next();
            ClusterView cluster = instance.getClusterView();
            if (cluster != null) {
                result.add(cluster);
            }
        }
        return new HashSet<ClusterView>(result);
View Full Code Here

Examples of org.apache.sling.discovery.InstanceDescription

    }
   
    private final InstanceDescription getLocalInstanceDescription(final ClusterView localClusterView) {
        for (Iterator<InstanceDescription> it = localClusterView.getInstances().iterator(); it
                .hasNext();) {
            InstanceDescription id = it.next();
            if (id.isLocal()) {
                return id;
            }
        }
        return null;
    }
View Full Code Here

Examples of org.apache.sling.discovery.InstanceDescription

        if (localClusterView==null) {
            throw new IllegalArgumentException("clusterView must not be null");
        }
        ResourceResolver resourceResolver = null;
        final Collection<Announcement> incomingAnnouncements = new LinkedList<Announcement>();
        final InstanceDescription localInstance = getLocalInstanceDescription(localClusterView);
        try {
            resourceResolver = resourceResolverFactory
                    .getAdministrativeResourceResolver(null);

            Resource clusterInstancesResource = ResourceHelper
                    .getOrCreateResource(
                            resourceResolver,
                            config.getClusterInstancesPath());

            Iterator<Resource> it0 = clusterInstancesResource.getChildren()
                    .iterator();
            while (it0.hasNext()) {
                Resource aClusterInstanceResource = it0.next();
                final String instanceId = aClusterInstanceResource.getName();
                if (localInstance!=null && localInstance.getSlingId().equals(instanceId)) {
                    // this is the local instance then - which we serve from the cache only
                    fillWithCachedAnnouncements(incomingAnnouncements);
                    continue;
                }
               
View Full Code Here

Examples of org.apache.sling.discovery.InstanceDescription

    }

    private final boolean contains(final ClusterView clusterView, final String instanceId) {
        for (Iterator<InstanceDescription> it = clusterView.getInstances().iterator(); it
                .hasNext();) {
            InstanceDescription instance = it.next();
            if (instance.getSlingId().equals(instanceId)) {
                // fine, then the instance is in the view
                return true;
            }
        }
        return false;
View Full Code Here

Examples of org.apache.sling.discovery.InstanceDescription

            // include the new owner
            Collection<InstanceDescription> attachedInstances = announcement
                    .listInstances();
            for (Iterator<InstanceDescription> it2 = attachedInstances
                    .iterator(); it2.hasNext();) {
                InstanceDescription instanceDescription = it2.next();
                if (topologyAnnouncement.getOwnerId().equals(
                        instanceDescription.getSlingId())) {
                    logger.info("registerAnnouncement: already have this instance attached: "
                            + instanceDescription.getSlingId());
                    return -1;
                }
            }
        }
View Full Code Here

Examples of org.apache.sling.discovery.InstanceDescription

     * Create a new description.
     */
    @Activate
    protected void activate() {
        logger.debug("NoClusterDiscoveryService started.");
        final InstanceDescription myDescription = new InstanceDescription() {

            public boolean isLocal() {
                return true;
            }

            public boolean isLeader() {
                return true;
            }

            public String getSlingId() {
                return settingsService.getSlingId();
            }

            public String getProperty(final String name) {
              synchronized(lock) {
                return cachedProperties.get(name);
              }
            }

      public Map<String, String> getProperties() {
        synchronized(lock) {
          return Collections.unmodifiableMap(cachedProperties);
        }
      }

      public ClusterView getClusterView() {
        final Collection<ClusterView> clusters = topologyView.getClusterViews();
        if (clusters==null || clusters.size()==0) {
          return null;
        }
        return clusters.iterator().next();
      }
        };
        final Set<InstanceDescription> instances = new HashSet<InstanceDescription>();
        instances.add(myDescription);

        final TopologyEventListener[] registeredServices;
    synchronized ( lock ) {
            registeredServices = this.listeners;
            final ClusterView clusterView = new ClusterView() {

                public InstanceDescription getLeader() {
                    return myDescription;
                }

                public List<InstanceDescription> getInstances() {
                    return new LinkedList<InstanceDescription>(instances);
                }

        public String getId() {
          return "0";
        }
            };
            this.topologyView = new TopologyView() {

          public InstanceDescription getLocalInstance() {
            return myDescription;
          }

          public boolean isCurrent() {
            return true;
          }

          public Set<InstanceDescription> getInstances() {
            return instances;
          }

          public Set<InstanceDescription> findInstances(InstanceFilter picker) {
            Set<InstanceDescription> result = new HashSet<InstanceDescription>();
            for (Iterator<InstanceDescription> it = getTopology().getInstances().iterator(); it.hasNext();) {
              InstanceDescription instance = it.next();
              if (picker.accept(instance)) {
                result.add(instance);
              }
            }
            return result;
View Full Code Here

Examples of org.apache.sling.discovery.InstanceDescription

    public boolean contains(final String slingId) {
        List<InstanceDescription> localInstances = getClusterView()
                .getInstances();
        for (Iterator<InstanceDescription> it = localInstances.iterator(); it
                .hasNext();) {
            InstanceDescription aLocalInstance = it.next();
            if (aLocalInstance.getSlingId().equals(slingId)) {
                return true;
            }
        }

        return false;
View Full Code Here

Examples of org.apache.sling.discovery.InstanceDescription

    }

    public boolean containsAny(Collection<InstanceDescription> listInstances) {
        for (Iterator<InstanceDescription> it = listInstances.iterator(); it
                .hasNext();) {
            InstanceDescription instanceDescription = it.next();
            if (contains(instanceDescription.getSlingId())) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

Examples of org.apache.sling.discovery.InstanceDescription

            EstablishedClusterView clusterViewImpl = new EstablishedClusterView(
                    config, view, getSlingId());
            boolean foundLocal = false;
            for (Iterator<InstanceDescription> it = clusterViewImpl
                    .getInstances().iterator(); it.hasNext();) {
                InstanceDescription instance = it.next();
                if (instance.isLocal()) {
                    foundLocal = true;
                    break;
                }
            }
            if (foundLocal) {
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.