当前位置: 首页>>代码示例>>Java>>正文


Java Frame类代码示例

本文整理汇总了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;
}
 
开发者ID:jonfryd,项目名称:tifoon,代码行数:26,代码来源:DockerExecutorPlugin.java

示例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() ));
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:19,代码来源:DockerContainerLogCallback.java

示例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();
		}
	}
	//
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:22,代码来源:Docker_Java.java

示例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());
    }
  }
}
 
开发者ID:scalecube,项目名称:docker-utils,代码行数:17,代码来源:Containers.java

示例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;
}
 
开发者ID:ContainerSolutions,项目名称:minimesos,代码行数:26,代码来源:DockerContainersUtil.java

示例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);
    }
}
 
开发者ID:vuminhkh,项目名称:tosca-runtime,代码行数:23,代码来源:DockerStreamDecoder.java

示例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;
}
 
开发者ID:jenkinsci,项目名称:docker-build-step-plugin,代码行数:26,代码来源:ExecStartRemoteCallable.java

示例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());
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:25,代码来源:LogContainerCmdExec.java

示例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);
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:22,代码来源:AttachContainerCmdExec.java

示例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;
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:26,代码来源:LogContainerCmdExec.java

示例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;
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:19,代码来源:AttachContainerCmdExec.java

示例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));
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:17,代码来源:FrameReaderITest.java

示例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();
    }
}
 
开发者ID:FaustXVI,项目名称:junit5-docker,代码行数:9,代码来源:StreamLog.java

示例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();
}
 
开发者ID:FaustXVI,项目名称:junit5-docker,代码行数:10,代码来源:StreamLogTest.java

示例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();
}
 
开发者ID:FaustXVI,项目名称:junit5-docker,代码行数:16,代码来源:StreamLogTest.java


注:本文中的com.github.dockerjava.api.model.Frame类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。