Java Code Examples for com.alipay.sofa.rpc.config.ProviderConfig#isRegister()
The following examples show how to use
com.alipay.sofa.rpc.config.ProviderConfig#isRegister() .
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: Curator4ZookeeperRegistry.java From spring-cloud-sofastack-samples with Apache License 2.0 | 6 votes |
@Override public void register(ProviderConfig config) { String appName = config.getAppName(); if (!registryConfig.isRegister()) { if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_CONFREG_IGNORE)); } return; } //发布 if (config.isRegister()) { registerProviderUrls(config); } if (config.isSubscribe()) { // 订阅配置节点 if (!INTERFACE_CONFIG_CACHE.containsKey(buildConfigPath(rootPath, config))) { //订阅接口级配置 subscribeConfig(config, config.getConfigListener()); } } }
Example 2
Source File: ZookeeperRegistry.java From sofa-rpc with Apache License 2.0 | 6 votes |
@Override public void register(ProviderConfig config) { String appName = config.getAppName(); if (!registryConfig.isRegister()) { if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_REGISTRY_IGNORE)); } return; } //发布 if (config.isRegister()) { registerProviderUrls(config); } if (config.isSubscribe()) { // 订阅配置节点 if (!INTERFACE_CONFIG_CACHE.containsKey(buildConfigPath(rootPath, config))) { //订阅接口级配置 subscribeConfig(config, config.getConfigListener()); } } }
Example 3
Source File: MulticastRegistry.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public void register(ProviderConfig config) { String appName = config.getAppName(); if (!registryConfig.isRegister()) { if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_REGISTRY_IGNORE)); } return; } if (config.isRegister()) { List<ServerConfig> serverConfigs = config.getServer(); if (CommonUtils.isNotEmpty(serverConfigs)) { for (ServerConfig server : serverConfigs) { String serviceName = MulticastRegistryHelper.buildListDataId(config, server.getProtocol()); ProviderInfo providerInfo = MulticastRegistryHelper.convertProviderToProviderInfo(config, server); if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_PUB_START, serviceName)); } doRegister(appName, serviceName, providerInfo); if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_PUB_OVER, serviceName)); } } if (EventBus.isEnable(ProviderPubEvent.class)) { ProviderPubEvent event = new ProviderPubEvent(config); EventBus.post(event); } } } }
Example 4
Source File: MulticastRegistry.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public void unRegister(ProviderConfig config) { String appName = config.getAppName(); if (!registryConfig.isRegister()) { // 注册中心不注册 if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_REGISTRY_IGNORE)); } return; } if (config.isRegister()) { // 服务不注册 List<ServerConfig> serverConfigs = config.getServer(); if (CommonUtils.isNotEmpty(serverConfigs)) { for (ServerConfig server : serverConfigs) { String serviceName = MulticastRegistryHelper.buildListDataId(config, server.getProtocol()); ProviderInfo providerInfo = MulticastRegistryHelper.convertProviderToProviderInfo(config, server); try { doUnRegister(serviceName, providerInfo); if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_UNPUB, serviceName, "1")); } } catch (Exception e) { LOGGER.errorWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_UNPUB, serviceName, "0"), e); } } } } }
Example 5
Source File: ConsulRegistry.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public void unRegister(ProviderConfig config) { String appName = config.getAppName(); if (!registryConfig.isRegister()) { // 注册中心不注册 if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_REGISTRY_IGNORE)); } return; } // 反注册服务端节点 if (!config.isRegister()) { return; } try { List<String> ids = buildServiceIds(config); if (CommonUtils.isNotEmpty(ids)) { ids.forEach(this::deregisterConsulService); if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_UNPUB, config.getInterfaceId(), ids.size())); } } } catch (Exception e) { if (!RpcRunningState.isShuttingDown()) { if ( e instanceof SofaRpcRuntimeException){ throw e; }else{ throw new SofaRpcRuntimeException(LogCodes.getLog(LogCodes.ERROR_UNREG_PROVIDER ,EXT_NAME), e); }} } }
Example 6
Source File: LocalRegistry.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public void register(ProviderConfig config) { String appName = config.getAppName(); if (!registryConfig.isRegister()) { if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_REGISTRY_IGNORE)); } return; } if (!config.isRegister()) { // 注册中心不注册或者服务不注册 return; } List<ServerConfig> serverConfigs = config.getServer(); if (CommonUtils.isNotEmpty(serverConfigs)) { for (ServerConfig server : serverConfigs) { String serviceName = LocalRegistryHelper.buildListDataId(config, server.getProtocol()); ProviderInfo providerInfo = LocalRegistryHelper.convertProviderToProviderInfo(config, server); if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_PUB_START, serviceName)); } doRegister(appName, serviceName, providerInfo); if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_PUB_OVER, serviceName)); } } if (EventBus.isEnable(ProviderPubEvent.class)) { ProviderPubEvent event = new ProviderPubEvent(config); EventBus.post(event); } } }
Example 7
Source File: LocalRegistry.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public void unRegister(ProviderConfig config) { String appName = config.getAppName(); if (!registryConfig.isRegister()) { // 注册中心不注册 if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_REGISTRY_IGNORE)); } return; } if (!config.isRegister()) { // 服务不注册 return; } List<ServerConfig> serverConfigs = config.getServer(); if (CommonUtils.isNotEmpty(serverConfigs)) { for (ServerConfig server : serverConfigs) { String serviceName = LocalRegistryHelper.buildListDataId(config, server.getProtocol()); ProviderInfo providerInfo = LocalRegistryHelper.convertProviderToProviderInfo(config, server); try { doUnRegister(serviceName, providerInfo); if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_UNPUB, serviceName, "1")); } } catch (Exception e) { LOGGER.errorWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_UNPUB, serviceName, "0"), e); } } } }
Example 8
Source File: SofaRegistry.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public void register(ProviderConfig config) { String appName = config.getAppName(); if (!registryConfig.isRegister()) { if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_REGISTRY_IGNORE)); } return; } if (!config.isRegister()) { // 注册中心不注册或者服务不注册 return; } List<ServerConfig> serverConfigs = config.getServer(); if (CommonUtils.isNotEmpty(serverConfigs)) { for (ServerConfig server : serverConfigs) { String serviceName = SofaRegistryHelper.buildListDataId(config, server.getProtocol()); String serviceData = SofaRegistryHelper.convertProviderToUrls(config, server); if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_PUB_START, serviceName)); } String groupId = config.getParameter(SofaRegistryConstants.SOFA_GROUP_KEY); groupId = groupId == null ? SofaRegistryHelper.SUBSCRIBER_LIST_GROUP_ID : groupId; doRegister(appName, serviceName, serviceData, groupId); if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_PUB_OVER, serviceName)); } } } }
Example 9
Source File: SofaRegistry.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public void unRegister(ProviderConfig config) { String appName = config.getAppName(); if (!registryConfig.isRegister()) { // 注册中心不注册 if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_REGISTRY_IGNORE)); } return; } if (!config.isRegister()) { // 服务不注册 return; } List<ServerConfig> serverConfigs = config.getServer(); if (CommonUtils.isNotEmpty(serverConfigs)) { for (ServerConfig server : serverConfigs) { String serviceName = SofaRegistryHelper.buildListDataId(config, server.getProtocol()); try { String groupId = config.getParameter(SofaRegistryConstants.SOFA_GROUP_KEY); groupId = groupId == null ? SofaRegistryHelper.SUBSCRIBER_LIST_GROUP_ID : groupId; doUnRegister(appName, serviceName, groupId); if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_UNPUB, serviceName, "1")); } } catch (Exception e) { LOGGER.errorWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_UNPUB, serviceName, "0"), e); } } } }
Example 10
Source File: NacosRegistry.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public void unRegister(ProviderConfig config) { String appName = config.getAppName(); if (!registryConfig.isRegister()) { // registry ignored if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_REGISTRY_IGNORE)); } return; } // unregister publisher if (config.isRegister()) { try { List<Instance> instances = providerInstances.remove(config); if (CommonUtils.isNotEmpty(instances)) { for (Instance instance : instances) { String serviceName = instance.getServiceName(); namingService.deregisterInstance(serviceName, instance.getIp(), instance.getPort(), instance.getClusterName()); if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_UNPUB, serviceName, instances.size())); } } } } catch (Exception e) { if (!RpcRunningState.isShuttingDown()) { if (e instanceof SofaRpcRuntimeException) { throw (SofaRpcRuntimeException) e; } else { throw new SofaRpcRuntimeException(LogCodes.getLog(LogCodes.ERROR_UNREG_PROVIDER, EXT_NAME), e); } } } } }
Example 11
Source File: MeshRegistry.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public void register(ProviderConfig config) { String appName = config.getAppName(); if (!registryConfig.isRegister()) { if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_REGISTRY_IGNORE)); } return; } if (!config.isRegister()) { // 注册中心不注册或者服务不注册 return; } List<ServerConfig> serverConfigs = config.getServer(); if (CommonUtils.isNotEmpty(serverConfigs)) { for (ServerConfig server : serverConfigs) { String serviceName = MeshRegistryHelper.buildMeshKey(config, server.getProtocol()); ProviderInfo providerInfo = MeshRegistryHelper.convertProviderToProviderInfo(config, server); if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_PUB_START, serviceName)); } doRegister(appName, serviceName, providerInfo, server.getProtocol()); if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_PUB_OVER, serviceName)); } } if (EventBus.isEnable(ProviderPubEvent.class)) { ProviderPubEvent event = new ProviderPubEvent(config); EventBus.post(event); } } }
Example 12
Source File: MeshRegistry.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public void unRegister(ProviderConfig config) { String appName = config.getAppName(); if (!registryConfig.isRegister()) { // 注册中心不注册 if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_REGISTRY_IGNORE)); } return; } if (!config.isRegister()) { // 服务不注册 return; } List<ServerConfig> serverConfigs = config.getServer(); if (CommonUtils.isNotEmpty(serverConfigs)) { for (ServerConfig server : serverConfigs) { String serviceName = MeshRegistryHelper.buildMeshKey(config, server.getProtocol()); ProviderInfo providerInfo = MeshRegistryHelper.convertProviderToProviderInfo(config, server); try { doUnRegister(serviceName, providerInfo); if (LOGGER.isInfoEnabled(appName)) { LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_UNPUB, serviceName, "1")); } } catch (Exception e) { LOGGER.errorWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_UNPUB, serviceName, "0"), e); } } } }