diff --git a/idl/recompile_thrift.sh b/idl/recompile_thrift.sh index 63365f86..375e36e6 100755 --- a/idl/recompile_thrift.sh +++ b/idl/recompile_thrift.sh @@ -25,6 +25,7 @@ mkdir -p $TMP_DIR $thrift --gen java rrdb.thrift $thrift --gen java replication.thrift $thrift --gen java security.thrift +$thrift --gen java version.thrift # as we pack the thrift source in our project, so we need to replace the package name find $TMP_DIR -name "*.java" | xargs sed -i -e "s/org.apache.thrift/com.xiaomi.infra.pegasus.thrift/g" diff --git a/idl/version.thrift b/idl/version.thrift new file mode 100644 index 00000000..dab0a9c3 --- /dev/null +++ b/idl/version.thrift @@ -0,0 +1,23 @@ +include "base.thrift" + +namespace cpp dsn.apps +namespace java com.xiaomi.infra.pegasus.apps +namespace py pypegasus.rrdb + +enum version_nego_status +{ + INVALID = 0, + MISMATCH, + MATCH +} + +struct version_nego_message +{ + 1: version_nego_status status; + 2: base.blob version; +} + +service version +{ + version_nego_message negotiate(1:version_nego_message nego_msg); +} \ No newline at end of file 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..ecc28aa5 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-04") 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..40d3da63 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-04") 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..196c6020 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-04") 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..cb3eedbe 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-04") 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..6522bb5a 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-04") 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..6c13d84f 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-04") 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..938d7d18 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-04") 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..b811c882 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-04") 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..01e94e57 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-04") 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..774088ab 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-04") 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..02a77a96 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-04") 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..5615c00f 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-04") 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..61ed755f 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-04") 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..597e72b1 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-04") 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..d63309c1 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-04") 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..0240cfec 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-04") 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/negotiation_message.java b/src/main/java/com/xiaomi/infra/pegasus/apps/negotiation_message.java index ddcf86b2..2513539f 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/negotiation_message.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/negotiation_message.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-09-19") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-04") public class negotiation_message 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("negotiation_message"); 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..5990a5df 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-04") 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..389e0404 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-04") 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..4154f555 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-04") 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..954cb328 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-04") 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/security.java b/src/main/java/com/xiaomi/infra/pegasus/apps/security.java index 1bc48e15..afc5e5f0 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/apps/security.java +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/security.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-09-19") +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-04") public class security { public interface Iface { 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..a5e7b57e 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-04") 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..f9758c7f 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-04") 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..a6994ce5 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-04") 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/apps/version.java b/src/main/java/com/xiaomi/infra/pegasus/apps/version.java new file mode 100644 index 00000000..48923a34 --- /dev/null +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/version.java @@ -0,0 +1,977 @@ +// Copyright (c) 2017, Xiaomi, Inc. All rights reserved. +// This source code is licensed under the Apache License Version 2.0, which +// can be found in the LICENSE file in the root directory of this source tree. +/** + * Autogenerated by Thrift Compiler (0.11.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package com.xiaomi.infra.pegasus.apps; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-04") +public class version { + + public interface Iface { + + public version_nego_message negotiate(version_nego_message nego_msg) throws com.xiaomi.infra.pegasus.thrift.TException; + + } + + public interface AsyncIface { + + public void negotiate(version_nego_message nego_msg, com.xiaomi.infra.pegasus.thrift.async.AsyncMethodCallback resultHandler) throws com.xiaomi.infra.pegasus.thrift.TException; + + } + + public static class Client extends com.xiaomi.infra.pegasus.thrift.TServiceClient implements Iface { + public static class Factory implements com.xiaomi.infra.pegasus.thrift.TServiceClientFactory { + public Factory() {} + public Client getClient(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol prot) { + return new Client(prot); + } + public Client getClient(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol iprot, com.xiaomi.infra.pegasus.thrift.protocol.TProtocol oprot) { + return new Client(iprot, oprot); + } + } + + public Client(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol prot) + { + super(prot, prot); + } + + public Client(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol iprot, com.xiaomi.infra.pegasus.thrift.protocol.TProtocol oprot) { + super(iprot, oprot); + } + + public version_nego_message negotiate(version_nego_message nego_msg) throws com.xiaomi.infra.pegasus.thrift.TException + { + send_negotiate(nego_msg); + return recv_negotiate(); + } + + public void send_negotiate(version_nego_message nego_msg) throws com.xiaomi.infra.pegasus.thrift.TException + { + negotiate_args args = new negotiate_args(); + args.setNego_msg(nego_msg); + sendBase("negotiate", args); + } + + public version_nego_message recv_negotiate() throws com.xiaomi.infra.pegasus.thrift.TException + { + negotiate_result result = new negotiate_result(); + receiveBase(result, "negotiate"); + if (result.isSetSuccess()) { + return result.success; + } + throw new com.xiaomi.infra.pegasus.thrift.TApplicationException(com.xiaomi.infra.pegasus.thrift.TApplicationException.MISSING_RESULT, "negotiate failed: unknown result"); + } + + } + public static class AsyncClient extends com.xiaomi.infra.pegasus.thrift.async.TAsyncClient implements AsyncIface { + public static class Factory implements com.xiaomi.infra.pegasus.thrift.async.TAsyncClientFactory { + private com.xiaomi.infra.pegasus.thrift.async.TAsyncClientManager clientManager; + private com.xiaomi.infra.pegasus.thrift.protocol.TProtocolFactory protocolFactory; + public Factory(com.xiaomi.infra.pegasus.thrift.async.TAsyncClientManager clientManager, com.xiaomi.infra.pegasus.thrift.protocol.TProtocolFactory protocolFactory) { + this.clientManager = clientManager; + this.protocolFactory = protocolFactory; + } + public AsyncClient getAsyncClient(com.xiaomi.infra.pegasus.thrift.transport.TNonblockingTransport transport) { + return new AsyncClient(protocolFactory, clientManager, transport); + } + } + + public AsyncClient(com.xiaomi.infra.pegasus.thrift.protocol.TProtocolFactory protocolFactory, com.xiaomi.infra.pegasus.thrift.async.TAsyncClientManager clientManager, com.xiaomi.infra.pegasus.thrift.transport.TNonblockingTransport transport) { + super(protocolFactory, clientManager, transport); + } + + public void negotiate(version_nego_message nego_msg, com.xiaomi.infra.pegasus.thrift.async.AsyncMethodCallback resultHandler) throws com.xiaomi.infra.pegasus.thrift.TException { + checkReady(); + negotiate_call method_call = new negotiate_call(nego_msg, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class negotiate_call extends com.xiaomi.infra.pegasus.thrift.async.TAsyncMethodCall { + private version_nego_message nego_msg; + public negotiate_call(version_nego_message nego_msg, com.xiaomi.infra.pegasus.thrift.async.AsyncMethodCallback resultHandler, com.xiaomi.infra.pegasus.thrift.async.TAsyncClient client, com.xiaomi.infra.pegasus.thrift.protocol.TProtocolFactory protocolFactory, com.xiaomi.infra.pegasus.thrift.transport.TNonblockingTransport transport) throws com.xiaomi.infra.pegasus.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.nego_msg = nego_msg; + } + + public void write_args(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol prot) throws com.xiaomi.infra.pegasus.thrift.TException { + prot.writeMessageBegin(new com.xiaomi.infra.pegasus.thrift.protocol.TMessage("negotiate", com.xiaomi.infra.pegasus.thrift.protocol.TMessageType.CALL, 0)); + negotiate_args args = new negotiate_args(); + args.setNego_msg(nego_msg); + args.write(prot); + prot.writeMessageEnd(); + } + + public version_nego_message getResult() throws com.xiaomi.infra.pegasus.thrift.TException { + if (getState() != com.xiaomi.infra.pegasus.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new java.lang.IllegalStateException("Method call not finished!"); + } + com.xiaomi.infra.pegasus.thrift.transport.TMemoryInputTransport memoryTransport = new com.xiaomi.infra.pegasus.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + com.xiaomi.infra.pegasus.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_negotiate(); + } + } + + } + + public static class Processor extends com.xiaomi.infra.pegasus.thrift.TBaseProcessor implements com.xiaomi.infra.pegasus.thrift.TProcessor { + private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(Processor.class.getName()); + public Processor(I iface) { + super(iface, getProcessMap(new java.util.HashMap>())); + } + + protected Processor(I iface, java.util.Map> processMap) { + super(iface, getProcessMap(processMap)); + } + + private static java.util.Map> getProcessMap(java.util.Map> processMap) { + processMap.put("negotiate", new negotiate()); + return processMap; + } + + public static class negotiate extends com.xiaomi.infra.pegasus.thrift.ProcessFunction { + public negotiate() { + super("negotiate"); + } + + public negotiate_args getEmptyArgsInstance() { + return new negotiate_args(); + } + + protected boolean isOneway() { + return false; + } + + @Override + protected boolean handleRuntimeExceptions() { + return false; + } + + public negotiate_result getResult(I iface, negotiate_args args) throws com.xiaomi.infra.pegasus.thrift.TException { + negotiate_result result = new negotiate_result(); + result.success = iface.negotiate(args.nego_msg); + return result; + } + } + + } + + public static class AsyncProcessor extends com.xiaomi.infra.pegasus.thrift.TBaseAsyncProcessor { + private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(AsyncProcessor.class.getName()); + public AsyncProcessor(I iface) { + super(iface, getProcessMap(new java.util.HashMap>())); + } + + protected AsyncProcessor(I iface, java.util.Map> processMap) { + super(iface, getProcessMap(processMap)); + } + + private static java.util.Map> getProcessMap(java.util.Map> processMap) { + processMap.put("negotiate", new negotiate()); + return processMap; + } + + public static class negotiate extends com.xiaomi.infra.pegasus.thrift.AsyncProcessFunction { + public negotiate() { + super("negotiate"); + } + + public negotiate_args getEmptyArgsInstance() { + return new negotiate_args(); + } + + public com.xiaomi.infra.pegasus.thrift.async.AsyncMethodCallback getResultHandler(final com.xiaomi.infra.pegasus.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { + final com.xiaomi.infra.pegasus.thrift.AsyncProcessFunction fcall = this; + return new com.xiaomi.infra.pegasus.thrift.async.AsyncMethodCallback() { + public void onComplete(version_nego_message o) { + negotiate_result result = new negotiate_result(); + result.success = o; + try { + fcall.sendResponse(fb, result, com.xiaomi.infra.pegasus.thrift.protocol.TMessageType.REPLY,seqid); + } catch (com.xiaomi.infra.pegasus.thrift.transport.TTransportException e) { + _LOGGER.error("TTransportException writing to internal frame buffer", e); + fb.close(); + } catch (java.lang.Exception e) { + _LOGGER.error("Exception writing to internal frame buffer", e); + onError(e); + } + } + public void onError(java.lang.Exception e) { + byte msgType = com.xiaomi.infra.pegasus.thrift.protocol.TMessageType.REPLY; + com.xiaomi.infra.pegasus.thrift.TSerializable msg; + negotiate_result result = new negotiate_result(); + if (e instanceof com.xiaomi.infra.pegasus.thrift.transport.TTransportException) { + _LOGGER.error("TTransportException inside handler", e); + fb.close(); + return; + } else if (e instanceof com.xiaomi.infra.pegasus.thrift.TApplicationException) { + _LOGGER.error("TApplicationException inside handler", e); + msgType = com.xiaomi.infra.pegasus.thrift.protocol.TMessageType.EXCEPTION; + msg = (com.xiaomi.infra.pegasus.thrift.TApplicationException)e; + } else { + _LOGGER.error("Exception inside handler", e); + msgType = com.xiaomi.infra.pegasus.thrift.protocol.TMessageType.EXCEPTION; + msg = new com.xiaomi.infra.pegasus.thrift.TApplicationException(com.xiaomi.infra.pegasus.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + } catch (java.lang.Exception ex) { + _LOGGER.error("Exception writing to internal frame buffer", ex); + fb.close(); + } + } + }; + } + + protected boolean isOneway() { + return false; + } + + public void start(I iface, negotiate_args args, com.xiaomi.infra.pegasus.thrift.async.AsyncMethodCallback resultHandler) throws com.xiaomi.infra.pegasus.thrift.TException { + iface.negotiate(args.nego_msg,resultHandler); + } + } + + } + + public static class negotiate_args 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("negotiate_args"); + + private static final com.xiaomi.infra.pegasus.thrift.protocol.TField NEGO_MSG_FIELD_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TField("nego_msg", com.xiaomi.infra.pegasus.thrift.protocol.TType.STRUCT, (short)1); + + private static final com.xiaomi.infra.pegasus.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new negotiate_argsStandardSchemeFactory(); + private static final com.xiaomi.infra.pegasus.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new negotiate_argsTupleSchemeFactory(); + + public version_nego_message nego_msg; // 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 { + NEGO_MSG((short)1, "nego_msg"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // NEGO_MSG + return NEGO_MSG; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public java.lang.String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final java.util.Map<_Fields, com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.NEGO_MSG, new com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData("nego_msg", com.xiaomi.infra.pegasus.thrift.TFieldRequirementType.DEFAULT, + new com.xiaomi.infra.pegasus.thrift.meta_data.StructMetaData(com.xiaomi.infra.pegasus.thrift.protocol.TType.STRUCT, version_nego_message.class))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData.addStructMetaDataMap(negotiate_args.class, metaDataMap); + } + + public negotiate_args() { + } + + public negotiate_args( + version_nego_message nego_msg) + { + this(); + this.nego_msg = nego_msg; + } + + /** + * Performs a deep copy on other. + */ + public negotiate_args(negotiate_args other) { + if (other.isSetNego_msg()) { + this.nego_msg = new version_nego_message(other.nego_msg); + } + } + + public negotiate_args deepCopy() { + return new negotiate_args(this); + } + + @Override + public void clear() { + this.nego_msg = null; + } + + public version_nego_message getNego_msg() { + return this.nego_msg; + } + + public negotiate_args setNego_msg(version_nego_message nego_msg) { + this.nego_msg = nego_msg; + return this; + } + + public void unsetNego_msg() { + this.nego_msg = null; + } + + /** Returns true if field nego_msg is set (has been assigned a value) and false otherwise */ + public boolean isSetNego_msg() { + return this.nego_msg != null; + } + + public void setNego_msgIsSet(boolean value) { + if (!value) { + this.nego_msg = null; + } + } + + public void setFieldValue(_Fields field, java.lang.Object value) { + switch (field) { + case NEGO_MSG: + if (value == null) { + unsetNego_msg(); + } else { + setNego_msg((version_nego_message)value); + } + break; + + } + } + + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + case NEGO_MSG: + return getNego_msg(); + + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + case NEGO_MSG: + return isSetNego_msg(); + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that == null) + return false; + if (that instanceof negotiate_args) + return this.equals((negotiate_args)that); + return false; + } + + public boolean equals(negotiate_args that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_nego_msg = true && this.isSetNego_msg(); + boolean that_present_nego_msg = true && that.isSetNego_msg(); + if (this_present_nego_msg || that_present_nego_msg) { + if (!(this_present_nego_msg && that_present_nego_msg)) + return false; + if (!this.nego_msg.equals(that.nego_msg)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetNego_msg()) ? 131071 : 524287); + if (isSetNego_msg()) + hashCode = hashCode * 8191 + nego_msg.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(negotiate_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = java.lang.Boolean.valueOf(isSetNego_msg()).compareTo(other.isSetNego_msg()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetNego_msg()) { + lastComparison = com.xiaomi.infra.pegasus.thrift.TBaseHelper.compareTo(this.nego_msg, other.nego_msg); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol iprot) throws com.xiaomi.infra.pegasus.thrift.TException { + scheme(iprot).read(iprot, this); + } + + public void write(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol oprot) throws com.xiaomi.infra.pegasus.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("negotiate_args("); + boolean first = true; + + sb.append("nego_msg:"); + if (this.nego_msg == null) { + sb.append("null"); + } else { + sb.append(this.nego_msg); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws com.xiaomi.infra.pegasus.thrift.TException { + // check for required fields + // check for sub-struct validity + if (nego_msg != null) { + nego_msg.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new com.xiaomi.infra.pegasus.thrift.protocol.TCompactProtocol(new com.xiaomi.infra.pegasus.thrift.transport.TIOStreamTransport(out))); + } catch (com.xiaomi.infra.pegasus.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { + try { + read(new com.xiaomi.infra.pegasus.thrift.protocol.TCompactProtocol(new com.xiaomi.infra.pegasus.thrift.transport.TIOStreamTransport(in))); + } catch (com.xiaomi.infra.pegasus.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class negotiate_argsStandardSchemeFactory implements com.xiaomi.infra.pegasus.thrift.scheme.SchemeFactory { + public negotiate_argsStandardScheme getScheme() { + return new negotiate_argsStandardScheme(); + } + } + + private static class negotiate_argsStandardScheme extends com.xiaomi.infra.pegasus.thrift.scheme.StandardScheme { + + public void read(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol iprot, negotiate_args struct) throws com.xiaomi.infra.pegasus.thrift.TException { + com.xiaomi.infra.pegasus.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == com.xiaomi.infra.pegasus.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // NEGO_MSG + if (schemeField.type == com.xiaomi.infra.pegasus.thrift.protocol.TType.STRUCT) { + struct.nego_msg = new version_nego_message(); + struct.nego_msg.read(iprot); + struct.setNego_msgIsSet(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); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol oprot, negotiate_args struct) throws com.xiaomi.infra.pegasus.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.nego_msg != null) { + oprot.writeFieldBegin(NEGO_MSG_FIELD_DESC); + struct.nego_msg.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class negotiate_argsTupleSchemeFactory implements com.xiaomi.infra.pegasus.thrift.scheme.SchemeFactory { + public negotiate_argsTupleScheme getScheme() { + return new negotiate_argsTupleScheme(); + } + } + + private static class negotiate_argsTupleScheme extends com.xiaomi.infra.pegasus.thrift.scheme.TupleScheme { + + @Override + public void write(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol prot, negotiate_args struct) throws com.xiaomi.infra.pegasus.thrift.TException { + com.xiaomi.infra.pegasus.thrift.protocol.TTupleProtocol oprot = (com.xiaomi.infra.pegasus.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetNego_msg()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetNego_msg()) { + struct.nego_msg.write(oprot); + } + } + + @Override + public void read(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol prot, negotiate_args 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(1); + if (incoming.get(0)) { + struct.nego_msg = new version_nego_message(); + struct.nego_msg.read(iprot); + struct.setNego_msgIsSet(true); + } + } + } + + private static S scheme(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol proto) { + return (com.xiaomi.infra.pegasus.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + + public static class negotiate_result 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("negotiate_result"); + + private static final com.xiaomi.infra.pegasus.thrift.protocol.TField SUCCESS_FIELD_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TField("success", com.xiaomi.infra.pegasus.thrift.protocol.TType.STRUCT, (short)0); + + private static final com.xiaomi.infra.pegasus.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new negotiate_resultStandardSchemeFactory(); + private static final com.xiaomi.infra.pegasus.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new negotiate_resultTupleSchemeFactory(); + + public version_nego_message success; // 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 { + SUCCESS((short)0, "success"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public java.lang.String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final java.util.Map<_Fields, com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData("success", com.xiaomi.infra.pegasus.thrift.TFieldRequirementType.DEFAULT, + new com.xiaomi.infra.pegasus.thrift.meta_data.StructMetaData(com.xiaomi.infra.pegasus.thrift.protocol.TType.STRUCT, version_nego_message.class))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData.addStructMetaDataMap(negotiate_result.class, metaDataMap); + } + + public negotiate_result() { + } + + public negotiate_result( + version_nego_message success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public negotiate_result(negotiate_result other) { + if (other.isSetSuccess()) { + this.success = new version_nego_message(other.success); + } + } + + public negotiate_result deepCopy() { + return new negotiate_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public version_nego_message getSuccess() { + return this.success; + } + + public negotiate_result setSuccess(version_nego_message success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, java.lang.Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((version_nego_message)value); + } + break; + + } + } + + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that == null) + return false; + if (that instanceof negotiate_result) + return this.equals((negotiate_result)that); + return false; + } + + public boolean equals(negotiate_result that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287); + if (isSetSuccess()) + hashCode = hashCode * 8191 + success.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(negotiate_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = com.xiaomi.infra.pegasus.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol iprot) throws com.xiaomi.infra.pegasus.thrift.TException { + scheme(iprot).read(iprot, this); + } + + public void write(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol oprot) throws com.xiaomi.infra.pegasus.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("negotiate_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws com.xiaomi.infra.pegasus.thrift.TException { + // check for required fields + // check for sub-struct validity + if (success != null) { + success.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new com.xiaomi.infra.pegasus.thrift.protocol.TCompactProtocol(new com.xiaomi.infra.pegasus.thrift.transport.TIOStreamTransport(out))); + } catch (com.xiaomi.infra.pegasus.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { + try { + read(new com.xiaomi.infra.pegasus.thrift.protocol.TCompactProtocol(new com.xiaomi.infra.pegasus.thrift.transport.TIOStreamTransport(in))); + } catch (com.xiaomi.infra.pegasus.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class negotiate_resultStandardSchemeFactory implements com.xiaomi.infra.pegasus.thrift.scheme.SchemeFactory { + public negotiate_resultStandardScheme getScheme() { + return new negotiate_resultStandardScheme(); + } + } + + private static class negotiate_resultStandardScheme extends com.xiaomi.infra.pegasus.thrift.scheme.StandardScheme { + + public void read(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol iprot, negotiate_result struct) throws com.xiaomi.infra.pegasus.thrift.TException { + com.xiaomi.infra.pegasus.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == com.xiaomi.infra.pegasus.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == com.xiaomi.infra.pegasus.thrift.protocol.TType.STRUCT) { + struct.success = new version_nego_message(); + struct.success.read(iprot); + struct.setSuccessIsSet(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); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol oprot, negotiate_result struct) throws com.xiaomi.infra.pegasus.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + struct.success.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class negotiate_resultTupleSchemeFactory implements com.xiaomi.infra.pegasus.thrift.scheme.SchemeFactory { + public negotiate_resultTupleScheme getScheme() { + return new negotiate_resultTupleScheme(); + } + } + + private static class negotiate_resultTupleScheme extends com.xiaomi.infra.pegasus.thrift.scheme.TupleScheme { + + @Override + public void write(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol prot, negotiate_result struct) throws com.xiaomi.infra.pegasus.thrift.TException { + com.xiaomi.infra.pegasus.thrift.protocol.TTupleProtocol oprot = (com.xiaomi.infra.pegasus.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + struct.success.write(oprot); + } + } + + @Override + public void read(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol prot, negotiate_result 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(1); + if (incoming.get(0)) { + struct.success = new version_nego_message(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } + } + } + + private static S scheme(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol proto) { + return (com.xiaomi.infra.pegasus.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + +} diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/version_nego_message.java b/src/main/java/com/xiaomi/infra/pegasus/apps/version_nego_message.java new file mode 100644 index 00000000..17df4b42 --- /dev/null +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/version_nego_message.java @@ -0,0 +1,500 @@ +// Copyright (c) 2017, Xiaomi, Inc. All rights reserved. +// This source code is licensed under the Apache License Version 2.0, which +// can be found in the LICENSE file in the root directory of this source tree. +/** + * Autogenerated by Thrift Compiler (0.11.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package com.xiaomi.infra.pegasus.apps; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-04") +public class version_nego_message 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("version_nego_message"); + + private static final com.xiaomi.infra.pegasus.thrift.protocol.TField STATUS_FIELD_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TField("status", com.xiaomi.infra.pegasus.thrift.protocol.TType.I32, (short)1); + private static final com.xiaomi.infra.pegasus.thrift.protocol.TField VERSION_FIELD_DESC = new com.xiaomi.infra.pegasus.thrift.protocol.TField("version", com.xiaomi.infra.pegasus.thrift.protocol.TType.STRUCT, (short)2); + + private static final com.xiaomi.infra.pegasus.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new version_nego_messageStandardSchemeFactory(); + private static final com.xiaomi.infra.pegasus.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new version_nego_messageTupleSchemeFactory(); + + /** + * + * @see version_nego_status + */ + public version_nego_status status; // required + public com.xiaomi.infra.pegasus.base.blob version; // 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 { + /** + * + * @see version_nego_status + */ + STATUS((short)1, "status"), + VERSION((short)2, "version"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // STATUS + return STATUS; + case 2: // VERSION + return VERSION; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(java.lang.String name) { + return byName.get(name); + } + + private final short _thriftId; + private final java.lang.String _fieldName; + + _Fields(short thriftId, java.lang.String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public java.lang.String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final java.util.Map<_Fields, com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.STATUS, new com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData("status", com.xiaomi.infra.pegasus.thrift.TFieldRequirementType.DEFAULT, + new com.xiaomi.infra.pegasus.thrift.meta_data.EnumMetaData(com.xiaomi.infra.pegasus.thrift.protocol.TType.ENUM, version_nego_status.class))); + tmpMap.put(_Fields.VERSION, new com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData("version", 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.blob.class))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + com.xiaomi.infra.pegasus.thrift.meta_data.FieldMetaData.addStructMetaDataMap(version_nego_message.class, metaDataMap); + } + + public version_nego_message() { + } + + public version_nego_message( + version_nego_status status, + com.xiaomi.infra.pegasus.base.blob version) + { + this(); + this.status = status; + this.version = version; + } + + /** + * Performs a deep copy on other. + */ + public version_nego_message(version_nego_message other) { + if (other.isSetStatus()) { + this.status = other.status; + } + if (other.isSetVersion()) { + this.version = new com.xiaomi.infra.pegasus.base.blob(other.version); + } + } + + public version_nego_message deepCopy() { + return new version_nego_message(this); + } + + @Override + public void clear() { + this.status = null; + this.version = null; + } + + /** + * + * @see version_nego_status + */ + public version_nego_status getStatus() { + return this.status; + } + + /** + * + * @see version_nego_status + */ + public version_nego_message setStatus(version_nego_status status) { + this.status = status; + return this; + } + + public void unsetStatus() { + this.status = null; + } + + /** Returns true if field status is set (has been assigned a value) and false otherwise */ + public boolean isSetStatus() { + return this.status != null; + } + + public void setStatusIsSet(boolean value) { + if (!value) { + this.status = null; + } + } + + public com.xiaomi.infra.pegasus.base.blob getVersion() { + return this.version; + } + + public version_nego_message setVersion(com.xiaomi.infra.pegasus.base.blob version) { + this.version = version; + return this; + } + + public void unsetVersion() { + this.version = null; + } + + /** Returns true if field version is set (has been assigned a value) and false otherwise */ + public boolean isSetVersion() { + return this.version != null; + } + + public void setVersionIsSet(boolean value) { + if (!value) { + this.version = null; + } + } + + public void setFieldValue(_Fields field, java.lang.Object value) { + switch (field) { + case STATUS: + if (value == null) { + unsetStatus(); + } else { + setStatus((version_nego_status)value); + } + break; + + case VERSION: + if (value == null) { + unsetVersion(); + } else { + setVersion((com.xiaomi.infra.pegasus.base.blob)value); + } + break; + + } + } + + public java.lang.Object getFieldValue(_Fields field) { + switch (field) { + case STATUS: + return getStatus(); + + case VERSION: + return getVersion(); + + } + throw new java.lang.IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new java.lang.IllegalArgumentException(); + } + + switch (field) { + case STATUS: + return isSetStatus(); + case VERSION: + return isSetVersion(); + } + throw new java.lang.IllegalStateException(); + } + + @Override + public boolean equals(java.lang.Object that) { + if (that == null) + return false; + if (that instanceof version_nego_message) + return this.equals((version_nego_message)that); + return false; + } + + public boolean equals(version_nego_message that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_status = true && this.isSetStatus(); + boolean that_present_status = true && that.isSetStatus(); + if (this_present_status || that_present_status) { + if (!(this_present_status && that_present_status)) + return false; + if (!this.status.equals(that.status)) + return false; + } + + boolean this_present_version = true && this.isSetVersion(); + boolean that_present_version = true && that.isSetVersion(); + if (this_present_version || that_present_version) { + if (!(this_present_version && that_present_version)) + return false; + if (!this.version.equals(that.version)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetStatus()) ? 131071 : 524287); + if (isSetStatus()) + hashCode = hashCode * 8191 + status.getValue(); + + hashCode = hashCode * 8191 + ((isSetVersion()) ? 131071 : 524287); + if (isSetVersion()) + hashCode = hashCode * 8191 + version.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(version_nego_message other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = java.lang.Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStatus()) { + lastComparison = com.xiaomi.infra.pegasus.thrift.TBaseHelper.compareTo(this.status, other.status); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = java.lang.Boolean.valueOf(isSetVersion()).compareTo(other.isSetVersion()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetVersion()) { + lastComparison = com.xiaomi.infra.pegasus.thrift.TBaseHelper.compareTo(this.version, other.version); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol iprot) throws com.xiaomi.infra.pegasus.thrift.TException { + scheme(iprot).read(iprot, this); + } + + public void write(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol oprot) throws com.xiaomi.infra.pegasus.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder("version_nego_message("); + boolean first = true; + + sb.append("status:"); + if (this.status == null) { + sb.append("null"); + } else { + sb.append(this.status); + } + first = false; + if (!first) sb.append(", "); + sb.append("version:"); + if (this.version == null) { + sb.append("null"); + } else { + sb.append(this.version); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws com.xiaomi.infra.pegasus.thrift.TException { + // check for required fields + // check for sub-struct validity + if (version != null) { + version.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new com.xiaomi.infra.pegasus.thrift.protocol.TCompactProtocol(new com.xiaomi.infra.pegasus.thrift.transport.TIOStreamTransport(out))); + } catch (com.xiaomi.infra.pegasus.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { + try { + read(new com.xiaomi.infra.pegasus.thrift.protocol.TCompactProtocol(new com.xiaomi.infra.pegasus.thrift.transport.TIOStreamTransport(in))); + } catch (com.xiaomi.infra.pegasus.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class version_nego_messageStandardSchemeFactory implements com.xiaomi.infra.pegasus.thrift.scheme.SchemeFactory { + public version_nego_messageStandardScheme getScheme() { + return new version_nego_messageStandardScheme(); + } + } + + private static class version_nego_messageStandardScheme extends com.xiaomi.infra.pegasus.thrift.scheme.StandardScheme { + + public void read(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol iprot, version_nego_message struct) throws com.xiaomi.infra.pegasus.thrift.TException { + com.xiaomi.infra.pegasus.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == com.xiaomi.infra.pegasus.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // STATUS + if (schemeField.type == com.xiaomi.infra.pegasus.thrift.protocol.TType.I32) { + struct.status = com.xiaomi.infra.pegasus.apps.version_nego_status.findByValue(iprot.readI32()); + struct.setStatusIsSet(true); + } else { + com.xiaomi.infra.pegasus.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // VERSION + if (schemeField.type == com.xiaomi.infra.pegasus.thrift.protocol.TType.STRUCT) { + struct.version = new com.xiaomi.infra.pegasus.base.blob(); + struct.version.read(iprot); + struct.setVersionIsSet(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); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol oprot, version_nego_message struct) throws com.xiaomi.infra.pegasus.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.status != null) { + oprot.writeFieldBegin(STATUS_FIELD_DESC); + oprot.writeI32(struct.status.getValue()); + oprot.writeFieldEnd(); + } + if (struct.version != null) { + oprot.writeFieldBegin(VERSION_FIELD_DESC); + struct.version.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class version_nego_messageTupleSchemeFactory implements com.xiaomi.infra.pegasus.thrift.scheme.SchemeFactory { + public version_nego_messageTupleScheme getScheme() { + return new version_nego_messageTupleScheme(); + } + } + + private static class version_nego_messageTupleScheme extends com.xiaomi.infra.pegasus.thrift.scheme.TupleScheme { + + @Override + public void write(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol prot, version_nego_message struct) throws com.xiaomi.infra.pegasus.thrift.TException { + com.xiaomi.infra.pegasus.thrift.protocol.TTupleProtocol oprot = (com.xiaomi.infra.pegasus.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetStatus()) { + optionals.set(0); + } + if (struct.isSetVersion()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetStatus()) { + oprot.writeI32(struct.status.getValue()); + } + if (struct.isSetVersion()) { + struct.version.write(oprot); + } + } + + @Override + public void read(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol prot, version_nego_message 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(2); + if (incoming.get(0)) { + struct.status = com.xiaomi.infra.pegasus.apps.version_nego_status.findByValue(iprot.readI32()); + struct.setStatusIsSet(true); + } + if (incoming.get(1)) { + struct.version = new com.xiaomi.infra.pegasus.base.blob(); + struct.version.read(iprot); + struct.setVersionIsSet(true); + } + } + } + + private static S scheme(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol proto) { + return (com.xiaomi.infra.pegasus.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } +} + diff --git a/src/main/java/com/xiaomi/infra/pegasus/apps/version_nego_status.java b/src/main/java/com/xiaomi/infra/pegasus/apps/version_nego_status.java new file mode 100644 index 00000000..dda4aa72 --- /dev/null +++ b/src/main/java/com/xiaomi/infra/pegasus/apps/version_nego_status.java @@ -0,0 +1,47 @@ +// Copyright (c) 2017, Xiaomi, Inc. All rights reserved. +// This source code is licensed under the Apache License Version 2.0, which +// can be found in the LICENSE file in the root directory of this source tree. +/** + * Autogenerated by Thrift Compiler (0.11.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package com.xiaomi.infra.pegasus.apps; + + +public enum version_nego_status implements com.xiaomi.infra.pegasus.thrift.TEnum { + INVALID(0), + MISMATCH(1), + MATCH(2); + + private final int value; + + private version_nego_status(int value) { + this.value = value; + } + + /** + * Get the integer value of this enum value, as defined in the Thrift IDL. + */ + public int getValue() { + return value; + } + + /** + * Find a the enum type by its integer value, as defined in the Thrift IDL. + * @return null if the value is not found. + */ + public static version_nego_status findByValue(int value) { + switch (value) { + case 0: + return INVALID; + case 1: + return MISMATCH; + case 2: + return MATCH; + default: + return null; + } + } +} diff --git a/src/main/java/com/xiaomi/infra/pegasus/operator/version_nego_operator.java b/src/main/java/com/xiaomi/infra/pegasus/operator/version_nego_operator.java new file mode 100644 index 00000000..d09f0668 --- /dev/null +++ b/src/main/java/com/xiaomi/infra/pegasus/operator/version_nego_operator.java @@ -0,0 +1,49 @@ +// Copyright (c) 2017, Xiaomi, Inc. All rights reserved. +// This source code is licensed under the Apache License Version 2.0, which +// can be found in the LICENSE file in the root directory of this source tree. +package com.xiaomi.infra.pegasus.operator; + +import com.xiaomi.infra.pegasus.apps.version; +import com.xiaomi.infra.pegasus.apps.version_nego_message; +import com.xiaomi.infra.pegasus.base.gpid; +import com.xiaomi.infra.pegasus.thrift.TException; +import com.xiaomi.infra.pegasus.thrift.protocol.TMessage; +import com.xiaomi.infra.pegasus.thrift.protocol.TMessageType; + +public class version_nego_operator extends client_operator { + public version_nego_operator(version_nego_message request) { + super(new gpid(), ""); // TODO HW gpid and tableName needless + this.request = request; + } + + public String name() { + return "version_negotiate"; + } + + public void send_data(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol oprot, int seqid) + throws TException { + TMessage msg = new TMessage("RPC_VERSION_NEGO", TMessageType.CALL, seqid); + oprot.writeMessageBegin(msg); + version.negotiate_args get_args = new version.negotiate_args(request); + get_args.write(oprot); + oprot.writeMessageEnd(); + } + + public void recv_data(com.xiaomi.infra.pegasus.thrift.protocol.TProtocol iprot) + throws TException { + version.negotiate_result result = new version.negotiate_result(); + result.read(iprot); + if (result.isSetSuccess()) resp = result.success; + else + throw new com.xiaomi.infra.pegasus.thrift.TApplicationException( + com.xiaomi.infra.pegasus.thrift.TApplicationException.MISSING_RESULT, + "get failed: unknown result"); + } + + public version_nego_message get_response() { + return resp; + } + + private version_nego_message request; + private version_nego_message resp; +} \ No newline at end of file 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..00627752 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-04") 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..a4723541 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-04") 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..bd483b78 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-04") 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"); diff --git a/src/main/java/com/xiaomi/infra/pegasus/rpc/async/ReplicaSession.java b/src/main/java/com/xiaomi/infra/pegasus/rpc/async/ReplicaSession.java index 15015be0..52f4c559 100644 --- a/src/main/java/com/xiaomi/infra/pegasus/rpc/async/ReplicaSession.java +++ b/src/main/java/com/xiaomi/infra/pegasus/rpc/async/ReplicaSession.java @@ -5,12 +5,15 @@ import com.xiaomi.infra.pegasus.apps.negotiation_message; import com.xiaomi.infra.pegasus.apps.negotiation_status; +import com.xiaomi.infra.pegasus.apps.version_nego_message; +import com.xiaomi.infra.pegasus.apps.version_nego_status; import com.xiaomi.infra.pegasus.base.blob; import com.xiaomi.infra.pegasus.base.error_code.error_types; import com.xiaomi.infra.pegasus.base.rpc_address; import com.xiaomi.infra.pegasus.operator.client_operator; import com.xiaomi.infra.pegasus.operator.negotiate_operator; +import com.xiaomi.infra.pegasus.operator.version_nego_operator; import com.xiaomi.infra.pegasus.rpc.ReplicationException; import com.xiaomi.infra.pegasus.thrift.protocol.TMessage; import io.netty.channel.*; @@ -57,7 +60,7 @@ public ReplicaSession(rpc_address address, EventLoopGroup rpcGroup, int socketTi } // You can specify a message response filter with constructor or with "setMessageResponseFilter" function. - // the mainly usage of filter is test, in which you can control whether to abaondon a response + // the mainly usage of filter is test, in which you can control whether to abandon a response // and how to abandon it, so as to emulate some network failure cases public ReplicaSession(rpc_address address, EventLoopGroup rpcGroup, int socketTimeout, MessageResponseFilter filter) { this(address, rpcGroup, socketTimeout, false, null, null, null); @@ -92,7 +95,7 @@ public void initChannel(SocketChannel ch) { // QOP(Quality of Protection) mismatch between client and server may cause the error - No common protection layer between client and server props.put(Sasl.QOP, "auth"); } else { - this.subject = new Subject(); + this.subject = null;//new Subject();// } } @@ -215,8 +218,9 @@ private void markSessionNegotiation(Channel activeChannel) { newCache.state = ConnState.NEGOTIATION; newCache.nettyChannel = activeChannel; fields = newCache; - logger.info("{}: mark session state negotiation, now negotiate", name()); - startNegotiation(); + logger.info("{}: mark session state negotiation(phase 1: version; phase 2: security), now negotiate in phase 1", name()); + //startNegotiation(); + //startVersionNego(); } private void markSessionDisconnect() { @@ -303,12 +307,12 @@ public void channelInactive(ChannelHandlerContext ctx) throws Exception { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { logger.info("Channel {} for session {} is active", ctx.channel().toString(), name()); - if (needAuthConnection() && !isAuthed()) { - logger.info("Session {} needs auth", name()); - markSessionNegotiation(ctx.channel()); - } else { - markSessionConnected(ctx.channel()); - } + + logger.info("Session {} needs negotiation(version + auth)", name()); + markSessionNegotiation(ctx.channel()); + //}// else { + //markSessionConnected(ctx.channel()); + // } } @Override @@ -331,6 +335,53 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E } } + //version + private void startVersionNego() { + version_nego_message msg = new version_nego_message(); + msg.status = version_nego_status.INVALID; + msg.version = new blob("1.12.SNAPSHOT".getBytes()); + final RequestEntry entry = new ReplicaSession.RequestEntry(); + entry.sequenceId = seqId.getAndIncrement(); + entry.op = new version_nego_operator(msg); + entry.callback = new VersionNegoHandler((version_nego_operator) entry.op); + pendingResponse.put(new Integer(entry.sequenceId), entry); + entry.timeoutTask = addTimer(entry.sequenceId, 1000); + + write(entry, fields); + } + + private class VersionNegoHandler implements Runnable { + version_nego_operator op; + + VersionNegoHandler(version_nego_operator op) { + this.op = op; + } + + @Override + public void run() { + try { + if (op.rpc_error.errno != error_types.ERR_OK) throw new ReplicationException(op.rpc_error.errno); + final version_nego_message resp = op.get_response(); + if (resp == null) { + throw new Exception("VersionNegoHandler received a null response, abandon it"); + } + + if (resp.status == version_nego_status.MATCH) { + logger.info("{}: version negotiation succeed", name()); + if (needAuthConnection() && !isAuthed()) + startNegotiation(); + else + markSessionConnected(fields.nettyChannel); + } else { + throw new Exception("Version negotiation failed, " + resp.status); + } + } catch (Exception e) { + // e.printStackTrace(); + logger.error("{}: {}", name(), e.toString()); + } + } + } + // security private boolean needAuthConnection() { return openAuth; @@ -350,7 +401,7 @@ private void startNegotiation() { sendNegoMsg(msg); - logger.info("{}: start negotiation", name()); + logger.info("{}: start negotiation in phase 2", name()); } private void sendNegoMsg(negotiation_message msg) {