From 68def260e8a4b08615641d978034c0b00179df7a Mon Sep 17 00:00:00 2001 From: slievrly Date: Tue, 7 Nov 2023 19:52:13 +0800 Subject: [PATCH 01/12] optimize: add fail over doc --- docs/v2/guide/user/failover.md | 1 + .../current/v2/guide/user/failover.md | 144 ++++++++++++++++++ .../version-1.X/v2/guide/user/failover.md | 144 ++++++++++++++++++ .../version-2.X/v2/guide/user/failover.md | 144 ++++++++++++++++++ .../current/failover.md | 144 ++++++++++++++++++ .../version-1.X/failover.md | 144 ++++++++++++++++++ .../version-2.X/failover.md | 144 ++++++++++++++++++ sidebars.js | 2 +- .../version-1.X/v2/guide/user/failover.md | 1 + .../version-2.X/v2/guide/user/failover.md | 1 + versioned_sidebars/version-1.X-sidebars.json | 3 +- versioned_sidebars/version-2.X-sidebars.json | 3 +- 12 files changed, 872 insertions(+), 3 deletions(-) create mode 100644 docs/v2/guide/user/failover.md create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md create mode 100644 i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md create mode 100644 i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md create mode 100644 i18n/zh-cn/docusaurus-plugin-content-docs/current/failover.md create mode 100644 i18n/zh-cn/docusaurus-plugin-content-docs/version-1.X/failover.md create mode 100644 i18n/zh-cn/docusaurus-plugin-content-docs/version-2.X/failover.md create mode 100644 versioned_docs/version-1.X/v2/guide/user/failover.md create mode 100644 versioned_docs/version-2.X/v2/guide/user/failover.md diff --git a/docs/v2/guide/user/failover.md b/docs/v2/guide/user/failover.md new file mode 100644 index 00000000000..e872b67af1f --- /dev/null +++ b/docs/v2/guide/user/failover.md @@ -0,0 +1 @@ +Placeholder. DO NOT DELETE. \ No newline at end of file diff --git a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md new file mode 100644 index 00000000000..255264c5694 --- /dev/null +++ b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md @@ -0,0 +1,144 @@ +--- +title: Java Client Failover +keywords: [Failover] +description: Java client failover user guide +--- + +# Java Client Failover + +We can turn on the local data failover feature to handle the situation when Nacos server side is unstable or has problematic data. + +There are two typical scenarios: + +1. When Nacos server is in deployment, we can switch on the failover so the clients use local data only. The data anomaly or oscillation at Nacos server won't affect the clients. After the deployment and the data verification are done, we can switch off the failover feature. +2. When there is a sudden data anomaly at Nacos server at runtime, we can turn on the failover feature to prevent Nacos clients using wrong data. + +The full detailed solution description can be found in https://github.com/alibaba/nacos/issues/11053 + +## Procedures + +image + +As shown above, the query requests to Nacos client would first be checked by FailoverReactor, and only if FailoverReactor has no related data, can the requests move on to query ServiceInfoHolder. + +## Disk based Failover + +FailoverReactor can select different data sources. Disk is the default option. + +### Disk Failover File Path + +The default path of disk failover files are: + +``` +{user.home}/nacos/naming/{namespace}/failover +``` + +This path can be customised via -D argument: + +``` +-DJM.SNAPSHOT.PATH=/mypath +``` + +So the path becomes: + +``` +/mypath/nacos/naming/{namespace}/failover +``` + +### Disk Failover Switch + +The disk failover switch is stored in a file with name: + +``` +00-00---000-VIPSRV_FAILOVER_SWITCH-000---00-00 +``` + +The content of this file is just a number 0 or 1, where 0 represents failover is off, 1 is on. + +### Disk Failover Data + +The disk failover data is stored in multiple files under the failover path. Each file stores the failover data for a single service. + +The file name is in the following format: + +``` +{group.name}%40%40{service.name} +``` +The content in the file is the JSON string of one ServiceInfo object, for instance: + +``` +{ + "name":"DEFAULT_GROUP@@test.2", + "groupName":"DEFAULT_GROUP", + "clusters":"", + "cacheMillis":10000, + "hosts":[ + { + "instanceId":"1.1.2.1#8888#DEFAULT#DEFAULT_GROUP@@test.2", + "ip":"1.1.2.1", + "port":8888, + "weight":1, + "healthy":true, + "enabled":true, + "ephemeral":true, + "clusterName":"DEFAULT", + "serviceName":"DEFAULT_GROUP@@test.2", + "metadata":{ + "k1":"v1" + }, + "instanceHeartBeatInterval":5000, + "instanceHeartBeatTimeOut":15000, + "ipDeleteTimeout":30000 + } + ], + "lastRefTime":1689835375819, + "checksum":"", + "allIPs":false, + "reachProtectionThreshold":false, + "valid":true +} +``` + +## Extent Failover Data Source + +Disk failover is simple and requires no extra remote components. But sometimes we may want to use another kind of data source, such as Redis, Mysql, etc. + +Now we support extending the failover data source with SPI mechanism. Here are the steps: + +### Develop Your Own Failover Data Source + +Write a class and implement the interface com.alibaba.nacos.client.naming.backups.FailoverDataSource: + +``` +public class MyFailoverDataSource implements FailoverDataSource { + + @Override + public FailoverSwitch getSwitch() { + // TODO write your own implementation. + return null; + } + + @Override + public Map getFailoverData() { + // TODO write your own implementation. For naming module, the map + // should contain failover data with service name as key and ServiceInfo as value + return null; + } +} +``` + +### Configure Failover Data Source Class + +Create a file under the resource root path: + +``` +{resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource +``` + +One example of {resource.root} is src/main/resources. + +The file content is: + +``` +your.package.MyFailoverDataSource +``` \ No newline at end of file diff --git a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md new file mode 100644 index 00000000000..255264c5694 --- /dev/null +++ b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md @@ -0,0 +1,144 @@ +--- +title: Java Client Failover +keywords: [Failover] +description: Java client failover user guide +--- + +# Java Client Failover + +We can turn on the local data failover feature to handle the situation when Nacos server side is unstable or has problematic data. + +There are two typical scenarios: + +1. When Nacos server is in deployment, we can switch on the failover so the clients use local data only. The data anomaly or oscillation at Nacos server won't affect the clients. After the deployment and the data verification are done, we can switch off the failover feature. +2. When there is a sudden data anomaly at Nacos server at runtime, we can turn on the failover feature to prevent Nacos clients using wrong data. + +The full detailed solution description can be found in https://github.com/alibaba/nacos/issues/11053 + +## Procedures + +image + +As shown above, the query requests to Nacos client would first be checked by FailoverReactor, and only if FailoverReactor has no related data, can the requests move on to query ServiceInfoHolder. + +## Disk based Failover + +FailoverReactor can select different data sources. Disk is the default option. + +### Disk Failover File Path + +The default path of disk failover files are: + +``` +{user.home}/nacos/naming/{namespace}/failover +``` + +This path can be customised via -D argument: + +``` +-DJM.SNAPSHOT.PATH=/mypath +``` + +So the path becomes: + +``` +/mypath/nacos/naming/{namespace}/failover +``` + +### Disk Failover Switch + +The disk failover switch is stored in a file with name: + +``` +00-00---000-VIPSRV_FAILOVER_SWITCH-000---00-00 +``` + +The content of this file is just a number 0 or 1, where 0 represents failover is off, 1 is on. + +### Disk Failover Data + +The disk failover data is stored in multiple files under the failover path. Each file stores the failover data for a single service. + +The file name is in the following format: + +``` +{group.name}%40%40{service.name} +``` +The content in the file is the JSON string of one ServiceInfo object, for instance: + +``` +{ + "name":"DEFAULT_GROUP@@test.2", + "groupName":"DEFAULT_GROUP", + "clusters":"", + "cacheMillis":10000, + "hosts":[ + { + "instanceId":"1.1.2.1#8888#DEFAULT#DEFAULT_GROUP@@test.2", + "ip":"1.1.2.1", + "port":8888, + "weight":1, + "healthy":true, + "enabled":true, + "ephemeral":true, + "clusterName":"DEFAULT", + "serviceName":"DEFAULT_GROUP@@test.2", + "metadata":{ + "k1":"v1" + }, + "instanceHeartBeatInterval":5000, + "instanceHeartBeatTimeOut":15000, + "ipDeleteTimeout":30000 + } + ], + "lastRefTime":1689835375819, + "checksum":"", + "allIPs":false, + "reachProtectionThreshold":false, + "valid":true +} +``` + +## Extent Failover Data Source + +Disk failover is simple and requires no extra remote components. But sometimes we may want to use another kind of data source, such as Redis, Mysql, etc. + +Now we support extending the failover data source with SPI mechanism. Here are the steps: + +### Develop Your Own Failover Data Source + +Write a class and implement the interface com.alibaba.nacos.client.naming.backups.FailoverDataSource: + +``` +public class MyFailoverDataSource implements FailoverDataSource { + + @Override + public FailoverSwitch getSwitch() { + // TODO write your own implementation. + return null; + } + + @Override + public Map getFailoverData() { + // TODO write your own implementation. For naming module, the map + // should contain failover data with service name as key and ServiceInfo as value + return null; + } +} +``` + +### Configure Failover Data Source Class + +Create a file under the resource root path: + +``` +{resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource +``` + +One example of {resource.root} is src/main/resources. + +The file content is: + +``` +your.package.MyFailoverDataSource +``` \ No newline at end of file diff --git a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md new file mode 100644 index 00000000000..255264c5694 --- /dev/null +++ b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md @@ -0,0 +1,144 @@ +--- +title: Java Client Failover +keywords: [Failover] +description: Java client failover user guide +--- + +# Java Client Failover + +We can turn on the local data failover feature to handle the situation when Nacos server side is unstable or has problematic data. + +There are two typical scenarios: + +1. When Nacos server is in deployment, we can switch on the failover so the clients use local data only. The data anomaly or oscillation at Nacos server won't affect the clients. After the deployment and the data verification are done, we can switch off the failover feature. +2. When there is a sudden data anomaly at Nacos server at runtime, we can turn on the failover feature to prevent Nacos clients using wrong data. + +The full detailed solution description can be found in https://github.com/alibaba/nacos/issues/11053 + +## Procedures + +image + +As shown above, the query requests to Nacos client would first be checked by FailoverReactor, and only if FailoverReactor has no related data, can the requests move on to query ServiceInfoHolder. + +## Disk based Failover + +FailoverReactor can select different data sources. Disk is the default option. + +### Disk Failover File Path + +The default path of disk failover files are: + +``` +{user.home}/nacos/naming/{namespace}/failover +``` + +This path can be customised via -D argument: + +``` +-DJM.SNAPSHOT.PATH=/mypath +``` + +So the path becomes: + +``` +/mypath/nacos/naming/{namespace}/failover +``` + +### Disk Failover Switch + +The disk failover switch is stored in a file with name: + +``` +00-00---000-VIPSRV_FAILOVER_SWITCH-000---00-00 +``` + +The content of this file is just a number 0 or 1, where 0 represents failover is off, 1 is on. + +### Disk Failover Data + +The disk failover data is stored in multiple files under the failover path. Each file stores the failover data for a single service. + +The file name is in the following format: + +``` +{group.name}%40%40{service.name} +``` +The content in the file is the JSON string of one ServiceInfo object, for instance: + +``` +{ + "name":"DEFAULT_GROUP@@test.2", + "groupName":"DEFAULT_GROUP", + "clusters":"", + "cacheMillis":10000, + "hosts":[ + { + "instanceId":"1.1.2.1#8888#DEFAULT#DEFAULT_GROUP@@test.2", + "ip":"1.1.2.1", + "port":8888, + "weight":1, + "healthy":true, + "enabled":true, + "ephemeral":true, + "clusterName":"DEFAULT", + "serviceName":"DEFAULT_GROUP@@test.2", + "metadata":{ + "k1":"v1" + }, + "instanceHeartBeatInterval":5000, + "instanceHeartBeatTimeOut":15000, + "ipDeleteTimeout":30000 + } + ], + "lastRefTime":1689835375819, + "checksum":"", + "allIPs":false, + "reachProtectionThreshold":false, + "valid":true +} +``` + +## Extent Failover Data Source + +Disk failover is simple and requires no extra remote components. But sometimes we may want to use another kind of data source, such as Redis, Mysql, etc. + +Now we support extending the failover data source with SPI mechanism. Here are the steps: + +### Develop Your Own Failover Data Source + +Write a class and implement the interface com.alibaba.nacos.client.naming.backups.FailoverDataSource: + +``` +public class MyFailoverDataSource implements FailoverDataSource { + + @Override + public FailoverSwitch getSwitch() { + // TODO write your own implementation. + return null; + } + + @Override + public Map getFailoverData() { + // TODO write your own implementation. For naming module, the map + // should contain failover data with service name as key and ServiceInfo as value + return null; + } +} +``` + +### Configure Failover Data Source Class + +Create a file under the resource root path: + +``` +{resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource +``` + +One example of {resource.root} is src/main/resources. + +The file content is: + +``` +your.package.MyFailoverDataSource +``` \ No newline at end of file diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/failover.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/failover.md new file mode 100644 index 00000000000..255264c5694 --- /dev/null +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/failover.md @@ -0,0 +1,144 @@ +--- +title: Java Client Failover +keywords: [Failover] +description: Java client failover user guide +--- + +# Java Client Failover + +We can turn on the local data failover feature to handle the situation when Nacos server side is unstable or has problematic data. + +There are two typical scenarios: + +1. When Nacos server is in deployment, we can switch on the failover so the clients use local data only. The data anomaly or oscillation at Nacos server won't affect the clients. After the deployment and the data verification are done, we can switch off the failover feature. +2. When there is a sudden data anomaly at Nacos server at runtime, we can turn on the failover feature to prevent Nacos clients using wrong data. + +The full detailed solution description can be found in https://github.com/alibaba/nacos/issues/11053 + +## Procedures + +image + +As shown above, the query requests to Nacos client would first be checked by FailoverReactor, and only if FailoverReactor has no related data, can the requests move on to query ServiceInfoHolder. + +## Disk based Failover + +FailoverReactor can select different data sources. Disk is the default option. + +### Disk Failover File Path + +The default path of disk failover files are: + +``` +{user.home}/nacos/naming/{namespace}/failover +``` + +This path can be customised via -D argument: + +``` +-DJM.SNAPSHOT.PATH=/mypath +``` + +So the path becomes: + +``` +/mypath/nacos/naming/{namespace}/failover +``` + +### Disk Failover Switch + +The disk failover switch is stored in a file with name: + +``` +00-00---000-VIPSRV_FAILOVER_SWITCH-000---00-00 +``` + +The content of this file is just a number 0 or 1, where 0 represents failover is off, 1 is on. + +### Disk Failover Data + +The disk failover data is stored in multiple files under the failover path. Each file stores the failover data for a single service. + +The file name is in the following format: + +``` +{group.name}%40%40{service.name} +``` +The content in the file is the JSON string of one ServiceInfo object, for instance: + +``` +{ + "name":"DEFAULT_GROUP@@test.2", + "groupName":"DEFAULT_GROUP", + "clusters":"", + "cacheMillis":10000, + "hosts":[ + { + "instanceId":"1.1.2.1#8888#DEFAULT#DEFAULT_GROUP@@test.2", + "ip":"1.1.2.1", + "port":8888, + "weight":1, + "healthy":true, + "enabled":true, + "ephemeral":true, + "clusterName":"DEFAULT", + "serviceName":"DEFAULT_GROUP@@test.2", + "metadata":{ + "k1":"v1" + }, + "instanceHeartBeatInterval":5000, + "instanceHeartBeatTimeOut":15000, + "ipDeleteTimeout":30000 + } + ], + "lastRefTime":1689835375819, + "checksum":"", + "allIPs":false, + "reachProtectionThreshold":false, + "valid":true +} +``` + +## Extent Failover Data Source + +Disk failover is simple and requires no extra remote components. But sometimes we may want to use another kind of data source, such as Redis, Mysql, etc. + +Now we support extending the failover data source with SPI mechanism. Here are the steps: + +### Develop Your Own Failover Data Source + +Write a class and implement the interface com.alibaba.nacos.client.naming.backups.FailoverDataSource: + +``` +public class MyFailoverDataSource implements FailoverDataSource { + + @Override + public FailoverSwitch getSwitch() { + // TODO write your own implementation. + return null; + } + + @Override + public Map getFailoverData() { + // TODO write your own implementation. For naming module, the map + // should contain failover data with service name as key and ServiceInfo as value + return null; + } +} +``` + +### Configure Failover Data Source Class + +Create a file under the resource root path: + +``` +{resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource +``` + +One example of {resource.root} is src/main/resources. + +The file content is: + +``` +your.package.MyFailoverDataSource +``` \ No newline at end of file diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-1.X/failover.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-1.X/failover.md new file mode 100644 index 00000000000..255264c5694 --- /dev/null +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-1.X/failover.md @@ -0,0 +1,144 @@ +--- +title: Java Client Failover +keywords: [Failover] +description: Java client failover user guide +--- + +# Java Client Failover + +We can turn on the local data failover feature to handle the situation when Nacos server side is unstable or has problematic data. + +There are two typical scenarios: + +1. When Nacos server is in deployment, we can switch on the failover so the clients use local data only. The data anomaly or oscillation at Nacos server won't affect the clients. After the deployment and the data verification are done, we can switch off the failover feature. +2. When there is a sudden data anomaly at Nacos server at runtime, we can turn on the failover feature to prevent Nacos clients using wrong data. + +The full detailed solution description can be found in https://github.com/alibaba/nacos/issues/11053 + +## Procedures + +image + +As shown above, the query requests to Nacos client would first be checked by FailoverReactor, and only if FailoverReactor has no related data, can the requests move on to query ServiceInfoHolder. + +## Disk based Failover + +FailoverReactor can select different data sources. Disk is the default option. + +### Disk Failover File Path + +The default path of disk failover files are: + +``` +{user.home}/nacos/naming/{namespace}/failover +``` + +This path can be customised via -D argument: + +``` +-DJM.SNAPSHOT.PATH=/mypath +``` + +So the path becomes: + +``` +/mypath/nacos/naming/{namespace}/failover +``` + +### Disk Failover Switch + +The disk failover switch is stored in a file with name: + +``` +00-00---000-VIPSRV_FAILOVER_SWITCH-000---00-00 +``` + +The content of this file is just a number 0 or 1, where 0 represents failover is off, 1 is on. + +### Disk Failover Data + +The disk failover data is stored in multiple files under the failover path. Each file stores the failover data for a single service. + +The file name is in the following format: + +``` +{group.name}%40%40{service.name} +``` +The content in the file is the JSON string of one ServiceInfo object, for instance: + +``` +{ + "name":"DEFAULT_GROUP@@test.2", + "groupName":"DEFAULT_GROUP", + "clusters":"", + "cacheMillis":10000, + "hosts":[ + { + "instanceId":"1.1.2.1#8888#DEFAULT#DEFAULT_GROUP@@test.2", + "ip":"1.1.2.1", + "port":8888, + "weight":1, + "healthy":true, + "enabled":true, + "ephemeral":true, + "clusterName":"DEFAULT", + "serviceName":"DEFAULT_GROUP@@test.2", + "metadata":{ + "k1":"v1" + }, + "instanceHeartBeatInterval":5000, + "instanceHeartBeatTimeOut":15000, + "ipDeleteTimeout":30000 + } + ], + "lastRefTime":1689835375819, + "checksum":"", + "allIPs":false, + "reachProtectionThreshold":false, + "valid":true +} +``` + +## Extent Failover Data Source + +Disk failover is simple and requires no extra remote components. But sometimes we may want to use another kind of data source, such as Redis, Mysql, etc. + +Now we support extending the failover data source with SPI mechanism. Here are the steps: + +### Develop Your Own Failover Data Source + +Write a class and implement the interface com.alibaba.nacos.client.naming.backups.FailoverDataSource: + +``` +public class MyFailoverDataSource implements FailoverDataSource { + + @Override + public FailoverSwitch getSwitch() { + // TODO write your own implementation. + return null; + } + + @Override + public Map getFailoverData() { + // TODO write your own implementation. For naming module, the map + // should contain failover data with service name as key and ServiceInfo as value + return null; + } +} +``` + +### Configure Failover Data Source Class + +Create a file under the resource root path: + +``` +{resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource +``` + +One example of {resource.root} is src/main/resources. + +The file content is: + +``` +your.package.MyFailoverDataSource +``` \ No newline at end of file diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-2.X/failover.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-2.X/failover.md new file mode 100644 index 00000000000..255264c5694 --- /dev/null +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-2.X/failover.md @@ -0,0 +1,144 @@ +--- +title: Java Client Failover +keywords: [Failover] +description: Java client failover user guide +--- + +# Java Client Failover + +We can turn on the local data failover feature to handle the situation when Nacos server side is unstable or has problematic data. + +There are two typical scenarios: + +1. When Nacos server is in deployment, we can switch on the failover so the clients use local data only. The data anomaly or oscillation at Nacos server won't affect the clients. After the deployment and the data verification are done, we can switch off the failover feature. +2. When there is a sudden data anomaly at Nacos server at runtime, we can turn on the failover feature to prevent Nacos clients using wrong data. + +The full detailed solution description can be found in https://github.com/alibaba/nacos/issues/11053 + +## Procedures + +image + +As shown above, the query requests to Nacos client would first be checked by FailoverReactor, and only if FailoverReactor has no related data, can the requests move on to query ServiceInfoHolder. + +## Disk based Failover + +FailoverReactor can select different data sources. Disk is the default option. + +### Disk Failover File Path + +The default path of disk failover files are: + +``` +{user.home}/nacos/naming/{namespace}/failover +``` + +This path can be customised via -D argument: + +``` +-DJM.SNAPSHOT.PATH=/mypath +``` + +So the path becomes: + +``` +/mypath/nacos/naming/{namespace}/failover +``` + +### Disk Failover Switch + +The disk failover switch is stored in a file with name: + +``` +00-00---000-VIPSRV_FAILOVER_SWITCH-000---00-00 +``` + +The content of this file is just a number 0 or 1, where 0 represents failover is off, 1 is on. + +### Disk Failover Data + +The disk failover data is stored in multiple files under the failover path. Each file stores the failover data for a single service. + +The file name is in the following format: + +``` +{group.name}%40%40{service.name} +``` +The content in the file is the JSON string of one ServiceInfo object, for instance: + +``` +{ + "name":"DEFAULT_GROUP@@test.2", + "groupName":"DEFAULT_GROUP", + "clusters":"", + "cacheMillis":10000, + "hosts":[ + { + "instanceId":"1.1.2.1#8888#DEFAULT#DEFAULT_GROUP@@test.2", + "ip":"1.1.2.1", + "port":8888, + "weight":1, + "healthy":true, + "enabled":true, + "ephemeral":true, + "clusterName":"DEFAULT", + "serviceName":"DEFAULT_GROUP@@test.2", + "metadata":{ + "k1":"v1" + }, + "instanceHeartBeatInterval":5000, + "instanceHeartBeatTimeOut":15000, + "ipDeleteTimeout":30000 + } + ], + "lastRefTime":1689835375819, + "checksum":"", + "allIPs":false, + "reachProtectionThreshold":false, + "valid":true +} +``` + +## Extent Failover Data Source + +Disk failover is simple and requires no extra remote components. But sometimes we may want to use another kind of data source, such as Redis, Mysql, etc. + +Now we support extending the failover data source with SPI mechanism. Here are the steps: + +### Develop Your Own Failover Data Source + +Write a class and implement the interface com.alibaba.nacos.client.naming.backups.FailoverDataSource: + +``` +public class MyFailoverDataSource implements FailoverDataSource { + + @Override + public FailoverSwitch getSwitch() { + // TODO write your own implementation. + return null; + } + + @Override + public Map getFailoverData() { + // TODO write your own implementation. For naming module, the map + // should contain failover data with service name as key and ServiceInfo as value + return null; + } +} +``` + +### Configure Failover Data Source Class + +Create a file under the resource root path: + +``` +{resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource +``` + +One example of {resource.root} is src/main/resources. + +The file content is: + +``` +your.package.MyFailoverDataSource +``` \ No newline at end of file diff --git a/sidebars.js b/sidebars.js index 16a0fdd3bc8..ed12ae56692 100644 --- a/sidebars.js +++ b/sidebars.js @@ -43,7 +43,7 @@ const sidebars = { type: 'category', label: 'User Guide', collapsible: false, - items: ['v2/guide/user/sdk', 'v2/guide/user/other-language', 'v2/guide/user/open-api','v2/guide/user/auth','v2/guide/user/faq','v2/guide/user/parameters-check'], + items: ['v2/guide/user/sdk', 'v2/guide/user/other-language', 'v2/guide/user/open-api','v2/guide/user/auth','v2/guide/user/faq','v2/guide/user/parameters-check','v2/guide/user/failover'], }, { type: 'category', diff --git a/versioned_docs/version-1.X/v2/guide/user/failover.md b/versioned_docs/version-1.X/v2/guide/user/failover.md new file mode 100644 index 00000000000..e872b67af1f --- /dev/null +++ b/versioned_docs/version-1.X/v2/guide/user/failover.md @@ -0,0 +1 @@ +Placeholder. DO NOT DELETE. \ No newline at end of file diff --git a/versioned_docs/version-2.X/v2/guide/user/failover.md b/versioned_docs/version-2.X/v2/guide/user/failover.md new file mode 100644 index 00000000000..e872b67af1f --- /dev/null +++ b/versioned_docs/version-2.X/v2/guide/user/failover.md @@ -0,0 +1 @@ +Placeholder. DO NOT DELETE. \ No newline at end of file diff --git a/versioned_sidebars/version-1.X-sidebars.json b/versioned_sidebars/version-1.X-sidebars.json index ee0788bc1b4..f978cf44478 100644 --- a/versioned_sidebars/version-1.X-sidebars.json +++ b/versioned_sidebars/version-1.X-sidebars.json @@ -50,7 +50,8 @@ "v2/guide/user/other-language", "v2/guide/user/open-api", "v2/guide/user/auth", - "v2/guide/user/faq" + "v2/guide/user/faq", + "v2/guide/user/failover" ] }, { diff --git a/versioned_sidebars/version-2.X-sidebars.json b/versioned_sidebars/version-2.X-sidebars.json index ee0788bc1b4..f978cf44478 100644 --- a/versioned_sidebars/version-2.X-sidebars.json +++ b/versioned_sidebars/version-2.X-sidebars.json @@ -50,7 +50,8 @@ "v2/guide/user/other-language", "v2/guide/user/open-api", "v2/guide/user/auth", - "v2/guide/user/faq" + "v2/guide/user/faq", + "v2/guide/user/failover" ] }, { From d257a4fec9dd8afc63090783a97bfc079afed6ea Mon Sep 17 00:00:00 2001 From: slievrly Date: Tue, 7 Nov 2023 20:11:51 +0800 Subject: [PATCH 02/12] optimize: add some docs --- .../current/v2/guide/user/failover.md | 4 +--- .../version-1.X/v2/guide/user/failover.md | 4 +--- .../version-2.X/v2/guide/user/failover.md | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md index 255264c5694..c54b468bbeb 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md @@ -139,6 +139,4 @@ One example of {resource.root} is src/main/resources. The file content is: -``` -your.package.MyFailoverDataSource -``` \ No newline at end of file +`your.package.MyFailoverDataSource` \ No newline at end of file diff --git a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md index 255264c5694..c54b468bbeb 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md @@ -139,6 +139,4 @@ One example of {resource.root} is src/main/resources. The file content is: -``` -your.package.MyFailoverDataSource -``` \ No newline at end of file +`your.package.MyFailoverDataSource` \ No newline at end of file diff --git a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md index 255264c5694..c54b468bbeb 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md @@ -139,6 +139,4 @@ One example of {resource.root} is src/main/resources. The file content is: -``` -your.package.MyFailoverDataSource -``` \ No newline at end of file +`your.package.MyFailoverDataSource` \ No newline at end of file From e8d05479262e0d0398d9e5fd2a1779dacc4fd278 Mon Sep 17 00:00:00 2001 From: slievrly Date: Tue, 7 Nov 2023 20:19:21 +0800 Subject: [PATCH 03/12] fix --- .../current/v2/guide/user/failover.md | 2 +- .../version-1.X/v2/guide/user/failover.md | 2 +- .../version-2.X/v2/guide/user/failover.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md index c54b468bbeb..6b17565de6b 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md @@ -135,7 +135,7 @@ Create a file under the resource root path: {resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource ``` -One example of {resource.root} is src/main/resources. +One example of \{resource.root\} is src/main/resources. The file content is: diff --git a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md index c54b468bbeb..6b17565de6b 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md @@ -135,7 +135,7 @@ Create a file under the resource root path: {resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource ``` -One example of {resource.root} is src/main/resources. +One example of \{resource.root\} is src/main/resources. The file content is: diff --git a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md index c54b468bbeb..6b17565de6b 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md @@ -135,7 +135,7 @@ Create a file under the resource root path: {resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource ``` -One example of {resource.root} is src/main/resources. +One example of \{resource.root\} is src/main/resources. The file content is: From 62c20a89d324d5670ad25b10d3c9412db403bc7d Mon Sep 17 00:00:00 2001 From: slievrly Date: Tue, 7 Nov 2023 20:30:03 +0800 Subject: [PATCH 04/12] fix --- .../current/v2/guide/user/failover.md | 3 +-- .../version-1.X/v2/guide/user/failover.md | 3 +-- .../version-2.X/v2/guide/user/failover.md | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md index 6b17565de6b..7d93d46a2d9 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md @@ -137,6 +137,5 @@ Create a file under the resource root path: One example of \{resource.root\} is src/main/resources. -The file content is: - +The file content is. `your.package.MyFailoverDataSource` \ No newline at end of file diff --git a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md index 6b17565de6b..7d93d46a2d9 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md @@ -137,6 +137,5 @@ Create a file under the resource root path: One example of \{resource.root\} is src/main/resources. -The file content is: - +The file content is. `your.package.MyFailoverDataSource` \ No newline at end of file diff --git a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md index 6b17565de6b..7d93d46a2d9 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md @@ -137,6 +137,5 @@ Create a file under the resource root path: One example of \{resource.root\} is src/main/resources. -The file content is: - +The file content is. `your.package.MyFailoverDataSource` \ No newline at end of file From a309468e764166f1eac5a17b2434aed6daa53be8 Mon Sep 17 00:00:00 2001 From: slievrly Date: Tue, 7 Nov 2023 20:57:31 +0800 Subject: [PATCH 05/12] fix --- .../current/v2/guide/user/failover.md | 6 +++--- .../version-1.X/v2/guide/user/failover.md | 6 +++--- .../version-2.X/v2/guide/user/failover.md | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md index 7d93d46a2d9..877634fdd4f 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md @@ -135,7 +135,7 @@ Create a file under the resource root path: {resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource ``` -One example of \{resource.root\} is src/main/resources. +One example of \{resource.root\} is src/main/resources. -The file content is. -`your.package.MyFailoverDataSource` \ No newline at end of file +The file content is: + `your.package.MyFailoverDataSource` diff --git a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md index 7d93d46a2d9..877634fdd4f 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md @@ -135,7 +135,7 @@ Create a file under the resource root path: {resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource ``` -One example of \{resource.root\} is src/main/resources. +One example of \{resource.root\} is src/main/resources. -The file content is. -`your.package.MyFailoverDataSource` \ No newline at end of file +The file content is: + `your.package.MyFailoverDataSource` diff --git a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md index 7d93d46a2d9..877634fdd4f 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md @@ -135,7 +135,7 @@ Create a file under the resource root path: {resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource ``` -One example of \{resource.root\} is src/main/resources. +One example of \{resource.root\} is src/main/resources. -The file content is. -`your.package.MyFailoverDataSource` \ No newline at end of file +The file content is: + `your.package.MyFailoverDataSource` From 4bcf7b281d16dee365340946d747c18d764d599f Mon Sep 17 00:00:00 2001 From: slievrly Date: Wed, 8 Nov 2023 11:07:21 +0800 Subject: [PATCH 06/12] fix --- .../current/v2/guide/user/failover.md | 8 +++++--- .../version-1.X/v2/guide/user/failover.md | 8 +++++--- .../version-2.X/v2/guide/user/failover.md | 8 +++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md index 877634fdd4f..d51ec097236 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md @@ -135,7 +135,9 @@ Create a file under the resource root path: {resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource ``` -One example of \{resource.root\} is src/main/resources. +One example of {resource.root} is src/main/resources. -The file content is: - `your.package.MyFailoverDataSource` +The file content is: +``` +your.package.MyFailoverDataSource +``` \ No newline at end of file diff --git a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md index 877634fdd4f..d51ec097236 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md @@ -135,7 +135,9 @@ Create a file under the resource root path: {resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource ``` -One example of \{resource.root\} is src/main/resources. +One example of {resource.root} is src/main/resources. -The file content is: - `your.package.MyFailoverDataSource` +The file content is: +``` +your.package.MyFailoverDataSource +``` \ No newline at end of file diff --git a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md index 877634fdd4f..65b35296a03 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md @@ -135,7 +135,9 @@ Create a file under the resource root path: {resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource ``` -One example of \{resource.root\} is src/main/resources. +One example of {resource.root} is src/main/resources. -The file content is: - `your.package.MyFailoverDataSource` +The file content is: +``` +your.package.MyFailoverDataSource +``` \ No newline at end of file From d5255db9abf920976ebb3fd37dde9df210bcc832 Mon Sep 17 00:00:00 2001 From: slievrly Date: Wed, 8 Nov 2023 11:16:06 +0800 Subject: [PATCH 07/12] fix --- .../current/v2/guide/user/failover.md | 2 +- .../version-1.X/v2/guide/user/failover.md | 2 +- .../version-2.X/v2/guide/user/failover.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md index d51ec097236..1e39bf8994f 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md @@ -135,7 +135,7 @@ Create a file under the resource root path: {resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource ``` -One example of {resource.root} is src/main/resources. +One example of `{resource.root}` is src/main/resources. The file content is: ``` diff --git a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md index d51ec097236..1e39bf8994f 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md @@ -135,7 +135,7 @@ Create a file under the resource root path: {resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource ``` -One example of {resource.root} is src/main/resources. +One example of `{resource.root}` is src/main/resources. The file content is: ``` diff --git a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md index 65b35296a03..24a5fe85b88 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md @@ -135,7 +135,7 @@ Create a file under the resource root path: {resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource ``` -One example of {resource.root} is src/main/resources. +One example of `{resource.root}` is src/main/resources. The file content is: ``` From 422931c977cf0c79f018c36a10389a6fd793fbc5 Mon Sep 17 00:00:00 2001 From: slievrly Date: Wed, 8 Nov 2023 13:37:40 +0800 Subject: [PATCH 08/12] fix --- .../current/v2/guide/user/failover.md | 1 + .../version-1.X/v2/guide/user/failover.md | 1 + .../version-2.X/v2/guide/user/failover.md | 1 + 3 files changed, 3 insertions(+) diff --git a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md index 1e39bf8994f..9d3d3acee94 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md @@ -138,6 +138,7 @@ Create a file under the resource root path: One example of `{resource.root}` is src/main/resources. The file content is: + ``` your.package.MyFailoverDataSource ``` \ No newline at end of file diff --git a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md index 1e39bf8994f..9d3d3acee94 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md @@ -138,6 +138,7 @@ Create a file under the resource root path: One example of `{resource.root}` is src/main/resources. The file content is: + ``` your.package.MyFailoverDataSource ``` \ No newline at end of file diff --git a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md index 24a5fe85b88..48f5da759d1 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md @@ -138,6 +138,7 @@ Create a file under the resource root path: One example of `{resource.root}` is src/main/resources. The file content is: + ``` your.package.MyFailoverDataSource ``` \ No newline at end of file From eeb1cfc106b8549654e52d9bd88aa4d8f01875e6 Mon Sep 17 00:00:00 2001 From: slievrly Date: Wed, 8 Nov 2023 13:51:00 +0800 Subject: [PATCH 09/12] fix --- .../current/failover.md | 144 ------------------ .../current/v2/guide/user/failover.md | 141 +++++++++++++++++ .../version-1.X/failover.md | 144 ------------------ .../version-1.X/v2/guide/user/failover.md | 141 +++++++++++++++++ .../version-2.X/failover.md | 144 ------------------ .../version-2.X/v2/guide/user/failover.md | 141 +++++++++++++++++ 6 files changed, 423 insertions(+), 432 deletions(-) delete mode 100644 i18n/zh-cn/docusaurus-plugin-content-docs/current/failover.md create mode 100644 i18n/zh-cn/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md delete mode 100644 i18n/zh-cn/docusaurus-plugin-content-docs/version-1.X/failover.md create mode 100644 i18n/zh-cn/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md delete mode 100644 i18n/zh-cn/docusaurus-plugin-content-docs/version-2.X/failover.md create mode 100644 i18n/zh-cn/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/failover.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/failover.md deleted file mode 100644 index 255264c5694..00000000000 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/failover.md +++ /dev/null @@ -1,144 +0,0 @@ ---- -title: Java Client Failover -keywords: [Failover] -description: Java client failover user guide ---- - -# Java Client Failover - -We can turn on the local data failover feature to handle the situation when Nacos server side is unstable or has problematic data. - -There are two typical scenarios: - -1. When Nacos server is in deployment, we can switch on the failover so the clients use local data only. The data anomaly or oscillation at Nacos server won't affect the clients. After the deployment and the data verification are done, we can switch off the failover feature. -2. When there is a sudden data anomaly at Nacos server at runtime, we can turn on the failover feature to prevent Nacos clients using wrong data. - -The full detailed solution description can be found in https://github.com/alibaba/nacos/issues/11053 - -## Procedures - -image - -As shown above, the query requests to Nacos client would first be checked by FailoverReactor, and only if FailoverReactor has no related data, can the requests move on to query ServiceInfoHolder. - -## Disk based Failover - -FailoverReactor can select different data sources. Disk is the default option. - -### Disk Failover File Path - -The default path of disk failover files are: - -``` -{user.home}/nacos/naming/{namespace}/failover -``` - -This path can be customised via -D argument: - -``` --DJM.SNAPSHOT.PATH=/mypath -``` - -So the path becomes: - -``` -/mypath/nacos/naming/{namespace}/failover -``` - -### Disk Failover Switch - -The disk failover switch is stored in a file with name: - -``` -00-00---000-VIPSRV_FAILOVER_SWITCH-000---00-00 -``` - -The content of this file is just a number 0 or 1, where 0 represents failover is off, 1 is on. - -### Disk Failover Data - -The disk failover data is stored in multiple files under the failover path. Each file stores the failover data for a single service. - -The file name is in the following format: - -``` -{group.name}%40%40{service.name} -``` -The content in the file is the JSON string of one ServiceInfo object, for instance: - -``` -{ - "name":"DEFAULT_GROUP@@test.2", - "groupName":"DEFAULT_GROUP", - "clusters":"", - "cacheMillis":10000, - "hosts":[ - { - "instanceId":"1.1.2.1#8888#DEFAULT#DEFAULT_GROUP@@test.2", - "ip":"1.1.2.1", - "port":8888, - "weight":1, - "healthy":true, - "enabled":true, - "ephemeral":true, - "clusterName":"DEFAULT", - "serviceName":"DEFAULT_GROUP@@test.2", - "metadata":{ - "k1":"v1" - }, - "instanceHeartBeatInterval":5000, - "instanceHeartBeatTimeOut":15000, - "ipDeleteTimeout":30000 - } - ], - "lastRefTime":1689835375819, - "checksum":"", - "allIPs":false, - "reachProtectionThreshold":false, - "valid":true -} -``` - -## Extent Failover Data Source - -Disk failover is simple and requires no extra remote components. But sometimes we may want to use another kind of data source, such as Redis, Mysql, etc. - -Now we support extending the failover data source with SPI mechanism. Here are the steps: - -### Develop Your Own Failover Data Source - -Write a class and implement the interface com.alibaba.nacos.client.naming.backups.FailoverDataSource: - -``` -public class MyFailoverDataSource implements FailoverDataSource { - - @Override - public FailoverSwitch getSwitch() { - // TODO write your own implementation. - return null; - } - - @Override - public Map getFailoverData() { - // TODO write your own implementation. For naming module, the map - // should contain failover data with service name as key and ServiceInfo as value - return null; - } -} -``` - -### Configure Failover Data Source Class - -Create a file under the resource root path: - -``` -{resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource -``` - -One example of {resource.root} is src/main/resources. - -The file content is: - -``` -your.package.MyFailoverDataSource -``` \ No newline at end of file diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md new file mode 100644 index 00000000000..c9bfdc14760 --- /dev/null +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md @@ -0,0 +1,141 @@ +--- +title: Java客户端容灾 +keywords: [容灾] +description: Java客户端容灾用户指南 +--- + +# Java客户端容灾 + +我们可以在客户端开启本地容灾,用来应对Nacos服务端出现问题时,保证客户端的数据和接口稳定性。 + +这里有两个使用场景: + +1. 在Nacos服务端发布的时候,我们主动把容灾打开,这样客户端只使用本地容灾数据,Nacos服务的数据抖动或者数据错误都不会影响客户端,我们在Nacos服务端升级完成并且数据验证没问题后再关闭容灾; +2. 在Nacos运行期间,突然出现接口不可用或者数据异常,我们可以快速的开启容灾,让客户端使用容灾数据,减小服务受影响的窗口,等Nacos服务端恢复后再关闭容灾; + +具体方案可以参考:https://github.com/alibaba/nacos/issues/11053 + +## 流程简介 + +image + +如上图所示,客户端的查询请求都会先经过FailoverReactor,如果FailoverReactor有数据,则直接使用,从而忽略掉Nacos Server返回的数据;如果FailoverReactor里面没有数据,则走正常流程,从ServiceInfoHolder里读取缓存; + +## 磁盘容灾 + +FailoverReactor里的数据可以使用不同的数据源,默认的数据源为磁盘。 + +### 磁盘容灾文件目录 + +默认的磁盘容灾文件目录为: + +``` +{user.home}/nacos/naming/{namespace}/failover +``` + +这个目录可以定制,如果设置了-D参数: + +``` +-DJM.SNAPSHOT.PATH=/mypath +``` + +则容灾磁盘文件目录变为: + +``` +/mypath/nacos/naming/{namespace}/failover +``` + +### 磁盘容灾开关 + +容灾开关存放在磁盘容灾文件目录下的一个文件里,具体文件名为: + +``` +00-00---000-VIPSRV_FAILOVER_SWITCH-000---00-00 +``` + +文件里存放一个数字0或者1,0代表关闭容灾,1代表打开容灾 + +### 磁盘容灾数据 + +容灾的数据分成多个文件,都是存放在磁盘容灾文件目录下,每一个文件存储一个单独的服务的容灾数据,每个文件的文件名格式如下: + +``` +{group.name}%40%40{service.name} +``` + +里面的内容为客户端的ServiceInfo类的JSON序列化字符串,例如: + +``` +{ + "name":"DEFAULT_GROUP@@test.2", + "groupName":"DEFAULT_GROUP", + "clusters":"", + "cacheMillis":10000, + "hosts":[ + { + "instanceId":"1.1.2.1#8888#DEFAULT#DEFAULT_GROUP@@test.2", + "ip":"1.1.2.1", + "port":8888, + "weight":1, + "healthy":true, + "enabled":true, + "ephemeral":true, + "clusterName":"DEFAULT", + "serviceName":"DEFAULT_GROUP@@test.2", + "metadata":{ + "k1":"v1" + }, + "instanceHeartBeatInterval":5000, + "instanceHeartBeatTimeOut":15000, + "ipDeleteTimeout":30000 + } + ], + "lastRefTime":1689835375819, + "checksum":"", + "allIPs":false, + "reachProtectionThreshold":false, + "valid":true +} +``` + +## 扩展容灾数据源 + +磁盘容灾不需要外部依赖,逻辑比较简单,但是管理起来不太方便。因此我们也支持使用SPI来扩展容灾数据源,使用磁盘以外的存储。以下是扩展的步骤。 + +### 开发自己的容灾数据源类 + +编写一个类,实现接口com.alibaba.nacos.client.naming.backups.FailoverDataSource: + +``` +public class MyFailoverDataSource implements FailoverDataSource { + + @Override + public FailoverSwitch getSwitch() { + // TODO write your own implementation. + return null; + } + + @Override + public Map getFailoverData() { + // TODO write your own implementation. For naming module, the map + // should contain failover data with service name as key and ServiceInfo as value + return null; + } +} +``` + +### 配置容灾数据源类 + +在资源目录下新建文件: + +``` +{resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource +``` + +{resource.root}的一个例子是src/main/resources。 + +文件内容为: + +``` +your.package.MyFailoverDataSource +``` \ No newline at end of file diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-1.X/failover.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-1.X/failover.md deleted file mode 100644 index 255264c5694..00000000000 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/version-1.X/failover.md +++ /dev/null @@ -1,144 +0,0 @@ ---- -title: Java Client Failover -keywords: [Failover] -description: Java client failover user guide ---- - -# Java Client Failover - -We can turn on the local data failover feature to handle the situation when Nacos server side is unstable or has problematic data. - -There are two typical scenarios: - -1. When Nacos server is in deployment, we can switch on the failover so the clients use local data only. The data anomaly or oscillation at Nacos server won't affect the clients. After the deployment and the data verification are done, we can switch off the failover feature. -2. When there is a sudden data anomaly at Nacos server at runtime, we can turn on the failover feature to prevent Nacos clients using wrong data. - -The full detailed solution description can be found in https://github.com/alibaba/nacos/issues/11053 - -## Procedures - -image - -As shown above, the query requests to Nacos client would first be checked by FailoverReactor, and only if FailoverReactor has no related data, can the requests move on to query ServiceInfoHolder. - -## Disk based Failover - -FailoverReactor can select different data sources. Disk is the default option. - -### Disk Failover File Path - -The default path of disk failover files are: - -``` -{user.home}/nacos/naming/{namespace}/failover -``` - -This path can be customised via -D argument: - -``` --DJM.SNAPSHOT.PATH=/mypath -``` - -So the path becomes: - -``` -/mypath/nacos/naming/{namespace}/failover -``` - -### Disk Failover Switch - -The disk failover switch is stored in a file with name: - -``` -00-00---000-VIPSRV_FAILOVER_SWITCH-000---00-00 -``` - -The content of this file is just a number 0 or 1, where 0 represents failover is off, 1 is on. - -### Disk Failover Data - -The disk failover data is stored in multiple files under the failover path. Each file stores the failover data for a single service. - -The file name is in the following format: - -``` -{group.name}%40%40{service.name} -``` -The content in the file is the JSON string of one ServiceInfo object, for instance: - -``` -{ - "name":"DEFAULT_GROUP@@test.2", - "groupName":"DEFAULT_GROUP", - "clusters":"", - "cacheMillis":10000, - "hosts":[ - { - "instanceId":"1.1.2.1#8888#DEFAULT#DEFAULT_GROUP@@test.2", - "ip":"1.1.2.1", - "port":8888, - "weight":1, - "healthy":true, - "enabled":true, - "ephemeral":true, - "clusterName":"DEFAULT", - "serviceName":"DEFAULT_GROUP@@test.2", - "metadata":{ - "k1":"v1" - }, - "instanceHeartBeatInterval":5000, - "instanceHeartBeatTimeOut":15000, - "ipDeleteTimeout":30000 - } - ], - "lastRefTime":1689835375819, - "checksum":"", - "allIPs":false, - "reachProtectionThreshold":false, - "valid":true -} -``` - -## Extent Failover Data Source - -Disk failover is simple and requires no extra remote components. But sometimes we may want to use another kind of data source, such as Redis, Mysql, etc. - -Now we support extending the failover data source with SPI mechanism. Here are the steps: - -### Develop Your Own Failover Data Source - -Write a class and implement the interface com.alibaba.nacos.client.naming.backups.FailoverDataSource: - -``` -public class MyFailoverDataSource implements FailoverDataSource { - - @Override - public FailoverSwitch getSwitch() { - // TODO write your own implementation. - return null; - } - - @Override - public Map getFailoverData() { - // TODO write your own implementation. For naming module, the map - // should contain failover data with service name as key and ServiceInfo as value - return null; - } -} -``` - -### Configure Failover Data Source Class - -Create a file under the resource root path: - -``` -{resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource -``` - -One example of {resource.root} is src/main/resources. - -The file content is: - -``` -your.package.MyFailoverDataSource -``` \ No newline at end of file diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md new file mode 100644 index 00000000000..c9bfdc14760 --- /dev/null +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md @@ -0,0 +1,141 @@ +--- +title: Java客户端容灾 +keywords: [容灾] +description: Java客户端容灾用户指南 +--- + +# Java客户端容灾 + +我们可以在客户端开启本地容灾,用来应对Nacos服务端出现问题时,保证客户端的数据和接口稳定性。 + +这里有两个使用场景: + +1. 在Nacos服务端发布的时候,我们主动把容灾打开,这样客户端只使用本地容灾数据,Nacos服务的数据抖动或者数据错误都不会影响客户端,我们在Nacos服务端升级完成并且数据验证没问题后再关闭容灾; +2. 在Nacos运行期间,突然出现接口不可用或者数据异常,我们可以快速的开启容灾,让客户端使用容灾数据,减小服务受影响的窗口,等Nacos服务端恢复后再关闭容灾; + +具体方案可以参考:https://github.com/alibaba/nacos/issues/11053 + +## 流程简介 + +image + +如上图所示,客户端的查询请求都会先经过FailoverReactor,如果FailoverReactor有数据,则直接使用,从而忽略掉Nacos Server返回的数据;如果FailoverReactor里面没有数据,则走正常流程,从ServiceInfoHolder里读取缓存; + +## 磁盘容灾 + +FailoverReactor里的数据可以使用不同的数据源,默认的数据源为磁盘。 + +### 磁盘容灾文件目录 + +默认的磁盘容灾文件目录为: + +``` +{user.home}/nacos/naming/{namespace}/failover +``` + +这个目录可以定制,如果设置了-D参数: + +``` +-DJM.SNAPSHOT.PATH=/mypath +``` + +则容灾磁盘文件目录变为: + +``` +/mypath/nacos/naming/{namespace}/failover +``` + +### 磁盘容灾开关 + +容灾开关存放在磁盘容灾文件目录下的一个文件里,具体文件名为: + +``` +00-00---000-VIPSRV_FAILOVER_SWITCH-000---00-00 +``` + +文件里存放一个数字0或者1,0代表关闭容灾,1代表打开容灾 + +### 磁盘容灾数据 + +容灾的数据分成多个文件,都是存放在磁盘容灾文件目录下,每一个文件存储一个单独的服务的容灾数据,每个文件的文件名格式如下: + +``` +{group.name}%40%40{service.name} +``` + +里面的内容为客户端的ServiceInfo类的JSON序列化字符串,例如: + +``` +{ + "name":"DEFAULT_GROUP@@test.2", + "groupName":"DEFAULT_GROUP", + "clusters":"", + "cacheMillis":10000, + "hosts":[ + { + "instanceId":"1.1.2.1#8888#DEFAULT#DEFAULT_GROUP@@test.2", + "ip":"1.1.2.1", + "port":8888, + "weight":1, + "healthy":true, + "enabled":true, + "ephemeral":true, + "clusterName":"DEFAULT", + "serviceName":"DEFAULT_GROUP@@test.2", + "metadata":{ + "k1":"v1" + }, + "instanceHeartBeatInterval":5000, + "instanceHeartBeatTimeOut":15000, + "ipDeleteTimeout":30000 + } + ], + "lastRefTime":1689835375819, + "checksum":"", + "allIPs":false, + "reachProtectionThreshold":false, + "valid":true +} +``` + +## 扩展容灾数据源 + +磁盘容灾不需要外部依赖,逻辑比较简单,但是管理起来不太方便。因此我们也支持使用SPI来扩展容灾数据源,使用磁盘以外的存储。以下是扩展的步骤。 + +### 开发自己的容灾数据源类 + +编写一个类,实现接口com.alibaba.nacos.client.naming.backups.FailoverDataSource: + +``` +public class MyFailoverDataSource implements FailoverDataSource { + + @Override + public FailoverSwitch getSwitch() { + // TODO write your own implementation. + return null; + } + + @Override + public Map getFailoverData() { + // TODO write your own implementation. For naming module, the map + // should contain failover data with service name as key and ServiceInfo as value + return null; + } +} +``` + +### 配置容灾数据源类 + +在资源目录下新建文件: + +``` +{resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource +``` + +{resource.root}的一个例子是src/main/resources。 + +文件内容为: + +``` +your.package.MyFailoverDataSource +``` \ No newline at end of file diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-2.X/failover.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-2.X/failover.md deleted file mode 100644 index 255264c5694..00000000000 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/version-2.X/failover.md +++ /dev/null @@ -1,144 +0,0 @@ ---- -title: Java Client Failover -keywords: [Failover] -description: Java client failover user guide ---- - -# Java Client Failover - -We can turn on the local data failover feature to handle the situation when Nacos server side is unstable or has problematic data. - -There are two typical scenarios: - -1. When Nacos server is in deployment, we can switch on the failover so the clients use local data only. The data anomaly or oscillation at Nacos server won't affect the clients. After the deployment and the data verification are done, we can switch off the failover feature. -2. When there is a sudden data anomaly at Nacos server at runtime, we can turn on the failover feature to prevent Nacos clients using wrong data. - -The full detailed solution description can be found in https://github.com/alibaba/nacos/issues/11053 - -## Procedures - -image - -As shown above, the query requests to Nacos client would first be checked by FailoverReactor, and only if FailoverReactor has no related data, can the requests move on to query ServiceInfoHolder. - -## Disk based Failover - -FailoverReactor can select different data sources. Disk is the default option. - -### Disk Failover File Path - -The default path of disk failover files are: - -``` -{user.home}/nacos/naming/{namespace}/failover -``` - -This path can be customised via -D argument: - -``` --DJM.SNAPSHOT.PATH=/mypath -``` - -So the path becomes: - -``` -/mypath/nacos/naming/{namespace}/failover -``` - -### Disk Failover Switch - -The disk failover switch is stored in a file with name: - -``` -00-00---000-VIPSRV_FAILOVER_SWITCH-000---00-00 -``` - -The content of this file is just a number 0 or 1, where 0 represents failover is off, 1 is on. - -### Disk Failover Data - -The disk failover data is stored in multiple files under the failover path. Each file stores the failover data for a single service. - -The file name is in the following format: - -``` -{group.name}%40%40{service.name} -``` -The content in the file is the JSON string of one ServiceInfo object, for instance: - -``` -{ - "name":"DEFAULT_GROUP@@test.2", - "groupName":"DEFAULT_GROUP", - "clusters":"", - "cacheMillis":10000, - "hosts":[ - { - "instanceId":"1.1.2.1#8888#DEFAULT#DEFAULT_GROUP@@test.2", - "ip":"1.1.2.1", - "port":8888, - "weight":1, - "healthy":true, - "enabled":true, - "ephemeral":true, - "clusterName":"DEFAULT", - "serviceName":"DEFAULT_GROUP@@test.2", - "metadata":{ - "k1":"v1" - }, - "instanceHeartBeatInterval":5000, - "instanceHeartBeatTimeOut":15000, - "ipDeleteTimeout":30000 - } - ], - "lastRefTime":1689835375819, - "checksum":"", - "allIPs":false, - "reachProtectionThreshold":false, - "valid":true -} -``` - -## Extent Failover Data Source - -Disk failover is simple and requires no extra remote components. But sometimes we may want to use another kind of data source, such as Redis, Mysql, etc. - -Now we support extending the failover data source with SPI mechanism. Here are the steps: - -### Develop Your Own Failover Data Source - -Write a class and implement the interface com.alibaba.nacos.client.naming.backups.FailoverDataSource: - -``` -public class MyFailoverDataSource implements FailoverDataSource { - - @Override - public FailoverSwitch getSwitch() { - // TODO write your own implementation. - return null; - } - - @Override - public Map getFailoverData() { - // TODO write your own implementation. For naming module, the map - // should contain failover data with service name as key and ServiceInfo as value - return null; - } -} -``` - -### Configure Failover Data Source Class - -Create a file under the resource root path: - -``` -{resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource -``` - -One example of {resource.root} is src/main/resources. - -The file content is: - -``` -your.package.MyFailoverDataSource -``` \ No newline at end of file diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md new file mode 100644 index 00000000000..c9bfdc14760 --- /dev/null +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md @@ -0,0 +1,141 @@ +--- +title: Java客户端容灾 +keywords: [容灾] +description: Java客户端容灾用户指南 +--- + +# Java客户端容灾 + +我们可以在客户端开启本地容灾,用来应对Nacos服务端出现问题时,保证客户端的数据和接口稳定性。 + +这里有两个使用场景: + +1. 在Nacos服务端发布的时候,我们主动把容灾打开,这样客户端只使用本地容灾数据,Nacos服务的数据抖动或者数据错误都不会影响客户端,我们在Nacos服务端升级完成并且数据验证没问题后再关闭容灾; +2. 在Nacos运行期间,突然出现接口不可用或者数据异常,我们可以快速的开启容灾,让客户端使用容灾数据,减小服务受影响的窗口,等Nacos服务端恢复后再关闭容灾; + +具体方案可以参考:https://github.com/alibaba/nacos/issues/11053 + +## 流程简介 + +image + +如上图所示,客户端的查询请求都会先经过FailoverReactor,如果FailoverReactor有数据,则直接使用,从而忽略掉Nacos Server返回的数据;如果FailoverReactor里面没有数据,则走正常流程,从ServiceInfoHolder里读取缓存; + +## 磁盘容灾 + +FailoverReactor里的数据可以使用不同的数据源,默认的数据源为磁盘。 + +### 磁盘容灾文件目录 + +默认的磁盘容灾文件目录为: + +``` +{user.home}/nacos/naming/{namespace}/failover +``` + +这个目录可以定制,如果设置了-D参数: + +``` +-DJM.SNAPSHOT.PATH=/mypath +``` + +则容灾磁盘文件目录变为: + +``` +/mypath/nacos/naming/{namespace}/failover +``` + +### 磁盘容灾开关 + +容灾开关存放在磁盘容灾文件目录下的一个文件里,具体文件名为: + +``` +00-00---000-VIPSRV_FAILOVER_SWITCH-000---00-00 +``` + +文件里存放一个数字0或者1,0代表关闭容灾,1代表打开容灾 + +### 磁盘容灾数据 + +容灾的数据分成多个文件,都是存放在磁盘容灾文件目录下,每一个文件存储一个单独的服务的容灾数据,每个文件的文件名格式如下: + +``` +{group.name}%40%40{service.name} +``` + +里面的内容为客户端的ServiceInfo类的JSON序列化字符串,例如: + +``` +{ + "name":"DEFAULT_GROUP@@test.2", + "groupName":"DEFAULT_GROUP", + "clusters":"", + "cacheMillis":10000, + "hosts":[ + { + "instanceId":"1.1.2.1#8888#DEFAULT#DEFAULT_GROUP@@test.2", + "ip":"1.1.2.1", + "port":8888, + "weight":1, + "healthy":true, + "enabled":true, + "ephemeral":true, + "clusterName":"DEFAULT", + "serviceName":"DEFAULT_GROUP@@test.2", + "metadata":{ + "k1":"v1" + }, + "instanceHeartBeatInterval":5000, + "instanceHeartBeatTimeOut":15000, + "ipDeleteTimeout":30000 + } + ], + "lastRefTime":1689835375819, + "checksum":"", + "allIPs":false, + "reachProtectionThreshold":false, + "valid":true +} +``` + +## 扩展容灾数据源 + +磁盘容灾不需要外部依赖,逻辑比较简单,但是管理起来不太方便。因此我们也支持使用SPI来扩展容灾数据源,使用磁盘以外的存储。以下是扩展的步骤。 + +### 开发自己的容灾数据源类 + +编写一个类,实现接口com.alibaba.nacos.client.naming.backups.FailoverDataSource: + +``` +public class MyFailoverDataSource implements FailoverDataSource { + + @Override + public FailoverSwitch getSwitch() { + // TODO write your own implementation. + return null; + } + + @Override + public Map getFailoverData() { + // TODO write your own implementation. For naming module, the map + // should contain failover data with service name as key and ServiceInfo as value + return null; + } +} +``` + +### 配置容灾数据源类 + +在资源目录下新建文件: + +``` +{resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource +``` + +{resource.root}的一个例子是src/main/resources。 + +文件内容为: + +``` +your.package.MyFailoverDataSource +``` \ No newline at end of file From 25911a15f364c351b2d27a0106489f280b33612e Mon Sep 17 00:00:00 2001 From: slievrly Date: Wed, 8 Nov 2023 13:59:29 +0800 Subject: [PATCH 10/12] fix --- .../current/v2/guide/user/failover.md | 6 ++---- .../version-1.X/v2/guide/user/failover.md | 6 ++---- .../version-2.X/v2/guide/user/failover.md | 8 +++----- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md index 9d3d3acee94..58e644fc316 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md @@ -137,8 +137,6 @@ Create a file under the resource root path: One example of `{resource.root}` is src/main/resources. -The file content is: +The file content is: -``` -your.package.MyFailoverDataSource -``` \ No newline at end of file +your.package.MyFailoverDataSource \ No newline at end of file diff --git a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md index 9d3d3acee94..58e644fc316 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md @@ -137,8 +137,6 @@ Create a file under the resource root path: One example of `{resource.root}` is src/main/resources. -The file content is: +The file content is: -``` -your.package.MyFailoverDataSource -``` \ No newline at end of file +your.package.MyFailoverDataSource \ No newline at end of file diff --git a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md index 48f5da759d1..58e644fc316 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md @@ -135,10 +135,8 @@ Create a file under the resource root path: {resource.root}/META-INF/services/com.alibaba.nacos.client.naming.backups.FailoverDataSource ``` -One example of `{resource.root}` is src/main/resources. +One example of `{resource.root}` is src/main/resources. -The file content is: +The file content is: -``` -your.package.MyFailoverDataSource -``` \ No newline at end of file +your.package.MyFailoverDataSource \ No newline at end of file From 4198a6b9b3a203e17334003a01fc57c920131503 Mon Sep 17 00:00:00 2001 From: slievrly Date: Wed, 8 Nov 2023 14:12:38 +0800 Subject: [PATCH 11/12] fix image --- .../current/v2/guide/user/failover.md | 2 +- .../version-1.X/v2/guide/user/failover.md | 2 +- .../version-2.X/v2/guide/user/failover.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md index 58e644fc316..f1d41fd179e 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md @@ -17,7 +17,7 @@ The full detailed solution description can be found in https://github.com/alibab ## Procedures -image +image As shown above, the query requests to Nacos client would first be checked by FailoverReactor, and only if FailoverReactor has no related data, can the requests move on to query ServiceInfoHolder. diff --git a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md index 58e644fc316..f1d41fd179e 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md @@ -17,7 +17,7 @@ The full detailed solution description can be found in https://github.com/alibab ## Procedures -image +image As shown above, the query requests to Nacos client would first be checked by FailoverReactor, and only if FailoverReactor has no related data, can the requests move on to query ServiceInfoHolder. diff --git a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md index 58e644fc316..f1d41fd179e 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md @@ -17,7 +17,7 @@ The full detailed solution description can be found in https://github.com/alibab ## Procedures -image +image As shown above, the query requests to Nacos client would first be checked by FailoverReactor, and only if FailoverReactor has no related data, can the requests move on to query ServiceInfoHolder. From 3790b3b8089051c87ae6fa815b8bf6d6a21feec2 Mon Sep 17 00:00:00 2001 From: slievrly Date: Wed, 8 Nov 2023 14:21:55 +0800 Subject: [PATCH 12/12] fix image --- .../current/v2/guide/user/failover.md | 4 +++- .../version-1.X/v2/guide/user/failover.md | 4 +++- .../version-2.X/v2/guide/user/failover.md | 4 +++- .../current/v2/guide/user/failover.md | 2 +- .../version-1.X/v2/guide/user/failover.md | 2 +- .../version-2.X/v2/guide/user/failover.md | 2 +- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md index f1d41fd179e..4ff7c60e607 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md @@ -139,4 +139,6 @@ One example of `{resource.root}` is src/main/resources. The file content is: -your.package.MyFailoverDataSource \ No newline at end of file +``` +your.package.MyFailoverDataSource +``` \ No newline at end of file diff --git a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md index f1d41fd179e..4ff7c60e607 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md @@ -139,4 +139,6 @@ One example of `{resource.root}` is src/main/resources. The file content is: -your.package.MyFailoverDataSource \ No newline at end of file +``` +your.package.MyFailoverDataSource +``` \ No newline at end of file diff --git a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md index f1d41fd179e..4ff7c60e607 100644 --- a/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md +++ b/i18n/en/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md @@ -139,4 +139,6 @@ One example of `{resource.root}` is src/main/resources. The file content is: -your.package.MyFailoverDataSource \ No newline at end of file +``` +your.package.MyFailoverDataSource +``` \ No newline at end of file diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md index c9bfdc14760..8f48458c74f 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/v2/guide/user/failover.md @@ -17,7 +17,7 @@ description: Java客户端容灾用户指南 ## 流程简介 -image +image 如上图所示,客户端的查询请求都会先经过FailoverReactor,如果FailoverReactor有数据,则直接使用,从而忽略掉Nacos Server返回的数据;如果FailoverReactor里面没有数据,则走正常流程,从ServiceInfoHolder里读取缓存; diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md index c9bfdc14760..8f48458c74f 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-1.X/v2/guide/user/failover.md @@ -17,7 +17,7 @@ description: Java客户端容灾用户指南 ## 流程简介 -image +image 如上图所示,客户端的查询请求都会先经过FailoverReactor,如果FailoverReactor有数据,则直接使用,从而忽略掉Nacos Server返回的数据;如果FailoverReactor里面没有数据,则走正常流程,从ServiceInfoHolder里读取缓存; diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md b/i18n/zh-cn/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md index c9bfdc14760..8f48458c74f 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-2.X/v2/guide/user/failover.md @@ -17,7 +17,7 @@ description: Java客户端容灾用户指南 ## 流程简介 -image +image 如上图所示,客户端的查询请求都会先经过FailoverReactor,如果FailoverReactor有数据,则直接使用,从而忽略掉Nacos Server返回的数据;如果FailoverReactor里面没有数据,则走正常流程,从ServiceInfoHolder里读取缓存;