Skip to content

Commit a11d670

Browse files
committed
succeed to print log
1 parent 13d3ff3 commit a11d670

5 files changed

Lines changed: 31 additions & 5 deletions

File tree

src/main/java/com/alipay/oceanbase/rpc/location/LocationUtil.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package com.alipay.oceanbase.rpc.location;
1919

2020
import com.fasterxml.jackson.core.JsonProcessingException;
21+
import com.fasterxml.jackson.databind.DeserializationFeature;
2122
import com.fasterxml.jackson.databind.ObjectMapper;
2223
import com.alipay.oceanbase.rpc.ObGlobal;
2324
import com.alipay.oceanbase.rpc.constant.Constants;
@@ -33,6 +34,7 @@
3334
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObIndexType;
3435
import com.alipay.oceanbase.rpc.protocol.payload.impl.parser.ObGeneratedColumnExpressParser;
3536
import com.alipay.oceanbase.rpc.util.TableClientLoggerFactory;
37+
import com.fasterxml.jackson.databind.SerializationFeature;
3638
import org.slf4j.Logger;
3739

3840
import java.io.*;
@@ -56,7 +58,12 @@ public class LocationUtil {
5658

5759
private static final Logger logger = TableClientLoggerFactory
5860
.getLogger(LocationUtil.class);
61+
62+
private static final ObjectMapper objectMapper = new ObjectMapper();
63+
5964
static {
65+
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
66+
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
6067
loadJdbcDriver();
6168
}
6269

@@ -233,7 +240,6 @@ public class LocationUtil {
233240
.getProperty(
234241
"table.entry.location.refresh.threshold",
235242
"0"));
236-
private static ObjectMapper objectMapper = new ObjectMapper();
237243

238244
private abstract static class TableEntryRefreshWithPriorityCallback<T> {
239245
abstract T execute(ObServerAddr obServerAddr) throws ObTableEntryRefreshException;

src/main/java/com/alipay/oceanbase/rpc/location/model/OcpResponse.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@
1717

1818
package com.alipay.oceanbase.rpc.location.model;
1919

20+
import com.fasterxml.jackson.annotation.JsonProperty;
21+
2022
public class OcpResponse {
2123
private int Code;
2224
private String Message;
2325
private boolean Success;
2426
private OcpResponseData Data;
25-
public OcpResponse() {}
2627

2728
/*
2829
* Get code.
2930
*/
31+
@JsonProperty("Code")
3032
public int getCode() {
3133
return Code;
3234
}
@@ -41,6 +43,7 @@ public void setCode(int code) {
4143
/*
4244
* Get message.
4345
*/
46+
@JsonProperty("Message")
4447
public String getMessage() {
4548
return Message;
4649
}
@@ -59,6 +62,11 @@ public boolean isSuccess() {
5962
return Success;
6063
}
6164

65+
@JsonProperty("Success")
66+
public boolean getSuccess() {
67+
return Success;
68+
}
69+
6270
/*
6371
* Set success.
6472
*/
@@ -69,6 +77,7 @@ public void setSuccess(boolean success) {
6977
/*
7078
* Get data.
7179
*/
80+
@JsonProperty("Data")
7281
public OcpResponseData getData() {
7382
return Data;
7483
}

src/main/java/com/alipay/oceanbase/rpc/location/model/OcpResponseData.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@
1717

1818
package com.alipay.oceanbase.rpc.location.model;
1919

20+
import com.fasterxml.jackson.annotation.JsonProperty;
21+
2022
import java.util.List;
2123

2224
public class OcpResponseData {
2325
private String ObRegion;
2426
private long ObRegionId = -1;
2527
private List<OcpResponseDataRs> RsList;
2628
private List<OcpResponseDataIDC> IDCList;
27-
public OcpResponseData() {}
2829

2930
/*
3031
* Get ob region.
3132
*/
33+
@JsonProperty("ObRegion")
3234
public String getObRegion() {
3335
return ObRegion;
3436
}
@@ -43,6 +45,7 @@ public void setObRegion(String obRegion) {
4345
/*
4446
* Get ob region id.
4547
*/
48+
@JsonProperty("ObRegionId")
4649
public long getObRegionId() {
4750
return ObRegionId;
4851
}
@@ -57,6 +60,7 @@ public void setObRegionId(long obRegionId) {
5760
/*
5861
* Get rs list.
5962
*/
63+
@JsonProperty("RsList")
6064
public List<OcpResponseDataRs> getRsList() {
6165
return RsList;
6266
}

src/main/java/com/alipay/oceanbase/rpc/location/model/OcpResponseDataRs.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package com.alipay.oceanbase.rpc.location.model;
1919

20+
import com.fasterxml.jackson.annotation.JsonProperty;
21+
2022
public class OcpResponseDataRs {
2123
private String address;
2224
private String role;
@@ -26,6 +28,7 @@ public OcpResponseDataRs() {}
2628
/*
2729
* Get address.
2830
*/
31+
@JsonProperty("address")
2932
public String getAddress() {
3033
return address;
3134
}
@@ -40,6 +43,7 @@ public void setAddress(String address) {
4043
/*
4144
* Get role.
4245
*/
46+
@JsonProperty("role")
4347
public String getRole() {
4448
return role;
4549
}
@@ -54,6 +58,7 @@ public void setRole(String role) {
5458
/*
5559
* Get sql_port.
5660
*/
61+
@JsonProperty("sql_port")
5762
public int getSql_port() {
5863
return sql_port;
5964
}

src/test/java/com/alipay/oceanbase/rpc/ObTableClientInfoTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717

1818
package com.alipay.oceanbase.rpc;
1919

20-
import com.alibaba.fastjson.JSON;
2120
import com.alipay.oceanbase.rpc.property.Property;
2221
import com.alipay.oceanbase.rpc.util.ObTableClientTestUtil;
22+
import com.fasterxml.jackson.core.type.TypeReference;
23+
import com.fasterxml.jackson.databind.ObjectMapper;
2324
import org.junit.Assert;
2425
import org.junit.Before;
2526
import org.junit.Test;
@@ -129,7 +130,8 @@ private void checkGvClientInfo(Connection conn, String tenantName, String userNa
129130
for (int i = 0; i < clientCnt; i++) {
130131
String json_config_str = resultMap.get(clients[i].getClientId());
131132
Assert.assertTrue(json_config_str != null);
132-
Map<String, Object> config_map = JSON.parseObject(json_config_str);
133+
ObjectMapper objectMapper = new ObjectMapper();
134+
Map<String, Object> config_map = objectMapper.readValue(json_config_str, new TypeReference<Map<String, Object>>() {});
133135
Long srcClientId = (Long) clients[i].getTableConfigs().get("client_id");
134136
Long dstClientId = (Long) config_map.get("client_id");
135137
Assert.assertEquals(srcClientId, dstClientId);

0 commit comments

Comments
 (0)