Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
13e6d52
autosharding: Add module build configuration and protobuf definitions
shivaspeaks Aug 26, 2026
04c6963
add import.sh
shivaspeaks Aug 26, 2026
d161705
autosharding: Move proto and import.sh to third_party/autosharding di…
shivaspeaks Sep 1, 2026
74bdfd1
autosharding: Add SliceMap and AutoShardingPicker
shivaspeaks Sep 1, 2026
2488b37
Merge branch 'master' of https://github.com/grpc/grpc-java into autos…
shivaspeaks Sep 2, 2026
e5b4b22
grfc updated
shivaspeaks Sep 2, 2026
7dfdf6b
autosharding: Return primitive int from SliceMap.lookup to eliminate …
shivaspeaks Sep 4, 2026
67abc20
use UnsignedBytes.lexicographicalComparator()
shivaspeaks Sep 4, 2026
789de22
use ImmutableList for endpoints
shivaspeaks Sep 4, 2026
426621f
add javadoc
shivaspeaks Sep 4, 2026
1b63d20
improvements
shivaspeaks Sep 4, 2026
0771433
have exitIdler functional interface
shivaspeaks Sep 4, 2026
1db8017
create Metadata.Key statically
shivaspeaks Sep 4, 2026
29957b6
add FunctionalInterface ThreadSafeRandom
shivaspeaks Sep 4, 2026
4105fd8
fast path
shivaspeaks Sep 4, 2026
be31260
javadoc
shivaspeaks Sep 7, 2026
b99fa0c
javadoc
shivaspeaks Sep 7, 2026
12765cf
javadoc and unit test
shivaspeaks Sep 7, 2026
903ec88
context specific error
shivaspeaks Sep 7, 2026
bb9a900
clone start key
shivaspeaks Sep 7, 2026
c11754e
add some behavioural unit tests
shivaspeaks Sep 7, 2026
c79cc59
autosharding: implementation of EndpointMap and LazyChildLB
shivaspeaks Sep 8, 2026
c961edf
Merge branch 'master' of https://github.com/grpc/grpc-java into autos…
shivaspeaks Sep 8, 2026
e350685
call request conn in parent policy
shivaspeaks Sep 8, 2026
ca8fd50
use exact same indices in toPickerEndpoints
shivaspeaks Sep 8, 2026
3a3f667
clear resources in shutdown
shivaspeaks Sep 8, 2026
bbf9a6f
reset connectingScheduled flag in exitIdle
shivaspeaks Sep 8, 2026
f47816f
update unit test
shivaspeaks Sep 8, 2026
fa76449
util: refactor LazyLoadBalancer into util to use it in autosharding
shivaspeaks Sep 9, 2026
bf6eda3
Merge branch 'move-lazy-load-balancer-to-util' into autosharding-part…
shivaspeaks Sep 9, 2026
07b604e
Merge branch 'master' of https://github.com/grpc/grpc-java into autos…
shivaspeaks Sep 10, 2026
d32c495
refactor to use LazyLB
shivaspeaks Sep 10, 2026
a92010a
implementation of autoshardinglb and autosharding client and work on …
shivaspeaks Sep 21, 2026
cc2822a
updates
shivaspeaks Sep 22, 2026
34a7cce
updates
shivaspeaks Sep 22, 2026
6e3cd8d
updates
shivaspeaks Sep 22, 2026
a957a80
updates
shivaspeaks Sep 22, 2026
c5b4d57
update
shivaspeaks Sep 23, 2026
2a71e7b
Merge remote-tracking branch 'upstream/master' into autosharding-part…
shivaspeaks Sep 24, 2026
b65dc36
updates
shivaspeaks Sep 24, 2026
a1931ee
updates
shivaspeaks Sep 24, 2026
768ef44
updates
shivaspeaks Sep 24, 2026
cb6e0eb
updates
shivaspeaks Sep 24, 2026
4927ecb
updates
shivaspeaks Sep 25, 2026
4cd5154
grfc updates
shivaspeaks Sep 25, 2026
32447e2
use apt locality
shivaspeaks Sep 28, 2026
3c87595
updates
shivaspeaks Sep 28, 2026
758dde1
updates
shivaspeaks Sep 28, 2026
033a131
updates
shivaspeaks Sep 28, 2026
ee1170c
updates
shivaspeaks Sep 28, 2026
e43f9e6
zero slices is now same as no usable slices in the assignment
shivaspeaks Sep 28, 2026
0f4f0e8
grfc new updates
shivaspeaks Sep 30, 2026
9d444b3
remove redundant code
shivaspeaks Oct 1, 2026
55f56b8
remove unreachable
shivaspeaks Oct 1, 2026
8b123e8
grfc updated
shivaspeaks Oct 6, 2026
6b257fa
no slices sent is a correct usecase
shivaspeaks Oct 19, 2026
0d03b0f
grfc updates
shivaspeaks Oct 26, 2026
a74bd42
align with go
shivaspeaks Oct 26, 2026
25c9bf2
fix NPE of runEndKey
shivaspeaks Oct 30, 2026
3807ca9
update slicemap along with endpointmap
shivaspeaks Oct 30, 2026
1e36329
handle inet socket addr
shivaspeaks Oct 30, 2026
0748322
use channel lease suggestion
shivaspeaks Nov 3, 2026
f1b0740
review comments
shivaspeaks Nov 3, 2026
3016f9c
use statusOr
shivaspeaks Nov 3, 2026
4560fa0
review comment
shivaspeaks Nov 3, 2026
17f8b04
use getters
shivaspeaks Nov 4, 2026
a74094e
remove checkNotNull from sync context
shivaspeaks Nov 4, 2026
c0c82dc
review comments
shivaspeaks Nov 4, 2026
5b376c2
review comments
shivaspeaks Nov 4, 2026
5bc98eb
match go
shivaspeaks Nov 4, 2026
0b3ba0e
review comments
shivaspeaks Nov 4, 2026
cf4a98f
review comments
shivaspeaks Nov 4, 2026
0e3de0e
suppress InlineMeInliner
shivaspeaks Nov 5, 2026
c65c2e1
fix docs
shivaspeaks Nov 6, 2026
27af005
review comments
shivaspeaks Nov 6, 2026
5df2360
fix javadocs
shivaspeaks Nov 9, 2026
d4d1b21
fix javadocs
shivaspeaks Nov 9, 2026
6bc44e7
fix javadoc
shivaspeaks Nov 9, 2026
ac0ea3d
Merge remote-tracking branch 'upstream/master' into autosharding-part…
shivaspeaks Nov 30, 2026
242f5a8
add deps for autosharding LB policy
shivaspeaks Nov 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions autosharding/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,18 @@ java_library(
srcs = glob([
"src/main/java/io/grpc/autosharding/*.java",
]),
resources = glob([
"src/main/resources/**",
]),
visibility = ["//visibility:public"],
deps = [
":autosharding_java_grpc",
":autosharding_java_proto",
"//api",
"//core:internal",
"//stub",
"//util",
"@com_google_protobuf//:protobuf_java",
artifact("com.google.code.findbugs:jsr305"),
artifact("com.google.guava:guava"),
],
Expand Down
3 changes: 3 additions & 0 deletions autosharding/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ tasks.named("javadoc").configure {
exclude 'io/grpc/autosharding/*Provider.java'
exclude 'io/grpc/autosharding/internal/**'
exclude 'io/grpc/autosharding/Internal*'
// @Internal types, published only so that the xDS integration can inject them.
exclude 'io/grpc/autosharding/AutoShardingAttributes.java'
exclude 'io/grpc/autosharding/ChannelFactory*'
}

tasks.named("jacocoTestReport").configure {
Expand Down
142 changes: 142 additions & 0 deletions autosharding/src/main/java/io/grpc/autosharding/Assignment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/*
* Copyright 2026 The gRPC Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.grpc.autosharding;

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.io.BaseEncoding;
import com.google.common.primitives.UnsignedBytes;
import java.util.Comparator;
import java.util.List;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

/**
* An immutable, validated assignment from the sharding service: slices sorted by start key that
* together cover the whole keyspace, from the empty key to infinity, without gaps or overlaps.
* Key ranges without a usable slice from the server are slices with no endpoints. Produced only
* by {@link AssignmentParser}; see gRFC A119, "Contract of the AutoshardingClient".
*/
@Immutable
final class Assignment {

/**
* A single contiguous key range and the endpoints assigned to it. Its key arrays are shared
* rather than copied, and must not be modified.
*/
@Immutable
@SuppressWarnings("Immutable") // The key arrays are never modified.
static final class Slice {
/** Orders slices by start key, compared as unsigned bytes. */
static final Comparator<Slice> START_KEY_ORDER =
(a, b) -> UnsignedBytes.lexicographicalComparator().compare(a.startKey, b.startKey);

private final byte[] startKey;
@Nullable private final byte[] endKey;
private final ImmutableList<Integer> endpoints;
private final boolean fallbackDisabled;

/**
* Constructs a {@link Slice} that may fall back.
*
* @param startKey the inclusive start key of the range
* @param endKey the exclusive end key of the range, or {@code null} for the infinity
* sentinel covering the largest allowed key
* @param endpoints indices into {@link Assignment#getEndpointNames()} assigned to this range
*/
Slice(byte[] startKey, @Nullable byte[] endKey, List<Integer> endpoints) {
this(startKey, endKey, endpoints, false);
}

/**
* Constructs a {@link Slice}.
*
* @param fallbackDisabled whether picks for this range must fail rather than fall back; set
* when the server assigned the range no endpoints, never for a filled gap
*/
Slice(
byte[] startKey,
@Nullable byte[] endKey,
List<Integer> endpoints,
boolean fallbackDisabled) {
this.startKey = checkNotNull(startKey, "startKey");
this.endKey = endKey;
this.endpoints = ImmutableList.copyOf(checkNotNull(endpoints, "endpoints"));
this.fallbackDisabled = fallbackDisabled;
}

byte[] getStartKey() {
return startKey;
}

@Nullable
byte[] getEndKey() {
return endKey;
}

ImmutableList<Integer> getEndpoints() {
return endpoints;
}

boolean isFallbackDisabled() {
return fallbackDisabled;
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("startKey", BaseEncoding.base16().encode(startKey))
.add("endKey", endKey == null ? "inf" : BaseEncoding.base16().encode(endKey))
.add("endpoints", endpoints)
.add("fallbackDisabled", fallbackDisabled)
.toString();
}
}

private final ImmutableList<Slice> slices;
private final ImmutableList<String> endpointNames;

/**
* Constructs an {@link Assignment}.
*
* @param slices the validated, sorted, contiguous and gap-free list of key-range slices
* @param endpointNames the complete list of endpoint names, combined across all chunks in
* chunk order
*/
Assignment(List<Slice> slices, List<String> endpointNames) {
this.slices = ImmutableList.copyOf(checkNotNull(slices, "slices"));
this.endpointNames = ImmutableList.copyOf(checkNotNull(endpointNames, "endpointNames"));
}

ImmutableList<Slice> getSlices() {
return slices;
}

ImmutableList<String> getEndpointNames() {
return endpointNames;
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("endpointNames", endpointNames)
.add("slices", slices)
.toString();
}
}
Loading
Loading