forked from sofastack/sofa-rpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize mesh support. (sofastack#722)
* optimize mesh support * add protocol type * add more * mesh api parameter settings
- Loading branch information
1 parent
e8c00d5
commit 3b3fab1
Showing
13 changed files
with
336 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,17 +20,7 @@ | |
import com.alipay.sofa.rpc.common.utils.StringUtils; | ||
import com.alipay.sofa.rpc.log.Logger; | ||
import com.alipay.sofa.rpc.log.LoggerFactory; | ||
import com.alipay.sofa.rpc.registry.mesh.model.ApplicationInfoRequest; | ||
import com.alipay.sofa.rpc.registry.mesh.model.ApplicationInfoResult; | ||
import com.alipay.sofa.rpc.registry.mesh.model.MeshEndpoint; | ||
import com.alipay.sofa.rpc.registry.mesh.model.PublishServiceRequest; | ||
import com.alipay.sofa.rpc.registry.mesh.model.PublishServiceResult; | ||
import com.alipay.sofa.rpc.registry.mesh.model.SubscribeServiceRequest; | ||
import com.alipay.sofa.rpc.registry.mesh.model.SubscribeServiceResult; | ||
import com.alipay.sofa.rpc.registry.mesh.model.UnPublishServiceRequest; | ||
import com.alipay.sofa.rpc.registry.mesh.model.UnPublishServiceResult; | ||
import com.alipay.sofa.rpc.registry.mesh.model.UnSubscribeServiceRequest; | ||
import com.alipay.sofa.rpc.registry.mesh.model.UnSubscribeServiceResult; | ||
import com.alipay.sofa.rpc.registry.mesh.model.*; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.DataOutputStream; | ||
|
@@ -41,7 +31,8 @@ | |
import java.net.URL; | ||
|
||
/** | ||
* @author <a href=mailto:[email protected]>leizhiyuan</a> | ||
* @author bystander | ||
* @version $Id: MeshApiClient.java, v 0.1 2018年03月27日 2:24 PM bystander Exp $ | ||
*/ | ||
public class MeshApiClient { | ||
|
||
|
@@ -52,12 +43,14 @@ public class MeshApiClient { | |
/** | ||
* 连接超时 | ||
*/ | ||
private static int connectTimeout = 1000; | ||
private static int connectTimeout = Integer.parseInt(System.getProperty( | ||
"mesh_http_connect_timeout", "3000")); ; | ||
|
||
/** | ||
* 读取超时 | ||
*/ | ||
private static int readTimeout = 1000; | ||
private static int readTimeout = Integer.parseInt(System.getProperty( | ||
"mesh_http_read_timeout", "15000")); | ||
|
||
private static String errorMessage = "ERROR"; | ||
|
||
|
@@ -93,7 +86,8 @@ public boolean registeApplication(ApplicationInfoRequest applicationInfoRequest) | |
String result = httpPost(MeshEndpoint.CONFIGS, json); | ||
|
||
if (!StringUtils.equals(result, errorMessage)) { | ||
final ApplicationInfoResult parse = JSON.parseObject(result, ApplicationInfoResult.class); | ||
final ApplicationInfoResult parse = JSON.parseObject(result, | ||
ApplicationInfoResult.class); | ||
if (parse.isSuccess()) { | ||
return true; | ||
} | ||
|
@@ -110,7 +104,8 @@ public int unPublishService(UnPublishServiceRequest request) { | |
String result = httpPost(MeshEndpoint.UN_PUBLISH, json); | ||
|
||
if (!StringUtils.equals(result, errorMessage)) { | ||
final UnPublishServiceResult parse = JSON.parseObject(result, UnPublishServiceResult.class); | ||
final UnPublishServiceResult parse = JSON.parseObject(result, | ||
UnPublishServiceResult.class); | ||
if (parse.isSuccess()) { | ||
return 1; | ||
} | ||
|
@@ -128,8 +123,7 @@ public SubscribeServiceResult subscribeService(SubscribeServiceRequest subscribe | |
|
||
SubscribeServiceResult subscribeServiceResult; | ||
if (!StringUtils.equals(result, errorMessage)) { | ||
subscribeServiceResult = JSON.parseObject(result, | ||
SubscribeServiceResult.class); | ||
subscribeServiceResult = JSON.parseObject(result, SubscribeServiceResult.class); | ||
return subscribeServiceResult; | ||
} else { | ||
subscribeServiceResult = new SubscribeServiceResult(); | ||
|
@@ -168,7 +162,7 @@ private HttpURLConnection createConnection(URL url, String method, boolean doOut | |
con.setRequestProperty("Content-Type", "text/plain"); | ||
return con; | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
LOGGER.errorWithApp(null, "uri:" + url, e); | ||
return null; | ||
} | ||
|
||
|
@@ -206,7 +200,13 @@ private String readDataFromConnection(HttpURLConnection con) { | |
return result; | ||
} | ||
|
||
private String httpGet(String path) { | ||
/** | ||
* for get method | ||
* | ||
* @param path | ||
* @return | ||
*/ | ||
public String httpGet(String path) { | ||
HttpURLConnection con = null; | ||
String result = null; | ||
try { | ||
|
Oops, something went wrong.