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

Java ContainerStatus类代码示例

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

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



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

示例1: resolve

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
public DeploymentState resolve(ContainerStatus containerStatus) {

		Stream<Predicate<ContainerStatus>> conditionsStream = Stream.of(conditions);
		Boolean allConditionsMet = conditionsStream.reduce((x, y) -> x.and(y)).get().test(containerStatus);

		if (allConditionsMet) {
			logger.debug("deployment state is " + resolvedState.name());
			return this.resolvedState;
		}
		else {
			Stream<ContainerStatusCondition> report = Stream.of(conditions);
			report.filter(c -> {
				boolean result= false;
				try {
					result = c.test(containerStatus);
				}
				catch (NullPointerException e) {

				}
				return !result;

			}).forEach(c -> logger.debug(c + " is not satisfied"));

		}
		return null;
	}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:27,代码来源:PredicateRunningPhaseDeploymentStateResolver.java


示例2: logLastLines

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
/**
 * Log the last lines of containers logs
 */
private void logLastLines(List<ContainerStatus> containers, String podId, String namespace, KubernetesSlave slave,
                          Map<String, Integer> errors, KubernetesClient client) {
    for (ContainerStatus containerStatus : containers) {
        String containerName = containerStatus.getName();
        PrettyLoggable<String, LogWatch> tailingLines = client.pods().inNamespace(namespace)
                .withName(podId).inContainer(containerStatus.getName()).tailingLines(30);
        String log = tailingLines.getLog();
        if (!StringUtils.isBlank(log)) {
            String msg = errors != null ? String.format(" exited with error %s", errors.get(containerName))
                    : "";
            LOGGER.log(Level.SEVERE,
                    "Error in provisioning; agent={0}, template={1}. Container {2}{3}. Logs: {4}",
                    new Object[]{slave, slave.getTemplate(), containerName, msg, tailingLines.getLog()});
        }
    }
}
 
开发者ID:carlossg,项目名称:jenkins-kubernetes-plugin,代码行数:20,代码来源:KubernetesLauncher.java


示例3: createMissingContainers

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
/**
 * Creates any missing containers; updating the currentState with the new values.
 */
public static String createMissingContainers(final ProcessManager processManager, final KubernetesModel model, final Pod pod,
                                             final PodStatus currentState, List<Container> containers) throws Exception {
    Map<String, ContainerStatus> currentContainers = KubernetesHelper.getCurrentContainers(currentState);

    for (final Container container : containers) {
        // lets update the pod model if we update the ports
        podTransaction(model, pod, new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                createContainer(processManager, model, container, pod, currentState);
                return null;
            }
        });
    }

    return null;
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:21,代码来源:NodeHelper.java


示例4: getPodRunningContainers

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
/**
 * Returns all the current containers and their pods
 */
@Override
public ImmutableMap<String, PodCurrentContainer> getPodRunningContainers(KubernetesModel model) {
    Map<String, PodCurrentContainer> answer = new HashMap<>();
    for (Map.Entry<String, Pod> entry : getInternalPodMap(namespace).entrySet()) {
        String podId = entry.getKey();
        Pod podSchema = entry.getValue();
        Map<String, ContainerStatus> currentContainers = KubernetesHelper.getCurrentContainers(podSchema);
        for (Map.Entry<String, ContainerStatus> containerEntry : currentContainers.entrySet()) {
            String containerId = containerEntry.getKey();
            ContainerStatus currentContainer = containerEntry.getValue();
            PodCurrentContainer podCurrentContainer = new PodCurrentContainer(model, podId, podSchema, containerId, currentContainer);
            answer.put(containerId, podCurrentContainer);
        }
    }
    return ImmutableMap.copyOf(answer);
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:20,代码来源:LocalKubernetesModel.java


示例5: allContainersReady

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
private boolean allContainersReady(List<ContainerStatus> containerStatuses) {
    boolean errorPresent = containerStatuses.stream()
            .filter(cs -> !cs.getReady().booleanValue())
            .findFirst()
            .isPresent();

    return !errorPresent ;
}
 
开发者ID:j-white,项目名称:activemq-k8s-discovery,代码行数:9,代码来源:KubernetesDiscoveryAgent.java


示例6: isInErrorState

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
private static Optional<Event> isInErrorState(WorkflowInstance workflowInstance, Pod pod) {
  final PodStatus status = pod.getStatus();
  final String phase = status.getPhase();

  switch (phase) {
    case "Pending":
      // check if one or more docker contains failed to pull their image, a possible silent error
      return status.getContainerStatuses().stream()
          .filter(IS_STYX_CONTAINER.and(KubernetesPodEventTranslator::hasPullImageError))
          .findAny()
          .map((x) -> Event.runError(workflowInstance, "One or more containers failed to pull their image"));

    case "Succeeded":
    case "Failed":
      final Optional<ContainerStatus> containerStatusOpt =
          pod.getStatus().getContainerStatuses().stream()
              .filter(IS_STYX_CONTAINER)
              .findFirst();

      if (!containerStatusOpt.isPresent()) {
        return Optional.of(Event.runError(workflowInstance, "Could not find our container in pod"));
      }

      final ContainerStatus containerStatus = containerStatusOpt.get();
      final ContainerStateTerminated terminated = containerStatus.getState().getTerminated();
      if (terminated == null) {
        return Optional.of(Event.runError(workflowInstance, "Unexpected null terminated status"));
      }
      return Optional.empty();

    case "Unknown":
      return Optional.of(Event.runError(workflowInstance, "Pod entered Unknown phase"));

    default:
      return Optional.empty();
  }
}
 
开发者ID:spotify,项目名称:styx,代码行数:38,代码来源:KubernetesPodEventTranslator.java


示例7: hasPullImageError

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
static boolean hasPullImageError(ContainerStatus cs) {
  ContainerStateWaiting waiting = cs.getState().getWaiting();
  return waiting != null && (
      "PullImageError".equals(waiting.getReason())
      || "ErrImagePull".equals(waiting.getReason())
      || "ImagePullBackOff".equals(waiting.getReason()));
}
 
开发者ID:spotify,项目名称:styx,代码行数:8,代码来源:KubernetesPodEventTranslator.java


示例8: deletePodIfNonDeletePeriodExpired

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
private void deletePodIfNonDeletePeriodExpired(WorkflowInstance workflowInstance,
                                               String executionId,
                                               ContainerStatus containerStatus) {
  if (isNonDeletePeriodExpired(containerStatus)) {
    // if terminated and after graceful period, delete the pod
    // otherwise wait until next polling happens
    deletePod(workflowInstance, executionId);
  }
}
 
开发者ID:spotify,项目名称:styx,代码行数:10,代码来源:KubernetesDockerRunner.java


示例9: cleanup

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
private void cleanup(WorkflowInstance workflowInstance, String executionId, 
                     Consumer<List<ContainerStatus>> cleaner) {
  Optional.ofNullable(client.pods().withName(executionId).get()).ifPresent(pod -> {
    final List<ContainerStatus> containerStatuses = pod.getStatus().getContainerStatuses();
    if (!containerStatuses.isEmpty()) {
      cleaner.accept(containerStatuses);
    } else {
      // for some cases such as evicted pod, there is no container status, so we delete directly
      deletePod(workflowInstance, executionId);
    }
  });
}
 
开发者ID:spotify,项目名称:styx,代码行数:13,代码来源:KubernetesDockerRunner.java


示例10: isNonDeletePeriodExpired

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
private boolean isNonDeletePeriodExpired(ContainerStatus containerStatus) {
  return Optional.ofNullable(containerStatus.getState().getTerminated().getFinishedAt())
      .map(finishedAt -> Instant.parse(finishedAt)
          .isBefore(clock.instant().minus(
              Duration.ofSeconds(podDeletionDelaySeconds))))
      .orElse(true);
}
 
开发者ID:spotify,项目名称:styx,代码行数:8,代码来源:KubernetesDockerRunner.java


示例11: ContainerReady

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
ContainerReady(KubernetesDeployerProperties properties) {
	super(properties, DeploymentState.deployed, new ContainerStatusCondition("container ready") {
		@Override
		public boolean test(ContainerStatus containerStatus) {
			return containerStatus.getReady();
		}
	});
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:9,代码来源:PredicateRunningPhaseDeploymentStateResolver.java


示例12: resolve

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
@Override
public DeploymentState resolve(ContainerStatus containerStatus) {
	for (RunningPhaseDeploymentStateResolver resolver: delegates) {
		DeploymentState deploymentState = resolver.resolve(containerStatus);
		if (deploymentState != null) {
			return deploymentState;
		}
	}
	return null;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:11,代码来源:CompositeDeploymentStateResolver.java


示例13: getOrCreateContainerStatuses

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
/**
 * Returns the current container map for the current pod state; lazily creating if required
 */
public static List<ContainerStatus> getOrCreateContainerStatuses(Pod pod) {
    PodStatus currentState = getOrCreatetStatus(pod);
    List<ContainerStatus> containerStatuses = currentState.getContainerStatuses();
    if (containerStatuses == null) {
        containerStatuses = new ArrayList<>();
        currentState.setContainerStatuses(containerStatuses);
    }
    return containerStatuses;
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:13,代码来源:NodeHelper.java


示例14: getOrCreateContainerState

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
/**
 * Returns the containers state, lazily creating any objects if required.
 */
public static ContainerState getOrCreateContainerState(Pod pod, String containerName) {
    ContainerStatus containerInfo = getOrCreateContainerInfo(pod, containerName);
    ContainerState state = containerInfo.getState();
    if (state == null) {
        state = new ContainerState();
        containerInfo.setState(state);
    }
    return state;
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:13,代码来源:NodeHelper.java


示例15: getOrCreateContainerInfo

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
/**
 * Returns the container information for the given pod and container name, lazily creating as required
 */
public static ContainerStatus getOrCreateContainerInfo(Pod pod, String containerName) {
    List<ContainerStatus> containerStatuses = getOrCreateContainerStatuses(pod);
    for (ContainerStatus containerStatus : containerStatuses) {
        String containerID = containerStatus.getContainerID();
        if (Objects.equal(containerName, containerID)) {
            return containerStatus;
        }
    }
    ContainerStatus status = new ContainerStatus();
    status.setContainerID(containerName);
    containerStatuses.add(status);
    return status;
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:17,代码来源:NodeHelper.java


示例16: containerAlive

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
public static void containerAlive(Pod pod, String id, boolean alive) {
    PodStatus currentState = getOrCreatetStatus(pod);
    if (alive) {
        setPodRunning(currentState);
    } else {
        // lets check if we're waiting...
        List<ContainerStatus> containerStatuses = getOrCreateContainerStatuses(pod);
        if (containerStatuses.isEmpty() || isWaiting(containerStatuses)) {
            setPodWaiting(currentState);
        } else {
            setPodTerminated(currentState, "Failed");
        }
    }
    setContainerRunningState(pod, id, alive);
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:16,代码来源:NodeHelper.java


示例17: isWaiting

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
protected static boolean isWaiting(List<ContainerStatus> containerStatuses) {
    for (ContainerStatus status : containerStatuses) {
        ContainerState state = status.getState();
        if (state != null && state.getWaiting() != null) {
            return true;
        }
    }
    return false;
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:10,代码来源:NodeHelper.java


示例18: setPodTerminated

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
public static void setPodTerminated(PodStatus podStatus, String message) {
    List<ContainerStatus> containerStatuses = podStatus.getContainerStatuses();
    if (containerStatuses == null) {
        containerStatuses = new ArrayList<ContainerStatus>();
        podStatus.setContainerStatuses(containerStatuses);
    }
    containerStatuses.clear();
    ContainerStatus status = new ContainerStatusBuilder().withNewState().
            withNewTermination().withMessage(message).withFinishedAt(createAtString()).endTermination().endState().
            build();
    containerStatuses.add(status);
    podStatus.setContainerStatuses(containerStatuses);
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:14,代码来源:NodeHelper.java


示例19: setPodRunning

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
public static void setPodRunning(PodStatus podStatus) {
    List<ContainerStatus> containerStatuses = podStatus.getContainerStatuses();
    if (containerStatuses == null) {
        containerStatuses = new ArrayList<ContainerStatus>();
        podStatus.setContainerStatuses(containerStatuses);
    }
    containerStatuses.clear();
    ContainerStatus status = new ContainerStatusBuilder().withNewState().
            withNewRunning().withStartedAt(createAtString()).endRunning().endState().
            build();
    containerStatuses.add(status);
    podStatus.setContainerStatuses(containerStatuses);
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:14,代码来源:NodeHelper.java


示例20: setPodWaiting

import io.fabric8.kubernetes.api.model.ContainerStatus; //导入依赖的package包/类
public static void setPodWaiting(PodStatus podStatus, String reason) {
    List<ContainerStatus> containerStatuses = podStatus.getContainerStatuses();
    if (containerStatuses == null) {
        containerStatuses = new ArrayList<ContainerStatus>();
        podStatus.setContainerStatuses(containerStatuses);
    }
    containerStatuses.clear();
    ContainerStatus status = new ContainerStatusBuilder().withNewState().
            withNewWaiting().withReason(reason).endWaiting().endState().
            build();
    containerStatuses.add(status);
    podStatus.setContainerStatuses(containerStatuses);
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:14,代码来源:NodeHelper.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java QueryUtils类代码示例发布时间:2022-05-23
下一篇:
Java DataStoreFactory类代码示例发布时间: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