Skip to content

Commit

Permalink
implementing resizable exec stream
Browse files Browse the repository at this point in the history
  • Loading branch information
yue9944882 committed Mar 30, 2020
1 parent 28cfba9 commit 35ee3d5
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion util/src/main/java/io/kubernetes/client/Exec.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,20 @@ static int parseExitCode(ApiClient client, InputStream inputStream) {
return -1;
}

protected static class ExecProcess extends Process {
// ResizableExecStream defines a getter for resize stream
public interface ResizableExecStream {
// Returns an output stream for sending resizing-windows requests
OutputStream getResizeStream();
}

// ConnectionErrorExecStream defines a getter for connection error stream
public interface ConnectionErrorExecStream {
// Returns an input stream which retrieves exec connection error from the endpoint.
InputStream getConnectionErrorStream();
}

protected static class ExecProcess extends Process
implements ResizableExecStream, ConnectionErrorExecStream {
private final WebSocketStreamHandler streamHandler;
private int statusCode = -1;
private boolean isAlive = true;
Expand Down Expand Up @@ -425,6 +438,16 @@ public InputStream getErrorStream() {
return getInputStream(2);
}

@Override
public InputStream getConnectionErrorStream() {
return getInputStream(3);
}

@Override
public OutputStream getResizeStream() {
return streamHandler.getOutputStream(4);
}

private synchronized InputStream getInputStream(int stream) {
if (!input.containsKey(stream)) {
input.put(stream, streamHandler.getInputStream(stream));
Expand Down

0 comments on commit 35ee3d5

Please sign in to comment.