Repository navigation
Commit 29d07cc
authored
xDS: Support retries in RawMessageClientInterceptor and conditionally add it to the filter chain (#13042)
### 1. Supporting retries
Previously, `RawMessageClientInterceptor.sendMessage()` forwarded a
single-use
InputStream directly to `rawCall.sendMessage()`. When retries were
triggered by
RetriableStream, attempt 1 drained the InputStream to EOF. Subsequent
retry
attempts would then serialize the already-drained stream, sending an
empty (0-byte)
request payload.
Fix this by:
1. Buffering the request stream into an immutable `ByteString` (using
`Drainable`
when supported) in `RawMessageClientInterceptor.sendMessage()` and
wrapping it
in a `KnownLengthInputStream`.
2. Exposing `getByteString()` on `KnownLengthInputStream`.
3. Having `RAW_MARSHALLER.stream()` return a fresh
`KnownLengthInputStream` wrapping
the underlying `ByteString` on each attempt, allowing retries to read
the payload
from byte 0.
### 2. Conditional addition of `RawMessageClientInterceptor`
Also we need to only install `RawMessageClientInterceptor` when a filter
requires payload access to avoid the performance hit for non ext_proc
cases. As suggested in the [grfc
discussion](grpc/proposal#484 (comment)),
introduce `Filter.requiresPayloadAccess(config, overrideConfig)` to
allow filters to declare whether they need access to message payloads.
Update `ExternalProcessorFilter` to implement this method, returning
false when body send mode is NONE for both request and response. Update
`XdsNameResolver` to only install `RawMessageClientInterceptor` when at
least one configured filter requires payload access. Generalize
`ExternalProcessorClientInterceptor` to support generic request/response
types when payload interception is not needed.
#### Generalizing `ExternalProcessorClientInterceptor` to Support
Pass-through Types
`ExternalProcessorClientInterceptor` previously hardcoded
`ClientCall<InputStream, InputStream>` and
`SimpleForwardingClientCallListener<InputStream>`, assuming
`RawMessageClientInterceptor` was always present earlier in the chain to
convert application messages to `InputStream`.
Now that `RawMessageClientInterceptor` is omitted when body send mode is
`NONE`, `ExternalProcessorClientInterceptor` directly handles the
application's request and response types (`ReqT`, `RespT`).
`DataPlaneClientCall` and `DataPlaneListener` were generalized to
`<ReqT, RespT>` to avoid compiler-generated synthetic bridge casts to
`InputStream`, which would otherwise result in a runtime
`ClassCastException` when sending or receiving application messages.
Fixes #130101 parent ecbe959 commit 29d07cc
10 files changed
Lines changed: 1239 additions & 192 deletions
File tree
- xds/src
- main/java/io/grpc/xds
- internal/extproc
- test/java/io/grpc/xds
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
137 | 162 | | |
138 | 163 | | |
139 | 164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
127 | 145 | | |
128 | 146 | | |
129 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
| |||
889 | 893 | | |
890 | 894 | | |
891 | 895 | | |
| 896 | + | |
| 897 | + | |
892 | 898 | | |
893 | 899 | | |
894 | 900 | | |
| |||
903 | 909 | | |
904 | 910 | | |
905 | 911 | | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
906 | 918 | | |
907 | 919 | | |
908 | 920 | | |
909 | 921 | | |
910 | | - | |
911 | | - | |
912 | | - | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
913 | 925 | | |
914 | 926 | | |
915 | 927 | | |
| |||
1134 | 1146 | | |
1135 | 1147 | | |
1136 | 1148 | | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
1137 | 1156 | | |
1138 | 1157 | | |
1139 | 1158 | | |
| |||
1143 | 1162 | | |
1144 | 1163 | | |
1145 | 1164 | | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
1146 | 1177 | | |
1147 | 1178 | | |
1148 | 1179 | | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
1149 | 1193 | | |
1150 | 1194 | | |
1151 | 1195 | | |
1152 | | - | |
| 1196 | + | |
1153 | 1197 | | |
1154 | | - | |
1155 | | - | |
1156 | | - | |
1157 | | - | |
1158 | | - | |
1159 | | - | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
1160 | 1201 | | |
1161 | | - | |
1162 | | - | |
1163 | | - | |
1164 | | - | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
1165 | 1206 | | |
1166 | | - | |
1167 | | - | |
1168 | | - | |
1169 | | - | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
1170 | 1213 | | |
1171 | | - | |
1172 | | - | |
1173 | | - | |
1174 | | - | |
1175 | | - | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
1176 | 1228 | | |
1177 | 1229 | | |
1178 | 1230 | | |
1179 | | - | |
1180 | | - | |
| 1231 | + | |
| 1232 | + | |
1181 | 1233 | | |
| 1234 | + | |
| 1235 | + | |
1182 | 1236 | | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
1183 | 1243 | | |
1184 | | - | |
1185 | | - | |
| 1244 | + | |
| 1245 | + | |
1186 | 1246 | | |
1187 | 1247 | | |
1188 | 1248 | | |
1189 | | - | |
1190 | | - | |
| 1249 | + | |
| 1250 | + | |
1191 | 1251 | | |
1192 | 1252 | | |
1193 | 1253 | | |
1194 | 1254 | | |
1195 | | - | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
1196 | 1267 | | |
1197 | 1268 | | |
1198 | 1269 | | |
1199 | | - | |
1200 | | - | |
| 1270 | + | |
| 1271 | + | |
1201 | 1272 | | |
1202 | 1273 | | |
1203 | 1274 | | |
1204 | | - | |
1205 | | - | |
| 1275 | + | |
| 1276 | + | |
1206 | 1277 | | |
1207 | 1278 | | |
1208 | 1279 | | |
1209 | | - | |
1210 | | - | |
| 1280 | + | |
| 1281 | + | |
1211 | 1282 | | |
1212 | 1283 | | |
1213 | 1284 | | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
1214 | 1346 | | |
1215 | 1347 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
34 | 40 | | |
35 | 41 | | |
36 | 42 | | |
| |||
0 commit comments