Skip to content

Commit 1193055

Browse files
chore: generate libraries at Thu Jan 8 06:14:20 UTC 2026
1 parent 5b5e6f5 commit 1193055

File tree

4 files changed

+150
-68
lines changed

4 files changed

+150
-68
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/ChannelFinder.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,20 @@ public void update(CacheUpdate cacheUpdate) {
6060
lock.writeLock().lock();
6161
try {
6262
if (databaseId != cacheUpdate.getDatabaseId()) {
63-
System.out.println("DEBUG [BYPASS]: Database ID changed from " + databaseId
64-
+ " to " + cacheUpdate.getDatabaseId() + ", clearing caches");
63+
System.out.println(
64+
"DEBUG [BYPASS]: Database ID changed from "
65+
+ databaseId
66+
+ " to "
67+
+ cacheUpdate.getDatabaseId()
68+
+ ", clearing caches");
6569
recipeCache.clear();
6670
rangeCache.clear();
6771
databaseId = cacheUpdate.getDatabaseId();
6872
}
6973
recipeCache.addRecipes(cacheUpdate.getKeyRecipes());
7074
rangeCache.addRanges(cacheUpdate);
71-
System.out.println("DEBUG [BYPASS]: Cache updated. Current state:\n" + rangeCache.debugString());
75+
System.out.println(
76+
"DEBUG [BYPASS]: Cache updated. Current state:\n" + rangeCache.debugString());
7277
} finally {
7378
lock.writeLock().unlock();
7479
}
@@ -88,15 +93,17 @@ public ChannelFinderServer findServer(ReadRequest.Builder reqBuilder) {
8893
if (databaseId != 0) {
8994
hintBuilder.setDatabaseId(databaseId);
9095
}
91-
System.out.println("DEBUG [BYPASS]: findServer - computing keys for table: "
92-
+ reqBuilder.getTable());
96+
System.out.println(
97+
"DEBUG [BYPASS]: findServer - computing keys for table: " + reqBuilder.getTable());
9398
recipeCache.computeKeys(reqBuilder); // Modifies hintBuilder within reqBuilder
94-
System.out.println("DEBUG [BYPASS]: findServer - after computeKeys, key: "
95-
+ hintBuilder.getKey().toStringUtf8());
96-
ChannelFinderServer server = rangeCache.fillRoutingInfo(
97-
reqBuilder.getSession(), false, hintBuilder);
98-
System.out.println("DEBUG [BYPASS]: findServer - fillRoutingInfo returned server: "
99-
+ (server != null ? server.getAddress() : "null"));
99+
System.out.println(
100+
"DEBUG [BYPASS]: findServer - after computeKeys, key: "
101+
+ hintBuilder.getKey().toStringUtf8());
102+
ChannelFinderServer server =
103+
rangeCache.fillRoutingInfo(reqBuilder.getSession(), false, hintBuilder);
104+
System.out.println(
105+
"DEBUG [BYPASS]: findServer - fillRoutingInfo returned server: "
106+
+ (server != null ? server.getAddress() : "null"));
100107
return server;
101108
} finally {
102109
lock.readLock().unlock();

google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/KeyAwareChannel.java

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -187,21 +187,22 @@ public void sendMessage(RequestT message) {
187187

188188
if (databaseId == null) {
189189
server = parentChannel.serverFactory.defaultServer();
190-
System.out.println("DEBUG [BYPASS]: No database ID found, using default server: "
191-
+ server.getAddress());
190+
System.out.println(
191+
"DEBUG [BYPASS]: No database ID found, using default server: " + server.getAddress());
192192
} else {
193193
this.channelFinder = parentChannel.getOrCreateChannelFinder(databaseId);
194194
server = this.channelFinder.findServer(reqBuilder);
195195
message = (RequestT) reqBuilder.build(); // Apply routing info changes
196-
196+
197197
ReadRequest finalReq = (ReadRequest) message;
198198
System.out.println("DEBUG [BYPASS]: === Request Details ===");
199199
System.out.println("DEBUG [BYPASS]: Table: " + finalReq.getTable());
200200
System.out.println("DEBUG [BYPASS]: KeySet: " + finalReq.getKeySet());
201201
System.out.println("DEBUG [BYPASS]: Routing hint: " + finalReq.getRoutingHint());
202202
System.out.println("DEBUG [BYPASS]: Selected server: " + server.getAddress());
203-
System.out.println("DEBUG [BYPASS]: Is bypass routing: "
204-
+ (finalReq.getRoutingHint().getGroupUid() != 0));
203+
System.out.println(
204+
"DEBUG [BYPASS]: Is bypass routing: "
205+
+ (finalReq.getRoutingHint().getGroupUid() != 0));
205206
System.out.println("DEBUG [BYPASS]: ========================");
206207
}
207208
} else {
@@ -261,27 +262,47 @@ public void onMessage(ResponseT message) {
261262
System.out.println("DEBUG [BYPASS]: groups count: " + update.getGroupCount());
262263
System.out.println("DEBUG [BYPASS]: ranges count: " + update.getRangeCount());
263264
if (update.hasKeyRecipes()) {
264-
System.out.println("DEBUG [BYPASS]: recipes count: "
265-
+ update.getKeyRecipes().getRecipeCount());
266-
System.out.println("DEBUG [BYPASS]: schema_generation: "
267-
+ update.getKeyRecipes().getSchemaGeneration());
265+
System.out.println(
266+
"DEBUG [BYPASS]: recipes count: " + update.getKeyRecipes().getRecipeCount());
267+
System.out.println(
268+
"DEBUG [BYPASS]: schema_generation: "
269+
+ update.getKeyRecipes().getSchemaGeneration());
268270
}
269271
for (int i = 0; i < update.getGroupCount(); i++) {
270272
com.google.spanner.v1.Group g = update.getGroup(i);
271-
System.out.println("DEBUG [BYPASS]: Group[" + i + "]: uid=" + g.getGroupUid()
272-
+ ", tablets=" + g.getTabletsCount() + ", leader_index=" + g.getLeaderIndex());
273+
System.out.println(
274+
"DEBUG [BYPASS]: Group["
275+
+ i
276+
+ "]: uid="
277+
+ g.getGroupUid()
278+
+ ", tablets="
279+
+ g.getTabletsCount()
280+
+ ", leader_index="
281+
+ g.getLeaderIndex());
273282
for (int t = 0; t < g.getTabletsCount(); t++) {
274283
com.google.spanner.v1.Tablet tab = g.getTablets(t);
275-
System.out.println("DEBUG [BYPASS]: Tablet[" + t + "]: uid=" + tab.getTabletUid()
276-
+ ", server=" + tab.getServerAddress()
277-
+ ", distance=" + tab.getDistance()
278-
+ ", skip=" + tab.getSkip());
284+
System.out.println(
285+
"DEBUG [BYPASS]: Tablet["
286+
+ t
287+
+ "]: uid="
288+
+ tab.getTabletUid()
289+
+ ", server="
290+
+ tab.getServerAddress()
291+
+ ", distance="
292+
+ tab.getDistance()
293+
+ ", skip="
294+
+ tab.getSkip());
279295
}
280296
}
281297
for (int i = 0; i < update.getRangeCount(); i++) {
282298
com.google.spanner.v1.Range r = update.getRange(i);
283-
System.out.println("DEBUG [BYPASS]: Range[" + i + "]: group_uid=" + r.getGroupUid()
284-
+ ", split_id=" + r.getSplitId());
299+
System.out.println(
300+
"DEBUG [BYPASS]: Range["
301+
+ i
302+
+ "]: group_uid="
303+
+ r.getGroupUid()
304+
+ ", split_id="
305+
+ r.getSplitId());
285306
}
286307
System.out.println("DEBUG [BYPASS]: ============================");
287308
call.channelFinder.update(update);

google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/KeyRangeCache.java

Lines changed: 94 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,13 @@ private class CachedGroup {
169169

170170
/** Updates group from proto, including its tablets. */
171171
void update(Group groupIn) {
172-
System.out.println("DEBUG [BYPASS]: Group.update for group " + groupUid
173-
+ ", incoming tablets: " + groupIn.getTabletsCount()
174-
+ ", leader_index: " + groupIn.getLeaderIndex());
172+
System.out.println(
173+
"DEBUG [BYPASS]: Group.update for group "
174+
+ groupUid
175+
+ ", incoming tablets: "
176+
+ groupIn.getTabletsCount()
177+
+ ", leader_index: "
178+
+ groupIn.getLeaderIndex());
175179

176180
// Only update leader if generation is newer
177181
if (ByteString.unsignedLexicographicalComparator()
@@ -221,48 +225,74 @@ void update(Group groupIn) {
221225
CachedTablet tablet = tabletsByUid.get(tabletIn.getTabletUid());
222226
if (tablet == null) {
223227
tablet = new CachedTablet();
224-
System.out.println("DEBUG [BYPASS]: Created new tablet for uid " + tabletIn.getTabletUid());
228+
System.out.println(
229+
"DEBUG [BYPASS]: Created new tablet for uid " + tabletIn.getTabletUid());
225230
}
226231
tablet.update(tabletIn);
227-
System.out.println("DEBUG [BYPASS]: Tablet[" + t + "]: uid=" + tablet.tabletUid
228-
+ ", server=" + tablet.serverAddress
229-
+ ", distance=" + tablet.distance);
232+
System.out.println(
233+
"DEBUG [BYPASS]: Tablet["
234+
+ t
235+
+ "]: uid="
236+
+ tablet.tabletUid
237+
+ ", server="
238+
+ tablet.serverAddress
239+
+ ", distance="
240+
+ tablet.distance);
230241
newTablets.add(tablet);
231242
}
232243
tablets = newTablets;
233-
System.out.println("DEBUG [BYPASS]: Group " + groupUid + " now has " + tablets.size() + " tablets");
244+
System.out.println(
245+
"DEBUG [BYPASS]: Group " + groupUid + " now has " + tablets.size() + " tablets");
234246
}
235247

236248
/** Fills routing hint with tablet information and returns the server. */
237249
ChannelFinderServer fillRoutingHint(boolean preferLeader, RoutingHint.Builder hintBuilder) {
238-
System.out.println("DEBUG [BYPASS]: Group.fillRoutingHint - preferLeader: " + preferLeader
239-
+ ", tablets count: " + tablets.size());
250+
System.out.println(
251+
"DEBUG [BYPASS]: Group.fillRoutingHint - preferLeader: "
252+
+ preferLeader
253+
+ ", tablets count: "
254+
+ tablets.size());
240255

241256
// Try leader first if preferred
242257
if (preferLeader && hasLeader()) {
243258
CachedTablet leaderTablet = leader();
244-
System.out.println("DEBUG [BYPASS]: Trying leader tablet: uid=" + leaderTablet.tabletUid
245-
+ ", address=" + leaderTablet.serverAddress
246-
+ ", skip=" + leaderTablet.skip);
259+
System.out.println(
260+
"DEBUG [BYPASS]: Trying leader tablet: uid="
261+
+ leaderTablet.tabletUid
262+
+ ", address="
263+
+ leaderTablet.serverAddress
264+
+ ", skip="
265+
+ leaderTablet.skip);
247266
if (!leaderTablet.shouldSkip(hintBuilder)) {
248267
ChannelFinderServer server = leaderTablet.pick(hintBuilder);
249-
System.out.println("DEBUG [BYPASS]: Leader tablet picked, server: "
250-
+ (server != null ? server.getAddress() : "null"));
268+
System.out.println(
269+
"DEBUG [BYPASS]: Leader tablet picked, server: "
270+
+ (server != null ? server.getAddress() : "null"));
251271
return server;
252272
}
253273
}
254274

255275
// Try other tablets in order (they're ordered by distance)
256276
for (int i = 0; i < tablets.size(); i++) {
257277
CachedTablet tablet = tablets.get(i);
258-
System.out.println("DEBUG [BYPASS]: Trying tablet[" + i + "]: uid=" + tablet.tabletUid
259-
+ ", address=" + tablet.serverAddress
260-
+ ", distance=" + tablet.distance
261-
+ ", skip=" + tablet.skip);
278+
System.out.println(
279+
"DEBUG [BYPASS]: Trying tablet["
280+
+ i
281+
+ "]: uid="
282+
+ tablet.tabletUid
283+
+ ", address="
284+
+ tablet.serverAddress
285+
+ ", distance="
286+
+ tablet.distance
287+
+ ", skip="
288+
+ tablet.skip);
262289
if (!tablet.shouldSkip(hintBuilder)) {
263290
ChannelFinderServer server = tablet.pick(hintBuilder);
264-
System.out.println("DEBUG [BYPASS]: Tablet[" + i + "] picked, server: "
265-
+ (server != null ? server.getAddress() : "null"));
291+
System.out.println(
292+
"DEBUG [BYPASS]: Tablet["
293+
+ i
294+
+ "] picked, server: "
295+
+ (server != null ? server.getAddress() : "null"));
266296
return server;
267297
}
268298
}
@@ -449,22 +479,32 @@ private boolean isNewerOrSame(
449479

450480
/** Applies cache updates. Tablets are processed inside group updates. */
451481
public void addRanges(CacheUpdate cacheUpdate) {
452-
System.out.println("DEBUG [BYPASS]: addRanges called with "
453-
+ cacheUpdate.getGroupCount() + " groups, "
454-
+ cacheUpdate.getRangeCount() + " ranges");
482+
System.out.println(
483+
"DEBUG [BYPASS]: addRanges called with "
484+
+ cacheUpdate.getGroupCount()
485+
+ " groups, "
486+
+ cacheUpdate.getRangeCount()
487+
+ " ranges");
455488

456489
// Insert all groups. Tablets are processed inside findOrInsertGroup -> Group.update()
457490
List<CachedGroup> newGroups = new ArrayList<>();
458491
for (Group groupIn : cacheUpdate.getGroupList()) {
459-
System.out.println("DEBUG [BYPASS]: Processing group " + groupIn.getGroupUid()
460-
+ " with " + groupIn.getTabletsCount() + " tablets");
492+
System.out.println(
493+
"DEBUG [BYPASS]: Processing group "
494+
+ groupIn.getGroupUid()
495+
+ " with "
496+
+ groupIn.getTabletsCount()
497+
+ " tablets");
461498
newGroups.add(findOrInsertGroup(groupIn));
462499
}
463500

464501
// Process ranges
465502
for (Range rangeIn : cacheUpdate.getRangeList()) {
466-
System.out.println("DEBUG [BYPASS]: Processing range for group " + rangeIn.getGroupUid()
467-
+ ", split_id=" + rangeIn.getSplitId());
503+
System.out.println(
504+
"DEBUG [BYPASS]: Processing range for group "
505+
+ rangeIn.getGroupUid()
506+
+ ", split_id="
507+
+ rangeIn.getSplitId());
468508
replaceRangeIfNewer(rangeIn);
469509
}
470510

@@ -473,16 +513,24 @@ public void addRanges(CacheUpdate cacheUpdate) {
473513
unref(g);
474514
}
475515

476-
System.out.println("DEBUG [BYPASS]: After addRanges - ranges: " + ranges.size()
477-
+ ", groups: " + groups.size() + ", servers: " + servers.size());
516+
System.out.println(
517+
"DEBUG [BYPASS]: After addRanges - ranges: "
518+
+ ranges.size()
519+
+ ", groups: "
520+
+ groups.size()
521+
+ ", servers: "
522+
+ servers.size());
478523
}
479524

480525
/** Fills routing hint and returns the server to use. */
481526
public ChannelFinderServer fillRoutingInfo(
482527
String sessionUri, boolean preferLeader, RoutingHint.Builder hintBuilder) {
483-
System.out.println("DEBUG [BYPASS]: fillRoutingInfo called, ranges in cache: " + ranges.size()
484-
+ ", groups in cache: " + groups.size());
485-
528+
System.out.println(
529+
"DEBUG [BYPASS]: fillRoutingInfo called, ranges in cache: "
530+
+ ranges.size()
531+
+ ", groups in cache: "
532+
+ groups.size());
533+
486534
if (hintBuilder.getKey().isEmpty()) {
487535
System.out.println("DEBUG [BYPASS]: No key in hint, using default server");
488536
return serverFactory.defaultServer();
@@ -505,8 +553,9 @@ public ChannelFinderServer fillRoutingInfo(
505553
if (ByteString.unsignedLexicographicalComparator().compare(requestKey, range.startKey) >= 0) {
506554
targetRange = range;
507555
targetRangeLimitKey = rangeLimit;
508-
System.out.println("DEBUG [BYPASS]: Found range for key, group_uid: "
509-
+ (range.group != null ? range.group.groupUid : "null"));
556+
System.out.println(
557+
"DEBUG [BYPASS]: Found range for key, group_uid: "
558+
+ (range.group != null ? range.group.groupUid : "null"));
510559
}
511560
}
512561

@@ -539,10 +588,16 @@ public ChannelFinderServer fillRoutingInfo(
539588
hintBuilder.setKey(targetRange.startKey);
540589
hintBuilder.setLimitKey(targetRangeLimitKey);
541590

542-
System.out.println("DEBUG [BYPASS]: Group " + targetRange.group.groupUid
543-
+ " has " + targetRange.group.tablets.size() + " tablets"
544-
+ ", hasLeader: " + targetRange.group.hasLeader()
545-
+ ", leaderIndex: " + targetRange.group.leaderIndex);
591+
System.out.println(
592+
"DEBUG [BYPASS]: Group "
593+
+ targetRange.group.groupUid
594+
+ " has "
595+
+ targetRange.group.tablets.size()
596+
+ " tablets"
597+
+ ", hasLeader: "
598+
+ targetRange.group.hasLeader()
599+
+ ", leaderIndex: "
600+
+ targetRange.group.leaderIndex);
546601

547602
// Let the group pick the tablet
548603
ChannelFinderServer server = targetRange.group.fillRoutingHint(preferLeader, hintBuilder);

google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/SsFormatTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.google.cloud.spanner.spi.v1;
1818

19-
import static org.junit.Assert.assertArrayEquals;
2019
import static org.junit.Assert.assertEquals;
2120
import static org.junit.Assert.assertTrue;
2221

0 commit comments

Comments
 (0)