You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/06/10 20:37:28 UTC

[GitHub] [servicecomb-java-chassis] jungan21 opened a new pull request #1827: [SCB-1997] Small improvement when Muticastscoket receive data

jungan21 opened a new pull request #1827:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1827


   Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it).  Trivial changes like typos do not require a JIRA issue.  Your pull request should address just this issue, without pulling in other changes.
    - [ ] Each commit in the pull request should have a meaningful subject line and body.
    - [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue.
    - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [ ] Run `mvn clean install -Pit` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   ---
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #1827: [SCB-1997] Small improvement when Muticastscoket receive data

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #1827:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1827#discussion_r438479863



##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/server/ServerUtil.java
##########
@@ -172,16 +172,29 @@ private static ServerMicroserviceInstance buildServerMicroserviceInstanceFromMap
     return map;
   }
 
+  private static void initMulticastSocket() throws IOException{
+    multicastSocket = new MulticastSocket(PORT);
+    group = InetAddress.getByName(GROUP);
+    multicastSocket.joinGroup(group); // need to join the group to be able to receive the data
+  }
+
   private static void startListenerForRegisterUnregisterEvent() {
     try {
       byte[] buffer = new byte[DATA_PACKET_BUFFER_SIZE];
-      multicastSocket = new MulticastSocket(PORT);
-      group = InetAddress.getByName(GROUP);
-      multicastSocket.joinGroup(group); // need to join the group to be able to receive the data
-
+      initMulticastSocket();
       while (true) {
         DatagramPacket receivePacketBuffer = new DatagramPacket(buffer, buffer.length);
-        multicastSocket.receive(receivePacketBuffer);
+        try {

Review comment:
       Maybe need look at the outer `try', if `IOException` is thrown, the tast is exit. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] jungan21 commented on a change in pull request #1827: [SCB-1997] Small improvement when Muticastscoket receive data

Posted by GitBox <gi...@apache.org>.
jungan21 commented on a change in pull request #1827:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1827#discussion_r438502695



##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/server/ServerUtil.java
##########
@@ -172,16 +172,29 @@ private static ServerMicroserviceInstance buildServerMicroserviceInstanceFromMap
     return map;
   }
 
+  private static void initMulticastSocket() throws IOException{
+    multicastSocket = new MulticastSocket(PORT);
+    group = InetAddress.getByName(GROUP);
+    multicastSocket.joinGroup(group); // need to join the group to be able to receive the data
+  }
+
   private static void startListenerForRegisterUnregisterEvent() {
     try {
       byte[] buffer = new byte[DATA_PACKET_BUFFER_SIZE];
-      multicastSocket = new MulticastSocket(PORT);
-      group = InetAddress.getByName(GROUP);
-      multicastSocket.joinGroup(group); // need to join the group to be able to receive the data
-
+      initMulticastSocket();
       while (true) {
         DatagramPacket receivePacketBuffer = new DatagramPacket(buffer, buffer.length);
-        multicastSocket.receive(receivePacketBuffer);
+        try {

Review comment:
       Correct. But the outer try/catch(IOException) is for initializing the Multicastsocket object ......the failure should rarely happen. I don't think we need to handle this for now.  I'm thinkg to throw exception, (like our servicecomb init task)...instead of the just logging.
   
   throw new IllegalStateException("Zero-Config init failed.", e);




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #1827: [SCB-1997] Small improvement when Muticastscoket receive data

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #1827:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1827#discussion_r439161786



##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/server/ServerUtil.java
##########
@@ -172,16 +172,29 @@ private static ServerMicroserviceInstance buildServerMicroserviceInstanceFromMap
     return map;
   }
 
+  private static void initMulticastSocket() throws IOException {
+    multicastSocket = new MulticastSocket(PORT);
+    group = InetAddress.getByName(GROUP);
+    multicastSocket.joinGroup(group); // need to join the group to be able to receive the data
+  }
+
   private static void startListenerForRegisterUnregisterEvent() {
     try {
       byte[] buffer = new byte[DATA_PACKET_BUFFER_SIZE];

Review comment:
       cyclomatic complexity of `startListenerForRegisterUnregisterEvent` is a bit too high, can be refactored. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 merged pull request #1827: [SCB-1997] Small improvement when Muticastscoket receive data

Posted by GitBox <gi...@apache.org>.
liubao68 merged pull request #1827:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1827


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] coveralls commented on pull request #1827: [SCB-1997] Small improvement when Muticastscoket receive data

Posted by GitBox <gi...@apache.org>.
coveralls commented on pull request #1827:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1827#issuecomment-642284272


   
   [![Coverage Status](https://coveralls.io/builds/31375760/badge)](https://coveralls.io/builds/31375760)
   
   Coverage decreased (-0.01%) to 86.813% when pulling **40505871fb490afad3f6b0acf4391a6b81ea9a1f on jungan21:master** into **35f7ea841a98a1a796adc5bdbb0f01bc6b5432e1 on apache:master**.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] jungan21 commented on a change in pull request #1827: [SCB-1997] Small improvement when Muticastscoket receive data

Posted by GitBox <gi...@apache.org>.
jungan21 commented on a change in pull request #1827:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1827#discussion_r438502695



##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/server/ServerUtil.java
##########
@@ -172,16 +172,29 @@ private static ServerMicroserviceInstance buildServerMicroserviceInstanceFromMap
     return map;
   }
 
+  private static void initMulticastSocket() throws IOException{
+    multicastSocket = new MulticastSocket(PORT);
+    group = InetAddress.getByName(GROUP);
+    multicastSocket.joinGroup(group); // need to join the group to be able to receive the data
+  }
+
   private static void startListenerForRegisterUnregisterEvent() {
     try {
       byte[] buffer = new byte[DATA_PACKET_BUFFER_SIZE];
-      multicastSocket = new MulticastSocket(PORT);
-      group = InetAddress.getByName(GROUP);
-      multicastSocket.joinGroup(group); // need to join the group to be able to receive the data
-
+      initMulticastSocket();
       while (true) {
         DatagramPacket receivePacketBuffer = new DatagramPacket(buffer, buffer.length);
-        multicastSocket.receive(receivePacketBuffer);
+        try {

Review comment:
       Correct. But the outer try/catch(IOException) is for initializing the Multicastsocket object ......the failure should rarely happen. I don't think we need to handle this for now




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] coveralls edited a comment on pull request #1827: [SCB-1997] Small improvement when Muticastscoket receive data

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #1827:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1827#issuecomment-642284272


   
   [![Coverage Status](https://coveralls.io/builds/31407194/badge)](https://coveralls.io/builds/31407194)
   
   Coverage decreased (-0.008%) to 86.795% when pulling **366296cec6dd02011627f64020d49846881f9d10 on jungan21:master** into **e54e0eae0629d7b5e66b534bd94aea002836ebeb on apache:master**.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] coveralls edited a comment on pull request #1827: [SCB-1997] Small improvement when Muticastscoket receive data

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #1827:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1827#issuecomment-642284272


   
   [![Coverage Status](https://coveralls.io/builds/31380536/badge)](https://coveralls.io/builds/31380536)
   
   Coverage decreased (-0.005%) to 86.818% when pulling **0d3fc41c60e81ba542fc961cdceee8a4856a4fee on jungan21:master** into **35f7ea841a98a1a796adc5bdbb0f01bc6b5432e1 on apache:master**.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #1827: [SCB-1997] Small improvement when Muticastscoket receive data

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #1827:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1827#discussion_r438479863



##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/server/ServerUtil.java
##########
@@ -172,16 +172,29 @@ private static ServerMicroserviceInstance buildServerMicroserviceInstanceFromMap
     return map;
   }
 
+  private static void initMulticastSocket() throws IOException{
+    multicastSocket = new MulticastSocket(PORT);
+    group = InetAddress.getByName(GROUP);
+    multicastSocket.joinGroup(group); // need to join the group to be able to receive the data
+  }
+
   private static void startListenerForRegisterUnregisterEvent() {
     try {
       byte[] buffer = new byte[DATA_PACKET_BUFFER_SIZE];
-      multicastSocket = new MulticastSocket(PORT);
-      group = InetAddress.getByName(GROUP);
-      multicastSocket.joinGroup(group); // need to join the group to be able to receive the data
-
+      initMulticastSocket();
       while (true) {
         DatagramPacket receivePacketBuffer = new DatagramPacket(buffer, buffer.length);
-        multicastSocket.receive(receivePacketBuffer);
+        try {

Review comment:
       Maybe need look at the outer `try`, if `IOException` is thrown, the task is exit. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #1827: [SCB-1997] Small improvement when Muticastscoket receive data

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #1827:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1827#discussion_r438479863



##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/server/ServerUtil.java
##########
@@ -172,16 +172,29 @@ private static ServerMicroserviceInstance buildServerMicroserviceInstanceFromMap
     return map;
   }
 
+  private static void initMulticastSocket() throws IOException{
+    multicastSocket = new MulticastSocket(PORT);
+    group = InetAddress.getByName(GROUP);
+    multicastSocket.joinGroup(group); // need to join the group to be able to receive the data
+  }
+
   private static void startListenerForRegisterUnregisterEvent() {
     try {
       byte[] buffer = new byte[DATA_PACKET_BUFFER_SIZE];
-      multicastSocket = new MulticastSocket(PORT);
-      group = InetAddress.getByName(GROUP);
-      multicastSocket.joinGroup(group); // need to join the group to be able to receive the data
-
+      initMulticastSocket();
       while (true) {
         DatagramPacket receivePacketBuffer = new DatagramPacket(buffer, buffer.length);
-        multicastSocket.receive(receivePacketBuffer);
+        try {

Review comment:
       Maybe need look at the outer `try`, if `IOException` is thrown, the tast is exit. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org