本文整理了Java中com.netflix.discovery.shared.Application.getName()
方法的一些代码示例,展示了Application.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Application.getName()
方法的具体详情如下:
包路径:com.netflix.discovery.shared.Application
类名称:Application
方法名:getName
[英]Gets the name of the application.
[中]获取应用程序的名称。
代码示例来源:origin: Netflix/eureka
public int compare(Application l, Application r) {
return l.getName().compareTo(r.getName());
}
};
代码示例来源:origin: Netflix/eureka
public static Set<String> applicationNames(Applications applications) {
Set<String> names = new HashSet<String>();
for (Application application : applications.getRegisteredApplications()) {
names.add(application.getName());
}
return names;
}
代码示例来源:origin: Netflix/eureka
/**
* Remove the <em>application</em> from the list.
*
* @param app the <em>application</em>
*/
public void removeApplication(Application app) {
this.appNameApplicationMap.remove(app.getName().toUpperCase(Locale.ROOT));
this.applications.remove(app);
}
}
代码示例来源:origin: Netflix/eureka
public static Set<String> selectApplicationNames(Applications applications) {
Set<String> result = new HashSet<>();
for (Application app : applications.getRegisteredApplications()) {
result.add(app.getName());
}
return result;
}
代码示例来源:origin: Netflix/eureka
@Override
public void serialize(Application value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
jgen.writeStartObject();
jgen.writeStringField(ELEM_NAME, value.getName());
jgen.writeObjectField(ELEM_INSTANCE, value.getInstances());
jgen.writeEndObject();
}
}
代码示例来源:origin: Netflix/eureka
/**
* Add the <em>application</em> to the list.
*
* @param app
* the <em>application</em> to be added.
*/
public void addApplication(Application app) {
appNameApplicationMap.put(app.getName().toUpperCase(Locale.ROOT), app);
addInstancesToVIPMaps(app, this.virtualHostNameAppMap, this.secureVirtualHostNameAppMap);
applications.add(app);
}
代码示例来源:origin: Netflix/eureka
public static Application copyOf(Application application) {
Application copy = new Application(application.getName());
for (InstanceInfo instance : application.getInstances()) {
copy.addInstance(instance);
}
return copy;
}
代码示例来源:origin: Netflix/eureka
public static Application copyApplication(Application application) {
Application copy = new Application(application.getName());
for (InstanceInfo instance : application.getInstances()) {
copy.addInstance(instance);
}
return copy;
}
代码示例来源:origin: Netflix/eureka
public static Application deepCopyApplication(Application source) {
Application result = new Application(source.getName());
deepCopyApplication(source, result, EurekaEntityTransformers.<InstanceInfo>identity());
return result;
}
代码示例来源:origin: Netflix/eureka
/**
* Generate pay load with both JSON and XML formats for a given application.
*/
private String getPayLoad(Key key, Application app) {
if (app == null) {
return EMPTY_PAYLOAD;
}
EncoderWrapper encoderWrapper = serverCodecs.getEncoder(key.getType(), key.getEurekaAccept());
try {
return encoderWrapper.encode(app);
} catch (Exception e) {
logger.error("Failed to encode the payload for application {}", app.getName(), e);
return "";
}
}
代码示例来源:origin: Netflix/eureka
public static void copyApplications(Applications source, Applications result) {
if (source != null) {
for (Application app : source.getRegisteredApplications()) {
result.addApplication(new Application(app.getName(), app.getInstances()));
}
}
}
代码示例来源:origin: Netflix/eureka
protected void populateLocalRegistryAtStartup() {
for (Application app : createLocalApps()) {
mockLocalEurekaServer.addLocalRegionApps(app.getName(), app);
}
for (Application appDelta : createLocalAppsDelta()) {
mockLocalEurekaServer.addLocalRegionAppsDelta(appDelta.getName(), appDelta);
}
}
代码示例来源:origin: Netflix/eureka
protected void populateRemoteRegistryAtStartup() {
for (Application app : createRemoteApps()) {
mockLocalEurekaServer.addRemoteRegionApps(app.getName(), app);
}
for (Application appDelta : createRemoteAppsDelta()) {
mockLocalEurekaServer.addRemoteRegionAppsDelta(appDelta.getName(), appDelta);
}
}
代码示例来源:origin: Netflix/eureka
@Test
public void testGetAppsFromAllRemoteRegions() throws Exception {
Applications apps = registry.getApplicationsFromAllRemoteRegions();
List<Application> registeredApplications = apps.getRegisteredApplications();
Assert.assertEquals("Apps size from remote regions do not match", 1, registeredApplications.size());
Application app = registeredApplications.iterator().next();
Assert.assertEquals("Added app did not return from remote registry", REMOTE_REGION_APP_NAME, app.getName());
Assert.assertEquals("Returned app did not have the instance", 1, app.getInstances().size());
}
代码示例来源:origin: Netflix/eureka
@Override
public void marshal(Object source, HierarchicalStreamWriter writer,
MarshallingContext context) {
Application app = (Application) source;
writer.startNode(ELEM_NAME);
writer.setValue(app.getName());
writer.endNode();
for (InstanceInfo instanceInfo : app.getInstances()) {
writer.startNode(NODE_INSTANCE);
context.convertAnother(instanceInfo);
writer.endNode();
}
}
代码示例来源:origin: Netflix/eureka
@Test
public void testFullVipGet() throws Exception {
Response response = resource.getVipResponse(
Version.V2.name(),
vipName,
MediaType.APPLICATION_JSON,
EurekaAccept.full,
Key.EntityType.VIP
);
String json = String.valueOf(response.getEntity());
DecoderWrapper decoder = CodecWrappers.getDecoder(CodecWrappers.LegacyJacksonJson.class);
Applications decodedApps = decoder.decode(json, Applications.class);
Application decodedApp = decodedApps.getRegisteredApplications(testApplication.getName());
assertThat(EurekaEntityComparators.equal(testApplication, decodedApp), is(true));
}
代码示例来源:origin: Netflix/eureka
@Test
public void testLocalOnly() throws Exception {
setUp(false);
Applications applications = client.getApplications();
List<Application> registeredApplications = applications.getRegisteredApplications();
System.out.println("***" + registeredApplications);
Assert.assertNotNull("Local region apps not found.", registeredApplications);
Assert.assertEquals("Local apps size not as expected.", 1, registeredApplications.size());
Assert.assertEquals("Local region apps not present.", LOCAL_REGION_APP_NAME, registeredApplications.get(0).getName());
}
代码示例来源:origin: Netflix/eureka
@Test
public void testGetAppsFromLocalRegionOnly() throws Exception {
registerInstanceLocally(createLocalInstance(LOCAL_REGION_INSTANCE_1_HOSTNAME));
Applications apps = registry.getApplicationsFromLocalRegionOnly();
List<Application> registeredApplications = apps.getRegisteredApplications();
Assert.assertEquals("Apps size from local region do not match", 1, registeredApplications.size());
Application app = registeredApplications.iterator().next();
Assert.assertEquals("Added app did not return from local registry", LOCAL_REGION_APP_NAME, app.getName());
Assert.assertEquals("Returned app did not have the instance", 1, app.getInstances().size());
}
代码示例来源:origin: Netflix/eureka
@Test
public void testRemoteEnabledAndQueried() throws Exception {
setUp(true);
Applications applications = client.getApplicationsForARegion(REMOTE_REGION);
List<Application> registeredApplications = applications.getRegisteredApplications();
Assert.assertNotNull("Remote region apps not found.", registeredApplications);
Assert.assertEquals("Remote apps size not as expected.", 1, registeredApplications.size());
Assert.assertEquals("Remote region apps not present.", REMOTE_REGION_APP_NAME, registeredApplications.get(0).getName());
}
代码示例来源:origin: Netflix/eureka
@Override
@Before
public void setUp() throws Exception {
super.setUp();
InstanceInfoGenerator instanceInfos = InstanceInfoGenerator.newBuilder(6, 1).build();
testApplication = instanceInfos.toApplications().getRegisteredApplications().get(0);
applicationResource = new ApplicationResource(testApplication.getName(), serverContext.getServerConfig(), serverContext.getRegistry());
for (InstanceInfo instanceInfo : testApplication.getInstances()) {
registry.register(instanceInfo, false);
}
}
内容来源于网络,如有侵权,请联系作者删除!