Java Code Examples for org.apache.brooklyn.api.location.Location#equals()

The following examples show how to use org.apache.brooklyn.api.location.Location#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalLocationManager.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
/**
 * Should ensure that the location is now managed somewhere, and known about in all the lists.
 * Returns true if the location has now become managed; false if it was already managed (anything else throws exception)
 * @param rebindPrimary true if rebinding primary, false if rebinding as copy, null if creating (not rebinding)
 */
private synchronized boolean manageNonRecursive(Location loc, ManagementTransitionMode mode) {
    Location old = locationsById.put(loc.getId(), loc);
    preRegisteredLocationsById.remove(loc.getId());

    locationTypes.put(loc.getId(), loc.getClass().getName());
    
    if (old!=null && mode.wasNotLoaded()) {
        if (old.equals(loc)) {
            log.warn("{} redundant call to start management of location {}", this, loc);
        } else {
            throw new IllegalStateException("call to manage location "+loc+" but different location "+old+" already known under that id at "+this);
        }
        return false;
    }

    if (old!=null && old!=loc) {
        // passing the transition info will ensure the right shutdown steps invoked for old instance
        unmanage(old, mode, true);
    }
    
    return true;
}
 
Example 2
Source File: PortForwardManagerImpl.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Override
public boolean forgetPortMappings(Location l) {
    List<PortMapping> result = Lists.newArrayList();
    synchronized (mutex) {
        for (Iterator<PortMapping> iter = mappings.values().iterator(); iter.hasNext();) {
            PortMapping m = iter.next();
            if (l.equals(m.target)) {
                iter.remove();
                result.add(m);
                emitAssociationDeletedEvent(associationMetadataFromPortMapping(m));
            }
        }
    }
    if (log.isDebugEnabled()) log.debug("cleared all port mappings for "+l+" - "+result);
    if (!result.isEmpty()) {
        onChanged();
    }
    return !result.isEmpty();
}
 
Example 3
Source File: DefaultFollowTheSunModel.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
private Set<ContainerType> getContainersInLocation(Location location) {
    Set<ContainerType> result = new LinkedHashSet<ContainerType>();
    for (Map.Entry<ContainerType, Location> entry : containerToLocation.entrySet()) {
        if (location.equals(entry.getValue())) {
            result.add(entry.getKey());
        }
    }
    return result;
}
 
Example 4
Source File: PortForwardManagerImpl.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@Override
public HostAndPort lookup(Location l, int privatePort) {
    synchronized (mutex) {
        for (PortMapping m: mappings.values()) {
            if (l.equals(m.target) && privatePort == m.privatePort)
                return getPublicHostAndPort(m);
        }
    }
    return null;
}
 
Example 5
Source File: PortForwardManagerImpl.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
/** returns the subset of port mappings associated with a given location */
@Override
public Collection<PortMapping> getLocationPublicIpIds(Location l) {
    List<PortMapping> result = new ArrayList<PortMapping>();
    synchronized (mutex) {
        for (PortMapping m: mappings.values())
            if (l.equals(m.getTarget())) result.add(m);
    }
    return result;
}
 
Example 6
Source File: PortForwardManagerImpl.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@Override
public PortMapping getPortMappingWithPrivateSide(Location l, int privatePort) {
    synchronized (mutex) {
        for (PortMapping m: mappings.values())
            if (l.equals(m.getTarget()) && privatePort==m.privatePort) return m;
    }
    return null;
}