Skip to content

Commit

Permalink
remote/http: support refresh of oauth2 tokens in the remote cache.
Browse files Browse the repository at this point in the history
Closes #4622.

PiperOrigin-RevId: 188595430
  • Loading branch information
buchgr authored and Copybara-Service committed Mar 10, 2018
1 parent 7e50ced commit deccc48
Show file tree
Hide file tree
Showing 11 changed files with 570 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ public Digest uploadBlob(byte[] blob) throws IOException, InterruptedException {
}

private Digest uploadBlob(byte[] blob, Digest digest) throws IOException, InterruptedException {
return uploadStream(digest, new ByteArrayInputStream(blob));
try (InputStream in = new ByteArrayInputStream(blob)) {
return uploadStream(digest, in);
}
}

public Digest uploadStream(Digest digest, InputStream in)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,27 @@ public interface SimpleBlobStore {
/**
* Fetches the BLOB associated with the {@code key} from the CAS and writes it to {@code out}.
*
* <p>The caller is responsible to close {@code out}.
*
* @return {@code true} if the {@code key} was found. {@code false} otherwise.
*/
boolean get(String key, OutputStream out) throws IOException, InterruptedException;

/**
* Fetches the BLOB associated with the {@code key} from the Action Cache and writes it to
* {@code out}.
* Fetches the BLOB associated with the {@code key} from the Action Cache and writes it to {@code
* out}.
*
* <p>The caller is responsible to close {@code out}.
*
* @return {@code true} if the {@code key} was found. {@code false} otherwise.
*/
boolean getActionResult(String actionKey, OutputStream out) throws IOException,
InterruptedException;
boolean getActionResult(String actionKey, OutputStream out)
throws IOException, InterruptedException;

/**
* Uploads a BLOB (as {@code in}) with length {@code length} indexed by {@code key} to the CAS.
*
* <p>The caller is responsible to close {@code in}.
*/
void put(String key, long length, InputStream in) throws IOException, InterruptedException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.io.IOException;
import java.net.SocketAddress;
import java.net.URI;
import java.nio.channels.ClosedChannelException;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -93,56 +94,61 @@ protected String constructHost(URI uri) {
}

@Override
public void exceptionCaught(ChannelHandlerContext channelHandlerContext, Throwable throwable)
throws Exception {
public void exceptionCaught(ChannelHandlerContext channelHandlerContext, Throwable throwable) {
failAndResetUserPromise(throwable);
}

@SuppressWarnings("FutureReturnValueIgnored")
@Override
public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise)
throws Exception {
public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) {
ctx.bind(localAddress, promise);
}

@SuppressWarnings("FutureReturnValueIgnored")
@SuppressWarnings("FutureReturnValueIgnored")
@Override
public void connect(
ChannelHandlerContext ctx,
SocketAddress remoteAddress,
SocketAddress localAddress,
ChannelPromise promise)
throws Exception {
ChannelPromise promise) {
ctx.connect(remoteAddress, localAddress, promise);
}

@SuppressWarnings("FutureReturnValueIgnored")
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) {
failAndResetUserPromise(new ClosedChannelException());
ctx.disconnect(promise);
}

@SuppressWarnings("FutureReturnValueIgnored")
@Override
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
public void close(ChannelHandlerContext ctx, ChannelPromise promise) {
failAndResetUserPromise(new ClosedChannelException());
ctx.close(promise);
}

@SuppressWarnings("FutureReturnValueIgnored")
@Override
public void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
public void deregister(ChannelHandlerContext ctx, ChannelPromise promise) {
ctx.deregister(promise);
}

@SuppressWarnings("FutureReturnValueIgnored")
@Override
public void read(ChannelHandlerContext ctx) throws Exception {
public void read(ChannelHandlerContext ctx) {
ctx.read();
}

@SuppressWarnings("FutureReturnValueIgnored")
@SuppressWarnings("FutureReturnValueIgnored")
@Override
public void flush(ChannelHandlerContext ctx) throws Exception {
public void flush(ChannelHandlerContext ctx) {
ctx.flush();
}

@Override
public void channelInactive(ChannelHandlerContext channelHandlerContext) throws Exception {
failAndResetUserPromise(new ClosedChannelException());
super.channelInactive(channelHandlerContext);
}
}

0 comments on commit deccc48

Please sign in to comment.