gpt4 book ai didi

com.mesosphere.sdk.config.validate.ZoneValidator类的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 12:13:31 26 4
gpt4 key购买 nike

本文整理了Java中com.mesosphere.sdk.config.validate.ZoneValidator类的一些代码示例,展示了ZoneValidator类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneValidator类的具体详情如下:
包路径:com.mesosphere.sdk.config.validate.ZoneValidator
类名称:ZoneValidator

ZoneValidator介绍

[英]This class validates that referencing Zones in placement constraints can only support the following transitions.

  1. null --> false 2. true --> true 3. false --> false
    [中]此类验证放置约束中的参照分区只能支持以下转换。
    1.空-->假2。真-->真3。假-->假

代码示例

代码示例来源:origin: mesosphere/dcos-commons

@Override
 public Collection<ConfigValidationError> validate(
   Optional<ServiceSpec> oldConfig,
   ServiceSpec newConfig)
 {
  return ZoneValidator
    .validate(oldConfig, newConfig, NAME_POD_TYPE, JOURNAL_POD_TYPE, DATA_POD_TYPE);
 }
}

代码示例来源:origin: mesosphere/dcos-commons

Optional<PodSpec> oldPod = getPodSpec(oldConfig.get(), podType);
if (!oldPod.isPresent()) {
Optional<PodSpec> newPod = getPodSpec(newConfig, podType);
if (!newPod.isPresent()) {
 throw new IllegalArgumentException(String.format(

代码示例来源:origin: mesosphere/dcos-commons

@Override
 public Collection<ConfigValidationError> validate(
   Optional<ServiceSpec> oldConfig,
   ServiceSpec newConfig)
 {
  return ZoneValidator.validate(oldConfig, newConfig, POD_TYPE);
 }
}

代码示例来源:origin: mesosphere/dcos-commons

@Override
 public Collection<ConfigValidationError> validate(
   Optional<ServiceSpec> oldConfig,
   ServiceSpec newConfig)
 {
  return ZoneValidator.validate(
    oldConfig,
    newConfig,
    MASTER_POD_TYPE,
    DATA_POD_TYPE,
    INGEST_POD_TYPE,
    COORDINATOR_POD_TYPE);
 }
}

代码示例来源:origin: mesosphere/dcos-commons

public static Collection<ConfigValidationError> validate(
  Optional<ServiceSpec> oldConfig,
  ServiceSpec newConfig,
  String... podTypes)
{
 return Arrays.stream(podTypes)
   .flatMap(p -> validate(oldConfig, newConfig, p).stream())
   .collect(Collectors.toList());
}

代码示例来源:origin: mesosphere/dcos-commons

@Test
public void noOldConfig() {
  Collection<ConfigValidationError> errors = ZoneValidator.validate(
      Optional.empty(), null, POD_TYPE);
  Assert.assertTrue(errors.isEmpty());
}

代码示例来源:origin: mesosphere/dcos-commons

@Test
public void falseToTrueShouldFail() {
  ServiceSpec oldSpec = getServiceSpec(false);
  ServiceSpec newSpec = getServiceSpec(true);
  Collection<ConfigValidationError> errors = ZoneValidator.validate(Optional.of(oldSpec), newSpec, POD_TYPE);
  Assert.assertEquals(1, errors.size());
}

代码示例来源:origin: mesosphere/dcos-commons

@Test
public void trueToFalseShouldFail() {
  ServiceSpec oldSpec = getServiceSpec(true);
  ServiceSpec newSpec = getServiceSpec(false);
  Collection<ConfigValidationError> errors = ZoneValidator.validate(Optional.of(oldSpec), newSpec, POD_TYPE);
  Assert.assertEquals(1, errors.size());
}

代码示例来源:origin: mesosphere/dcos-commons

@Test
public void emptyToFalseShouldSucceed() {
  TaskSpec oldTaskSpec = getTaskSpec(Collections.emptyMap());
  ServiceSpec oldSpec = getServiceSpec(oldTaskSpec);
  ServiceSpec newSpec = getServiceSpec(false);
  Collection<ConfigValidationError> errors = ZoneValidator.validate(Optional.of(oldSpec), newSpec, POD_TYPE);
  Assert.assertTrue(errors.isEmpty());
}

代码示例来源:origin: mesosphere/dcos-commons

@Test
public void trueToTrueShouldSucceed() {
  ServiceSpec oldSpec = getServiceSpec(true);
  ServiceSpec newSpec = getServiceSpec(true);
  Collection<ConfigValidationError> errors = ZoneValidator.validate(Optional.of(oldSpec), newSpec, POD_TYPE);
  Assert.assertTrue(errors.isEmpty());
}

代码示例来源:origin: mesosphere/dcos-commons

@Test
public void emptyToTrueShouldFail() {
  TaskSpec oldTaskSpec = getTaskSpec(Collections.emptyMap());
  ServiceSpec oldSpec = getServiceSpec(oldTaskSpec);
  ServiceSpec newSpec = getServiceSpec(true);
  Collection<ConfigValidationError> errors = ZoneValidator.validate(Optional.of(oldSpec), newSpec, POD_TYPE);
  Assert.assertEquals(1, errors.size());
}

代码示例来源:origin: mesosphere/dcos-commons

@Test
public void taskTypeMissingInOldSpec() {
  TaskSpec oldTaskSpec = getTaskSpec(TASK_NAME, Collections.emptyMap());
  TaskSpec newTaskSpec = getTaskSpec(Collections.emptyMap());
  ServiceSpec oldSpec = getServiceSpec(oldTaskSpec);
  ServiceSpec newSpec = getServiceSpec(newTaskSpec);
  Collection<ConfigValidationError> errors = ZoneValidator.validate(Optional.of(oldSpec), newSpec, POD_TYPE);
  Assert.assertTrue(errors.isEmpty());
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com