X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/main/java/com/github/dockerjava/api/DockerClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@
import com.github.dockerjava.api.command.WaitContainerCmd;
import com.github.dockerjava.api.model.AuthConfig;
import com.github.dockerjava.api.model.Event;
import com.github.dockerjava.api.model.BuildResponseItem;
import com.github.dockerjava.api.model.Frame;
import com.github.dockerjava.api.model.Identifier;
import com.github.dockerjava.api.model.PullResponseItem;
import com.github.dockerjava.api.model.PushResponseItem;
import com.github.dockerjava.api.model.Statistics;

// https://godoc.org/github.com/fsouza/go-dockerclient
Expand Down Expand Up @@ -114,13 +117,13 @@ public interface DockerClient extends Closeable {

public WaitContainerCmd waitContainerCmd(String containerId);

public AttachContainerCmd attachContainerCmd(String containerId, ResultCallback<Frame> resultCallback);
public AttachContainerCmd attachContainerCmd(String containerId);

public ExecStartCmd execStartCmd(String containerId);

public InspectExecCmd inspectExecCmd(String execId);

public LogContainerCmd logContainerCmd(String containerId, ResultCallback<Frame> resultCallback);
public LogContainerCmd logContainerCmd(String containerId);

public CopyFileFromContainerCmd copyFileFromContainerCmd(String containerId, String resource);

Expand Down Expand Up @@ -148,9 +151,9 @@ public interface DockerClient extends Closeable {

public UnpauseContainerCmd unpauseContainerCmd(String containerId);

public EventsCmd eventsCmd(ResultCallback<Event> resultCallback);
public EventsCmd eventsCmd();

public StatsCmd statsCmd(ResultCallback<Statistics> resultCallback);
public StatsCmd statsCmd();

@Override
public void close() throws IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
/**
* Result callback
*/
public interface ResultCallback<RES_T> extends Closeable {
public interface ResultCallback<A_RES_T> extends Closeable {
/**
* Called when the async processing starts. The passed {@link Closeable} can be used to close/interrupt the
* processing
*/
void onStart(Closeable closeable);

/** Called when an async result event occurs */
void onNext(RES_T object);
void onNext(A_RES_T object);

/** Called when an exception occurs while processing */
void onError(Throwable throwable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
* @author marcus
*
*/
public interface AsyncDockerCmd<CMD_T extends DockerCmd<RES_T>, A_RES_T, RES_T> extends DockerCmd<RES_T> {
public interface AsyncDockerCmd<CMD_T extends AsyncDockerCmd<CMD_T, A_RES_T>, A_RES_T> extends DockerCmd<Void> {

public ResultCallback<A_RES_T> getResultCallback();

public CMD_T withResultCallback(ResultCallback<A_RES_T> resultCallback);
public <T extends ResultCallback<A_RES_T>> T exec(T resultCallback);

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.io.InputStream;

import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.NotFoundException;
import com.github.dockerjava.api.model.Frame;

/**
Expand All @@ -21,7 +20,7 @@
* @param timestamps
* - true or false, if true, print timestamps for every log line. Defaults to false.
*/
public interface AttachContainerCmd extends AsyncDockerCmd<AttachContainerCmd, Frame, Void> {
public interface AttachContainerCmd extends AsyncDockerCmd<AttachContainerCmd, Frame> {

public String getContainerId();

Expand Down Expand Up @@ -63,16 +62,7 @@ public interface AttachContainerCmd extends AsyncDockerCmd<AttachContainerCmd, F

public AttachContainerCmd withLogs();

/**
* Its the responsibility of the caller to consume and/or close the {@link InputStream} to prevent connection leaks.
*
* @throws NotFoundException
* No such container
*/
@Override
public Void exec() throws NotFoundException;

public static interface Exec extends DockerCmdExec<AttachContainerCmd, Void> {
public static interface Exec extends DockerCmdAsyncExec<AttachContainerCmd, Frame> {
}

}
8 changes: 4 additions & 4 deletions src/main/java/com/github/dockerjava/api/command/AuthCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import com.github.dockerjava.api.model.AuthResponse;

/**
*
*
* Authenticate with the server, useful for checking authentication.
*
*
*/
public interface AuthCmd extends DockerCmd<AuthResponse> {
public interface AuthCmd extends SyncDockerCmd<AuthResponse> {

public AuthConfig getAuthConfig();

Expand All @@ -24,7 +24,7 @@ public interface AuthCmd extends DockerCmd<AuthResponse> {
@Override
public AuthResponse exec() throws UnauthorizedException;

public static interface Exec extends DockerCmdExec<AuthCmd, AuthResponse> {
public static interface Exec extends DockerCmdSyncExec<AuthCmd, AuthResponse> {
}

}
24 changes: 9 additions & 15 deletions src/main/java/com/github/dockerjava/api/command/BuildImageCmd.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.github.dockerjava.api.command;

import com.github.dockerjava.api.model.AuthConfigurations;
import com.github.dockerjava.api.model.EventStreamItem;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import com.github.dockerjava.api.model.AuthConfigurations;
import com.github.dockerjava.api.model.BuildResponseItem;

/**
*
*
* Build an image from Dockerfile.
*
*
* TODO: http://docs.docker.com/reference/builder/#dockerignore
*
*
*/
public interface BuildImageCmd extends DockerCmd<BuildImageCmd.Response> {
public interface BuildImageCmd extends AsyncDockerCmd<BuildImageCmd, BuildResponseItem> {

public BuildImageCmd withTag(String tag);

Expand Down Expand Up @@ -58,14 +57,9 @@ public interface BuildImageCmd extends DockerCmd<BuildImageCmd.Response> {

public BuildImageCmd withBuildAuthConfigs(AuthConfigurations authConfig);

public static interface Exec extends DockerCmdExec<BuildImageCmd, BuildImageCmd.Response> {
public static interface Exec extends DockerCmdAsyncExec<BuildImageCmd, BuildResponseItem> {
}

/**
* @see {@link com.github.dockerjava.core.command.EventStreamReader}
*/
public static abstract class Response extends InputStream {
public abstract Iterable<EventStreamItem> getItems() throws IOException;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Create a new image from a container's changes. Returns the new image ID.
*
*/
public interface CommitCmd extends DockerCmd<String> {
public interface CommitCmd extends SyncDockerCmd<String> {

public String getContainerId();

Expand Down Expand Up @@ -110,7 +110,7 @@ public interface CommitCmd extends DockerCmd<String> {
@Override
public String exec() throws NotFoundException;

public static interface Exec extends DockerCmdExec<CommitCmd, String> {
public static interface Exec extends DockerCmdSyncExec<CommitCmd, String> {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.github.dockerjava.api.NotFoundException;
import com.github.dockerjava.api.model.ChangeLog;

public interface ContainerDiffCmd extends DockerCmd<List<ChangeLog>> {
public interface ContainerDiffCmd extends SyncDockerCmd<List<ChangeLog>> {

public String getContainerId();

Expand All @@ -27,7 +27,7 @@ public interface ContainerDiffCmd extends DockerCmd<List<ChangeLog>> {
@Override
public List<ChangeLog> exec() throws NotFoundException;

public static interface Exec extends DockerCmdExec<ContainerDiffCmd, List<ChangeLog>> {
public static interface Exec extends DockerCmdSyncExec<ContainerDiffCmd, List<ChangeLog>> {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import com.github.dockerjava.api.NotFoundException;

public interface CopyFileFromContainerCmd extends DockerCmd<InputStream> {
public interface CopyFileFromContainerCmd extends SyncDockerCmd<InputStream> {

public String getContainerId();

Expand All @@ -20,14 +20,14 @@ public interface CopyFileFromContainerCmd extends DockerCmd<InputStream> {

/**
* Its the responsibility of the caller to consume and/or close the {@link InputStream} to prevent connection leaks.
*
*
* @throws NotFoundException
* No such container
*/
@Override
public InputStream exec() throws NotFoundException;

public static interface Exec extends DockerCmdExec<CopyFileFromContainerCmd, InputStream> {
public static interface Exec extends DockerCmdSyncExec<CopyFileFromContainerCmd, InputStream> {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import com.github.dockerjava.api.model.Volume;
import com.github.dockerjava.api.model.VolumesFrom;

public interface CreateContainerCmd extends DockerCmd<CreateContainerResponse> {
public interface CreateContainerCmd extends SyncDockerCmd<CreateContainerResponse> {

public static interface Exec extends DockerCmdExec<CreateContainerCmd, CreateContainerResponse> {
public static interface Exec extends DockerCmdSyncExec<CreateContainerCmd, CreateContainerResponse> {
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.io.InputStream;

public interface CreateImageCmd extends DockerCmd<CreateImageResponse> {
public interface CreateImageCmd extends SyncDockerCmd<CreateImageResponse> {

public String getRepository();

Expand Down Expand Up @@ -30,7 +30,7 @@ public interface CreateImageCmd extends DockerCmd<CreateImageResponse> {
*/
public CreateImageCmd withTag(String tag);

public static interface Exec extends DockerCmdExec<CreateImageCmd, CreateImageResponse> {
public static interface Exec extends DockerCmdSyncExec<CreateImageCmd, CreateImageResponse> {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

public interface DockerCmd<RES_T> extends Closeable {

public RES_T exec();


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.github.dockerjava.api.command;

import com.github.dockerjava.api.async.ResultCallback;

public interface DockerCmdAsyncExec<CMD_T extends DockerCmd<Void>, A_RES_T> {

public Void exec(CMD_T command, ResultCallback<A_RES_T> resultCallback);

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.dockerjava.api.command;

public interface DockerCmdExec<CMD_T extends DockerCmd<RES_T>, RES_T> {
public interface DockerCmdSyncExec<CMD_T extends DockerCmd<RES_T>, RES_T> {

public RES_T exec(CMD_T command);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @param until
* - Stream events until this timestamp
*/
public interface EventsCmd extends AsyncDockerCmd<EventsCmd, Event, Void> {
public interface EventsCmd extends AsyncDockerCmd<EventsCmd, Event> {
public EventsCmd withSince(String since);

public EventsCmd withUntil(String until);
Expand All @@ -19,6 +19,6 @@ public interface EventsCmd extends AsyncDockerCmd<EventsCmd, Event, Void> {

public String getUntil();

public static interface Exec extends DockerCmdExec<EventsCmd, Void> {
public static interface Exec extends DockerCmdAsyncExec<EventsCmd, Event> {
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.dockerjava.api.command;

public interface ExecCreateCmd extends DockerCmd<ExecCreateCmdResponse> {
public interface ExecCreateCmd extends SyncDockerCmd<ExecCreateCmdResponse> {

public String getContainerId();

Expand Down Expand Up @@ -32,6 +32,6 @@ public interface ExecCreateCmd extends DockerCmd<ExecCreateCmdResponse> {

public boolean hasTtyEnabled();

public static interface Exec extends DockerCmdExec<ExecCreateCmd, ExecCreateCmdResponse> {
public static interface Exec extends DockerCmdSyncExec<ExecCreateCmd, ExecCreateCmdResponse> {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import java.io.InputStream;

public interface ExecStartCmd extends DockerCmd<InputStream> {
public interface ExecStartCmd extends SyncDockerCmd<InputStream> {

public String getExecId();

Expand All @@ -24,13 +24,13 @@ public interface ExecStartCmd extends DockerCmd<InputStream> {

/**
* Its the responsibility of the caller to consume and/or close the {@link InputStream} to prevent connection leaks.
*
*
* @throws com.github.dockerjava.api.NotFoundException
* No such exec instance
*/
@Override
public InputStream exec() throws NotFoundException;

public static interface Exec extends DockerCmdExec<ExecStartCmd, InputStream> {
public static interface Exec extends DockerCmdSyncExec<ExecStartCmd, InputStream> {
}
}
4 changes: 2 additions & 2 deletions src/main/java/com/github/dockerjava/api/command/InfoCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import com.github.dockerjava.api.model.Info;

public interface InfoCmd extends DockerCmd<Info> {
public interface InfoCmd extends SyncDockerCmd<Info> {

public static interface Exec extends DockerCmdExec<InfoCmd, Info> {
public static interface Exec extends DockerCmdSyncExec<InfoCmd, Info> {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.github.dockerjava.api.NotFoundException;

public interface InspectContainerCmd extends DockerCmd<InspectContainerResponse> {
public interface InspectContainerCmd extends SyncDockerCmd<InspectContainerResponse> {

public String getContainerId();

Expand All @@ -15,7 +15,7 @@ public interface InspectContainerCmd extends DockerCmd<InspectContainerResponse>
@Override
public InspectContainerResponse exec() throws NotFoundException;

public static interface Exec extends DockerCmdExec<InspectContainerCmd, InspectContainerResponse> {
public static interface Exec extends DockerCmdSyncExec<InspectContainerCmd, InspectContainerResponse> {
}

}
Loading
X Tutup