Search in sources :

Example 26 with InstanceInfo

use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.

the class EurekaEntityComparators method equal.

public static boolean equal(Application first, Application second) {
    if (first == second) {
        return true;
    }
    if (first == null || first == null && second != null) {
        return false;
    }
    if (first.getName() != null ? !first.getName().equals(second.getName()) : second.getName() != null) {
        return false;
    }
    List<InstanceInfo> firstInstanceInfos = first.getInstances();
    List<InstanceInfo> secondInstanceInfos = second.getInstances();
    if (firstInstanceInfos == null && secondInstanceInfos == null) {
        return true;
    }
    if (firstInstanceInfos == null || secondInstanceInfos == null || firstInstanceInfos.size() != secondInstanceInfos.size()) {
        return false;
    }
    for (InstanceInfo firstInstanceInfo : firstInstanceInfos) {
        InstanceInfo secondInstanceInfo = second.getByInstanceId(firstInstanceInfo.getId());
        if (!equal(firstInstanceInfo, secondInstanceInfo)) {
            return false;
        }
    }
    return true;
}
Also used : InstanceInfo(com.netflix.appinfo.InstanceInfo)

Example 27 with InstanceInfo

use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.

the class EurekaEntityFunctions method copyInstances.

public static void copyInstances(Collection<InstanceInfo> instances, Applications result) {
    if (instances != null) {
        for (InstanceInfo instance : instances) {
            Application app = result.getRegisteredApplications(instance.getAppName());
            if (app == null) {
                app = new Application(instance.getAppName());
                result.addApplication(app);
            }
            app.addInstance(instance);
        }
    }
}
Also used : InstanceInfo(com.netflix.appinfo.InstanceInfo) Application(com.netflix.discovery.shared.Application)

Example 28 with InstanceInfo

use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.

the class EurekaEntityFunctions method toApplications.

public static Applications toApplications(List<InstanceInfo> instances) {
    Applications result = new Applications();
    for (InstanceInfo instance : instances) {
        Application app = result.getRegisteredApplications(instance.getAppName());
        if (app == null) {
            app = new Application(instance.getAppName());
            result.addApplication(app);
        }
        app.addInstance(instance);
    }
    return updateMeta(result);
}
Also used : Applications(com.netflix.discovery.shared.Applications) InstanceInfo(com.netflix.appinfo.InstanceInfo) Application(com.netflix.discovery.shared.Application)

Example 29 with InstanceInfo

use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.

the class EurekaEntityFunctions method copyInstance.

public static InstanceInfo copyInstance(InstanceInfo original, ActionType actionType) {
    InstanceInfo copy = new InstanceInfo(original);
    copy.setActionType(actionType);
    return copy;
}
Also used : InstanceInfo(com.netflix.appinfo.InstanceInfo)

Example 30 with InstanceInfo

use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.

the class ApplicationsResolver method getClusterEndpoints.

@Override
public List<AwsEndpoint> getClusterEndpoints() {
    List<AwsEndpoint> result = new ArrayList<>();
    Applications applications = applicationsSource.getApplications(transportConfig.getApplicationsResolverDataStalenessThresholdSeconds(), TimeUnit.SECONDS);
    if (applications != null && vipAddress != null) {
        List<InstanceInfo> validInstanceInfos = applications.getInstancesByVirtualHostName(vipAddress);
        for (InstanceInfo instanceInfo : validInstanceInfos) {
            if (instanceInfo.getStatus() == InstanceInfo.InstanceStatus.UP) {
                AwsEndpoint endpoint = ResolverUtils.instanceInfoToEndpoint(clientConfig, transportConfig, instanceInfo);
                if (endpoint != null) {
                    result.add(endpoint);
                }
            }
        }
    }
    logger.debug("Retrieved endpoint list {}", result);
    return result;
}
Also used : Applications(com.netflix.discovery.shared.Applications) ArrayList(java.util.ArrayList) InstanceInfo(com.netflix.appinfo.InstanceInfo)

Aggregations

InstanceInfo (com.netflix.appinfo.InstanceInfo)192 Test (org.junit.Test)74 Application (com.netflix.discovery.shared.Application)35 Applications (com.netflix.discovery.shared.Applications)22 AmazonInfo (com.netflix.appinfo.AmazonInfo)21 ArrayList (java.util.ArrayList)19 InstanceStatus (com.netflix.appinfo.InstanceInfo.InstanceStatus)11 Before (org.junit.Before)11 DiscoveryClient (com.netflix.discovery.DiscoveryClient)10 DecoderWrapper (com.netflix.discovery.converters.wrappers.DecoderWrapper)10 Lease (com.netflix.eureka.lease.Lease)9 HashMap (java.util.HashMap)8 Response (javax.ws.rs.core.Response)8 DataCenterInfo (com.netflix.appinfo.DataCenterInfo)7 CodecWrappers (com.netflix.discovery.converters.wrappers.CodecWrappers)7 EncoderWrapper (com.netflix.discovery.converters.wrappers.EncoderWrapper)7 ByteArrayInputStream (java.io.ByteArrayInputStream)7 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)6 EurekaEntityFunctions.mergeApplications (com.netflix.discovery.util.EurekaEntityFunctions.mergeApplications)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)6