Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 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
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
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
132 changes: 132 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,132 @@
/*
* 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 java.util.List;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

/**
* An immutable, validated, gap-free snapshot of a logical assignment received from the
* autosharding service.
*
* <p>Instances are produced exclusively by {@link AssignmentParser}, which guarantees the
* following invariants (see gRFC A119, "Contract of the AutoshardingClient"):
* <ol>
* <li>The {@link #getSlices()} list covers the entire keyspace, starting at the minimum
* possible key (the empty byte string) and ending at the maximum possible key
* (infinity, represented by a {@code null} {@link Slice#getEndKey()}).</li>
* <li>The slices are sorted in ascending lexicographical (unsigned) order by
* {@link Slice#getStartKey()}.</li>
* <li>The partitioning is contiguous and non-overlapping: for every index {@code i} in
* {@code [0, N-2]}, {@code slices[i].endKey} is exactly {@code slices[i + 1].startKey}.</li>
* <li>Key ranges not assigned by the autosharding server are present as slices with an
* empty {@link Slice#getEndpoints()} list.</li>
* </ol>
*/
@Immutable
final class Assignment {

/** A single contiguous key range and the endpoints assigned to it. */
@Immutable
@SuppressWarnings("Immutable") // Defensive copies are made; arrays are never mutated.
static final class Slice {
private final byte[] startKey;
@Nullable private final byte[] endKey;
private final ImmutableList<Integer> endpoints;

/**
* Constructs a {@link Slice}.
*
* @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 = checkNotNull(startKey, "startKey").clone();
this.endKey = endKey == null ? null : endKey.clone();
this.endpoints = ImmutableList.copyOf(checkNotNull(endpoints, "endpoints"));
}

byte[] getStartKey() {
return startKey.clone();
}

@Nullable
byte[] getEndKey() {
return endKey == null ? null : endKey.clone();
}

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

@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)
.toString();
}
}

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

/**
* 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
* @param generation the generation number of this logical assignment
*/
Assignment(List<Slice> slices, List<String> endpointNames, long generation) {
this.slices = ImmutableList.copyOf(checkNotNull(slices, "slices"));
this.endpointNames = ImmutableList.copyOf(checkNotNull(endpointNames, "endpointNames"));
this.generation = generation;
}

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

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

long getGeneration() {
return generation;
}

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