From 696b53a6384375248e91df8bcbd45b4c16c29181 Mon Sep 17 00:00:00 2001 From: qinzuoyan Date: Sun, 13 Jan 2019 15:33:45 +0800 Subject: [PATCH 1/3] re-implement getting forward address from configuration_query_by_index_response --- idl/replication.thrift | 3 +- .../apps/check_and_mutate_request.java | 2 +- .../apps/check_and_mutate_response.java | 2 +- .../pegasus/apps/check_and_set_request.java | 2 +- .../pegasus/apps/check_and_set_response.java | 2 +- .../infra/pegasus/apps/count_response.java | 2 +- .../pegasus/apps/get_scanner_request.java | 2 +- .../infra/pegasus/apps/incr_request.java | 2 +- .../infra/pegasus/apps/incr_response.java | 2 +- .../xiaomi/infra/pegasus/apps/key_value.java | 2 +- .../com/xiaomi/infra/pegasus/apps/meta.java | 2 +- .../infra/pegasus/apps/multi_get_request.java | 2 +- .../pegasus/apps/multi_get_response.java | 2 +- .../infra/pegasus/apps/multi_put_request.java | 2 +- .../pegasus/apps/multi_remove_request.java | 2 +- .../pegasus/apps/multi_remove_response.java | 2 +- .../com/xiaomi/infra/pegasus/apps/mutate.java | 2 +- .../infra/pegasus/apps/read_response.java | 2 +- .../com/xiaomi/infra/pegasus/apps/rrdb.java | 2 +- .../infra/pegasus/apps/scan_request.java | 2 +- .../infra/pegasus/apps/scan_response.java | 2 +- .../infra/pegasus/apps/ttl_response.java | 2 +- .../infra/pegasus/apps/update_request.java | 2 +- .../infra/pegasus/apps/update_response.java | 2 +- .../replication/partition_configuration.java | 2 +- .../replication/query_cfg_request.java | 2 +- .../replication/query_cfg_response.java | 119 +----------------- .../infra/pegasus/rpc/async/MetaSession.java | 11 +- 28 files changed, 42 insertions(+), 141 deletions(-) diff --git a/idl/replication.thrift b/idl/replication.thrift index c816a806..29be735e 100644 --- a/idl/replication.thrift +++ b/idl/replication.thrift @@ -21,6 +21,8 @@ struct query_cfg_request 2:list partition_indices; } +// for server version > 1.11.2, if err == ERR_FORWARD_TO_OTHERS, +// then the forward address will be put in partitions[0].primary if exist. struct query_cfg_response { 1:base.error_code err; @@ -28,5 +30,4 @@ struct query_cfg_response 3:i32 partition_count; 4:bool is_stateful; 5:list partitions; - 6:base.rpc_address forward_address; } diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/check_and_mutate_request.java b/src/main/java/com/xiaomi/infra/pegasus/apps/check_and_mutate_request.java index 4c8fdd0c..a1c84126 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/check_and_mutate_request.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/check_and_mutate_request.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class check_and_mutate_request implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("check_and_mutate_request"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/check_and_mutate_response.java b/src/main/java/com/xiaomi/infra/pegasus/apps/check_and_mutate_response.java index 55dec1a8..8346d20b 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/check_and_mutate_response.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/check_and_mutate_response.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class check_and_mutate_response implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("check_and_mutate_response"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/check_and_set_request.java b/src/main/java/com/xiaomi/infra/pegasus/apps/check_and_set_request.java index 70985173..7d902c85 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/check_and_set_request.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/check_and_set_request.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class check_and_set_request implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("check_and_set_request"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/check_and_set_response.java b/src/main/java/com/xiaomi/infra/pegasus/apps/check_and_set_response.java index 5217413e..196f9437 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/check_and_set_response.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/check_and_set_response.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class check_and_set_response implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("check_and_set_response"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/count_response.java b/src/main/java/com/xiaomi/infra/pegasus/apps/count_response.java index 8ee1691d..6540a764 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/count_response.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/count_response.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class count_response implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("count_response"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/get_scanner_request.java b/src/main/java/com/xiaomi/infra/pegasus/apps/get_scanner_request.java index c4134750..edcaf2e9 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/get_scanner_request.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/get_scanner_request.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class get_scanner_request implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("get_scanner_request"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/incr_request.java b/src/main/java/com/xiaomi/infra/pegasus/apps/incr_request.java index 703cacab..e757f636 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/incr_request.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/incr_request.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class incr_request implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("incr_request"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/incr_response.java b/src/main/java/com/xiaomi/infra/pegasus/apps/incr_response.java index c6a89e80..a9b45fa4 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/incr_response.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/incr_response.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class incr_response implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("incr_response"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/key_value.java b/src/main/java/com/xiaomi/infra/pegasus/apps/key_value.java index 741bd50b..95aa9b1b 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/key_value.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/key_value.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class key_value implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("key_value"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/meta.java b/src/main/java/com/xiaomi/infra/pegasus/apps/meta.java index cd25f411..bbf5dc9e 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/meta.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/meta.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class meta { public interface Iface { diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/multi_get_request.java b/src/main/java/com/xiaomi/infra/pegasus/apps/multi_get_request.java index fecb8b22..7c7207a5 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/multi_get_request.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/multi_get_request.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class multi_get_request implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("multi_get_request"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/multi_get_response.java b/src/main/java/com/xiaomi/infra/pegasus/apps/multi_get_response.java index 0a9af533..bd14389a 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/multi_get_response.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/multi_get_response.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class multi_get_response implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("multi_get_response"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/multi_put_request.java b/src/main/java/com/xiaomi/infra/pegasus/apps/multi_put_request.java index 10f79fa4..300b0ff9 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/multi_put_request.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/multi_put_request.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class multi_put_request implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("multi_put_request"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/multi_remove_request.java b/src/main/java/com/xiaomi/infra/pegasus/apps/multi_remove_request.java index 3e1a53b1..85ed70e7 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/multi_remove_request.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/multi_remove_request.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class multi_remove_request implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("multi_remove_request"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/multi_remove_response.java b/src/main/java/com/xiaomi/infra/pegasus/apps/multi_remove_response.java index 23099ad1..ad372f9d 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/multi_remove_response.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/multi_remove_response.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class multi_remove_response implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("multi_remove_response"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/mutate.java b/src/main/java/com/xiaomi/infra/pegasus/apps/mutate.java index 55730d41..b12de56f 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/mutate.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/mutate.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class mutate implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("mutate"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/read_response.java b/src/main/java/com/xiaomi/infra/pegasus/apps/read_response.java index 5b9b845a..2dcbddd3 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/read_response.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/read_response.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class read_response implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("read_response"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/rrdb.java b/src/main/java/com/xiaomi/infra/pegasus/apps/rrdb.java index 15c7c70c..4efcf8d4 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/rrdb.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/rrdb.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class rrdb { public interface Iface { diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/scan_request.java b/src/main/java/com/xiaomi/infra/pegasus/apps/scan_request.java index 73e069ca..56f58f3a 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/scan_request.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/scan_request.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class scan_request implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("scan_request"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/scan_response.java b/src/main/java/com/xiaomi/infra/pegasus/apps/scan_response.java index 39a853b5..b99a7eec 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/scan_response.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/scan_response.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class scan_response implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("scan_response"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/ttl_response.java b/src/main/java/com/xiaomi/infra/pegasus/apps/ttl_response.java index b13803f8..1c694be1 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/ttl_response.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/ttl_response.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class ttl_response implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("ttl_response"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/update_request.java b/src/main/java/com/xiaomi/infra/pegasus/apps/update_request.java index 893d8a13..f87f84ad 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/update_request.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/update_request.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class update_request implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("update_request"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/update_response.java b/src/main/java/com/xiaomi/infra/pegasus/apps/update_response.java index 8f9bd6d4..b19438fd 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/update_response.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/update_response.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.apps; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class update_response implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("update_response"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/replication/partition_configuration.java b/src/main/java/com/xiaomi/infra/pegasus/replication/partition_configuration.java index dc087ba0..2e218a71 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/replication/partition_configuration.java +++ b/src/main/java/com/xiaomi/infra/pegasus/replication/partition_configuration.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.replication; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class partition_configuration implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("partition_configuration"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/replication/query_cfg_request.java b/src/main/java/com/xiaomi/infra/pegasus/replication/query_cfg_request.java index ce8c3d53..7242c88c 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/replication/query_cfg_request.java +++ b/src/main/java/com/xiaomi/infra/pegasus/replication/query_cfg_request.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.replication; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class query_cfg_request implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("query_cfg_request"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/replication/query_cfg_response.java b/src/main/java/com/xiaomi/infra/pegasus/replication/query_cfg_response.java index 70b407f2..4b3f7716 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/replication/query_cfg_response.java +++ b/src/main/java/com/xiaomi/infra/pegasus/replication/query_cfg_response.java @@ -10,7 +10,7 @@ package com.xiaomi.infra.pegasus.replication; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-12-27") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-13") public class query_cfg_response implements com.xiaomi.infra.pegasus.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final com.xiaomi.infra.pegasus.thrift.protocol.TStruct STRUCT_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TStruct("query_cfg_response"); @@ -19,7 +19,6 @@ public class query_cfg_response implements com.xiaomi.infra.pegasus.thrift.TBase private static final com.xiaomi.infra.pegasus.thrift.protocol.TField PARTITION_COUNT_FIELD_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TField("partition_count", com.xiaomi.infra.pegasus.thrift.protocol.TType.I32, (short)3); private static final com.xiaomi.infra.pegasus.thrift.protocol.TField IS_STATEFUL_FIELD_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TField("is_stateful", com.xiaomi.infra.pegasus.thrift.protocol.TType.BOOL, (short)4); private static final com.xiaomi.infra.pegasus.thrift.protocol.TField PARTITIONS_FIELD_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TField("partitions", com.xiaomi.infra.pegasus.thrift.protocol.TType.LIST, (short)5); - private static final com.xiaomi.infra.pegasus.thrift.protocol.TField FORWARD_ADDRESS_FIELD_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TField("forward_address", com.xiaomi.infra.pegasus.thrift.protocol.TType.STRUCT, (short)6); private static final com.xiaomi.infra.pegasus.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new query_cfg_responseStandardSchemeFactory(); private static final com.xiaomi.infra.pegasus.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new query_cfg_responseTupleSchemeFactory(); @@ -29,7 +28,6 @@ public class query_cfg_response implements com.xiaomi.infra.pegasus.thrift.TBase public int partition_count; // required public boolean is_stateful; // required public java.util.List partitions; // required - public com.xiaomi.infra.pegasus.base.rpc_address forward_address; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements com.xiaomi.infra.pegasus.thrift.TFieldIdEnum { @@ -37,8 +35,7 @@ public enum _Fields implements com.xiaomi.infra.pegasus.thrift.TFieldIdEnum { APP_ID((short)2, "app_id"), PARTITION_COUNT((short)3, "partition_count"), IS_STATEFUL((short)4, "is_stateful"), - PARTITIONS((short)5, "partitions"), - FORWARD_ADDRESS((short)6, "forward_address"); + PARTITIONS((short)5, "partitions"); private static final java.util.Map byName = new java.util.HashMap(); @@ -63,8 +60,6 @@ public static _Fields findByThriftId(int fieldId) { return IS_STATEFUL; case 5: // PARTITIONS return PARTITIONS; - case 6: // FORWARD_ADDRESS - return FORWARD_ADDRESS; default: return null; } @@ -123,8 +118,6 @@ public java.lang.String getFieldName() { tmpMap.put(_Fields.PARTITIONS, new com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData("partitions", com.xiaomi.infra.pegasus.thrift.TFieldRequirementType.DEFAULT, new com.xiaomi.infra.pegasus.thrift.meta_data.ListMetaData(com.xiaomi.infra.pegasus.thrift.protocol.TType.LIST, new com.xiaomi.infra.pegasus.thrift.meta_data.StructMetaData(com.xiaomi.infra.pegasus.thrift.protocol.TType.STRUCT, partition_configuration.class)))); - tmpMap.put(_Fields.FORWARD_ADDRESS, new com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData("forward_address", com.xiaomi.infra.pegasus.thrift.TFieldRequirementType.DEFAULT, - new com.xiaomi.infra.pegasus.thrift.meta_data.StructMetaData(com.xiaomi.infra.pegasus.thrift.protocol.TType.STRUCT, com.xiaomi.infra.pegasus.base.rpc_address.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData.addStructMetaDataMap(query_cfg_response.class, metaDataMap); } @@ -137,8 +130,7 @@ public query_cfg_response( int app_id, int partition_count, boolean is_stateful, - java.util.List partitions, - com.xiaomi.infra.pegasus.base.rpc_address forward_address) + java.util.List partitions) { this(); this.err = err; @@ -149,7 +141,6 @@ public query_cfg_response( this.is_stateful = is_stateful; setIs_statefulIsSet(true); this.partitions = partitions; - this.forward_address = forward_address; } /** @@ -170,9 +161,6 @@ public query_cfg_response(query_cfg_response other) { } this.partitions = __this__partitions; } - if (other.isSetForward_address()) { - this.forward_address = new com.xiaomi.infra.pegasus.base.rpc_address(other.forward_address); - } } public query_cfg_response deepCopy() { @@ -189,7 +177,6 @@ public void clear() { setIs_statefulIsSet(false); this.is_stateful = false; this.partitions = null; - this.forward_address = null; } public com.xiaomi.infra.pegasus.base.error_code getErr() { @@ -324,30 +311,6 @@ public void setPartitionsIsSet(boolean value) { } } - public com.xiaomi.infra.pegasus.base.rpc_address getForward_address() { - return this.forward_address; - } - - public query_cfg_response setForward_address(com.xiaomi.infra.pegasus.base.rpc_address forward_address) { - this.forward_address = forward_address; - return this; - } - - public void unsetForward_address() { - this.forward_address = null; - } - - /** Returns true if field forward_address is set (has been assigned a value) and false otherwise */ - public boolean isSetForward_address() { - return this.forward_address != null; - } - - public void setForward_addressIsSet(boolean value) { - if (!value) { - this.forward_address = null; - } - } - public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case ERR: @@ -390,14 +353,6 @@ public void setFieldValue(_Fields field, java.lang.Object value) { } break; - case FORWARD_ADDRESS: - if (value == null) { - unsetForward_address(); - } else { - setForward_address((com.xiaomi.infra.pegasus.base.rpc_address)value); - } - break; - } } @@ -418,9 +373,6 @@ public java.lang.Object getFieldValue(_Fields field) { case PARTITIONS: return getPartitions(); - case FORWARD_ADDRESS: - return getForward_address(); - } throw new java.lang.IllegalStateException(); } @@ -442,8 +394,6 @@ public boolean isSet(_Fields field) { return isSetIs_stateful(); case PARTITIONS: return isSetPartitions(); - case FORWARD_ADDRESS: - return isSetForward_address(); } throw new java.lang.IllegalStateException(); } @@ -508,15 +458,6 @@ public boolean equals(query_cfg_response that) { return false; } - boolean this_present_forward_address = true && this.isSetForward_address(); - boolean that_present_forward_address = true && that.isSetForward_address(); - if (this_present_forward_address || that_present_forward_address) { - if (!(this_present_forward_address && that_present_forward_address)) - return false; - if (!this.forward_address.equals(that.forward_address)) - return false; - } - return true; } @@ -538,10 +479,6 @@ public int hashCode() { if (isSetPartitions()) hashCode = hashCode * 8191 + partitions.hashCode(); - hashCode = hashCode * 8191 + ((isSetForward_address()) ? 131071 : 524287); - if (isSetForward_address()) - hashCode = hashCode * 8191 + forward_address.hashCode(); - return hashCode; } @@ -603,16 +540,6 @@ public int compareTo(query_cfg_response other) { return lastComparison; } } - lastComparison = java.lang.Boolean.valueOf(isSetForward_address()).compareTo(other.isSetForward_address()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetForward_address()) { - lastComparison = com.xiaomi.infra.pegasus.thrift.TBaseHelper.compareTo(this.forward_address, other.forward_address); - if (lastComparison != 0) { - return lastComparison; - } - } return 0; } @@ -660,14 +587,6 @@ public java.lang.String toString() { sb.append(this.partitions); } first = false; - if (!first) sb.append(", "); - sb.append("forward_address:"); - if (this.forward_address == null) { - sb.append("null"); - } else { - sb.append(this.forward_address); - } - first = false; sb.append(")"); return sb.toString(); } @@ -678,9 +597,6 @@ public void validate() throws com.xiaomi.infra.pegasus.thrift.TException { if (err != null) { err.validate(); } - if (forward_address != null) { - forward_address.validate(); - } } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { @@ -771,15 +687,6 @@ public void read(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol iprot, query com.xiaomi.infra.pegasus.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 6: // FORWARD_ADDRESS - if (schemeField.type == com.xiaomi.infra.pegasus.thrift.protocol.TType.STRUCT) { - struct.forward_address = new com.xiaomi.infra.pegasus.base.rpc_address(); - struct.forward_address.read(iprot); - struct.setForward_addressIsSet(true); - } else { - com.xiaomi.infra.pegasus.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; default: com.xiaomi.infra.pegasus.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -821,11 +728,6 @@ public void write(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol oprot, quer } oprot.writeFieldEnd(); } - if (struct.forward_address != null) { - oprot.writeFieldBegin(FORWARD_ADDRESS_FIELD_DESC); - struct.forward_address.write(oprot); - oprot.writeFieldEnd(); - } oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -859,10 +761,7 @@ public void write(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol prot, query if (struct.isSetPartitions()) { optionals.set(4); } - if (struct.isSetForward_address()) { - optionals.set(5); - } - oprot.writeBitSet(optionals, 6); + oprot.writeBitSet(optionals, 5); if (struct.isSetErr()) { struct.err.write(oprot); } @@ -884,15 +783,12 @@ public void write(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol prot, query } } } - if (struct.isSetForward_address()) { - struct.forward_address.write(oprot); - } } @Override public void read(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol prot, query_cfg_response struct) throws com.xiaomi.infra.pegasus.thrift.TException { com.xiaomi.infra.pegasus.thrift.protocol.TTupleProtocol iprot = (com.xiaomi.infra.pegasus.thrift.protocol.TTupleProtocol) prot; - java.util.BitSet incoming = iprot.readBitSet(6); + java.util.BitSet incoming = iprot.readBitSet(5); if (incoming.get(0)) { struct.err = new com.xiaomi.infra.pegasus.base.error_code(); struct.err.read(iprot); @@ -924,11 +820,6 @@ public void read(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol prot, query_ } struct.setPartitionsIsSet(true); } - if (incoming.get(5)) { - struct.forward_address = new com.xiaomi.infra.pegasus.base.rpc_address(); - struct.forward_address.read(iprot); - struct.setForward_addressIsSet(true); - } } } diff --git a/src/main/java/com/xiaomi/infra/pegasus/rpc/async/MetaSession.java b/src/main/java/com/xiaomi/infra/pegasus/rpc/async/MetaSession.java index 2171ed35..0870f25c 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/rpc/async/MetaSession.java +++ b/src/main/java/com/xiaomi/infra/pegasus/rpc/async/MetaSession.java @@ -7,6 +7,7 @@ import com.xiaomi.infra.pegasus.base.rpc_address; import com.xiaomi.infra.pegasus.operator.client_operator; import com.xiaomi.infra.pegasus.operator.query_cfg_operator; +import com.xiaomi.infra.pegasus.replication.partition_configuration; import io.netty.channel.EventLoopGroup; import java.util.ArrayList; @@ -55,7 +56,15 @@ static public final rpc_address getMetaServiceForwardAddress(client_operator met if (metaQueryOp.rpc_error.errno != error_types.ERR_OK) return null; query_cfg_operator op = (query_cfg_operator) metaQueryOp; - return op.get_response().getForward_address(); + if (op.get_response().getErr().errno != error_types.ERR_FORWARD_TO_OTHERS) + return null; + java.util.List partitions = op.get_response().getPartitions(); + if (partitions == null || partitions.isEmpty()) + return null; + rpc_address addr = partitions.get(0).getPrimary(); + if (addr == null || addr.isInvalid()) + return null; + return addr; } public final void asyncQuery(client_operator op, Runnable callbackFunc, int maxQueryCount) { From fb0485c61be04b8a495ba7d10f14fd78813a8116 Mon Sep 17 00:00:00 2001 From: qinzuoyan Date: Mon, 14 Jan 2019 11:12:59 +0800 Subject: [PATCH 2/3] improve --- .../infra/pegasus/rpc/async/MetaSession.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/xiaomi/infra/pegasus/rpc/async/MetaSession.java b/src/main/java/com/xiaomi/infra/pegasus/rpc/async/MetaSession.java index 0870f25c..70666d4b 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/rpc/async/MetaSession.java +++ b/src/main/java/com/xiaomi/infra/pegasus/rpc/async/MetaSession.java @@ -122,17 +122,13 @@ private final void onFinishQueryMeta(final MetaRequestRound round) { rpc_address forwardAddress = null; --round.maxQueryCount; - if (round.maxQueryCount == 0) { - round.callbackFunc.run(); - return; - } error_types metaError = error_types.ERR_UNKNOWN; if (op.rpc_error.errno == error_types.ERR_OK) { metaError = getMetaServiceError(op); if (metaError == error_types.ERR_SERVICE_NOT_ACTIVE) { - needDelay = true; - needSwitchLeader = false; + needDelay = false; + needSwitchLeader = true; } else if (metaError == error_types.ERR_FORWARD_TO_OTHERS) { needDelay = false; @@ -145,7 +141,7 @@ else if (metaError == error_types.ERR_FORWARD_TO_OTHERS) { } } else if (op.rpc_error.errno == error_types.ERR_SESSION_RESET || op.rpc_error.errno == error_types.ERR_TIMEOUT) { - needDelay = true; + needDelay = false; needSwitchLeader = true; } else { @@ -188,6 +184,11 @@ else if (metaList.get(curLeader) == round.lastSession) { round.lastSession = metaList.get(curLeader); } + if (round.maxQueryCount == 0) { + round.callbackFunc.run(); + return; + } + group.schedule(new Runnable() { @Override public void run() { From 7c8e012cd45093b644088e03e83308ba99a85c32 Mon Sep 17 00:00:00 2001 From: qinzuoyan Date: Mon, 14 Jan 2019 15:51:32 +0800 Subject: [PATCH 3/3] fix according to code review --- .../java/com/xiaomi/infra/pegasus/rpc/async/MetaSession.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/xiaomi/infra/pegasus/rpc/async/MetaSession.java b/src/main/java/com/xiaomi/infra/pegasus/rpc/async/MetaSession.java index 70666d4b..fc9d7ef8 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/rpc/async/MetaSession.java +++ b/src/main/java/com/xiaomi/infra/pegasus/rpc/async/MetaSession.java @@ -127,8 +127,8 @@ private final void onFinishQueryMeta(final MetaRequestRound round) { if (op.rpc_error.errno == error_types.ERR_OK) { metaError = getMetaServiceError(op); if (metaError == error_types.ERR_SERVICE_NOT_ACTIVE) { - needDelay = false; - needSwitchLeader = true; + needDelay = true; + needSwitchLeader = false; } else if (metaError == error_types.ERR_FORWARD_TO_OTHERS) { needDelay = false;