Eureka overlooks implementation of UniqueIdentifier to get instance ID

160 views
Skip to first unread message

bhe...@shaklee.com

unread,
Mar 31, 2015, 5:29:24 PM3/31/15
to eureka_...@googlegroups.com
Hi,

Been trying to register multiple instances of an application all deployed on the same host. However, Eureka is defaulting to using the hostname as the instance ID, ignoring my implementation of the UniqueIdentifier to generate my own instance id. Hence, overriding previous instance registrations. So, only one instance is registered per host.

The discovery client is initialized like this 

DiscoveryManager.getInstance().initComponent(
    new MyDataCenterInstanceConfig("eureka.", new MyDataCenterInfo()),
    new DefaultEurekaClientConfig()
);

Is there something I'm missing?

dl...@netflix.com

unread,
Apr 1, 2015, 12:02:05 AM4/1/15
to eureka_...@googlegroups.com
Hi,

Can you share the code for your custom MyDataCenterInfo? Also, are you running eureka with spring cloud or with your own custom deployments?

Thanks,
David

bhe...@shaklee.com

unread,
Apr 1, 2015, 2:21:03 PM4/1/15
to eureka_...@googlegroups.com
My own custom deployments. Using the play framework. See below for snippet.

public class MyDataCenterInfo implements DataCenterInfo, UniqueIdentifier {

    private Name name = Name.MyOwn;

    @Override
    public Name getName() {
        return name;
    }

    @Override
    public String getId() {
        Configuration config = Play.application().configuration();
        return config.getInt("application.name") + "-" + config.getString("application.name");
    }
}


Thanks.
Barry

dl...@netflix.com

unread,
Apr 1, 2015, 7:15:12 PM4/1/15
to eureka_...@googlegroups.com
Hmm that is strange. In the eureka source code (https://github.com/Netflix/eureka/blob/master/eureka-client/src/main/java/com/netflix/appinfo/InstanceInfo.java#L709) InstanceInfo.getId() should return the appropriate id if you implement UniqueIdentifier. This change should be available in eureka-client from release 1.1.127 onwards as part of this commit (https://github.com/Netflix/eureka/commit/3d2a2e555f58f9eb8b67fcc41e0dc3c61358c05a). Are you able to use a debugger to see if perhaps the InstanceInfos are not created with the appropriate dataCenters? 
Reply all
Reply to author
Forward
0 new messages