com.alibaba.nacos.api.naming.NamingMaintainService Java Examples
The following examples show how to use
com.alibaba.nacos.api.naming.NamingMaintainService.
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: CacheableEventPublishingNacosServiceFactory.java From nacos-spring-project with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public void publishDeferService(ApplicationContext context) throws NacosException { setApplicationContext(context); for (DeferServiceHolder holder : deferServiceCache) { final Object o = holder.getHolder(); final Properties properties = holder.getProperties(); if (o instanceof ConfigService) { ConfigService configService = (ConfigService) o; createWorkerManager.get(ServiceType.CONFIG).run(properties, configService); } else if (o instanceof NamingService) { NamingService namingService = (NamingService) o; createWorkerManager.get(ServiceType.NAMING).run(properties, namingService); } else if (o instanceof NamingMaintainService) { NamingMaintainService maintainService = (NamingMaintainService) o; createWorkerManager.get(ServiceType.MAINTAIN).run(properties, maintainService); } } deferServiceCache.clear(); }
Example #2
Source File: CacheableEventPublishingNacosServiceFactory.java From nacos-spring-project with Apache License 2.0 | 6 votes |
@Override public NamingMaintainService run(Properties properties, NamingMaintainService service) throws NacosException { String cacheKey = identify(properties); NamingMaintainService namingMaintainService = maintainServiceCache .get(cacheKey); if (namingMaintainService == null) { if (service == null) { service = NacosFactory.createMaintainService(properties); } namingMaintainService = new DelegatingNamingMaintainService(service, properties); maintainServiceCache.put(cacheKey, namingMaintainService); } return namingMaintainService; }
Example #3
Source File: NacosDiscoveryProperties.java From spring-cloud-alibaba with Apache License 2.0 | 6 votes |
@Deprecated public NamingMaintainService namingMaintainServiceInstance() { if (null != namingMaintainService) { return namingMaintainService; } try { namingMaintainService = NamingMaintainFactory .createMaintainService(getNacosProperties()); } catch (Exception e) { log.error("create naming service error!properties={},e=,", this, e); return null; } return namingMaintainService; }
Example #4
Source File: CacheableEventPublishingNacosServiceFactory.java From nacos-spring-project with Apache License 2.0 | 5 votes |
@Override public NamingMaintainService createNamingMaintainService(Properties properties) throws NacosException { Properties copy = new Properties(); copy.putAll(properties); return (NamingMaintainService) createWorkerManager.get(ServiceType.MAINTAIN) .run(copy, null); }
Example #5
Source File: CacheableEventPublishingNacosServiceFactoryTest.java From nacos-spring-project with Apache License 2.0 | 5 votes |
@Test public void testGetNamingMaintainServices() throws NacosException { NamingMaintainService maintainService = nacosServiceFactory .createNamingMaintainService(properties); NamingMaintainService maintainService2 = nacosServiceFactory .createNamingMaintainService(properties); Assert.assertTrue(maintainService == maintainService2); Assert.assertEquals(1, nacosServiceFactory.getNamingMaintainService().size()); Assert.assertEquals(maintainService, nacosServiceFactory.getNamingMaintainService().iterator().next()); }
Example #6
Source File: DelegatingNamingMaintainService.java From nacos-spring-project with Apache License 2.0 | 4 votes |
DelegatingNamingMaintainService(NamingMaintainService delegate, Properties properties) { this.delegate = delegate; this.properties = properties; }
Example #7
Source File: CacheableEventPublishingNacosServiceFactory.java From nacos-spring-project with Apache License 2.0 | 4 votes |
@Override public Collection<NamingMaintainService> getNamingMaintainService() { return maintainServiceCache.values(); }
Example #8
Source File: NamingMaintainServiceBeanBuilder.java From nacos-spring-project with Apache License 2.0 | 4 votes |
@Override protected NamingMaintainService createService(NacosServiceFactory nacosServiceFactory, Properties properties) throws NacosException { return nacosServiceFactory.createNamingMaintainService(properties); }
Example #9
Source File: MockNacosServiceFactory.java From nacos-spring-project with Apache License 2.0 | 4 votes |
@Override public NamingMaintainService createNamingMaintainService(Properties properties) throws NacosException { return Mockito.mock(NamingMaintainService.class); }
Example #10
Source File: MockNacosServiceFactory.java From nacos-spring-project with Apache License 2.0 | 4 votes |
@Override public Collection<NamingMaintainService> getNamingMaintainService() { return Collections.emptyList(); }
Example #11
Source File: NacosServiceFactory.java From nacos-spring-project with Apache License 2.0 | 2 votes |
/** * Create {@link NamingMaintainService} instance * * @param properties init param * @return a {@link NamingMaintainService} instance * @throws NacosException If creation is failed. * @see NacosFactory#createNamingService(Properties) */ NamingMaintainService createNamingMaintainService(Properties properties) throws NacosException;
Example #12
Source File: NacosServiceFactory.java From nacos-spring-project with Apache License 2.0 | 2 votes |
/** * Get all instances of {@link NamingMaintainService} * * @return read-only {@link Collection} */ Collection<NamingMaintainService> getNamingMaintainService();