WillemJiang closed pull request #29: SCB-133 user guide document for dynamic 
config
URL: https://github.com/apache/incubator-servicecomb-website/pull/29
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/_data/navigation.yml b/_data/navigation.yml
index 9905397..25d50eb 100755
--- a/_data/navigation.yml
+++ b/_data/navigation.yml
@@ -84,6 +84,8 @@ t:
             url: /users/distributed-tracing/
           - title: Customized Tracing
             url: /users/customized-tracing/
+         - title: Dynamic Configurations
+           url: /users/dynamic-config/
 
       - title: Edging Service
         children:
@@ -209,6 +211,8 @@ t:
             url: /cn/users/distributed-tracing/
           - title: ????????
             url: /cn/users/customized-tracing/
+         - title: ????
+           url: /cn/users/dynamic-config/
 
       - title: ??????
         children:
diff --git a/_users/cn/dynamic-config.md b/_users/cn/dynamic-config.md
new file mode 100644
index 0000000..d11f698
--- /dev/null
+++ b/_users/cn/dynamic-config.md
@@ -0,0 +1,105 @@
+---
+title: "????"
+lang: cn
+ref: customized-tracing
+permalink: /cn/users/dynamic-config/
+excerpt: "????"
+last_modified_at: 2018-01-11T15:01:43-04:00
+redirect_from:
+  - /theme-setup/
+---
+
+{% include toc %}
+## ????
+
+?????????????????????????????????????????????????????xml?properties????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Java
 Chassis??????????Apollo?????????Java Chassis?????????????????????
+
+## ????:
+
+### ?????Apollo????
+
+????????Apollo???????[????](https://github.com/ctripcorp/apollo/wiki/Apollo-Quick-Start-Docker%E9%83%A8%E7%BD%B2)??????????????
+
+   ```bash
+   git clone https://github.com/lijasonvip/apollo-image-for-servicecomb.git
+   cd apollo-image-for-servicecomb && docker-compose up
+   ```
+???? `Portal started. You can visit http://localhost:8070 now!` 
???????????????????`http://localhost:8070`????????? 
`docker-compose`?????[??](https://docs.docker.com/compose/install/)?
+
+### ??Apollo????????TOKEN
+
+* ##### ??Apollo????????
+
+  ??????????????????????`IP:PORT`????8070??`http://192.168.199.1:8070`
+
+  ![??????](E:\opensource\dynamic 
config\incubator-servicecomb-website\assets\images\config/login.png)
+
+  Apollo????????????apollo/admin?????????????????????
+
+* ##### ????
+
+  ![????](E:\opensource\dynamic 
config\incubator-servicecomb-website\assets\images\config\create_project.png)
+
+  
?????????????SampleApp????????????????????????????????Id??????????????????????????
+
+![????](E:\opensource\dynamic 
config\incubator-servicecomb-website\assets\images\config\create_project2.png)
+
+* ##### ??TOKEN
+
+????`http://192.168.199.1:8070/open/manage.html`??????????????????????????????????????????TOKEN?????TOKEN?????????????
+
+![??TOKEN](E:\opensource\dynamic 
config\incubator-servicecomb-website\assets\images\config\token.png)
+
+### ????????
+
+```xml
+    <dependency>
+          <groupId>com.netflix.archaius</groupId>
+          <artifactId>archaius-core</artifactId>
+    </dependency>   
+    <dependency>
+          <groupId>io.servicecomb</groupId>
+          <artifactId>config-apollo</artifactId>
+    </dependency>
+```
+### ?????
+
+   ```yaml
+   cse:
+     config:
+       client:
+       serverUri: http://127.0.0.1:8070
+   apollo:
+     config:
+       serverUri: http://127.0.0.1:8070
+       serviceName: SampleApp
+       env: DEV
+       clusters: default
+       namespace: application
+       token: testtoken
+       refreshInterval: 10
+   ```
+?      
`cse.config.client.serverUri`?????Apollo????portal????????????????`apollo.config`??????????????????????????????namespace?token????????????????????????????????`refreshInterval:
 10`???????10??????????????????????????????30??
+
+### ??????
+
+?      ??????????`timeout`??????????`100`????????      
![????timeout](E:\opensource\dynamic 
config\incubator-servicecomb-website\assets\images\config\release_config.png)
+
+?      
???????`DynamicPropertyFactory.getInstance().getProperty()`?????????????`getProperty`??????????????????????`getIntProperty()`,`getStringProperty()`??
+
+   ```java
+   public class XXX {
+      public static void main(String[] args) throws Exception {
+        Log4jUtils.init();
+        BeanUtils.init();
+        while (true) {
+          DynamicIntProperty timeout = DynamicPropertyFactory.getInstance().
+            getIntProperty("timeout", -1);
+          System.out.println(timeout);
+          Thread.sleep(3000);
+        }
+      }
+    }
+   ```
+?      Apollo???????????????????????????????`timeout`??
+
diff --git a/_users/dynamic-config.md b/_users/dynamic-config.md
new file mode 100644
index 0000000..22a678a
--- /dev/null
+++ b/_users/dynamic-config.md
@@ -0,0 +1,104 @@
+---
+title: "Dynamic Configuration"
+lang: en
+ref: customized-tracing
+permalink: /users/dynamic-config/
+excerpt: "Dynamic Configuration"
+last_modified_at: 2018-01-15T15:01:43-04:00
+redirect_from:
+  - /theme-setup/
+---
+
+{% include toc %}
+## Concept Description
+
+Dynamic Configuration makes it possible to update configuration items during 
the life-cycle of the service without re-deploying it. Users have to deploy 
services with those configurations in xml or properties file in traditional way 
and have to redeploy and restart services to update the configurations which 
could be very difficult to maintain and cost lots time. This problem can be 
solved by importing configuration center, all configuration items can be stored 
and maintained by configuration center, services can get latest configuration 
items through a fixed time period thread without redeploying themselves. Java 
Chassis supports Apollo configuration center currently and it\'s easy to extend 
to other kind of configuration centers by implementing provided interfaces.
+
+## Development Example:
+
+### Deploy and start Apollo configuration center
+
+Apollo services can be easily deployed and started step by step following its 
[official 
document](https://github.com/ctripcorp/apollo/wiki/Apollo-Quick-Start-Docker%E9%83%A8%E7%BD%B2),
 You can also do that by following command:
+
+   ```bash
+   git clone https://github.com/lijasonvip/apollo-image-for-servicecomb.git
+   cd apollo-image-for-servicecomb && docker-compose up
+   ```
+When your console shows `Portal started. You can visit http://localhost:8070 
now!` , it means the service is started and ready for use. Visit Apollo 
configuration pages at `http://localhost:8070` in a browser. Please refer to 
[Docker document](https://docs.docker.com/compose/install/) about 
`docker-compose`.
+
+### Configure services and get a token
+
+* ##### Login to Configuration center and create a project
+
+  Visit the address of Apollo configuration portal service , for example: 
`http://192.168.199.1:8070`
+
+  ![??????](E:\opensource\dynamic 
config\incubator-servicecomb-website\assets\images\config/login.png)
+
+  The default account to login to Apollo configuration center is apollo and 
admin for username and password respectively.
+
+* ##### Create a project
+
+  ![????](E:\opensource\dynamic 
config\incubator-servicecomb-website\assets\images\config\create_project.png)
+
+  There is a demo project named SampleApp, you can create a project for your 
service by click the green icon `+`. The picture below is a example to create a 
project, fill in your application ID and service name and choose the department 
and owner of the project and then submit them.
+
+![????](E:\opensource\dynamic 
config\incubator-servicecomb-website\assets\images\config\create_project2.png)
+
+* ##### Generate a Token
+
+Visit `http://192.168.199.1:8070/open/manage.html` and fill in application ID 
and service name you just created at last step, then choose department and 
owner of the project and click the create button to generate a token. The token 
will be used later in project code.
+
+![??TOKEN](E:\opensource\dynamic 
config\incubator-servicecomb-website\assets\images\config\token.png)
+
+### Add dependency in pom.xml
+
+```xml
+    <dependency>
+          <groupId>com.netflix.archaius</groupId>
+          <artifactId>archaius-core</artifactId>
+    </dependency>   
+    <dependency>
+          <groupId>io.servicecomb</groupId>
+          <artifactId>config-apollo</artifactId>
+    </dependency>
+```
+### Add configurations in microservice.yaml
+
+   ```yaml
+   cse:
+     config:
+       client:
+       serverUri: http://127.0.0.1:8070
+   apollo:
+     config:
+       serverUri: http://127.0.0.1:8070
+       serviceName: SampleApp
+       env: DEV
+       clusters: default
+       namespace: application
+       token: testtoken
+       refreshInterval: 10
+   ```
+?      Configuration `cse.config.client.serverUri` is the portal address of 
Apollo configuration center just the same as `apollo.config.serverUri`. 
Configurations under `apollo.config` are parameters of the project that users 
created above, including serviceName, env, clusters, namespace, token and 
refreshInterval. Pay attention to `refreshInterval: 10`, it means service will 
fetch latest configuration items every each 10 seconds, default refresh cycle 
is 30 second if no value is configured here.
+
+### Get configurations
+
+?      Creating a configuration item named `timeout` and set its value to 
`100` then release the configuration with some comments. Example as below:   
![????timeout](E:\opensource\dynamic 
config\incubator-servicecomb-website\assets\images\config\release_config.png)
+
+?      You can use`DynamicPropertyFactory.getInstance().getProperty()` to get 
the value of configuration items. 
+
+   ```java
+   public class Demo {
+      public static void main(String[] args) throws Exception {
+        Log4jUtils.init();
+        BeanUtils.init();
+        while (true) {
+          DynamicIntProperty timeout = DynamicPropertyFactory.getInstance().
+            getIntProperty("timeout", -1);
+          System.out.println(timeout);
+          Thread.sleep(3000);
+        }
+      }
+    }
+   ```
+?      When the configuration items are modified and released in Apollo 
configuration center, the example code above will print latest value of 
`timeout` after a refreshing cycle.
diff --git a/assets/images/config/create_project.png 
b/assets/images/config/create_project.png
new file mode 100644
index 0000000..3256249
Binary files /dev/null and b/assets/images/config/create_project.png differ
diff --git a/assets/images/config/create_project2.png 
b/assets/images/config/create_project2.png
new file mode 100644
index 0000000..955d580
Binary files /dev/null and b/assets/images/config/create_project2.png differ
diff --git a/assets/images/config/login.png b/assets/images/config/login.png
new file mode 100644
index 0000000..ddb2270
Binary files /dev/null and b/assets/images/config/login.png differ
diff --git a/assets/images/config/release_config.png 
b/assets/images/config/release_config.png
new file mode 100644
index 0000000..fd632e7
Binary files /dev/null and b/assets/images/config/release_config.png differ
diff --git a/assets/images/config/token.png b/assets/images/config/token.png
new file mode 100644
index 0000000..7c1948f
Binary files /dev/null and b/assets/images/config/token.png differ


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to