id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
127,400
grpc/grpc-java
core/src/main/java/io/grpc/util/RoundRobinLoadBalancer.java
RoundRobinLoadBalancer.filterNonFailingSubchannels
private static List<Subchannel> filterNonFailingSubchannels( Collection<Subchannel> subchannels) { List<Subchannel> readySubchannels = new ArrayList<>(subchannels.size()); for (Subchannel subchannel : subchannels) { if (isReady(subchannel)) { readySubchannels.add(subchannel); } } ...
java
private static List<Subchannel> filterNonFailingSubchannels( Collection<Subchannel> subchannels) { List<Subchannel> readySubchannels = new ArrayList<>(subchannels.size()); for (Subchannel subchannel : subchannels) { if (isReady(subchannel)) { readySubchannels.add(subchannel); } } ...
[ "private", "static", "List", "<", "Subchannel", ">", "filterNonFailingSubchannels", "(", "Collection", "<", "Subchannel", ">", "subchannels", ")", "{", "List", "<", "Subchannel", ">", "readySubchannels", "=", "new", "ArrayList", "<>", "(", "subchannels", ".", "s...
Filters out non-ready subchannels.
[ "Filters", "out", "non", "-", "ready", "subchannels", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/util/RoundRobinLoadBalancer.java#L243-L252
127,401
grpc/grpc-java
benchmarks/src/jmh/java/io/grpc/benchmarks/netty/UnaryCallQpsBenchmark.java
UnaryCallQpsBenchmark.setup
@Setup(Level.Trial) public void setup() throws Exception { super.setup(ExecutorType.DIRECT, ExecutorType.DIRECT, MessageSize.SMALL, MessageSize.SMALL, FlowWindowSize.LARGE, ChannelType.NIO, maxConcurrentStreams, channelCount); callCounter = new AtomicLon...
java
@Setup(Level.Trial) public void setup() throws Exception { super.setup(ExecutorType.DIRECT, ExecutorType.DIRECT, MessageSize.SMALL, MessageSize.SMALL, FlowWindowSize.LARGE, ChannelType.NIO, maxConcurrentStreams, channelCount); callCounter = new AtomicLon...
[ "@", "Setup", "(", "Level", ".", "Trial", ")", "public", "void", "setup", "(", ")", "throws", "Exception", "{", "super", ".", "setup", "(", "ExecutorType", ".", "DIRECT", ",", "ExecutorType", ".", "DIRECT", ",", "MessageSize", ".", "SMALL", ",", "Message...
Setup with direct executors, small payloads and a large flow control window.
[ "Setup", "with", "direct", "executors", "small", "payloads", "and", "a", "large", "flow", "control", "window", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/benchmarks/src/jmh/java/io/grpc/benchmarks/netty/UnaryCallQpsBenchmark.java#L68-L81
127,402
grpc/grpc-java
api/src/main/java/io/grpc/CallOptions.java
CallOptions.withoutWaitForReady
public CallOptions withoutWaitForReady() { CallOptions newOptions = new CallOptions(this); newOptions.waitForReady = Boolean.FALSE; return newOptions; }
java
public CallOptions withoutWaitForReady() { CallOptions newOptions = new CallOptions(this); newOptions.waitForReady = Boolean.FALSE; return newOptions; }
[ "public", "CallOptions", "withoutWaitForReady", "(", ")", "{", "CallOptions", "newOptions", "=", "new", "CallOptions", "(", "this", ")", ";", "newOptions", ".", "waitForReady", "=", "Boolean", ".", "FALSE", ";", "return", "newOptions", ";", "}" ]
Disables 'wait for ready' feature for the call. This method should be rarely used because the default is without 'wait for ready'.
[ "Disables", "wait", "for", "ready", "feature", "for", "the", "call", ".", "This", "method", "should", "be", "rarely", "used", "because", "the", "default", "is", "without", "wait", "for", "ready", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/api/src/main/java/io/grpc/CallOptions.java#L166-L170
127,403
grpc/grpc-java
api/src/main/java/io/grpc/CallOptions.java
CallOptions.withOption
public <T> CallOptions withOption(Key<T> key, T value) { Preconditions.checkNotNull(key, "key"); Preconditions.checkNotNull(value, "value"); CallOptions newOptions = new CallOptions(this); int existingIdx = -1; for (int i = 0; i < customOptions.length; i++) { if (key.equals(customOptions[i][0...
java
public <T> CallOptions withOption(Key<T> key, T value) { Preconditions.checkNotNull(key, "key"); Preconditions.checkNotNull(value, "value"); CallOptions newOptions = new CallOptions(this); int existingIdx = -1; for (int i = 0; i < customOptions.length; i++) { if (key.equals(customOptions[i][0...
[ "public", "<", "T", ">", "CallOptions", "withOption", "(", "Key", "<", "T", ">", "key", ",", "T", "value", ")", "{", "Preconditions", ".", "checkNotNull", "(", "key", ",", "\"key\"", ")", ";", "Preconditions", ".", "checkNotNull", "(", "value", ",", "\...
Sets a custom option. Any existing value for the key is overwritten. @param key The option key @param value The option value. @since 1.13.0
[ "Sets", "a", "custom", "option", ".", "Any", "existing", "value", "for", "the", "key", "is", "overwritten", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/api/src/main/java/io/grpc/CallOptions.java#L316-L341
127,404
grpc/grpc-java
api/src/main/java/io/grpc/CallOptions.java
CallOptions.getOption
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1869") @SuppressWarnings("unchecked") public <T> T getOption(Key<T> key) { Preconditions.checkNotNull(key, "key"); for (int i = 0; i < customOptions.length; i++) { if (key.equals(customOptions[i][0])) { return (T) customOptions[i][1]; ...
java
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1869") @SuppressWarnings("unchecked") public <T> T getOption(Key<T> key) { Preconditions.checkNotNull(key, "key"); for (int i = 0; i < customOptions.length; i++) { if (key.equals(customOptions[i][0])) { return (T) customOptions[i][1]; ...
[ "@", "ExperimentalApi", "(", "\"https://github.com/grpc/grpc-java/issues/1869\"", ")", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "getOption", "(", "Key", "<", "T", ">", "key", ")", "{", "Preconditions", ".", "checkNotNull", ...
Get the value for a custom option or its inherent default. @param key Key identifying option
[ "Get", "the", "value", "for", "a", "custom", "option", "or", "its", "inherent", "default", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/api/src/main/java/io/grpc/CallOptions.java#L347-L357
127,405
grpc/grpc-java
api/src/main/java/io/grpc/CallOptions.java
CallOptions.withMaxOutboundMessageSize
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2563") public CallOptions withMaxOutboundMessageSize(int maxSize) { checkArgument(maxSize >= 0, "invalid maxsize %s", maxSize); CallOptions newOptions = new CallOptions(this); newOptions.maxOutboundMessageSize = maxSize; return newOptions; }
java
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2563") public CallOptions withMaxOutboundMessageSize(int maxSize) { checkArgument(maxSize >= 0, "invalid maxsize %s", maxSize); CallOptions newOptions = new CallOptions(this); newOptions.maxOutboundMessageSize = maxSize; return newOptions; }
[ "@", "ExperimentalApi", "(", "\"https://github.com/grpc/grpc-java/issues/2563\"", ")", "public", "CallOptions", "withMaxOutboundMessageSize", "(", "int", "maxSize", ")", "{", "checkArgument", "(", "maxSize", ">=", "0", ",", "\"invalid maxsize %s\"", ",", "maxSize", ")", ...
Sets the maximum allowed message size acceptable sent to the remote peer.
[ "Sets", "the", "maximum", "allowed", "message", "size", "acceptable", "sent", "to", "the", "remote", "peer", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/api/src/main/java/io/grpc/CallOptions.java#L395-L401
127,406
grpc/grpc-java
alts/src/main/java/io/grpc/alts/internal/AltsTsiHandshaker.java
AltsTsiHandshaker.processBytesFromPeer
@Override public boolean processBytesFromPeer(ByteBuffer bytes) throws GeneralSecurityException { // If we're the client and we haven't given an output frame, we shouldn't be processing any // bytes. if (outputFrame == null && isClient) { return true; } // If we already have bytes to write, ...
java
@Override public boolean processBytesFromPeer(ByteBuffer bytes) throws GeneralSecurityException { // If we're the client and we haven't given an output frame, we shouldn't be processing any // bytes. if (outputFrame == null && isClient) { return true; } // If we already have bytes to write, ...
[ "@", "Override", "public", "boolean", "processBytesFromPeer", "(", "ByteBuffer", "bytes", ")", "throws", "GeneralSecurityException", "{", "// If we're the client and we haven't given an output frame, we shouldn't be processing any", "// bytes.", "if", "(", "outputFrame", "==", "n...
Process the bytes received from the peer. @param bytes The buffer containing the handshake bytes from the peer. @return true, if the handshake has all the data it needs to process and false, if the method must be called again to complete processing.
[ "Process", "the", "bytes", "received", "from", "the", "peer", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/alts/src/main/java/io/grpc/alts/internal/AltsTsiHandshaker.java#L61-L92
127,407
grpc/grpc-java
alts/src/main/java/io/grpc/alts/internal/AltsTsiHandshaker.java
AltsTsiHandshaker.newClient
public static TsiHandshaker newClient(HandshakerServiceStub stub, AltsHandshakerOptions options) { return new AltsTsiHandshaker(true, stub, options); }
java
public static TsiHandshaker newClient(HandshakerServiceStub stub, AltsHandshakerOptions options) { return new AltsTsiHandshaker(true, stub, options); }
[ "public", "static", "TsiHandshaker", "newClient", "(", "HandshakerServiceStub", "stub", ",", "AltsHandshakerOptions", "options", ")", "{", "return", "new", "AltsTsiHandshaker", "(", "true", ",", "stub", ",", "options", ")", ";", "}" ]
Creates a new TsiHandshaker for use by the client.
[ "Creates", "a", "new", "TsiHandshaker", "for", "use", "by", "the", "client", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/alts/src/main/java/io/grpc/alts/internal/AltsTsiHandshaker.java#L122-L124
127,408
grpc/grpc-java
alts/src/main/java/io/grpc/alts/internal/AltsTsiHandshaker.java
AltsTsiHandshaker.newServer
public static TsiHandshaker newServer(HandshakerServiceStub stub, AltsHandshakerOptions options) { return new AltsTsiHandshaker(false, stub, options); }
java
public static TsiHandshaker newServer(HandshakerServiceStub stub, AltsHandshakerOptions options) { return new AltsTsiHandshaker(false, stub, options); }
[ "public", "static", "TsiHandshaker", "newServer", "(", "HandshakerServiceStub", "stub", ",", "AltsHandshakerOptions", "options", ")", "{", "return", "new", "AltsTsiHandshaker", "(", "false", ",", "stub", ",", "options", ")", ";", "}" ]
Creates a new TsiHandshaker for use by the server.
[ "Creates", "a", "new", "TsiHandshaker", "for", "use", "by", "the", "server", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/alts/src/main/java/io/grpc/alts/internal/AltsTsiHandshaker.java#L127-L129
127,409
grpc/grpc-java
alts/src/main/java/io/grpc/alts/internal/AltsTsiHandshaker.java
AltsTsiHandshaker.getBytesToSendToPeer
@Override public void getBytesToSendToPeer(ByteBuffer bytes) throws GeneralSecurityException { if (outputFrame == null) { // A null outputFrame indicates we haven't started the handshake. if (isClient) { outputFrame = handshaker.startClientHandshake(); } else { // The server needs byte...
java
@Override public void getBytesToSendToPeer(ByteBuffer bytes) throws GeneralSecurityException { if (outputFrame == null) { // A null outputFrame indicates we haven't started the handshake. if (isClient) { outputFrame = handshaker.startClientHandshake(); } else { // The server needs byte...
[ "@", "Override", "public", "void", "getBytesToSendToPeer", "(", "ByteBuffer", "bytes", ")", "throws", "GeneralSecurityException", "{", "if", "(", "outputFrame", "==", "null", ")", "{", "// A null outputFrame indicates we haven't started the handshake.", "if", "(", "isClie...
Gets bytes that need to be sent to the peer. @param bytes The buffer to put handshake bytes.
[ "Gets", "bytes", "that", "need", "to", "be", "sent", "to", "the", "peer", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/alts/src/main/java/io/grpc/alts/internal/AltsTsiHandshaker.java#L136-L154
127,410
grpc/grpc-java
benchmarks/src/jmh/java/io/grpc/benchmarks/netty/StreamingResponseBandwidthBenchmark.java
StreamingResponseBandwidthBenchmark.setup
@Setup(Level.Trial) public void setup() throws Exception { super.setup(ExecutorType.DIRECT, ExecutorType.DIRECT, MessageSize.SMALL, responseSize, clientInboundFlowWindow, ChannelType.NIO, maxConcurrentStreams, 1); callCounter = new AtomicLong(); comp...
java
@Setup(Level.Trial) public void setup() throws Exception { super.setup(ExecutorType.DIRECT, ExecutorType.DIRECT, MessageSize.SMALL, responseSize, clientInboundFlowWindow, ChannelType.NIO, maxConcurrentStreams, 1); callCounter = new AtomicLong(); comp...
[ "@", "Setup", "(", "Level", ".", "Trial", ")", "public", "void", "setup", "(", ")", "throws", "Exception", "{", "super", ".", "setup", "(", "ExecutorType", ".", "DIRECT", ",", "ExecutorType", ".", "DIRECT", ",", "MessageSize", ".", "SMALL", ",", "respons...
Setup with direct executors and one channel.
[ "Setup", "with", "direct", "executors", "and", "one", "channel", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/benchmarks/src/jmh/java/io/grpc/benchmarks/netty/StreamingResponseBandwidthBenchmark.java#L77-L92
127,411
grpc/grpc-java
services/src/main/java/io/grpc/services/ChannelzService.java
ChannelzService.getServers
@Override public void getServers( GetServersRequest request, StreamObserver<GetServersResponse> responseObserver) { ServerList servers = channelz.getServers(request.getStartServerId(), maxPageSize); GetServersResponse resp; try { resp = ChannelzProtoUtil.toGetServersResponse(servers); } c...
java
@Override public void getServers( GetServersRequest request, StreamObserver<GetServersResponse> responseObserver) { ServerList servers = channelz.getServers(request.getStartServerId(), maxPageSize); GetServersResponse resp; try { resp = ChannelzProtoUtil.toGetServersResponse(servers); } c...
[ "@", "Override", "public", "void", "getServers", "(", "GetServersRequest", "request", ",", "StreamObserver", "<", "GetServersResponse", ">", "responseObserver", ")", "{", "ServerList", "servers", "=", "channelz", ".", "getServers", "(", "request", ".", "getStartServ...
Returns servers.
[ "Returns", "servers", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/services/src/main/java/io/grpc/services/ChannelzService.java#L112-L127
127,412
grpc/grpc-java
services/src/main/java/io/grpc/services/ChannelzService.java
ChannelzService.getSubchannel
@Override public void getSubchannel( GetSubchannelRequest request, StreamObserver<GetSubchannelResponse> responseObserver) { InternalInstrumented<ChannelStats> s = channelz.getSubchannel(request.getSubchannelId()); if (s == null) { responseObserver.onError( Status.NOT_FOUND.withDescripti...
java
@Override public void getSubchannel( GetSubchannelRequest request, StreamObserver<GetSubchannelResponse> responseObserver) { InternalInstrumented<ChannelStats> s = channelz.getSubchannel(request.getSubchannelId()); if (s == null) { responseObserver.onError( Status.NOT_FOUND.withDescripti...
[ "@", "Override", "public", "void", "getSubchannel", "(", "GetSubchannelRequest", "request", ",", "StreamObserver", "<", "GetSubchannelResponse", ">", "responseObserver", ")", "{", "InternalInstrumented", "<", "ChannelStats", ">", "s", "=", "channelz", ".", "getSubchan...
Returns a subchannel.
[ "Returns", "a", "subchannel", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/services/src/main/java/io/grpc/services/ChannelzService.java#L130-L154
127,413
grpc/grpc-java
core/src/main/java/io/grpc/internal/KeepAliveManager.java
KeepAliveManager.onDataReceived
public synchronized void onDataReceived() { stopwatch.reset().start(); // We do not cancel the ping future here. This avoids constantly scheduling and cancellation in // a busy transport. Instead, we update the status here and reschedule later. So we actually // keep one sendPing task always in flight w...
java
public synchronized void onDataReceived() { stopwatch.reset().start(); // We do not cancel the ping future here. This avoids constantly scheduling and cancellation in // a busy transport. Instead, we update the status here and reschedule later. So we actually // keep one sendPing task always in flight w...
[ "public", "synchronized", "void", "onDataReceived", "(", ")", "{", "stopwatch", ".", "reset", "(", ")", ".", "start", "(", ")", ";", "// We do not cancel the ping future here. This avoids constantly scheduling and cancellation in", "// a busy transport. Instead, we update the sta...
Transport has received some data so that we can delay sending keepalives.
[ "Transport", "has", "received", "some", "data", "so", "that", "we", "can", "delay", "sending", "keepalives", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/KeepAliveManager.java#L160-L183
127,414
grpc/grpc-java
core/src/main/java/io/grpc/internal/KeepAliveManager.java
KeepAliveManager.onTransportActive
public synchronized void onTransportActive() { if (state == State.IDLE) { // When the transport goes active, we do not reset the nextKeepaliveTime. This allows us to // quickly check whether the connection is still working. state = State.PING_SCHEDULED; if (pingFuture == null) { ping...
java
public synchronized void onTransportActive() { if (state == State.IDLE) { // When the transport goes active, we do not reset the nextKeepaliveTime. This allows us to // quickly check whether the connection is still working. state = State.PING_SCHEDULED; if (pingFuture == null) { ping...
[ "public", "synchronized", "void", "onTransportActive", "(", ")", "{", "if", "(", "state", "==", "State", ".", "IDLE", ")", "{", "// When the transport goes active, we do not reset the nextKeepaliveTime. This allows us to", "// quickly check whether the connection is still working."...
Transport has active streams. Start sending keepalives if necessary.
[ "Transport", "has", "active", "streams", ".", "Start", "sending", "keepalives", "if", "necessary", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/KeepAliveManager.java#L188-L202
127,415
grpc/grpc-java
core/src/main/java/io/grpc/internal/KeepAliveManager.java
KeepAliveManager.onTransportIdle
public synchronized void onTransportIdle() { if (keepAliveDuringTransportIdle) { return; } if (state == State.PING_SCHEDULED || state == State.PING_DELAYED) { state = State.IDLE; } if (state == State.PING_SENT) { state = State.IDLE_AND_PING_SENT; } }
java
public synchronized void onTransportIdle() { if (keepAliveDuringTransportIdle) { return; } if (state == State.PING_SCHEDULED || state == State.PING_DELAYED) { state = State.IDLE; } if (state == State.PING_SENT) { state = State.IDLE_AND_PING_SENT; } }
[ "public", "synchronized", "void", "onTransportIdle", "(", ")", "{", "if", "(", "keepAliveDuringTransportIdle", ")", "{", "return", ";", "}", "if", "(", "state", "==", "State", ".", "PING_SCHEDULED", "||", "state", "==", "State", ".", "PING_DELAYED", ")", "{"...
Transport has finished all streams.
[ "Transport", "has", "finished", "all", "streams", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/KeepAliveManager.java#L207-L217
127,416
grpc/grpc-java
core/src/main/java/io/grpc/internal/KeepAliveManager.java
KeepAliveManager.onTransportTermination
public synchronized void onTransportTermination() { if (state != State.DISCONNECTED) { state = State.DISCONNECTED; if (shutdownFuture != null) { shutdownFuture.cancel(false); } if (pingFuture != null) { pingFuture.cancel(false); pingFuture = null; } } }
java
public synchronized void onTransportTermination() { if (state != State.DISCONNECTED) { state = State.DISCONNECTED; if (shutdownFuture != null) { shutdownFuture.cancel(false); } if (pingFuture != null) { pingFuture.cancel(false); pingFuture = null; } } }
[ "public", "synchronized", "void", "onTransportTermination", "(", ")", "{", "if", "(", "state", "!=", "State", ".", "DISCONNECTED", ")", "{", "state", "=", "State", ".", "DISCONNECTED", ";", "if", "(", "shutdownFuture", "!=", "null", ")", "{", "shutdownFuture...
Transport is being terminated. We no longer need to do keepalives.
[ "Transport", "is", "being", "terminated", ".", "We", "no", "longer", "need", "to", "do", "keepalives", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/KeepAliveManager.java#L222-L233
127,417
grpc/grpc-java
examples/android/clientcache/app/src/main/java/io/grpc/clientcacheexample/ClientCacheExampleActivity.java
ClientCacheExampleActivity.sendMessage
public void sendMessage(View view) { ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(hostEdit.getWindowToken(), 0); sendButton.setEnabled(false); resultText.setText(""); new GrpcTask(this, cache) .execute( hostEdit.getText().toSt...
java
public void sendMessage(View view) { ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(hostEdit.getWindowToken(), 0); sendButton.setEnabled(false); resultText.setText(""); new GrpcTask(this, cache) .execute( hostEdit.getText().toSt...
[ "public", "void", "sendMessage", "(", "View", "view", ")", "{", "(", "(", "InputMethodManager", ")", "getSystemService", "(", "Context", ".", "INPUT_METHOD_SERVICE", ")", ")", ".", "hideSoftInputFromWindow", "(", "hostEdit", ".", "getWindowToken", "(", ")", ",",...
Sends RPC. Invoked when app button is pressed.
[ "Sends", "RPC", ".", "Invoked", "when", "app", "button", "is", "pressed", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/examples/android/clientcache/app/src/main/java/io/grpc/clientcacheexample/ClientCacheExampleActivity.java#L78-L91
127,418
grpc/grpc-java
core/src/main/java/io/grpc/internal/ConnectivityStateManager.java
ConnectivityStateManager.notifyWhenStateChanged
void notifyWhenStateChanged(Runnable callback, Executor executor, ConnectivityState source) { checkNotNull(callback, "callback"); checkNotNull(executor, "executor"); checkNotNull(source, "source"); Listener stateChangeListener = new Listener(callback, executor); if (state != source) { stateCh...
java
void notifyWhenStateChanged(Runnable callback, Executor executor, ConnectivityState source) { checkNotNull(callback, "callback"); checkNotNull(executor, "executor"); checkNotNull(source, "source"); Listener stateChangeListener = new Listener(callback, executor); if (state != source) { stateCh...
[ "void", "notifyWhenStateChanged", "(", "Runnable", "callback", ",", "Executor", "executor", ",", "ConnectivityState", "source", ")", "{", "checkNotNull", "(", "callback", ",", "\"callback\"", ")", ";", "checkNotNull", "(", "executor", ",", "\"executor\"", ")", ";"...
Adds a listener for state change event. <p>The {@code executor} must be one that can run RPC call listeners.
[ "Adds", "a", "listener", "for", "state", "change", "event", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/ConnectivityStateManager.java#L45-L56
127,419
grpc/grpc-java
protobuf/src/main/java/io/grpc/protobuf/ProtoUtils.java
ProtoUtils.keyForProto
public static <T extends Message> Metadata.Key<T> keyForProto(T instance) { return Metadata.Key.of( instance.getDescriptorForType().getFullName() + Metadata.BINARY_HEADER_SUFFIX, metadataMarshaller(instance)); }
java
public static <T extends Message> Metadata.Key<T> keyForProto(T instance) { return Metadata.Key.of( instance.getDescriptorForType().getFullName() + Metadata.BINARY_HEADER_SUFFIX, metadataMarshaller(instance)); }
[ "public", "static", "<", "T", "extends", "Message", ">", "Metadata", ".", "Key", "<", "T", ">", "keyForProto", "(", "T", "instance", ")", "{", "return", "Metadata", ".", "Key", ".", "of", "(", "instance", ".", "getDescriptorForType", "(", ")", ".", "ge...
Produce a metadata key for a generated protobuf type. @since 1.0.0
[ "Produce", "a", "metadata", "key", "for", "a", "generated", "protobuf", "type", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/protobuf/src/main/java/io/grpc/protobuf/ProtoUtils.java#L65-L69
127,420
grpc/grpc-java
alts/src/main/java/io/grpc/alts/internal/AltsHandshakerStub.java
AltsHandshakerStub.send
public HandshakerResp send(HandshakerReq req) throws InterruptedException, IOException { maybeThrowIoException(); if (!responseQueue.isEmpty()) { throw new IOException("Received an unexpected response."); } writer.onNext(req); Optional<HandshakerResp> result = responseQueue.take(); if (!re...
java
public HandshakerResp send(HandshakerReq req) throws InterruptedException, IOException { maybeThrowIoException(); if (!responseQueue.isEmpty()) { throw new IOException("Received an unexpected response."); } writer.onNext(req); Optional<HandshakerResp> result = responseQueue.take(); if (!re...
[ "public", "HandshakerResp", "send", "(", "HandshakerReq", "req", ")", "throws", "InterruptedException", ",", "IOException", "{", "maybeThrowIoException", "(", ")", ";", "if", "(", "!", "responseQueue", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "IOExc...
Send a handshaker request and return the handshaker response.
[ "Send", "a", "handshaker", "request", "and", "return", "the", "handshaker", "response", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerStub.java#L55-L66
127,421
grpc/grpc-java
core/src/main/java/io/grpc/internal/MessageFramer.java
MessageFramer.writeKnownLengthUncompressed
private int writeKnownLengthUncompressed(InputStream message, int messageLength) throws IOException { if (maxOutboundMessageSize >= 0 && messageLength > maxOutboundMessageSize) { throw Status.RESOURCE_EXHAUSTED .withDescription( String.format("message too large %d > %d", messageL...
java
private int writeKnownLengthUncompressed(InputStream message, int messageLength) throws IOException { if (maxOutboundMessageSize >= 0 && messageLength > maxOutboundMessageSize) { throw Status.RESOURCE_EXHAUSTED .withDescription( String.format("message too large %d > %d", messageL...
[ "private", "int", "writeKnownLengthUncompressed", "(", "InputStream", "message", ",", "int", "messageLength", ")", "throws", "IOException", "{", "if", "(", "maxOutboundMessageSize", ">=", "0", "&&", "messageLength", ">", "maxOutboundMessageSize", ")", "{", "throw", ...
Write an unserialized message with a known length, uncompressed.
[ "Write", "an", "unserialized", "message", "with", "a", "known", "length", "uncompressed", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/MessageFramer.java#L212-L230
127,422
grpc/grpc-java
core/src/main/java/io/grpc/internal/MessageFramer.java
MessageFramer.writeBufferChain
private void writeBufferChain(BufferChainOutputStream bufferChain, boolean compressed) { ByteBuffer header = ByteBuffer.wrap(headerScratch); header.put(compressed ? COMPRESSED : UNCOMPRESSED); int messageLength = bufferChain.readableBytes(); header.putInt(messageLength); WritableBuffer writeableHead...
java
private void writeBufferChain(BufferChainOutputStream bufferChain, boolean compressed) { ByteBuffer header = ByteBuffer.wrap(headerScratch); header.put(compressed ? COMPRESSED : UNCOMPRESSED); int messageLength = bufferChain.readableBytes(); header.putInt(messageLength); WritableBuffer writeableHead...
[ "private", "void", "writeBufferChain", "(", "BufferChainOutputStream", "bufferChain", ",", "boolean", "compressed", ")", "{", "ByteBuffer", "header", "=", "ByteBuffer", ".", "wrap", "(", "headerScratch", ")", ";", "header", ".", "put", "(", "compressed", "?", "C...
Write a message that has been serialized to a sequence of buffers.
[ "Write", "a", "message", "that", "has", "been", "serialized", "to", "a", "sequence", "of", "buffers", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/MessageFramer.java#L235-L263
127,423
grpc/grpc-java
core/src/main/java/io/grpc/internal/MessageFramer.java
MessageFramer.close
@Override public void close() { if (!isClosed()) { closed = true; // With the current code we don't expect readableBytes > 0 to be possible here, added // defensively to prevent buffer leak issues if the framer code changes later. if (buffer != null && buffer.readableBytes() == 0) { ...
java
@Override public void close() { if (!isClosed()) { closed = true; // With the current code we don't expect readableBytes > 0 to be possible here, added // defensively to prevent buffer leak issues if the framer code changes later. if (buffer != null && buffer.readableBytes() == 0) { ...
[ "@", "Override", "public", "void", "close", "(", ")", "{", "if", "(", "!", "isClosed", "(", ")", ")", "{", "closed", "=", "true", ";", "// With the current code we don't expect readableBytes > 0 to be possible here, added", "// defensively to prevent buffer leak issues if t...
Flushes and closes the framer and releases any buffers. After the framer is closed or disposed, additional calls to this method will have no affect.
[ "Flushes", "and", "closes", "the", "framer", "and", "releases", "any", "buffers", ".", "After", "the", "framer", "is", "closed", "or", "disposed", "additional", "calls", "to", "this", "method", "will", "have", "no", "affect", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/MessageFramer.java#L317-L328
127,424
grpc/grpc-java
alts/src/main/java/io/grpc/alts/internal/AltsHandshakerClient.java
AltsHandshakerClient.setStartClientFields
private void setStartClientFields(HandshakerReq.Builder req) { // Sets the default values. StartClientHandshakeReq.Builder startClientReq = StartClientHandshakeReq.newBuilder() .setHandshakeSecurityProtocol(HandshakeProtocol.ALTS) .addApplicationProtocols(APPLICATION_PROTOCOL) ...
java
private void setStartClientFields(HandshakerReq.Builder req) { // Sets the default values. StartClientHandshakeReq.Builder startClientReq = StartClientHandshakeReq.newBuilder() .setHandshakeSecurityProtocol(HandshakeProtocol.ALTS) .addApplicationProtocols(APPLICATION_PROTOCOL) ...
[ "private", "void", "setStartClientFields", "(", "HandshakerReq", ".", "Builder", "req", ")", "{", "// Sets the default values.", "StartClientHandshakeReq", ".", "Builder", "startClientReq", "=", "StartClientHandshakeReq", ".", "newBuilder", "(", ")", ".", "setHandshakeSec...
Sets the start client fields for the passed handshake request.
[ "Sets", "the", "start", "client", "fields", "for", "the", "passed", "handshake", "request", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerClient.java#L65-L86
127,425
grpc/grpc-java
alts/src/main/java/io/grpc/alts/internal/AltsHandshakerClient.java
AltsHandshakerClient.setStartServerFields
private void setStartServerFields(HandshakerReq.Builder req, ByteBuffer inBytes) { ServerHandshakeParameters serverParameters = ServerHandshakeParameters.newBuilder().addRecordProtocols(RECORD_PROTOCOL).build(); StartServerHandshakeReq.Builder startServerReq = StartServerHandshakeReq.newBuilder(...
java
private void setStartServerFields(HandshakerReq.Builder req, ByteBuffer inBytes) { ServerHandshakeParameters serverParameters = ServerHandshakeParameters.newBuilder().addRecordProtocols(RECORD_PROTOCOL).build(); StartServerHandshakeReq.Builder startServerReq = StartServerHandshakeReq.newBuilder(...
[ "private", "void", "setStartServerFields", "(", "HandshakerReq", ".", "Builder", "req", ",", "ByteBuffer", "inBytes", ")", "{", "ServerHandshakeParameters", "serverParameters", "=", "ServerHandshakeParameters", ".", "newBuilder", "(", ")", ".", "addRecordProtocols", "("...
Sets the start server fields for the passed handshake request.
[ "Sets", "the", "start", "server", "fields", "for", "the", "passed", "handshake", "request", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerClient.java#L89-L101
127,426
grpc/grpc-java
alts/src/main/java/io/grpc/alts/internal/AltsHandshakerClient.java
AltsHandshakerClient.isFinished
public boolean isFinished() { // If we have a HandshakeResult, we are done. if (result != null) { return true; } // If we have an error status, we are done. if (status != null && status.getCode() != Status.Code.OK.value()) { return true; } return false; }
java
public boolean isFinished() { // If we have a HandshakeResult, we are done. if (result != null) { return true; } // If we have an error status, we are done. if (status != null && status.getCode() != Status.Code.OK.value()) { return true; } return false; }
[ "public", "boolean", "isFinished", "(", ")", "{", "// If we have a HandshakeResult, we are done.", "if", "(", "result", "!=", "null", ")", "{", "return", "true", ";", "}", "// If we have an error status, we are done.", "if", "(", "status", "!=", "null", "&&", "statu...
Returns true if the handshake is complete.
[ "Returns", "true", "if", "the", "handshake", "is", "complete", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerClient.java#L104-L114
127,427
grpc/grpc-java
alts/src/main/java/io/grpc/alts/internal/AltsHandshakerClient.java
AltsHandshakerClient.getKey
public byte[] getKey() { if (result == null) { return null; } if (result.getKeyData().size() < KEY_LENGTH) { throw new IllegalStateException("Could not get enough key data from the handshake."); } byte[] key = new byte[KEY_LENGTH]; result.getKeyData().copyTo(key, 0, 0, KEY_LENGTH); ...
java
public byte[] getKey() { if (result == null) { return null; } if (result.getKeyData().size() < KEY_LENGTH) { throw new IllegalStateException("Could not get enough key data from the handshake."); } byte[] key = new byte[KEY_LENGTH]; result.getKeyData().copyTo(key, 0, 0, KEY_LENGTH); ...
[ "public", "byte", "[", "]", "getKey", "(", ")", "{", "if", "(", "result", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "result", ".", "getKeyData", "(", ")", ".", "size", "(", ")", "<", "KEY_LENGTH", ")", "{", "throw", "new", ...
Returns the resulting key of the handshake, if the handshake is completed. Note that the key data returned from the handshake may be more than the key length required for the record protocol, thus we need to truncate to the right size.
[ "Returns", "the", "resulting", "key", "of", "the", "handshake", "if", "the", "handshake", "is", "completed", ".", "Note", "that", "the", "key", "data", "returned", "from", "the", "handshake", "may", "be", "more", "than", "the", "key", "length", "required", ...
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerClient.java#L131-L141
127,428
grpc/grpc-java
alts/src/main/java/io/grpc/alts/internal/AltsHandshakerClient.java
AltsHandshakerClient.handleResponse
private void handleResponse(HandshakerResp resp) throws GeneralSecurityException { status = resp.getStatus(); if (resp.hasResult()) { result = resp.getResult(); close(); } if (status.getCode() != Status.Code.OK.value()) { String error = "Handshaker service error: " + status.getDetails(...
java
private void handleResponse(HandshakerResp resp) throws GeneralSecurityException { status = resp.getStatus(); if (resp.hasResult()) { result = resp.getResult(); close(); } if (status.getCode() != Status.Code.OK.value()) { String error = "Handshaker service error: " + status.getDetails(...
[ "private", "void", "handleResponse", "(", "HandshakerResp", "resp", ")", "throws", "GeneralSecurityException", "{", "status", "=", "resp", ".", "getStatus", "(", ")", ";", "if", "(", "resp", ".", "hasResult", "(", ")", ")", "{", "result", "=", "resp", ".",...
Parses a handshake response, setting the status, result, and closing the handshaker, as needed.
[ "Parses", "a", "handshake", "response", "setting", "the", "status", "result", "and", "closing", "the", "handshaker", "as", "needed", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerClient.java#L146-L158
127,429
grpc/grpc-java
cronet/src/main/java/io/grpc/cronet/CronetChannelBuilder.java
CronetChannelBuilder.forAddress
public static CronetChannelBuilder forAddress(String host, int port, CronetEngine cronetEngine) { Preconditions.checkNotNull(cronetEngine, "cronetEngine"); return new CronetChannelBuilder(host, port, cronetEngine); }
java
public static CronetChannelBuilder forAddress(String host, int port, CronetEngine cronetEngine) { Preconditions.checkNotNull(cronetEngine, "cronetEngine"); return new CronetChannelBuilder(host, port, cronetEngine); }
[ "public", "static", "CronetChannelBuilder", "forAddress", "(", "String", "host", ",", "int", "port", ",", "CronetEngine", "cronetEngine", ")", "{", "Preconditions", ".", "checkNotNull", "(", "cronetEngine", ",", "\"cronetEngine\"", ")", ";", "return", "new", "Cron...
Creates a new builder for the given server host, port and CronetEngine.
[ "Creates", "a", "new", "builder", "for", "the", "given", "server", "host", "port", "and", "CronetEngine", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/cronet/src/main/java/io/grpc/cronet/CronetChannelBuilder.java#L56-L59
127,430
grpc/grpc-java
examples/src/main/java/io/grpc/examples/routeguide/RouteGuideServer.java
RouteGuideServer.start
public void start() throws IOException { server.start(); logger.info("Server started, listening on " + port); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { // Use stderr here since the logger may has been reset by its JVM shutdown hook. System....
java
public void start() throws IOException { server.start(); logger.info("Server started, listening on " + port); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { // Use stderr here since the logger may has been reset by its JVM shutdown hook. System....
[ "public", "void", "start", "(", ")", "throws", "IOException", "{", "server", ".", "start", "(", ")", ";", "logger", ".", "info", "(", "\"Server started, listening on \"", "+", "port", ")", ";", "Runtime", ".", "getRuntime", "(", ")", ".", "addShutdownHook", ...
Start serving requests.
[ "Start", "serving", "requests", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/examples/src/main/java/io/grpc/examples/routeguide/RouteGuideServer.java#L68-L80
127,431
grpc/grpc-java
examples/src/main/java/io/grpc/examples/routeguide/RouteGuideServer.java
RouteGuideServer.main
public static void main(String[] args) throws Exception { RouteGuideServer server = new RouteGuideServer(8980); server.start(); server.blockUntilShutdown(); }
java
public static void main(String[] args) throws Exception { RouteGuideServer server = new RouteGuideServer(8980); server.start(); server.blockUntilShutdown(); }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "Exception", "{", "RouteGuideServer", "server", "=", "new", "RouteGuideServer", "(", "8980", ")", ";", "server", ".", "start", "(", ")", ";", "server", ".", "blockUntilShut...
Main method. This comment makes the linter happy.
[ "Main", "method", ".", "This", "comment", "makes", "the", "linter", "happy", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/examples/src/main/java/io/grpc/examples/routeguide/RouteGuideServer.java#L101-L105
127,432
grpc/grpc-java
netty/src/main/java/io/grpc/netty/NettyServerTransport.java
NettyServerTransport.createHandler
private NettyServerHandler createHandler( ServerTransportListener transportListener, ChannelPromise channelUnused) { return NettyServerHandler.newHandler( transportListener, channelUnused, streamTracerFactories, transportTracer, maxStreams, flowControlWindow, ...
java
private NettyServerHandler createHandler( ServerTransportListener transportListener, ChannelPromise channelUnused) { return NettyServerHandler.newHandler( transportListener, channelUnused, streamTracerFactories, transportTracer, maxStreams, flowControlWindow, ...
[ "private", "NettyServerHandler", "createHandler", "(", "ServerTransportListener", "transportListener", ",", "ChannelPromise", "channelUnused", ")", "{", "return", "NettyServerHandler", ".", "newHandler", "(", "transportListener", ",", "channelUnused", ",", "streamTracerFactor...
Creates the Netty handler to be used in the channel pipeline.
[ "Creates", "the", "Netty", "handler", "to", "be", "used", "in", "the", "channel", "pipeline", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/netty/src/main/java/io/grpc/netty/NettyServerTransport.java#L255-L273
127,433
grpc/grpc-java
xds/src/main/java/io/grpc/xds/XdsLoadReportStore.java
XdsLoadReportStore.recordDroppedRequest
void recordDroppedRequest(String category) { AtomicLong counter = dropCounters.get(category); if (counter == null) { counter = dropCounters.putIfAbsent(category, new AtomicLong()); if (counter == null) { counter = dropCounters.get(category); } } counter.getAndIncrement(); }
java
void recordDroppedRequest(String category) { AtomicLong counter = dropCounters.get(category); if (counter == null) { counter = dropCounters.putIfAbsent(category, new AtomicLong()); if (counter == null) { counter = dropCounters.get(category); } } counter.getAndIncrement(); }
[ "void", "recordDroppedRequest", "(", "String", "category", ")", "{", "AtomicLong", "counter", "=", "dropCounters", ".", "get", "(", "category", ")", ";", "if", "(", "counter", "==", "null", ")", "{", "counter", "=", "dropCounters", ".", "putIfAbsent", "(", ...
Record that a request has been dropped by drop overload policy with the provided category instructed by the remote balancer.
[ "Record", "that", "a", "request", "has", "been", "dropped", "by", "drop", "overload", "policy", "with", "the", "provided", "category", "instructed", "by", "the", "remote", "balancer", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/xds/src/main/java/io/grpc/xds/XdsLoadReportStore.java#L159-L168
127,434
grpc/grpc-java
grpclb/src/main/java/io/grpc/grpclb/GrpclbState.java
GrpclbState.handleAddresses
void handleAddresses( List<LbAddressGroup> newLbAddressGroups, List<EquivalentAddressGroup> newBackendServers) { if (newLbAddressGroups.isEmpty()) { // No balancer address: close existing balancer connection and enter fallback mode // immediately. shutdownLbComm(); syncContext.execute(...
java
void handleAddresses( List<LbAddressGroup> newLbAddressGroups, List<EquivalentAddressGroup> newBackendServers) { if (newLbAddressGroups.isEmpty()) { // No balancer address: close existing balancer connection and enter fallback mode // immediately. shutdownLbComm(); syncContext.execute(...
[ "void", "handleAddresses", "(", "List", "<", "LbAddressGroup", ">", "newLbAddressGroups", ",", "List", "<", "EquivalentAddressGroup", ">", "newBackendServers", ")", "{", "if", "(", "newLbAddressGroups", ".", "isEmpty", "(", ")", ")", "{", "// No balancer address: cl...
Handle new addresses of the balancer and backends from the resolver, and create connection if not yet connected.
[ "Handle", "new", "addresses", "of", "the", "balancer", "and", "backends", "from", "the", "resolver", "and", "create", "connection", "if", "not", "yet", "connected", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/grpclb/src/main/java/io/grpc/grpclb/GrpclbState.java#L196-L225
127,435
grpc/grpc-java
grpclb/src/main/java/io/grpc/grpclb/GrpclbState.java
GrpclbState.useFallbackBackends
private void useFallbackBackends() { usingFallbackBackends = true; logger.log(ChannelLogLevel.INFO, "Using fallback backends"); List<DropEntry> newDropList = new ArrayList<>(); List<BackendAddressGroup> newBackendAddrList = new ArrayList<>(); for (EquivalentAddressGroup eag : fallbackBackendList) {...
java
private void useFallbackBackends() { usingFallbackBackends = true; logger.log(ChannelLogLevel.INFO, "Using fallback backends"); List<DropEntry> newDropList = new ArrayList<>(); List<BackendAddressGroup> newBackendAddrList = new ArrayList<>(); for (EquivalentAddressGroup eag : fallbackBackendList) {...
[ "private", "void", "useFallbackBackends", "(", ")", "{", "usingFallbackBackends", "=", "true", ";", "logger", ".", "log", "(", "ChannelLogLevel", ".", "INFO", ",", "\"Using fallback backends\"", ")", ";", "List", "<", "DropEntry", ">", "newDropList", "=", "new",...
Populate the round-robin lists with the fallback backends.
[ "Populate", "the", "round", "-", "robin", "lists", "with", "the", "fallback", "backends", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/grpclb/src/main/java/io/grpc/grpclb/GrpclbState.java#L246-L257
127,436
grpc/grpc-java
grpclb/src/main/java/io/grpc/grpclb/GrpclbState.java
GrpclbState.maybeUpdatePicker
private void maybeUpdatePicker() { List<RoundRobinEntry> pickList; ConnectivityState state; switch (mode) { case ROUND_ROBIN: pickList = new ArrayList<>(backendList.size()); Status error = null; boolean hasIdle = false; for (BackendEntry entry : backendList) { ...
java
private void maybeUpdatePicker() { List<RoundRobinEntry> pickList; ConnectivityState state; switch (mode) { case ROUND_ROBIN: pickList = new ArrayList<>(backendList.size()); Status error = null; boolean hasIdle = false; for (BackendEntry entry : backendList) { ...
[ "private", "void", "maybeUpdatePicker", "(", ")", "{", "List", "<", "RoundRobinEntry", ">", "pickList", ";", "ConnectivityState", "state", ";", "switch", "(", "mode", ")", "{", "case", "ROUND_ROBIN", ":", "pickList", "=", "new", "ArrayList", "<>", "(", "back...
Make and use a picker out of the current lists and the states of subchannels if they have changed since the last picker created.
[ "Make", "and", "use", "a", "picker", "out", "of", "the", "current", "lists", "and", "the", "states", "of", "subchannels", "if", "they", "have", "changed", "since", "the", "last", "picker", "created", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/grpclb/src/main/java/io/grpc/grpclb/GrpclbState.java#L679-L743
127,437
grpc/grpc-java
grpclb/src/main/java/io/grpc/grpclb/GrpclbState.java
GrpclbState.maybeUpdatePicker
private void maybeUpdatePicker(ConnectivityState state, RoundRobinPicker picker) { // Discard the new picker if we are sure it won't make any difference, in order to save // re-processing pending streams, and avoid unnecessary resetting of the pointer in // RoundRobinPicker. if (picker.dropList.equals(c...
java
private void maybeUpdatePicker(ConnectivityState state, RoundRobinPicker picker) { // Discard the new picker if we are sure it won't make any difference, in order to save // re-processing pending streams, and avoid unnecessary resetting of the pointer in // RoundRobinPicker. if (picker.dropList.equals(c...
[ "private", "void", "maybeUpdatePicker", "(", "ConnectivityState", "state", ",", "RoundRobinPicker", "picker", ")", "{", "// Discard the new picker if we are sure it won't make any difference, in order to save", "// re-processing pending streams, and avoid unnecessary resetting of the pointer...
Update the given picker to the helper if it's different from the current one.
[ "Update", "the", "given", "picker", "to", "the", "helper", "if", "it", "s", "different", "from", "the", "current", "one", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/grpclb/src/main/java/io/grpc/grpclb/GrpclbState.java#L748-L760
127,438
grpc/grpc-java
grpclb/src/main/java/io/grpc/grpclb/GrpclbState.java
GrpclbState.flattenEquivalentAddressGroup
private static EquivalentAddressGroup flattenEquivalentAddressGroup( List<EquivalentAddressGroup> groupList, Attributes attrs) { List<SocketAddress> addrs = new ArrayList<>(); for (EquivalentAddressGroup group : groupList) { addrs.addAll(group.getAddresses()); } return new EquivalentAddressG...
java
private static EquivalentAddressGroup flattenEquivalentAddressGroup( List<EquivalentAddressGroup> groupList, Attributes attrs) { List<SocketAddress> addrs = new ArrayList<>(); for (EquivalentAddressGroup group : groupList) { addrs.addAll(group.getAddresses()); } return new EquivalentAddressG...
[ "private", "static", "EquivalentAddressGroup", "flattenEquivalentAddressGroup", "(", "List", "<", "EquivalentAddressGroup", ">", "groupList", ",", "Attributes", "attrs", ")", "{", "List", "<", "SocketAddress", ">", "addrs", "=", "new", "ArrayList", "<>", "(", ")", ...
Flattens list of EquivalentAddressGroup objects into one EquivalentAddressGroup object.
[ "Flattens", "list", "of", "EquivalentAddressGroup", "objects", "into", "one", "EquivalentAddressGroup", "object", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/grpclb/src/main/java/io/grpc/grpclb/GrpclbState.java#L791-L798
127,439
grpc/grpc-java
core/src/main/java/io/grpc/internal/Rescheduler.java
Rescheduler.cancel
void cancel(boolean permanent) { enabled = false; if (permanent && wakeUp != null) { wakeUp.cancel(false); wakeUp = null; } }
java
void cancel(boolean permanent) { enabled = false; if (permanent && wakeUp != null) { wakeUp.cancel(false); wakeUp = null; } }
[ "void", "cancel", "(", "boolean", "permanent", ")", "{", "enabled", "=", "false", ";", "if", "(", "permanent", "&&", "wakeUp", "!=", "null", ")", "{", "wakeUp", ".", "cancel", "(", "false", ")", ";", "wakeUp", "=", "null", ";", "}", "}" ]
must be called from channel executor
[ "must", "be", "called", "from", "channel", "executor" ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/Rescheduler.java#L69-L75
127,440
grpc/grpc-java
benchmarks/src/jmh/java/io/grpc/benchmarks/netty/AbstractBenchmark.java
AbstractBenchmark.buildBenchmarkAddr
private static InetAddress buildBenchmarkAddr() { InetAddress tmp = null; try { Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); outer: while (networkInterfaces.hasMoreElements()) { NetworkInterface networkInterface = networkInterfaces.nextElement();...
java
private static InetAddress buildBenchmarkAddr() { InetAddress tmp = null; try { Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); outer: while (networkInterfaces.hasMoreElements()) { NetworkInterface networkInterface = networkInterfaces.nextElement();...
[ "private", "static", "InetAddress", "buildBenchmarkAddr", "(", ")", "{", "InetAddress", "tmp", "=", "null", ";", "try", "{", "Enumeration", "<", "NetworkInterface", ">", "networkInterfaces", "=", "NetworkInterface", ".", "getNetworkInterfaces", "(", ")", ";", "out...
Resolve the address bound to the benchmark interface. Currently we assume it's a child interface of the loopback interface with the term 'benchmark' in its name. <p>>This allows traffic shaping to be applied to an IP address and to have the benchmarks detect it's presence and use it. E.g for Linux we can apply netem t...
[ "Resolve", "the", "address", "bound", "to", "the", "benchmark", "interface", ".", "Currently", "we", "assume", "it", "s", "a", "child", "interface", "of", "the", "loopback", "interface", "with", "the", "term", "benchmark", "in", "its", "name", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/benchmarks/src/jmh/java/io/grpc/benchmarks/netty/AbstractBenchmark.java#L138-L171
127,441
grpc/grpc-java
benchmarks/src/jmh/java/io/grpc/benchmarks/netty/AbstractBenchmark.java
AbstractBenchmark.teardown
protected void teardown() throws Exception { logger.fine("shutting down channels"); for (ManagedChannel channel : channels) { channel.shutdown(); } logger.fine("shutting down server"); server.shutdown(); if (!server.awaitTermination(5, TimeUnit.SECONDS)) { logger.warning("Failed to s...
java
protected void teardown() throws Exception { logger.fine("shutting down channels"); for (ManagedChannel channel : channels) { channel.shutdown(); } logger.fine("shutting down server"); server.shutdown(); if (!server.awaitTermination(5, TimeUnit.SECONDS)) { logger.warning("Failed to s...
[ "protected", "void", "teardown", "(", ")", "throws", "Exception", "{", "logger", ".", "fine", "(", "\"shutting down channels\"", ")", ";", "for", "(", "ManagedChannel", "channel", ":", "channels", ")", "{", "channel", ".", "shutdown", "(", ")", ";", "}", "...
Shutdown all the client channels and then shutdown the server.
[ "Shutdown", "all", "the", "client", "channels", "and", "then", "shutdown", "the", "server", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/benchmarks/src/jmh/java/io/grpc/benchmarks/netty/AbstractBenchmark.java#L534-L551
127,442
grpc/grpc-java
netty/src/main/java/io/grpc/netty/MaxConnectionIdleManager.java
MaxConnectionIdleManager.onTransportIdle
void onTransportIdle() { isActive = false; if (shutdownFuture == null) { return; } if (shutdownFuture.isDone()) { shutdownDelayed = false; shutdownFuture = scheduler .schedule(shutdownTask, maxConnectionIdleInNanos, TimeUnit.NANOSECONDS); } else { nextIdleMonitorTim...
java
void onTransportIdle() { isActive = false; if (shutdownFuture == null) { return; } if (shutdownFuture.isDone()) { shutdownDelayed = false; shutdownFuture = scheduler .schedule(shutdownTask, maxConnectionIdleInNanos, TimeUnit.NANOSECONDS); } else { nextIdleMonitorTim...
[ "void", "onTransportIdle", "(", ")", "{", "isActive", "=", "false", ";", "if", "(", "shutdownFuture", "==", "null", ")", "{", "return", ";", "}", "if", "(", "shutdownFuture", ".", "isDone", "(", ")", ")", "{", "shutdownDelayed", "=", "false", ";", "shu...
There are no outstanding RPCs on the transport.
[ "There", "are", "no", "outstanding", "RPCs", "on", "the", "transport", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/netty/src/main/java/io/grpc/netty/MaxConnectionIdleManager.java#L104-L116
127,443
grpc/grpc-java
api/src/main/java/io/grpc/NameResolver.java
NameResolver.start
@Deprecated public void start(final Listener listener) { if (listener instanceof Observer) { start((Observer) listener); } else { start(new Observer() { @Override public void onError(Status error) { listener.onError(error); } @Override ...
java
@Deprecated public void start(final Listener listener) { if (listener instanceof Observer) { start((Observer) listener); } else { start(new Observer() { @Override public void onError(Status error) { listener.onError(error); } @Override ...
[ "@", "Deprecated", "public", "void", "start", "(", "final", "Listener", "listener", ")", "{", "if", "(", "listener", "instanceof", "Observer", ")", "{", "start", "(", "(", "Observer", ")", "listener", ")", ";", "}", "else", "{", "start", "(", "new", "O...
Starts the resolution. @param listener used to receive updates on the target @deprecated override {@link #start(Observer)} instead. @since 1.0.0
[ "Starts", "the", "resolution", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/api/src/main/java/io/grpc/NameResolver.java#L77-L94
127,444
grpc/grpc-java
api/src/main/java/io/grpc/InternalChannelz.java
InternalChannelz.addServer
public void addServer(InternalInstrumented<ServerStats> server) { ServerSocketMap prev = perServerSockets.put(id(server), new ServerSocketMap()); assert prev == null; add(servers, server); }
java
public void addServer(InternalInstrumented<ServerStats> server) { ServerSocketMap prev = perServerSockets.put(id(server), new ServerSocketMap()); assert prev == null; add(servers, server); }
[ "public", "void", "addServer", "(", "InternalInstrumented", "<", "ServerStats", ">", "server", ")", "{", "ServerSocketMap", "prev", "=", "perServerSockets", ".", "put", "(", "id", "(", "server", ")", ",", "new", "ServerSocketMap", "(", ")", ")", ";", "assert...
Adds a server.
[ "Adds", "a", "server", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/api/src/main/java/io/grpc/InternalChannelz.java#L79-L83
127,445
grpc/grpc-java
api/src/main/java/io/grpc/InternalChannelz.java
InternalChannelz.addServerSocket
public void addServerSocket( InternalInstrumented<ServerStats> server, InternalInstrumented<SocketStats> socket) { ServerSocketMap serverSockets = perServerSockets.get(id(server)); assert serverSockets != null; add(serverSockets, socket); }
java
public void addServerSocket( InternalInstrumented<ServerStats> server, InternalInstrumented<SocketStats> socket) { ServerSocketMap serverSockets = perServerSockets.get(id(server)); assert serverSockets != null; add(serverSockets, socket); }
[ "public", "void", "addServerSocket", "(", "InternalInstrumented", "<", "ServerStats", ">", "server", ",", "InternalInstrumented", "<", "SocketStats", ">", "socket", ")", "{", "ServerSocketMap", "serverSockets", "=", "perServerSockets", ".", "get", "(", "id", "(", ...
Adds a server socket.
[ "Adds", "a", "server", "socket", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/api/src/main/java/io/grpc/InternalChannelz.java#L105-L110
127,446
grpc/grpc-java
api/src/main/java/io/grpc/InternalChannelz.java
InternalChannelz.removeServer
public void removeServer(InternalInstrumented<ServerStats> server) { remove(servers, server); ServerSocketMap prev = perServerSockets.remove(id(server)); assert prev != null; assert prev.isEmpty(); }
java
public void removeServer(InternalInstrumented<ServerStats> server) { remove(servers, server); ServerSocketMap prev = perServerSockets.remove(id(server)); assert prev != null; assert prev.isEmpty(); }
[ "public", "void", "removeServer", "(", "InternalInstrumented", "<", "ServerStats", ">", "server", ")", "{", "remove", "(", "servers", ",", "server", ")", ";", "ServerSocketMap", "prev", "=", "perServerSockets", ".", "remove", "(", "id", "(", "server", ")", "...
Removes a server.
[ "Removes", "a", "server", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/api/src/main/java/io/grpc/InternalChannelz.java#L113-L118
127,447
grpc/grpc-java
api/src/main/java/io/grpc/InternalChannelz.java
InternalChannelz.removeServerSocket
public void removeServerSocket( InternalInstrumented<ServerStats> server, InternalInstrumented<SocketStats> socket) { ServerSocketMap socketsOfServer = perServerSockets.get(id(server)); assert socketsOfServer != null; remove(socketsOfServer, socket); }
java
public void removeServerSocket( InternalInstrumented<ServerStats> server, InternalInstrumented<SocketStats> socket) { ServerSocketMap socketsOfServer = perServerSockets.get(id(server)); assert socketsOfServer != null; remove(socketsOfServer, socket); }
[ "public", "void", "removeServerSocket", "(", "InternalInstrumented", "<", "ServerStats", ">", "server", ",", "InternalInstrumented", "<", "SocketStats", ">", "socket", ")", "{", "ServerSocketMap", "socketsOfServer", "=", "perServerSockets", ".", "get", "(", "id", "(...
Removes a server socket.
[ "Removes", "a", "server", "socket", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/api/src/main/java/io/grpc/InternalChannelz.java#L137-L142
127,448
grpc/grpc-java
api/src/main/java/io/grpc/InternalChannelz.java
InternalChannelz.getServers
public ServerList getServers(long fromId, int maxPageSize) { List<InternalInstrumented<ServerStats>> serverList = new ArrayList<>(maxPageSize); Iterator<InternalInstrumented<ServerStats>> iterator = servers.tailMap(fromId).values().iterator(); while (iterator.hasNext() && serverList.size() ...
java
public ServerList getServers(long fromId, int maxPageSize) { List<InternalInstrumented<ServerStats>> serverList = new ArrayList<>(maxPageSize); Iterator<InternalInstrumented<ServerStats>> iterator = servers.tailMap(fromId).values().iterator(); while (iterator.hasNext() && serverList.size() ...
[ "public", "ServerList", "getServers", "(", "long", "fromId", ",", "int", "maxPageSize", ")", "{", "List", "<", "InternalInstrumented", "<", "ServerStats", ">>", "serverList", "=", "new", "ArrayList", "<>", "(", "maxPageSize", ")", ";", "Iterator", "<", "Intern...
Returns a server list.
[ "Returns", "a", "server", "list", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/api/src/main/java/io/grpc/InternalChannelz.java#L170-L180
127,449
grpc/grpc-java
api/src/main/java/io/grpc/InternalChannelz.java
InternalChannelz.getServerSockets
@Nullable public ServerSocketsList getServerSockets(long serverId, long fromId, int maxPageSize) { ServerSocketMap serverSockets = perServerSockets.get(serverId); if (serverSockets == null) { return null; } List<InternalWithLogId> socketList = new ArrayList<>(maxPageSize); Iterator<InternalI...
java
@Nullable public ServerSocketsList getServerSockets(long serverId, long fromId, int maxPageSize) { ServerSocketMap serverSockets = perServerSockets.get(serverId); if (serverSockets == null) { return null; } List<InternalWithLogId> socketList = new ArrayList<>(maxPageSize); Iterator<InternalI...
[ "@", "Nullable", "public", "ServerSocketsList", "getServerSockets", "(", "long", "serverId", ",", "long", "fromId", ",", "int", "maxPageSize", ")", "{", "ServerSocketMap", "serverSockets", "=", "perServerSockets", ".", "get", "(", "serverId", ")", ";", "if", "("...
Returns socket refs for a server.
[ "Returns", "socket", "refs", "for", "a", "server", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/api/src/main/java/io/grpc/InternalChannelz.java#L183-L196
127,450
grpc/grpc-java
context/src/main/java/io/grpc/PersistentHashArrayMappedTrie.java
PersistentHashArrayMappedTrie.put
public PersistentHashArrayMappedTrie<K,V> put(K key, V value) { if (root == null) { return new PersistentHashArrayMappedTrie<>(new Leaf<>(key, value)); } else { return new PersistentHashArrayMappedTrie<>(root.put(key, value, key.hashCode(), 0)); } }
java
public PersistentHashArrayMappedTrie<K,V> put(K key, V value) { if (root == null) { return new PersistentHashArrayMappedTrie<>(new Leaf<>(key, value)); } else { return new PersistentHashArrayMappedTrie<>(root.put(key, value, key.hashCode(), 0)); } }
[ "public", "PersistentHashArrayMappedTrie", "<", "K", ",", "V", ">", "put", "(", "K", "key", ",", "V", "value", ")", "{", "if", "(", "root", "==", "null", ")", "{", "return", "new", "PersistentHashArrayMappedTrie", "<>", "(", "new", "Leaf", "<>", "(", "...
Returns a new trie where the key is set to the specified value.
[ "Returns", "a", "new", "trie", "where", "the", "key", "is", "set", "to", "the", "specified", "value", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/context/src/main/java/io/grpc/PersistentHashArrayMappedTrie.java#L63-L69
127,451
grpc/grpc-java
api/src/main/java/io/grpc/MethodDescriptor.java
MethodDescriptor.generateFullMethodName
public static String generateFullMethodName(String fullServiceName, String methodName) { return checkNotNull(fullServiceName, "fullServiceName") + "/" + checkNotNull(methodName, "methodName"); }
java
public static String generateFullMethodName(String fullServiceName, String methodName) { return checkNotNull(fullServiceName, "fullServiceName") + "/" + checkNotNull(methodName, "methodName"); }
[ "public", "static", "String", "generateFullMethodName", "(", "String", "fullServiceName", ",", "String", "methodName", ")", "{", "return", "checkNotNull", "(", "fullServiceName", ",", "\"fullServiceName\"", ")", "+", "\"/\"", "+", "checkNotNull", "(", "methodName", ...
Generate the fully qualified method name. This matches the name @param fullServiceName the fully qualified service name that is prefixed with the package name @param methodName the short method name @since 1.0.0
[ "Generate", "the", "fully", "qualified", "method", "name", ".", "This", "matches", "the", "name" ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/api/src/main/java/io/grpc/MethodDescriptor.java#L386-L390
127,452
grpc/grpc-java
api/src/main/java/io/grpc/MethodDescriptor.java
MethodDescriptor.toBuilder
@CheckReturnValue public <NewReqT, NewRespT> Builder<NewReqT, NewRespT> toBuilder( Marshaller<NewReqT> requestMarshaller, Marshaller<NewRespT> responseMarshaller) { return MethodDescriptor.<NewReqT, NewRespT>newBuilder() .setRequestMarshaller(requestMarshaller) .setResponseMarshaller(respons...
java
@CheckReturnValue public <NewReqT, NewRespT> Builder<NewReqT, NewRespT> toBuilder( Marshaller<NewReqT> requestMarshaller, Marshaller<NewRespT> responseMarshaller) { return MethodDescriptor.<NewReqT, NewRespT>newBuilder() .setRequestMarshaller(requestMarshaller) .setResponseMarshaller(respons...
[ "@", "CheckReturnValue", "public", "<", "NewReqT", ",", "NewRespT", ">", "Builder", "<", "NewReqT", ",", "NewRespT", ">", "toBuilder", "(", "Marshaller", "<", "NewReqT", ">", "requestMarshaller", ",", "Marshaller", "<", "NewRespT", ">", "responseMarshaller", ")"...
Turns this descriptor into a builder, replacing the request and response marshallers. @since 1.1.0
[ "Turns", "this", "descriptor", "into", "a", "builder", "replacing", "the", "request", "and", "response", "marshallers", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/api/src/main/java/io/grpc/MethodDescriptor.java#L446-L458
127,453
grpc/grpc-java
alts/src/main/java/io/grpc/alts/AltsServerBuilder.java
AltsServerBuilder.forPort
public static AltsServerBuilder forPort(int port) { NettyServerBuilder nettyDelegate = NettyServerBuilder.forAddress(new InetSocketAddress(port)); return new AltsServerBuilder(nettyDelegate); }
java
public static AltsServerBuilder forPort(int port) { NettyServerBuilder nettyDelegate = NettyServerBuilder.forAddress(new InetSocketAddress(port)); return new AltsServerBuilder(nettyDelegate); }
[ "public", "static", "AltsServerBuilder", "forPort", "(", "int", "port", ")", "{", "NettyServerBuilder", "nettyDelegate", "=", "NettyServerBuilder", ".", "forAddress", "(", "new", "InetSocketAddress", "(", "port", ")", ")", ";", "return", "new", "AltsServerBuilder", ...
Creates a gRPC server builder for the given port.
[ "Creates", "a", "gRPC", "server", "builder", "for", "the", "given", "port", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/alts/src/main/java/io/grpc/alts/AltsServerBuilder.java#L72-L75
127,454
grpc/grpc-java
core/src/main/java/io/grpc/internal/AbstractManagedChannelImplBuilder.java
AbstractManagedChannelImplBuilder.makeTargetStringForDirectAddress
@VisibleForTesting static String makeTargetStringForDirectAddress(SocketAddress address) { try { return new URI(DIRECT_ADDRESS_SCHEME, "", "/" + address, null).toString(); } catch (URISyntaxException e) { // It should not happen. throw new RuntimeException(e); } }
java
@VisibleForTesting static String makeTargetStringForDirectAddress(SocketAddress address) { try { return new URI(DIRECT_ADDRESS_SCHEME, "", "/" + address, null).toString(); } catch (URISyntaxException e) { // It should not happen. throw new RuntimeException(e); } }
[ "@", "VisibleForTesting", "static", "String", "makeTargetStringForDirectAddress", "(", "SocketAddress", "address", ")", "{", "try", "{", "return", "new", "URI", "(", "DIRECT_ADDRESS_SCHEME", ",", "\"\"", ",", "\"/\"", "+", "address", ",", "null", ")", ".", "toSt...
Returns a target string for the SocketAddress. It is only used as a placeholder, because DirectAddressNameResolverFactory will not actually try to use it. However, it must be a valid URI.
[ "Returns", "a", "target", "string", "for", "the", "SocketAddress", ".", "It", "is", "only", "used", "as", "a", "placeholder", "because", "DirectAddressNameResolverFactory", "will", "not", "actually", "try", "to", "use", "it", ".", "However", "it", "must", "be"...
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/AbstractManagedChannelImplBuilder.java#L191-L199
127,455
grpc/grpc-java
core/src/main/java/io/grpc/internal/MetadataApplierImpl.java
MetadataApplierImpl.returnStream
ClientStream returnStream() { synchronized (lock) { if (returnedStream == null) { // apply() has not been called, needs to buffer the requests. delayedStream = new DelayedStream(); return returnedStream = delayedStream; } else { return returnedStream; } } }
java
ClientStream returnStream() { synchronized (lock) { if (returnedStream == null) { // apply() has not been called, needs to buffer the requests. delayedStream = new DelayedStream(); return returnedStream = delayedStream; } else { return returnedStream; } } }
[ "ClientStream", "returnStream", "(", ")", "{", "synchronized", "(", "lock", ")", "{", "if", "(", "returnedStream", "==", "null", ")", "{", "// apply() has not been called, needs to buffer the requests.", "delayedStream", "=", "new", "DelayedStream", "(", ")", ";", "...
Return a stream on which the RPC will run on.
[ "Return", "a", "stream", "on", "which", "the", "RPC", "will", "run", "on", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/MetadataApplierImpl.java#L104-L114
127,456
grpc/grpc-java
benchmarks/src/jmh/java/io/grpc/benchmarks/netty/FlowControlledMessagesPerSecondBenchmark.java
FlowControlledMessagesPerSecondBenchmark.setup
@Setup(Level.Trial) public void setup() throws Exception { super.setup(clientExecutor, ExecutorType.DIRECT, MessageSize.SMALL, responseSize, FlowWindowSize.MEDIUM, ChannelType.NIO, maxConcurrentStreams, channelCount); callCounter = new AtomicLong(); ...
java
@Setup(Level.Trial) public void setup() throws Exception { super.setup(clientExecutor, ExecutorType.DIRECT, MessageSize.SMALL, responseSize, FlowWindowSize.MEDIUM, ChannelType.NIO, maxConcurrentStreams, channelCount); callCounter = new AtomicLong(); ...
[ "@", "Setup", "(", "Level", ".", "Trial", ")", "public", "void", "setup", "(", ")", "throws", "Exception", "{", "super", ".", "setup", "(", "clientExecutor", ",", "ExecutorType", ".", "DIRECT", ",", "MessageSize", ".", "SMALL", ",", "responseSize", ",", ...
Setup with direct executors, small payloads and the default flow-control window.
[ "Setup", "with", "direct", "executors", "small", "payloads", "and", "the", "default", "flow", "-", "control", "window", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/benchmarks/src/jmh/java/io/grpc/benchmarks/netty/FlowControlledMessagesPerSecondBenchmark.java#L83-L98
127,457
grpc/grpc-java
api/src/main/java/io/grpc/DecompressorRegistry.java
DecompressorRegistry.getAdvertisedMessageEncodings
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704") public Set<String> getAdvertisedMessageEncodings() { Set<String> advertisedDecompressors = new HashSet<>(decompressors.size()); for (Entry<String, DecompressorInfo> entry : decompressors.entrySet()) { if (entry.getValue().advertised) { ...
java
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704") public Set<String> getAdvertisedMessageEncodings() { Set<String> advertisedDecompressors = new HashSet<>(decompressors.size()); for (Entry<String, DecompressorInfo> entry : decompressors.entrySet()) { if (entry.getValue().advertised) { ...
[ "@", "ExperimentalApi", "(", "\"https://github.com/grpc/grpc-java/issues/1704\"", ")", "public", "Set", "<", "String", ">", "getAdvertisedMessageEncodings", "(", ")", "{", "Set", "<", "String", ">", "advertisedDecompressors", "=", "new", "HashSet", "<>", "(", "decompr...
Provides a list of all message encodings that have decompressors available and should be advertised. <p>The specification doesn't say anything about ordering, or preference, so the returned codes can be arbitrary.
[ "Provides", "a", "list", "of", "all", "message", "encodings", "that", "have", "decompressors", "available", "and", "should", "be", "advertised", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/api/src/main/java/io/grpc/DecompressorRegistry.java#L116-L125
127,458
grpc/grpc-java
netty/src/jmh/java/io/grpc/netty/OutboundHeadersBenchmark.java
OutboundHeadersBenchmark.encodeClientHeaders
@Benchmark @BenchmarkMode(Mode.SampleTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public ByteBuf encodeClientHeaders() throws Exception { scratchBuffer.clear(); Http2Headers headers = Utils.convertClientHeaders(metadata, scheme, defaultPath, authority, Utils.HTTP_METHOD, userAgent); ...
java
@Benchmark @BenchmarkMode(Mode.SampleTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public ByteBuf encodeClientHeaders() throws Exception { scratchBuffer.clear(); Http2Headers headers = Utils.convertClientHeaders(metadata, scheme, defaultPath, authority, Utils.HTTP_METHOD, userAgent); ...
[ "@", "Benchmark", "@", "BenchmarkMode", "(", "Mode", ".", "SampleTime", ")", "@", "OutputTimeUnit", "(", "TimeUnit", ".", "NANOSECONDS", ")", "public", "ByteBuf", "encodeClientHeaders", "(", ")", "throws", "Exception", "{", "scratchBuffer", ".", "clear", "(", ...
This will encode the random metadata fields, and repeatedly lookup the default other headers.
[ "This", "will", "encode", "the", "random", "metadata", "fields", "and", "repeatedly", "lookup", "the", "default", "other", "headers", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/netty/src/jmh/java/io/grpc/netty/OutboundHeadersBenchmark.java#L91-L101
127,459
grpc/grpc-java
netty/src/main/java/io/grpc/netty/AbstractNettyHandler.java
AbstractNettyHandler.sendInitialConnectionWindow
private void sendInitialConnectionWindow() throws Http2Exception { if (ctx.channel().isActive() && initialConnectionWindow > 0) { Http2Stream connectionStream = connection().connectionStream(); int currentSize = connection().local().flowController().windowSize(connectionStream); int delta = initia...
java
private void sendInitialConnectionWindow() throws Http2Exception { if (ctx.channel().isActive() && initialConnectionWindow > 0) { Http2Stream connectionStream = connection().connectionStream(); int currentSize = connection().local().flowController().windowSize(connectionStream); int delta = initia...
[ "private", "void", "sendInitialConnectionWindow", "(", ")", "throws", "Http2Exception", "{", "if", "(", "ctx", ".", "channel", "(", ")", ".", "isActive", "(", ")", "&&", "initialConnectionWindow", ">", "0", ")", "{", "Http2Stream", "connectionStream", "=", "co...
Sends initial connection window to the remote endpoint if necessary.
[ "Sends", "initial", "connection", "window", "to", "the", "remote", "endpoint", "if", "necessary", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/netty/src/main/java/io/grpc/netty/AbstractNettyHandler.java#L94-L103
127,460
grpc/grpc-java
benchmarks/src/main/java/io/grpc/benchmarks/driver/LoadClient.java
LoadClient.getStats
Stats.ClientStats getStats() { Histogram intervalHistogram = recorder.getIntervalHistogram(); Stats.ClientStats.Builder statsBuilder = Stats.ClientStats.newBuilder(); Stats.HistogramData.Builder latenciesBuilder = statsBuilder.getLatenciesBuilder(); double resolution = 1.0 + Math.max(config.getHistogra...
java
Stats.ClientStats getStats() { Histogram intervalHistogram = recorder.getIntervalHistogram(); Stats.ClientStats.Builder statsBuilder = Stats.ClientStats.newBuilder(); Stats.HistogramData.Builder latenciesBuilder = statsBuilder.getLatenciesBuilder(); double resolution = 1.0 + Math.max(config.getHistogra...
[ "Stats", ".", "ClientStats", "getStats", "(", ")", "{", "Histogram", "intervalHistogram", "=", "recorder", ".", "getIntervalHistogram", "(", ")", ";", "Stats", ".", "ClientStats", ".", "Builder", "statsBuilder", "=", "Stats", ".", "ClientStats", ".", "newBuilder...
Take a snapshot of the statistics which can be returned to the driver.
[ "Take", "a", "snapshot", "of", "the", "statistics", "which", "can", "be", "returned", "to", "the", "driver", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/benchmarks/src/main/java/io/grpc/benchmarks/driver/LoadClient.java#L229-L264
127,461
grpc/grpc-java
benchmarks/src/main/java/io/grpc/benchmarks/driver/LoadClient.java
LoadClient.delay
void delay(long alreadyElapsed) { recorder.recordValue(alreadyElapsed); if (distribution != null) { long nextPermitted = Math.round(distribution.sample() * 1000000000.0); if (nextPermitted > alreadyElapsed) { LockSupport.parkNanos(nextPermitted - alreadyElapsed); } } }
java
void delay(long alreadyElapsed) { recorder.recordValue(alreadyElapsed); if (distribution != null) { long nextPermitted = Math.round(distribution.sample() * 1000000000.0); if (nextPermitted > alreadyElapsed) { LockSupport.parkNanos(nextPermitted - alreadyElapsed); } } }
[ "void", "delay", "(", "long", "alreadyElapsed", ")", "{", "recorder", ".", "recordValue", "(", "alreadyElapsed", ")", ";", "if", "(", "distribution", "!=", "null", ")", "{", "long", "nextPermitted", "=", "Math", ".", "round", "(", "distribution", ".", "sam...
Record the event elapsed time to the histogram and delay initiation of the next event based on the load distribution.
[ "Record", "the", "event", "elapsed", "time", "to", "the", "histogram", "and", "delay", "initiation", "of", "the", "next", "event", "based", "on", "the", "load", "distribution", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/benchmarks/src/main/java/io/grpc/benchmarks/driver/LoadClient.java#L290-L298
127,462
grpc/grpc-java
examples/src/main/java/io/grpc/examples/routeguide/RouteGuideClient.java
RouteGuideClient.getFeature
public void getFeature(int lat, int lon) { info("*** GetFeature: lat={0} lon={1}", lat, lon); Point request = Point.newBuilder().setLatitude(lat).setLongitude(lon).build(); Feature feature; try { feature = blockingStub.getFeature(request); if (testHelper != null) { testHelper.onMes...
java
public void getFeature(int lat, int lon) { info("*** GetFeature: lat={0} lon={1}", lat, lon); Point request = Point.newBuilder().setLatitude(lat).setLongitude(lon).build(); Feature feature; try { feature = blockingStub.getFeature(request); if (testHelper != null) { testHelper.onMes...
[ "public", "void", "getFeature", "(", "int", "lat", ",", "int", "lon", ")", "{", "info", "(", "\"*** GetFeature: lat={0} lon={1}\"", ",", "lat", ",", "lon", ")", ";", "Point", "request", "=", "Point", ".", "newBuilder", "(", ")", ".", "setLatitude", "(", ...
Blocking unary call example. Calls getFeature and prints the response.
[ "Blocking", "unary", "call", "example", ".", "Calls", "getFeature", "and", "prints", "the", "response", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/examples/src/main/java/io/grpc/examples/routeguide/RouteGuideClient.java#L69-L97
127,463
grpc/grpc-java
examples/src/main/java/io/grpc/examples/routeguide/RouteGuideClient.java
RouteGuideClient.listFeatures
public void listFeatures(int lowLat, int lowLon, int hiLat, int hiLon) { info("*** ListFeatures: lowLat={0} lowLon={1} hiLat={2} hiLon={3}", lowLat, lowLon, hiLat, hiLon); Rectangle request = Rectangle.newBuilder() .setLo(Point.newBuilder().setLatitude(lowLat).setLongitude(lowLon).b...
java
public void listFeatures(int lowLat, int lowLon, int hiLat, int hiLon) { info("*** ListFeatures: lowLat={0} lowLon={1} hiLat={2} hiLon={3}", lowLat, lowLon, hiLat, hiLon); Rectangle request = Rectangle.newBuilder() .setLo(Point.newBuilder().setLatitude(lowLat).setLongitude(lowLon).b...
[ "public", "void", "listFeatures", "(", "int", "lowLat", ",", "int", "lowLon", ",", "int", "hiLat", ",", "int", "hiLon", ")", "{", "info", "(", "\"*** ListFeatures: lowLat={0} lowLon={1} hiLat={2} hiLon={3}\"", ",", "lowLat", ",", "lowLon", ",", "hiLat", ",", "hi...
Blocking server-streaming example. Calls listFeatures with a rectangle of interest. Prints each response feature as it arrives.
[ "Blocking", "server", "-", "streaming", "example", ".", "Calls", "listFeatures", "with", "a", "rectangle", "of", "interest", ".", "Prints", "each", "response", "feature", "as", "it", "arrives", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/examples/src/main/java/io/grpc/examples/routeguide/RouteGuideClient.java#L103-L127
127,464
grpc/grpc-java
examples/src/main/java/io/grpc/examples/routeguide/RouteGuideClient.java
RouteGuideClient.routeChat
public CountDownLatch routeChat() { info("*** RouteChat"); final CountDownLatch finishLatch = new CountDownLatch(1); StreamObserver<RouteNote> requestObserver = asyncStub.routeChat(new StreamObserver<RouteNote>() { @Override public void onNext(RouteNote note) { info("...
java
public CountDownLatch routeChat() { info("*** RouteChat"); final CountDownLatch finishLatch = new CountDownLatch(1); StreamObserver<RouteNote> requestObserver = asyncStub.routeChat(new StreamObserver<RouteNote>() { @Override public void onNext(RouteNote note) { info("...
[ "public", "CountDownLatch", "routeChat", "(", ")", "{", "info", "(", "\"*** RouteChat\"", ")", ";", "final", "CountDownLatch", "finishLatch", "=", "new", "CountDownLatch", "(", "1", ")", ";", "StreamObserver", "<", "RouteNote", ">", "requestObserver", "=", "asyn...
Bi-directional example, which can only be asynchronous. Send some chat messages, and print any chat messages that are sent from the server.
[ "Bi", "-", "directional", "example", "which", "can", "only", "be", "asynchronous", ".", "Send", "some", "chat", "messages", "and", "print", "any", "chat", "messages", "that", "are", "sent", "from", "the", "server", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/examples/src/main/java/io/grpc/examples/routeguide/RouteGuideClient.java#L199-L249
127,465
grpc/grpc-java
examples/src/main/java/io/grpc/examples/routeguide/RouteGuideClient.java
RouteGuideClient.main
public static void main(String[] args) throws InterruptedException { List<Feature> features; try { features = RouteGuideUtil.parseFeatures(RouteGuideUtil.getDefaultFeaturesFile()); } catch (IOException ex) { ex.printStackTrace(); return; } RouteGuideClient client = new RouteGuideC...
java
public static void main(String[] args) throws InterruptedException { List<Feature> features; try { features = RouteGuideUtil.parseFeatures(RouteGuideUtil.getDefaultFeaturesFile()); } catch (IOException ex) { ex.printStackTrace(); return; } RouteGuideClient client = new RouteGuideC...
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "InterruptedException", "{", "List", "<", "Feature", ">", "features", ";", "try", "{", "features", "=", "RouteGuideUtil", ".", "parseFeatures", "(", "RouteGuideUtil", ".", "g...
Issues several different requests and then exits.
[ "Issues", "several", "different", "requests", "and", "then", "exits", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/examples/src/main/java/io/grpc/examples/routeguide/RouteGuideClient.java#L252-L284
127,466
grpc/grpc-java
core/src/main/java/io/grpc/internal/ManagedChannelImpl.java
ManagedChannelImpl.handleServiceConfigUpdate
private void handleServiceConfigUpdate() { waitingForServiceConfig = false; serviceConfigInterceptor.handleUpdate(lastServiceConfig); if (retryEnabled) { throttle = ServiceConfigUtil.getThrottlePolicy(lastServiceConfig); } }
java
private void handleServiceConfigUpdate() { waitingForServiceConfig = false; serviceConfigInterceptor.handleUpdate(lastServiceConfig); if (retryEnabled) { throttle = ServiceConfigUtil.getThrottlePolicy(lastServiceConfig); } }
[ "private", "void", "handleServiceConfigUpdate", "(", ")", "{", "waitingForServiceConfig", "=", "false", ";", "serviceConfigInterceptor", ".", "handleUpdate", "(", "lastServiceConfig", ")", ";", "if", "(", "retryEnabled", ")", "{", "throttle", "=", "ServiceConfigUtil",...
May only be called in constructor or syncContext
[ "May", "only", "be", "called", "in", "constructor", "or", "syncContext" ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java#L649-L655
127,467
grpc/grpc-java
core/src/main/java/io/grpc/internal/ManagedChannelImpl.java
ManagedChannelImpl.shutdown
@Override public ManagedChannelImpl shutdown() { channelLogger.log(ChannelLogLevel.DEBUG, "shutdown() called"); if (!shutdown.compareAndSet(false, true)) { return this; } // Put gotoState(SHUTDOWN) as early into the syncContext's queue as possible. // delayedTransport.shutdown() may also ad...
java
@Override public ManagedChannelImpl shutdown() { channelLogger.log(ChannelLogLevel.DEBUG, "shutdown() called"); if (!shutdown.compareAndSet(false, true)) { return this; } // Put gotoState(SHUTDOWN) as early into the syncContext's queue as possible. // delayedTransport.shutdown() may also ad...
[ "@", "Override", "public", "ManagedChannelImpl", "shutdown", "(", ")", "{", "channelLogger", ".", "log", "(", "ChannelLogLevel", ".", "DEBUG", ",", "\"shutdown() called\"", ")", ";", "if", "(", "!", "shutdown", ".", "compareAndSet", "(", "false", ",", "true", ...
Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately cancelled.
[ "Initiates", "an", "orderly", "shutdown", "in", "which", "preexisting", "calls", "continue", "but", "new", "calls", "are", "immediately", "cancelled", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java#L706-L737
127,468
grpc/grpc-java
examples/src/main/java/io/grpc/examples/routeguide/RouteGuideUtil.java
RouteGuideUtil.parseFeatures
public static List<Feature> parseFeatures(URL file) throws IOException { InputStream input = file.openStream(); try { Reader reader = new InputStreamReader(input, Charset.forName("UTF-8")); try { FeatureDatabase.Builder database = FeatureDatabase.newBuilder(); JsonFormat.parser().mer...
java
public static List<Feature> parseFeatures(URL file) throws IOException { InputStream input = file.openStream(); try { Reader reader = new InputStreamReader(input, Charset.forName("UTF-8")); try { FeatureDatabase.Builder database = FeatureDatabase.newBuilder(); JsonFormat.parser().mer...
[ "public", "static", "List", "<", "Feature", ">", "parseFeatures", "(", "URL", "file", ")", "throws", "IOException", "{", "InputStream", "input", "=", "file", ".", "openStream", "(", ")", ";", "try", "{", "Reader", "reader", "=", "new", "InputStreamReader", ...
Parses the JSON input file containing the list of features.
[ "Parses", "the", "JSON", "input", "file", "containing", "the", "list", "of", "features", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/examples/src/main/java/io/grpc/examples/routeguide/RouteGuideUtil.java#L58-L72
127,469
grpc/grpc-java
core/src/main/java/io/grpc/internal/TransportTracer.java
TransportTracer.getStats
public TransportStats getStats() { long localFlowControlWindow = flowControlWindowReader == null ? -1 : flowControlWindowReader.read().localBytes; long remoteFlowControlWindow = flowControlWindowReader == null ? -1 : flowControlWindowReader.read().remoteBytes; return new TransportStats( ...
java
public TransportStats getStats() { long localFlowControlWindow = flowControlWindowReader == null ? -1 : flowControlWindowReader.read().localBytes; long remoteFlowControlWindow = flowControlWindowReader == null ? -1 : flowControlWindowReader.read().remoteBytes; return new TransportStats( ...
[ "public", "TransportStats", "getStats", "(", ")", "{", "long", "localFlowControlWindow", "=", "flowControlWindowReader", "==", "null", "?", "-", "1", ":", "flowControlWindowReader", ".", "read", "(", ")", ".", "localBytes", ";", "long", "remoteFlowControlWindow", ...
Returns a read only set of current stats.
[ "Returns", "a", "read", "only", "set", "of", "current", "stats", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/TransportTracer.java#L58-L76
127,470
grpc/grpc-java
examples/src/main/java/io/grpc/examples/header/CustomHeaderClient.java
CustomHeaderClient.main
public static void main(String[] args) throws Exception { CustomHeaderClient client = new CustomHeaderClient("localhost", 50051); try { /* Access a service running on the local machine on port 50051 */ String user = "world"; if (args.length > 0) { user = args[0]; /* Use the arg as the ...
java
public static void main(String[] args) throws Exception { CustomHeaderClient client = new CustomHeaderClient("localhost", 50051); try { /* Access a service running on the local machine on port 50051 */ String user = "world"; if (args.length > 0) { user = args[0]; /* Use the arg as the ...
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "Exception", "{", "CustomHeaderClient", "client", "=", "new", "CustomHeaderClient", "(", "\"localhost\"", ",", "50051", ")", ";", "try", "{", "/* Access a service running on the lo...
Main start the client from the command line.
[ "Main", "start", "the", "client", "from", "the", "command", "line", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/examples/src/main/java/io/grpc/examples/header/CustomHeaderClient.java#L77-L89
127,471
grpc/grpc-java
stub/src/main/java/io/grpc/stub/ServerCalls.java
ServerCalls.asyncUnimplementedUnaryCall
public static void asyncUnimplementedUnaryCall( MethodDescriptor<?, ?> methodDescriptor, StreamObserver<?> responseObserver) { checkNotNull(methodDescriptor, "methodDescriptor"); checkNotNull(responseObserver, "responseObserver"); responseObserver.onError(Status.UNIMPLEMENTED .withDescription(...
java
public static void asyncUnimplementedUnaryCall( MethodDescriptor<?, ?> methodDescriptor, StreamObserver<?> responseObserver) { checkNotNull(methodDescriptor, "methodDescriptor"); checkNotNull(responseObserver, "responseObserver"); responseObserver.onError(Status.UNIMPLEMENTED .withDescription(...
[ "public", "static", "void", "asyncUnimplementedUnaryCall", "(", "MethodDescriptor", "<", "?", ",", "?", ">", "methodDescriptor", ",", "StreamObserver", "<", "?", ">", "responseObserver", ")", "{", "checkNotNull", "(", "methodDescriptor", ",", "\"methodDescriptor\"", ...
Sets unimplemented status for method on given response stream for unary call. @param methodDescriptor of method for which error will be thrown. @param responseObserver on which error will be set.
[ "Sets", "unimplemented", "status", "for", "method", "on", "given", "response", "stream", "for", "unary", "call", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/stub/src/main/java/io/grpc/stub/ServerCalls.java#L408-L416
127,472
grpc/grpc-java
stub/src/main/java/io/grpc/stub/ServerCalls.java
ServerCalls.asyncUnimplementedStreamingCall
public static <T> StreamObserver<T> asyncUnimplementedStreamingCall( MethodDescriptor<?, ?> methodDescriptor, StreamObserver<?> responseObserver) { // NB: For streaming call we want to do the same as for unary call. Fail-fast by setting error // on responseObserver and then return no-op observer. asyn...
java
public static <T> StreamObserver<T> asyncUnimplementedStreamingCall( MethodDescriptor<?, ?> methodDescriptor, StreamObserver<?> responseObserver) { // NB: For streaming call we want to do the same as for unary call. Fail-fast by setting error // on responseObserver and then return no-op observer. asyn...
[ "public", "static", "<", "T", ">", "StreamObserver", "<", "T", ">", "asyncUnimplementedStreamingCall", "(", "MethodDescriptor", "<", "?", ",", "?", ">", "methodDescriptor", ",", "StreamObserver", "<", "?", ">", "responseObserver", ")", "{", "// NB: For streaming c...
Sets unimplemented status for streaming call. @param methodDescriptor of method for which error will be thrown. @param responseObserver on which error will be set.
[ "Sets", "unimplemented", "status", "for", "streaming", "call", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/stub/src/main/java/io/grpc/stub/ServerCalls.java#L424-L430
127,473
grpc/grpc-java
context/src/main/java/io/grpc/Deadline.java
Deadline.runOnExpiration
public ScheduledFuture<?> runOnExpiration(Runnable task, ScheduledExecutorService scheduler) { checkNotNull(task, "task"); checkNotNull(scheduler, "scheduler"); return scheduler.schedule(task, deadlineNanos - ticker.read(), TimeUnit.NANOSECONDS); }
java
public ScheduledFuture<?> runOnExpiration(Runnable task, ScheduledExecutorService scheduler) { checkNotNull(task, "task"); checkNotNull(scheduler, "scheduler"); return scheduler.schedule(task, deadlineNanos - ticker.read(), TimeUnit.NANOSECONDS); }
[ "public", "ScheduledFuture", "<", "?", ">", "runOnExpiration", "(", "Runnable", "task", ",", "ScheduledExecutorService", "scheduler", ")", "{", "checkNotNull", "(", "task", ",", "\"task\"", ")", ";", "checkNotNull", "(", "scheduler", ",", "\"scheduler\"", ")", "...
Schedule a task to be run when the deadline expires. @param task to run on expiration @param scheduler used to execute the task @return {@link ScheduledFuture} which can be used to cancel execution of the task
[ "Schedule", "a", "task", "to", "be", "run", "when", "the", "deadline", "expires", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/context/src/main/java/io/grpc/Deadline.java#L140-L144
127,474
grpc/grpc-java
alts/src/main/java/io/grpc/alts/internal/TsiHandshakeHandler.java
TsiHandshakeHandler.sendHandshake
private void sendHandshake(ChannelHandlerContext ctx) { boolean needToFlush = false; // Iterate until there is nothing left to write. while (true) { buffer = getOrCreateBuffer(ctx.alloc()); try { handshaker.getBytesToSendToPeer(buffer); } catch (GeneralSecurityException e) { ...
java
private void sendHandshake(ChannelHandlerContext ctx) { boolean needToFlush = false; // Iterate until there is nothing left to write. while (true) { buffer = getOrCreateBuffer(ctx.alloc()); try { handshaker.getBytesToSendToPeer(buffer); } catch (GeneralSecurityException e) { ...
[ "private", "void", "sendHandshake", "(", "ChannelHandlerContext", "ctx", ")", "{", "boolean", "needToFlush", "=", "false", ";", "// Iterate until there is nothing left to write.", "while", "(", "true", ")", "{", "buffer", "=", "getOrCreateBuffer", "(", "ctx", ".", "...
Sends as many bytes as are available from the handshaker to the remote peer.
[ "Sends", "as", "many", "bytes", "as", "are", "available", "from", "the", "handshaker", "to", "the", "remote", "peer", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/alts/src/main/java/io/grpc/alts/internal/TsiHandshakeHandler.java#L200-L225
127,475
grpc/grpc-java
core/src/main/java/io/grpc/internal/SharedResourceHolder.java
SharedResourceHolder.release
public static <T> T release(final Resource<T> resource, final T instance) { return holder.releaseInternal(resource, instance); }
java
public static <T> T release(final Resource<T> resource, final T instance) { return holder.releaseInternal(resource, instance); }
[ "public", "static", "<", "T", ">", "T", "release", "(", "final", "Resource", "<", "T", ">", "resource", ",", "final", "T", "instance", ")", "{", "return", "holder", ".", "releaseInternal", "(", "resource", ",", "instance", ")", ";", "}" ]
Releases an instance of the given resource. <p>The instance must have been obtained from {@link #get(Resource)}. Otherwise will throw IllegalArgumentException. <p>Caller must not release a reference more than once. It's advisory that you clear the reference to the instance with the null returned by this method. @par...
[ "Releases", "an", "instance", "of", "the", "given", "resource", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/SharedResourceHolder.java#L91-L93
127,476
grpc/grpc-java
okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelBuilder.java
OkHttpChannelBuilder.enableKeepAlive
@Deprecated public final OkHttpChannelBuilder enableKeepAlive(boolean enable) { if (enable) { return keepAliveTime(DEFAULT_KEEPALIVE_TIME_NANOS, TimeUnit.NANOSECONDS); } else { return keepAliveTime(KEEPALIVE_TIME_NANOS_DISABLED, TimeUnit.NANOSECONDS); } }
java
@Deprecated public final OkHttpChannelBuilder enableKeepAlive(boolean enable) { if (enable) { return keepAliveTime(DEFAULT_KEEPALIVE_TIME_NANOS, TimeUnit.NANOSECONDS); } else { return keepAliveTime(KEEPALIVE_TIME_NANOS_DISABLED, TimeUnit.NANOSECONDS); } }
[ "@", "Deprecated", "public", "final", "OkHttpChannelBuilder", "enableKeepAlive", "(", "boolean", "enable", ")", "{", "if", "(", "enable", ")", "{", "return", "keepAliveTime", "(", "DEFAULT_KEEPALIVE_TIME_NANOS", ",", "TimeUnit", ".", "NANOSECONDS", ")", ";", "}", ...
Enable keepalive with default delay and timeout. @deprecated Use {@link #keepAliveTime} instead
[ "Enable", "keepalive", "with", "default", "delay", "and", "timeout", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelBuilder.java#L206-L213
127,477
grpc/grpc-java
okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelBuilder.java
OkHttpChannelBuilder.connectionSpec
public final OkHttpChannelBuilder connectionSpec( com.squareup.okhttp.ConnectionSpec connectionSpec) { Preconditions.checkArgument(connectionSpec.isTls(), "plaintext ConnectionSpec is not accepted"); this.connectionSpec = Utils.convertSpec(connectionSpec); return this; }
java
public final OkHttpChannelBuilder connectionSpec( com.squareup.okhttp.ConnectionSpec connectionSpec) { Preconditions.checkArgument(connectionSpec.isTls(), "plaintext ConnectionSpec is not accepted"); this.connectionSpec = Utils.convertSpec(connectionSpec); return this; }
[ "public", "final", "OkHttpChannelBuilder", "connectionSpec", "(", "com", ".", "squareup", ".", "okhttp", ".", "ConnectionSpec", "connectionSpec", ")", "{", "Preconditions", ".", "checkArgument", "(", "connectionSpec", ".", "isTls", "(", ")", ",", "\"plaintext Connec...
For secure connection, provides a ConnectionSpec to specify Cipher suite and TLS versions. <p>By default a modern, HTTP/2-compatible spec will be used. <p>This method is only used when building a secure connection. For plaintext connection, use {@link #usePlaintext()} instead. @throws IllegalArgumentException If {@c...
[ "For", "secure", "connection", "provides", "a", "ConnectionSpec", "to", "specify", "Cipher", "suite", "and", "TLS", "versions", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelBuilder.java#L329-L334
127,478
grpc/grpc-java
okhttp/src/main/java/io/grpc/okhttp/OutboundFlowController.java
OutboundFlowController.data
void data(boolean outFinished, int streamId, Buffer source, boolean flush) { Preconditions.checkNotNull(source, "source"); OkHttpClientStream stream = transport.getStream(streamId); if (stream == null) { // This is possible for a stream that has received end-of-stream from server (but hasn't sent ...
java
void data(boolean outFinished, int streamId, Buffer source, boolean flush) { Preconditions.checkNotNull(source, "source"); OkHttpClientStream stream = transport.getStream(streamId); if (stream == null) { // This is possible for a stream that has received end-of-stream from server (but hasn't sent ...
[ "void", "data", "(", "boolean", "outFinished", ",", "int", "streamId", ",", "Buffer", "source", ",", "boolean", "flush", ")", "{", "Preconditions", ".", "checkNotNull", "(", "source", ",", "\"source\"", ")", ";", "OkHttpClientStream", "stream", "=", "transport...
Must be called with holding transport lock.
[ "Must", "be", "called", "with", "holding", "transport", "lock", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/okhttp/src/main/java/io/grpc/okhttp/OutboundFlowController.java#L107-L138
127,479
grpc/grpc-java
okhttp/src/main/java/io/grpc/okhttp/OutboundFlowController.java
OutboundFlowController.writeStreams
void writeStreams() { OkHttpClientStream[] streams = transport.getActiveStreams(); int connectionWindow = connectionState.window(); for (int numStreams = streams.length; numStreams > 0 && connectionWindow > 0;) { int nextNumStreams = 0; int windowSlice = (int) ceil(connectionWindow / (float) num...
java
void writeStreams() { OkHttpClientStream[] streams = transport.getActiveStreams(); int connectionWindow = connectionState.window(); for (int numStreams = streams.length; numStreams > 0 && connectionWindow > 0;) { int nextNumStreams = 0; int windowSlice = (int) ceil(connectionWindow / (float) num...
[ "void", "writeStreams", "(", ")", "{", "OkHttpClientStream", "[", "]", "streams", "=", "transport", ".", "getActiveStreams", "(", ")", ";", "int", "connectionWindow", "=", "connectionState", ".", "window", "(", ")", ";", "for", "(", "int", "numStreams", "=",...
Writes as much data for all the streams as possible given the current flow control windows. <p>Must be called with holding transport lock.
[ "Writes", "as", "much", "data", "for", "all", "the", "streams", "as", "possible", "given", "the", "current", "flow", "control", "windows", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/okhttp/src/main/java/io/grpc/okhttp/OutboundFlowController.java#L162-L198
127,480
grpc/grpc-java
core/src/main/java/io/grpc/internal/CensusTracingModule.java
CensusTracingModule.generateTraceSpanName
@VisibleForTesting static String generateTraceSpanName(boolean isServer, String fullMethodName) { String prefix = isServer ? "Recv" : "Sent"; return prefix + "." + fullMethodName.replace('/', '.'); }
java
@VisibleForTesting static String generateTraceSpanName(boolean isServer, String fullMethodName) { String prefix = isServer ? "Recv" : "Sent"; return prefix + "." + fullMethodName.replace('/', '.'); }
[ "@", "VisibleForTesting", "static", "String", "generateTraceSpanName", "(", "boolean", "isServer", ",", "String", "fullMethodName", ")", "{", "String", "prefix", "=", "isServer", "?", "\"Recv\"", ":", "\"Sent\"", ";", "return", "prefix", "+", "\".\"", "+", "full...
Convert a full method name to a tracing span name. @param isServer {@code false} if the span is on the client-side, {@code true} if on the server-side @param fullMethodName the method name as returned by {@link MethodDescriptor#getFullMethodName}.
[ "Convert", "a", "full", "method", "name", "to", "a", "tracing", "span", "name", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/CensusTracingModule.java#L415-L419
127,481
grpc/grpc-java
core/src/main/java/io/grpc/internal/CompositeReadableBuffer.java
CompositeReadableBuffer.advanceBufferIfNecessary
private void advanceBufferIfNecessary() { ReadableBuffer buffer = buffers.peek(); if (buffer.readableBytes() == 0) { buffers.remove().close(); } }
java
private void advanceBufferIfNecessary() { ReadableBuffer buffer = buffers.peek(); if (buffer.readableBytes() == 0) { buffers.remove().close(); } }
[ "private", "void", "advanceBufferIfNecessary", "(", ")", "{", "ReadableBuffer", "buffer", "=", "buffers", ".", "peek", "(", ")", ";", "if", "(", "buffer", ".", "readableBytes", "(", ")", "==", "0", ")", "{", "buffers", ".", "remove", "(", ")", ".", "cl...
If the current buffer is exhausted, removes and closes it.
[ "If", "the", "current", "buffer", "is", "exhausted", "removes", "and", "closes", "it", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/CompositeReadableBuffer.java#L196-L201
127,482
grpc/grpc-java
core/src/main/java/io/grpc/internal/ServerImpl.java
ServerImpl.start
@Override public ServerImpl start() throws IOException { synchronized (lock) { checkState(!started, "Already started"); checkState(!shutdown, "Shutting down"); // Start and wait for any ports to actually be bound. ServerListenerImpl listener = new ServerListenerImpl(); for (Internal...
java
@Override public ServerImpl start() throws IOException { synchronized (lock) { checkState(!started, "Already started"); checkState(!shutdown, "Shutting down"); // Start and wait for any ports to actually be bound. ServerListenerImpl listener = new ServerListenerImpl(); for (Internal...
[ "@", "Override", "public", "ServerImpl", "start", "(", ")", "throws", "IOException", "{", "synchronized", "(", "lock", ")", "{", "checkState", "(", "!", "started", ",", "\"Already started\"", ")", ";", "checkState", "(", "!", "shutdown", ",", "\"Shutting down\...
Bind and start the server. @return {@code this} object @throws IllegalStateException if already started @throws IOException if unable to bind
[ "Bind", "and", "start", "the", "server", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/ServerImpl.java#L168-L184
127,483
grpc/grpc-java
core/src/main/java/io/grpc/internal/ServerImpl.java
ServerImpl.shutdown
@Override public ServerImpl shutdown() { boolean shutdownTransportServers; synchronized (lock) { if (shutdown) { return this; } shutdown = true; shutdownTransportServers = started; if (!shutdownTransportServers) { transportServersTerminated = true; checkFo...
java
@Override public ServerImpl shutdown() { boolean shutdownTransportServers; synchronized (lock) { if (shutdown) { return this; } shutdown = true; shutdownTransportServers = started; if (!shutdownTransportServers) { transportServersTerminated = true; checkFo...
[ "@", "Override", "public", "ServerImpl", "shutdown", "(", ")", "{", "boolean", "shutdownTransportServers", ";", "synchronized", "(", "lock", ")", "{", "if", "(", "shutdown", ")", "{", "return", "this", ";", "}", "shutdown", "=", "true", ";", "shutdownTranspo...
Initiates an orderly shutdown in which preexisting calls continue but new calls are rejected.
[ "Initiates", "an", "orderly", "shutdown", "in", "which", "preexisting", "calls", "continue", "but", "new", "calls", "are", "rejected", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/ServerImpl.java#L250-L270
127,484
grpc/grpc-java
core/src/main/java/io/grpc/internal/ServerImpl.java
ServerImpl.transportClosed
private void transportClosed(ServerTransport transport) { synchronized (lock) { if (!transports.remove(transport)) { throw new AssertionError("Transport already removed"); } channelz.removeServerSocket(ServerImpl.this, transport); checkForTermination(); } }
java
private void transportClosed(ServerTransport transport) { synchronized (lock) { if (!transports.remove(transport)) { throw new AssertionError("Transport already removed"); } channelz.removeServerSocket(ServerImpl.this, transport); checkForTermination(); } }
[ "private", "void", "transportClosed", "(", "ServerTransport", "transport", ")", "{", "synchronized", "(", "lock", ")", "{", "if", "(", "!", "transports", ".", "remove", "(", "transport", ")", ")", "{", "throw", "new", "AssertionError", "(", "\"Transport alread...
Remove transport service from accounting collection and notify of complete shutdown if necessary. @param transport service to remove
[ "Remove", "transport", "service", "from", "accounting", "collection", "and", "notify", "of", "complete", "shutdown", "if", "necessary", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/ServerImpl.java#L341-L349
127,485
grpc/grpc-java
core/src/main/java/io/grpc/internal/ServerImpl.java
ServerImpl.checkForTermination
private void checkForTermination() { synchronized (lock) { if (shutdown && transports.isEmpty() && transportServersTerminated) { if (terminated) { throw new AssertionError("Server already terminated"); } terminated = true; channelz.removeServer(this); if (exec...
java
private void checkForTermination() { synchronized (lock) { if (shutdown && transports.isEmpty() && transportServersTerminated) { if (terminated) { throw new AssertionError("Server already terminated"); } terminated = true; channelz.removeServer(this); if (exec...
[ "private", "void", "checkForTermination", "(", ")", "{", "synchronized", "(", "lock", ")", "{", "if", "(", "shutdown", "&&", "transports", ".", "isEmpty", "(", ")", "&&", "transportServersTerminated", ")", "{", "if", "(", "terminated", ")", "{", "throw", "...
Notify of complete shutdown if necessary.
[ "Notify", "of", "complete", "shutdown", "if", "necessary", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/ServerImpl.java#L352-L366
127,486
grpc/grpc-java
netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java
ProtocolNegotiators.serverPlaintext
public static ProtocolNegotiator serverPlaintext() { return new ProtocolNegotiator() { @Override public ChannelHandler newHandler(final GrpcHttp2ConnectionHandler handler) { class PlaintextHandler extends ChannelHandlerAdapter { @Override public void handlerAdded(ChannelHandl...
java
public static ProtocolNegotiator serverPlaintext() { return new ProtocolNegotiator() { @Override public ChannelHandler newHandler(final GrpcHttp2ConnectionHandler handler) { class PlaintextHandler extends ChannelHandlerAdapter { @Override public void handlerAdded(ChannelHandl...
[ "public", "static", "ProtocolNegotiator", "serverPlaintext", "(", ")", "{", "return", "new", "ProtocolNegotiator", "(", ")", "{", "@", "Override", "public", "ChannelHandler", "newHandler", "(", "final", "GrpcHttp2ConnectionHandler", "handler", ")", "{", "class", "Pl...
Create a server plaintext handler for gRPC.
[ "Create", "a", "server", "plaintext", "handler", "for", "gRPC", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java#L84-L113
127,487
grpc/grpc-java
netty/src/main/java/io/grpc/netty/WriteQueue.java
WriteQueue.enqueue
void enqueue(Runnable runnable, boolean flush) { queue.add(new RunnableCommand(runnable)); if (flush) { scheduleFlush(); } }
java
void enqueue(Runnable runnable, boolean flush) { queue.add(new RunnableCommand(runnable)); if (flush) { scheduleFlush(); } }
[ "void", "enqueue", "(", "Runnable", "runnable", ",", "boolean", "flush", ")", "{", "queue", ".", "add", "(", "new", "RunnableCommand", "(", "runnable", ")", ")", ";", "if", "(", "flush", ")", "{", "scheduleFlush", "(", ")", ";", "}", "}" ]
Enqueue the runnable. It is not safe for another thread to queue an Runnable directly to the event loop, because it will be out-of-order with writes. This method allows the Runnable to be processed in-order with writes.
[ "Enqueue", "the", "runnable", ".", "It", "is", "not", "safe", "for", "another", "thread", "to", "queue", "an", "Runnable", "directly", "to", "the", "event", "loop", "because", "it", "will", "be", "out", "-", "of", "-", "order", "with", "writes", ".", "...
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/netty/src/main/java/io/grpc/netty/WriteQueue.java#L95-L100
127,488
grpc/grpc-java
netty/src/main/java/io/grpc/netty/WriteQueue.java
WriteQueue.flush
private void flush() { try { QueuedCommand cmd; int i = 0; boolean flushedOnce = false; while ((cmd = queue.poll()) != null) { cmd.run(channel); if (++i == DEQUE_CHUNK_SIZE) { i = 0; // Flush each chunk so we are releasing buffers periodically. In theory t...
java
private void flush() { try { QueuedCommand cmd; int i = 0; boolean flushedOnce = false; while ((cmd = queue.poll()) != null) { cmd.run(channel); if (++i == DEQUE_CHUNK_SIZE) { i = 0; // Flush each chunk so we are releasing buffers periodically. In theory t...
[ "private", "void", "flush", "(", ")", "{", "try", "{", "QueuedCommand", "cmd", ";", "int", "i", "=", "0", ";", "boolean", "flushedOnce", "=", "false", ";", "while", "(", "(", "cmd", "=", "queue", ".", "poll", "(", ")", ")", "!=", "null", ")", "{"...
Process the queue of commands and dispatch them to the stream. This method is only called in the event loop
[ "Process", "the", "queue", "of", "commands", "and", "dispatch", "them", "to", "the", "stream", ".", "This", "method", "is", "only", "called", "in", "the", "event", "loop" ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/netty/src/main/java/io/grpc/netty/WriteQueue.java#L106-L133
127,489
grpc/grpc-java
context/src/jmh/java/io/grpc/WriteBenchmark.java
WriteBenchmark.doWrite
@Benchmark @BenchmarkMode(Mode.SampleTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public Context doWrite(ContextState state, Blackhole bh) { return state.context.withValues( state.key1, state.val, state.key2, state.val, state.key3, state.val, state.key4, state.val); }
java
@Benchmark @BenchmarkMode(Mode.SampleTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public Context doWrite(ContextState state, Blackhole bh) { return state.context.withValues( state.key1, state.val, state.key2, state.val, state.key3, state.val, state.key4, state.val); }
[ "@", "Benchmark", "@", "BenchmarkMode", "(", "Mode", ".", "SampleTime", ")", "@", "OutputTimeUnit", "(", "TimeUnit", ".", "NANOSECONDS", ")", "public", "Context", "doWrite", "(", "ContextState", "state", ",", "Blackhole", "bh", ")", "{", "return", "state", "...
Perform the write operation.
[ "Perform", "the", "write", "operation", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/context/src/jmh/java/io/grpc/WriteBenchmark.java#L54-L63
127,490
grpc/grpc-java
benchmarks/src/jmh/java/io/grpc/benchmarks/netty/StreamingPingPongsPerSecondBenchmark.java
StreamingPingPongsPerSecondBenchmark.pingPong
@Benchmark public void pingPong(AdditionalCounters counters) throws Exception { record.set(true); // No need to do anything, just sleep here. Thread.sleep(1001); record.set(false); }
java
@Benchmark public void pingPong(AdditionalCounters counters) throws Exception { record.set(true); // No need to do anything, just sleep here. Thread.sleep(1001); record.set(false); }
[ "@", "Benchmark", "public", "void", "pingPong", "(", "AdditionalCounters", "counters", ")", "throws", "Exception", "{", "record", ".", "set", "(", "true", ")", ";", "// No need to do anything, just sleep here.", "Thread", ".", "sleep", "(", "1001", ")", ";", "re...
Measure throughput of unary calls. The calls are already running, we just observe a counter of received responses.
[ "Measure", "throughput", "of", "unary", "calls", ".", "The", "calls", "are", "already", "running", "we", "just", "observe", "a", "counter", "of", "received", "responses", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/benchmarks/src/jmh/java/io/grpc/benchmarks/netty/StreamingPingPongsPerSecondBenchmark.java#L109-L115
127,491
grpc/grpc-java
core/src/main/java/io/grpc/internal/DelayedClientTransport.java
DelayedClientTransport.shutdownNow
@Override public final void shutdownNow(Status status) { shutdown(status); Collection<PendingStream> savedPendingStreams; Runnable savedReportTransportTerminated; synchronized (lock) { savedPendingStreams = pendingStreams; savedReportTransportTerminated = reportTransportTerminated; r...
java
@Override public final void shutdownNow(Status status) { shutdown(status); Collection<PendingStream> savedPendingStreams; Runnable savedReportTransportTerminated; synchronized (lock) { savedPendingStreams = pendingStreams; savedReportTransportTerminated = reportTransportTerminated; r...
[ "@", "Override", "public", "final", "void", "shutdownNow", "(", "Status", "status", ")", "{", "shutdown", "(", "status", ")", ";", "Collection", "<", "PendingStream", ">", "savedPendingStreams", ";", "Runnable", "savedReportTransportTerminated", ";", "synchronized",...
Shuts down this transport and cancels all streams that it owns, hence immediately terminates this transport.
[ "Shuts", "down", "this", "transport", "and", "cancels", "all", "streams", "that", "it", "owns", "hence", "immediately", "terminates", "this", "transport", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/DelayedClientTransport.java#L233-L254
127,492
grpc/grpc-java
netty/src/main/java/io/grpc/netty/WriteBufferingAndExceptionHandler.java
WriteBufferingAndExceptionHandler.channelInactive
@Override public void channelInactive(ChannelHandlerContext ctx) { Status status = Status.UNAVAILABLE.withDescription( "Connection closed while performing protocol negotiation for " + ctx.pipeline().names()); failWrites(status.asRuntimeException()); }
java
@Override public void channelInactive(ChannelHandlerContext ctx) { Status status = Status.UNAVAILABLE.withDescription( "Connection closed while performing protocol negotiation for " + ctx.pipeline().names()); failWrites(status.asRuntimeException()); }
[ "@", "Override", "public", "void", "channelInactive", "(", "ChannelHandlerContext", "ctx", ")", "{", "Status", "status", "=", "Status", ".", "UNAVAILABLE", ".", "withDescription", "(", "\"Connection closed while performing protocol negotiation for \"", "+", "ctx", ".", ...
If this channel becomes inactive, then notify all buffered writes that we failed.
[ "If", "this", "channel", "becomes", "inactive", "then", "notify", "all", "buffered", "writes", "that", "we", "failed", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/netty/src/main/java/io/grpc/netty/WriteBufferingAndExceptionHandler.java#L73-L78
127,493
grpc/grpc-java
netty/src/main/java/io/grpc/netty/WriteBufferingAndExceptionHandler.java
WriteBufferingAndExceptionHandler.close
@Override public void close(ChannelHandlerContext ctx, ChannelPromise future) throws Exception { Status status = Status.UNAVAILABLE.withDescription( "Connection closing while performing protocol negotiation for " + ctx.pipeline().names()); failWrites(status.asRuntimeException()); super.close(ctx, ...
java
@Override public void close(ChannelHandlerContext ctx, ChannelPromise future) throws Exception { Status status = Status.UNAVAILABLE.withDescription( "Connection closing while performing protocol negotiation for " + ctx.pipeline().names()); failWrites(status.asRuntimeException()); super.close(ctx, ...
[ "@", "Override", "public", "void", "close", "(", "ChannelHandlerContext", "ctx", ",", "ChannelPromise", "future", ")", "throws", "Exception", "{", "Status", "status", "=", "Status", ".", "UNAVAILABLE", ".", "withDescription", "(", "\"Connection closing while performin...
If we are still performing protocol negotiation, then this will propagate failures to all buffered writes.
[ "If", "we", "are", "still", "performing", "protocol", "negotiation", "then", "this", "will", "propagate", "failures", "to", "all", "buffered", "writes", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/netty/src/main/java/io/grpc/netty/WriteBufferingAndExceptionHandler.java#L160-L166
127,494
grpc/grpc-java
netty/src/main/java/io/grpc/netty/WriteBufferingAndExceptionHandler.java
WriteBufferingAndExceptionHandler.failWrites
@SuppressWarnings("FutureReturnValueIgnored") private void failWrites(Throwable cause) { if (failCause == null) { failCause = cause; } else { logger.log(Level.FINE, "Ignoring duplicate failure", cause); } while (!bufferedWrites.isEmpty()) { ChannelWrite write = bufferedWrites.poll();...
java
@SuppressWarnings("FutureReturnValueIgnored") private void failWrites(Throwable cause) { if (failCause == null) { failCause = cause; } else { logger.log(Level.FINE, "Ignoring duplicate failure", cause); } while (!bufferedWrites.isEmpty()) { ChannelWrite write = bufferedWrites.poll();...
[ "@", "SuppressWarnings", "(", "\"FutureReturnValueIgnored\"", ")", "private", "void", "failWrites", "(", "Throwable", "cause", ")", "{", "if", "(", "failCause", "==", "null", ")", "{", "failCause", "=", "cause", ";", "}", "else", "{", "logger", ".", "log", ...
Propagate failures to all buffered writes.
[ "Propagate", "failures", "to", "all", "buffered", "writes", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/netty/src/main/java/io/grpc/netty/WriteBufferingAndExceptionHandler.java#L193-L205
127,495
grpc/grpc-java
services/src/main/java/io/grpc/protobuf/services/ProtoReflectionService.java
ProtoReflectionService.updateIndexIfNecessary
private ServerReflectionIndex updateIndexIfNecessary() { synchronized (lock) { if (serverReflectionIndex == null) { serverReflectionIndex = new ServerReflectionIndex(server.getImmutableServices(), server.getMutableServices()); return serverReflectionIndex; } Set<FileDe...
java
private ServerReflectionIndex updateIndexIfNecessary() { synchronized (lock) { if (serverReflectionIndex == null) { serverReflectionIndex = new ServerReflectionIndex(server.getImmutableServices(), server.getMutableServices()); return serverReflectionIndex; } Set<FileDe...
[ "private", "ServerReflectionIndex", "updateIndexIfNecessary", "(", ")", "{", "synchronized", "(", "lock", ")", "{", "if", "(", "serverReflectionIndex", "==", "null", ")", "{", "serverReflectionIndex", "=", "new", "ServerReflectionIndex", "(", "server", ".", "getImmu...
Checks for updates to the server's mutable services and updates the index if any changes are detected. A change is any addition or removal in the set of file descriptors attached to the mutable services or a change in the service names. @return The (potentially updated) index.
[ "Checks", "for", "updates", "to", "the", "server", "s", "mutable", "services", "and", "updates", "the", "index", "if", "any", "changes", "are", "detected", ".", "A", "change", "is", "any", "addition", "or", "removal", "in", "the", "set", "of", "file", "d...
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/services/src/main/java/io/grpc/protobuf/services/ProtoReflectionService.java#L93-L128
127,496
grpc/grpc-java
context/src/main/java/io/grpc/Context.java
Context.addListener
public void addListener(final CancellationListener cancellationListener, final Executor executor) { checkNotNull(cancellationListener, "cancellationListener"); checkNotNull(executor, "executor"); if (canBeCancelled()) { ExecutableListener executableListener = new Ex...
java
public void addListener(final CancellationListener cancellationListener, final Executor executor) { checkNotNull(cancellationListener, "cancellationListener"); checkNotNull(executor, "executor"); if (canBeCancelled()) { ExecutableListener executableListener = new Ex...
[ "public", "void", "addListener", "(", "final", "CancellationListener", "cancellationListener", ",", "final", "Executor", "executor", ")", "{", "checkNotNull", "(", "cancellationListener", ",", "\"cancellationListener\"", ")", ";", "checkNotNull", "(", "executor", ",", ...
Add a listener that will be notified when the context becomes cancelled.
[ "Add", "a", "listener", "that", "will", "be", "notified", "when", "the", "context", "becomes", "cancelled", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/context/src/main/java/io/grpc/Context.java#L460-L485
127,497
grpc/grpc-java
context/src/main/java/io/grpc/Context.java
Context.notifyAndClearListeners
void notifyAndClearListeners() { if (!canBeCancelled()) { return; } ArrayList<ExecutableListener> tmpListeners; synchronized (this) { if (listeners == null) { return; } tmpListeners = listeners; listeners = null; } // Deliver events to non-child context list...
java
void notifyAndClearListeners() { if (!canBeCancelled()) { return; } ArrayList<ExecutableListener> tmpListeners; synchronized (this) { if (listeners == null) { return; } tmpListeners = listeners; listeners = null; } // Deliver events to non-child context list...
[ "void", "notifyAndClearListeners", "(", ")", "{", "if", "(", "!", "canBeCancelled", "(", ")", ")", "{", "return", ";", "}", "ArrayList", "<", "ExecutableListener", ">", "tmpListeners", ";", "synchronized", "(", "this", ")", "{", "if", "(", "listeners", "==...
Notify all listeners that this context has been cancelled and immediately release any reference to them so that they may be garbage collected.
[ "Notify", "all", "listeners", "that", "this", "context", "has", "been", "cancelled", "and", "immediately", "release", "any", "reference", "to", "them", "so", "that", "they", "may", "be", "garbage", "collected", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/context/src/main/java/io/grpc/Context.java#L519-L548
127,498
grpc/grpc-java
context/src/main/java/io/grpc/Context.java
Context.validateGeneration
private static void validateGeneration(int generation) { if (generation == CONTEXT_DEPTH_WARN_THRESH) { log.log( Level.SEVERE, "Context ancestry chain length is abnormally long. " + "This suggests an error in application code. " + "Length exceeded: " + CONTEXT_D...
java
private static void validateGeneration(int generation) { if (generation == CONTEXT_DEPTH_WARN_THRESH) { log.log( Level.SEVERE, "Context ancestry chain length is abnormally long. " + "This suggests an error in application code. " + "Length exceeded: " + CONTEXT_D...
[ "private", "static", "void", "validateGeneration", "(", "int", "generation", ")", "{", "if", "(", "generation", "==", "CONTEXT_DEPTH_WARN_THRESH", ")", "{", "log", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"Context ancestry chain length is abnormally long. \"", ...
If the ancestry chain length is unreasonably long, then print an error to the log and record the stack trace.
[ "If", "the", "ancestry", "chain", "length", "is", "unreasonably", "long", "then", "print", "an", "error", "to", "the", "log", "and", "record", "the", "stack", "trace", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/context/src/main/java/io/grpc/Context.java#L1057-L1066
127,499
grpc/grpc-java
okhttp/src/main/java/io/grpc/okhttp/OkHttpTlsUpgrader.java
OkHttpTlsUpgrader.upgrade
public static SSLSocket upgrade(SSLSocketFactory sslSocketFactory, HostnameVerifier hostnameVerifier, Socket socket, String host, int port, ConnectionSpec spec) throws IOException { Preconditions.checkNotNull(sslSocketFactory, "sslSocketFactory"); Preconditions.checkNotNull(socket, "socket"); Pr...
java
public static SSLSocket upgrade(SSLSocketFactory sslSocketFactory, HostnameVerifier hostnameVerifier, Socket socket, String host, int port, ConnectionSpec spec) throws IOException { Preconditions.checkNotNull(sslSocketFactory, "sslSocketFactory"); Preconditions.checkNotNull(socket, "socket"); Pr...
[ "public", "static", "SSLSocket", "upgrade", "(", "SSLSocketFactory", "sslSocketFactory", ",", "HostnameVerifier", "hostnameVerifier", ",", "Socket", "socket", ",", "String", "host", ",", "int", "port", ",", "ConnectionSpec", "spec", ")", "throws", "IOException", "{"...
Upgrades given Socket to be a SSLSocket. @throws IOException if an IO error was encountered during the upgrade handshake. @throws RuntimeException if the upgrade negotiation failed.
[ "Upgrades", "given", "Socket", "to", "be", "a", "SSLSocket", "." ]
973885457f9609de232d2553b82c67f6c3ff57bf
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/okhttp/src/main/java/io/grpc/okhttp/OkHttpTlsUpgrader.java#L54-L77