• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LogContainerCmd类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.github.dockerjava.api.command.LogContainerCmd的典型用法代码示例。如果您正苦于以下问题:Java LogContainerCmd类的具体用法?Java LogContainerCmd怎么用?Java LogContainerCmd使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LogContainerCmd类属于com.github.dockerjava.api.command包,在下文中一共展示了LogContainerCmd类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: run

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的package包/类
@Override
protected Stream<LogEntry> run() throws Exception {
  LogContainerCmd cmd = dockerClient.logContainerCmd(containerId);
  if (params.isWithStdOut()) {
    cmd.withStdOut(true);
  }
  if (params.isWithStdErr()) {
    cmd.withStdErr(true);
  }
  if (params.isWithTimestamps()) {
    cmd.withTimestamps(true);
  }
  if (params.getTail() > 0) {
    cmd.withTail(params.getTail());
  }

  LogContainerCallback callBack = new LogContainerCallback();
  Sssh.waitForCompletion(cmd.exec(callBack));
  return callBack.entries.stream();
}
 
开发者ID:Qorr,项目名称:Hvalspik,代码行数:21,代码来源:GetContainerLogsCommand.java


示例2: getDockerLogs

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的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


示例3: followOutput

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void followOutput(DockerClient dockerClient, String containerId,
                         Consumer<OutputFrame> consumer, OutputFrame.OutputType... types) {

    final LogContainerCmd cmd = dockerClient.logContainerCmd(containerId)
            .withFollowStream(true)
            .withSince(0);

    final FrameConsumerResultCallback callback = new FrameConsumerResultCallback();
    for (OutputFrame.OutputType type : types) {
        callback.addConsumer(type, consumer);
        if (type == STDOUT) cmd.withStdOut(true);
        if (type == STDERR) cmd.withStdErr(true);
    }

    cmd.exec(callback);
}
 
开发者ID:testcontainers,项目名称:testcontainers-java,代码行数:20,代码来源:LogUtils.java


示例4: callbackNotifier

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的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


示例5: execute0

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的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


示例6: containerTailStream

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的package包/类
public void containerTailStream (
									String id,
									String name,
									HttpServletResponse response,
									int numberOfLines ) {
	try {
		String targetId = getContainerId( id, name );
		// docker.startContainer( container.id());
		DockerContainerLogCallback loggingCallback = new DockerContainerLogCallback( response.getWriter() );
		LogContainerCmd logCommand = dockerClient
			.logContainerCmd( targetId )
			.withStdErr( true )
			.withStdOut( true );

		if ( numberOfLines > 0 ) {
			logCommand.withTail( numberOfLines );
		}

		logCommand.exec( loggingCallback );

		loggingCallback.awaitCompletion( 3, TimeUnit.SECONDS );

	} catch (Exception e) {
		String reason = CSAP.getCsapFilteredStackTrace( e );
		logger.warn( "Failed starting {}, {}", name, reason );
		try {
			response.getWriter().println( "Failed getting file: " + reason );
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}

	return;
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:36,代码来源:DockerHelper.java


示例7: copyLog

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的package包/类
public void copyLog(String containerId, boolean follow, boolean stdout, boolean stderr, boolean timestamps, int tail,
    OutputStream outputStream) throws IOException {
    this.readWriteLock.readLock().lock();
    try {
        LogContainerCmd logContainerCmd =
            dockerClient.logContainerCmd(containerId).withStdErr(false).withStdOut(false);

        logContainerCmd.withFollowStream(follow);
        logContainerCmd.withStdOut(stdout);
        logContainerCmd.withStdErr(stderr);
        logContainerCmd.withTimestamps(timestamps);

        if (tail < 0) {
            logContainerCmd.withTailAll();
        } else {
            logContainerCmd.withTail(tail);
        }

        OutputStreamLogsResultCallback outputStreamLogsResultCallback =
            new OutputStreamLogsResultCallback(outputStream);
        logContainerCmd.exec(outputStreamLogsResultCallback);
        try {
            outputStreamLogsResultCallback.awaitCompletion();
        } catch (InterruptedException e) {
            throw new IOException(e);
        }
    } finally {
        this.readWriteLock.readLock().unlock();
    }
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:31,代码来源:DockerClientExecutor.java


示例8: containerTail

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的package包/类
public ObjectNode containerTail (
									String id,
									String name,
									int numberOfLines,
									int since ) {

	ObjectNode result = jacksonMapper.createObjectNode();
	result.put( "since", since );
	try {
		String targetId = getContainerId( id, name );
		// docker.startContainer( container.id());
		if ( targetId == null ) {
			result.put( "result", "View logs: " + targetId );
			result.put( "plainText", "Unable to locate container - verify it is created and running" );
			return result;
		}
		DockerContainerLogCallback loggingCallback = new DockerContainerLogCallback( true );
		LogContainerCmd logCommand = dockerClient
			.logContainerCmd( targetId )
			.withStdErr( true )
			.withStdOut( true )
			.withTail( numberOfLines );

		if ( since < 0 ) {
			int timestamp = (int) (System.currentTimeMillis() / 1000) - 1;
			since = timestamp;
		}

		if ( since > 0 ) {
			logCommand.withSince( since );
		}

		result.put( "since", since );

		logCommand.exec( loggingCallback );
		loggingCallback.awaitCompletion( 3, TimeUnit.SECONDS );

		result.put( "result", "View logs: " + targetId );
		result.put( "plainText", loggingCallback.toString() );
		String parameterName = "?id=" + id;
		if ( id == null )
			parameterName = "?name=" + name;
		result.put( "url", parameterName + "&numberOfLines="
				+ numberOfLines );

	} catch (Exception e) {
		String reason = CSAP.getCsapFilteredStackTrace( e );
		logger.warn( "Failed getting logs {}, {}", name, reason );
		result.put( DockerJson.error.key, "Failed starting: " + name );
		result.put( DockerJson.errorReason.key, reason );
	}

	return result;
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:55,代码来源:DockerHelper.java


示例9: createLogContainerCmdExec

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的package包/类
@Override
public LogContainerCmd.Exec createLogContainerCmdExec() {
    return new LogContainerCmdExec(getBaseResource(), getDockerClientConfig());
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:5,代码来源:JerseyDockerCmdExecFactory.java


示例10: logContainerCmd

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的package包/类
@Override
public LogContainerCmd logContainerCmd(String containerId) {
    return new LogContainerCmdImpl(getDockerCmdExecFactory().createLogContainerCmdExec(), containerId);
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:5,代码来源:DockerClientImpl.java


示例11: LogContainerCmdImpl

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的package包/类
public LogContainerCmdImpl(LogContainerCmd.Exec exec, String containerId) {
    super(exec);
    withContainerId(containerId);
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:5,代码来源:LogContainerCmdImpl.java


示例12: withContainerId

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的package包/类
@Override
public LogContainerCmd withContainerId(String containerId) {
    checkNotNull(containerId, "containerId was not specified");
    this.containerId = containerId;
    return this;
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:7,代码来源:LogContainerCmdImpl.java


示例13: withFollowStream

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的package包/类
@Override
public LogContainerCmd withFollowStream(Boolean followStream) {
    this.followStream = followStream;
    return this;
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:6,代码来源:LogContainerCmdImpl.java


示例14: withTimestamps

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的package包/类
@Override
public LogContainerCmd withTimestamps(Boolean timestamps) {
    this.timestamps = timestamps;
    return this;
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:6,代码来源:LogContainerCmdImpl.java


示例15: withStdOut

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的package包/类
@Override
public LogContainerCmd withStdOut(Boolean stdout) {
    this.stdout = stdout;
    return this;
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:6,代码来源:LogContainerCmdImpl.java


示例16: withStdErr

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的package包/类
@Override
public LogContainerCmd withStdErr(Boolean stderr) {
    this.stderr = stderr;
    return this;
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:6,代码来源:LogContainerCmdImpl.java


示例17: withTailAll

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的package包/类
@Override
public LogContainerCmd withTailAll() {
    this.tail = -1;
    return this;
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:6,代码来源:LogContainerCmdImpl.java


示例18: withTail

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的package包/类
@Override
public LogContainerCmd withTail(Integer tail) {
    this.tail = tail;
    return this;
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:6,代码来源:LogContainerCmdImpl.java


示例19: withSince

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的package包/类
@Override
public LogContainerCmd withSince(Integer since) {
    this.since = since;
    return this;
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:6,代码来源:LogContainerCmdImpl.java


示例20: createLogContainerCmdExec

import com.github.dockerjava.api.command.LogContainerCmd; //导入依赖的package包/类
@Override
public LogContainerCmd.Exec createLogContainerCmdExec() {
    return delegate.createLogContainerCmdExec();
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:5,代码来源:TestDockerCmdExecFactory.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InteractionSpec类代码示例发布时间:2022-05-23
下一篇:
Java UserType类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap