本文整理汇总了Java中com.github.dockerjava.api.model.Frame类的典型用法代码示例。如果您正苦于以下问题:Java Frame类的具体用法?Java Frame怎么用?Java Frame使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Frame类属于com.github.dockerjava.api.model包,在下文中一共展示了Frame类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runCommand
import com.github.dockerjava.api.model.Frame; //导入依赖的package包/类
private boolean runCommand(@NonNull final DockerClient _dockerClient,
@NonNull final CreateContainerResponse _container,
@NonNull final String[] _commandWithArguments) {
final ExecCreateCmdResponse mExecCreateCmdResponse = _dockerClient
.execCreateCmd(_container.getId())
.withAttachStdout(true)
.withCmd(_commandWithArguments)
.exec();
try {
return _dockerClient
.execStartCmd(mExecCreateCmdResponse.getId())
.exec(new ExecStartResultCallback() {
@Override
public void onNext(Frame frame) {
super.onNext(frame);
}
})
.awaitCompletion(30, TimeUnit.MINUTES);
} catch (InterruptedException e) {
// ignore
}
return false;
}
示例2: onNext
import com.github.dockerjava.api.model.Frame; //导入依赖的package包/类
@Override
public void onNext ( Frame frame ) {
if ( collectFrames )
collectedFrames.add( frame );
if ( collectLog )
log.append( new String( frame.getPayload() ) );
if ( writer != null ) {
try {
writer.write( new String( frame.getPayload() ) );
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// logger.info( "payload: {}", new String( frame.getPayload() ));
}
示例3: onNext
import com.github.dockerjava.api.model.Frame; //导入依赖的package包/类
@Override
public void onNext ( Frame frame ) {
// logger.info( "Got frame: {}", frame );
if ( collectFrames )
collectedFrames.add( frame );
if ( collectLog ) {
String lastLog = new String( frame.getPayload() );
// logger.info( "lastLog: {}", lastLog );
log.append( lastLog );
}
if ( writer != null ) {
try {
writer.write( new String( frame.getPayload() ) );
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//
}
示例4: onNext
import com.github.dockerjava.api.model.Frame; //导入依赖的package包/类
@Override
public void onNext(Frame frame) {
if (frame != null) {
switch (frame.getStreamType()) {
case STDOUT:
case RAW:
soutResult.add(new String(frame.getPayload()));
break;
case STDERR:
serrResult.add(new String(frame.getPayload()));
break;
default:
LOGGER.error("Unknown stream type: " + frame.getStreamType());
}
}
}
示例5: getDockerLogs
import com.github.dockerjava.api.model.Frame; //导入依赖的package包/类
/**
* Synchronized method for returning logs of docker container
*
* @param containerId - ID of the container ot lookup logs
* @return list of strings, where every string is log line
*/
public static List<String> getDockerLogs(String containerId) {
final List<String> logs = new ArrayList<>();
LogContainerCmd logContainerCmd = DockerClientFactory.build().logContainerCmd(containerId);
logContainerCmd.withStdOut(true).withStdErr(true);
try {
logContainerCmd.exec(new LogContainerResultCallback() {
@Override
public void onNext(Frame item) {
logs.add(item.toString());
}
}).awaitCompletion();
} catch (InterruptedException e) {
throw new MinimesosException("Failed to retrieve logs of container " + containerId, e);
}
return logs;
}
示例6: onNext
import com.github.dockerjava.api.model.Frame; //导入依赖的package包/类
@Override
public void onNext(Frame frame) {
List<DecoderResult> result = Lists.newArrayList();
try {
StringBuilder currentLine = getBuffer(frame.getStreamType());
String newData = new String(frame.getPayload(), "UTF-8");
for (int i = 0; i < newData.length(); i++) {
char c = newData.charAt(i);
if (c == '\n') {
result.add(new DecoderResult(frame.getStreamType(), currentLine.toString()));
currentLine.setLength(0);
} else {
currentLine.append(c);
}
}
for (DecoderResult line : result) {
logger.log(line);
}
} catch (IOException e) {
onError(e);
}
}
示例7: call
import com.github.dockerjava.api.model.Frame; //导入依赖的package包/类
public Void call() throws Exception {
final ConsoleLogger console = new ConsoleLogger(listener);
DockerClient client = DockerCommand.getClient(descriptor, cfgData.dockerUrlRes, cfgData.dockerVersionRes, cfgData.dockerCertPathRes, null);
ExecStartResultCallback callback = new ExecStartResultCallback() {
@Override
public void onNext(Frame item) {
console.logInfo(item.toString());
super.onNext(item);
}
@Override
public void onError(Throwable throwable) {
console.logError("Failed to exec start:" + throwable.getMessage());
super.onError(throwable);
}
};
try {
client.execStartCmd(cmdId).exec(callback).awaitCompletion();
} catch (InterruptedException e) {
console.logError("Failed to exec start:" + e.getMessage());
}
return null;
}
示例8: callbackNotifier
import com.github.dockerjava.api.model.Frame; //导入依赖的package包/类
@Override
protected AbstractCallbackNotifier<Frame> callbackNotifier(LogContainerCmd command,
ResultCallback<Frame> resultCallback) {
WebTarget webTarget = getBaseResource().path("/containers/{id}/logs").resolveTemplate("id",
command.getContainerId());
if (command.getTail() != null) {
webTarget = webTarget.queryParam("tail", command.getTail());
}
if (command.getSince() != null) {
webTarget = webTarget.queryParam("since", command.getSince());
}
webTarget = booleanQueryParam(webTarget, "timestamps", command.hasTimestampsEnabled());
webTarget = booleanQueryParam(webTarget, "stdout", command.hasStdoutEnabled());
webTarget = booleanQueryParam(webTarget, "stderr", command.hasStderrEnabled());
webTarget = booleanQueryParam(webTarget, "follow", command.hasFollowStreamEnabled());
LOGGER.trace("GET: {}", webTarget);
return new GETCallbackNotifier<Frame>(new FrameStreamProcessor(), resultCallback, webTarget.request());
}
示例9: callbackNotifier
import com.github.dockerjava.api.model.Frame; //导入依赖的package包/类
@Override
protected AbstractCallbackNotifier<Frame> callbackNotifier(AttachContainerCmd command,
ResultCallback<Frame> resultCallback) {
if (command.getStdin() != null) {
throw new UnsupportedOperationException(
"Passing stdin to the container is currently not supported. Try experimental netty engine!");
}
WebTarget webTarget = getBaseResource().path("/containers/{id}/attach").resolveTemplate("id",
command.getContainerId());
webTarget = booleanQueryParam(webTarget, "logs", command.hasLogsEnabled());
webTarget = booleanQueryParam(webTarget, "stdout", command.hasStdoutEnabled());
webTarget = booleanQueryParam(webTarget, "stderr", command.hasStderrEnabled());
webTarget = booleanQueryParam(webTarget, "stream", command.hasFollowStreamEnabled());
LOGGER.trace("POST: {}", webTarget);
return new POSTCallbackNotifier<Frame>(new FrameStreamProcessor(), resultCallback, webTarget.request(), null);
}
示例10: execute0
import com.github.dockerjava.api.model.Frame; //导入依赖的package包/类
@Override
protected Void execute0(LogContainerCmd command, ResultCallback<Frame> resultCallback) {
WebTarget webTarget = getBaseResource().path("/containers/{id}/logs").resolveTemplate("id",
command.getContainerId());
if (command.getTail() != null) {
webTarget = webTarget.queryParam("tail", command.getTail());
}
if (command.getSince() != null) {
webTarget = webTarget.queryParam("since", command.getSince());
}
webTarget = booleanQueryParam(webTarget, "timestamps", command.hasTimestampsEnabled());
webTarget = booleanQueryParam(webTarget, "stdout", command.hasStdoutEnabled());
webTarget = booleanQueryParam(webTarget, "stderr", command.hasStderrEnabled());
webTarget = booleanQueryParam(webTarget, "follow", command.hasFollowStreamEnabled());
LOGGER.trace("GET: {}", webTarget);
webTarget.request().get(resultCallback);
return null;
}
示例11: execute0
import com.github.dockerjava.api.model.Frame; //导入依赖的package包/类
@Override
protected Void execute0(AttachContainerCmd command, ResultCallback<Frame> resultCallback) {
WebTarget webTarget = getBaseResource().path("/containers/{id}/attach").resolveTemplate("id",
command.getContainerId());
webTarget = booleanQueryParam(webTarget, "logs", command.hasLogsEnabled());
webTarget = booleanQueryParam(webTarget, "stdout", command.hasStdoutEnabled());
webTarget = booleanQueryParam(webTarget, "stderr", command.hasStderrEnabled());
webTarget = booleanQueryParam(webTarget, "stdin", command.getStdin() != null);
webTarget = booleanQueryParam(webTarget, "stream", command.hasFollowStreamEnabled());
LOGGER.trace("POST: {}", webTarget);
webTarget.request().post(null, command.getStdin(), resultCallback);
return null;
}
示例12: canCloseFrameReaderAndReadExpectedLines
import com.github.dockerjava.api.model.Frame; //导入依赖的package包/类
@Test
public void canCloseFrameReaderAndReadExpectedLines() throws Exception {
assumeNotSwarm("", dockerClient);
// wait for the container to be successfully executed
int exitCode = dockerClient.waitContainerCmd(dockerfileFixture.getContainerId())
.exec(new WaitContainerResultCallback()).awaitStatusCode();
assertEquals(0, exitCode);
final List<Frame> loggingFrames = getLoggingFrames();
final Frame outFrame = new Frame(StreamType.STDOUT, "to stdout\n".getBytes());
final Frame errFrame = new Frame(StreamType.STDERR, "to stderr\n".getBytes());
assertThat(loggingFrames, containsInAnyOrder(outFrame, errFrame));
assertThat(loggingFrames, hasSize(2));
}
示例13: onNext
import com.github.dockerjava.api.model.Frame; //导入依赖的package包/类
@Override
public void onNext(Frame item) {
try {
lines.put(new String(item.getPayload(), UTF_8));
} catch (InterruptedException e) {
currentThread().interrupt();
}
}
示例14: shouldGiveAStreamContainingLineOfFrameFromOtherThread
import com.github.dockerjava.api.model.Frame; //导入依赖的package包/类
@Test
public void shouldGiveAStreamContainingLineOfFrameFromOtherThread()
throws ExecutionException, InterruptedException {
CountDownLatch streamStarted = new CountDownLatch(1);
executor.submit(() -> streamLog.onNext(new Frame(StreamType.RAW, "added line".getBytes(UTF_8))));
Future<?> streamCompleted = executor.submit(completeStreamOnceStarted(streamStarted));
assertThat(streamLog.stream().peek((l) -> streamStarted.countDown())).contains("added line");
assertExecutionOf(streamCompleted::get).hasNoAssertionFailures();
}
示例15: shouldReadLineAsUtf8
import com.github.dockerjava.api.model.Frame; //导入依赖的package包/类
@Test
public void shouldReadLineAsUtf8() throws ExecutionException, InterruptedException {
CountDownLatch streamFinished = new CountDownLatch(2);
String originalString = "use of accents é";
byte[] utf8String = originalString.getBytes(UTF_8);
byte[] isoString = originalString.getBytes(ISO_8859_1);
String misinterpretedString = new String(isoString, UTF_8);
executor.submit(() -> streamLog.onNext(new Frame(StreamType.RAW, utf8String)));
executor.submit(() -> streamLog.onNext(new Frame(StreamType.RAW, isoString)));
Future<?> streamCompleted = executor.submit(completeStreamOnceStarted(streamFinished));
assertThat(streamLog.stream().peek((l) -> streamFinished.countDown()))
.hasSize(2)
.containsOnlyOnce(originalString, misinterpretedString);
assertExecutionOf(streamCompleted::get).hasNoAssertionFailures();
}