本文整理了Java中io.cattle.platform.core.model.Instance.getStartCount()
方法的一些代码示例,展示了Instance.getStartCount()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instance.getStartCount()
方法的具体详情如下:
包路径:io.cattle.platform.core.model.Instance
类名称:Instance
方法名:getStartCount
[英]Getter for cattle.instance.start_count
.
[中]cattle.instance.start_count
的Getter。
代码示例来源:origin: rancher/cattle
protected boolean isStartOnce(Instance instance) {
Map<String, Object> labels = DataAccessor
.fieldMap(instance, InstanceConstants.FIELD_LABELS);
boolean startOnce = false;
List<String> stoppedStates = Arrays.asList(InstanceConstants.STATE_STOPPED, InstanceConstants.STATE_STOPPING);
if (labels.containsKey(SystemLabels.LABEL_SERVICE_CONTAINER_START_ONCE)) {
startOnce = Boolean.valueOf(((String) labels
.get(SystemLabels.LABEL_SERVICE_CONTAINER_START_ONCE)))
&& instance.getStartCount() != null && instance.getStartCount() >= 1L
&& stoppedStates.contains(instance.getState());
}
return startOnce;
}
代码示例来源:origin: rancher/cattle
@Override
public HandlerResult handle(ProcessState state, ProcessInstance process) {
InstanceHostMap map = (InstanceHostMap) state.getResource();
Instance instance = getObjectManager().loadResource(Instance.class, map.getInstanceId());
if (instance == null) {
return null;
}
// set startCount
Long startCount = instance.getStartCount() == null ? 1 : instance.getStartCount() + 1;
objectManager.setFields(instance, INSTANCE.START_COUNT, startCount);
return null;
}
代码示例来源:origin: rancher/cattle
protected List<? extends Instance> getServiceInstancesToRestart(Service service) {
// get all instances of the service
List<? extends Instance> instances = exposeMapDao.listServiceManagedInstances(service);
List<Instance> toRestart = new ArrayList<>();
ServiceRestart svcRestart = DataAccessor.field(service, ServiceConstants.FIELD_RESTART,
jsonMapper, ServiceRestart.class);
RollingRestartStrategy strategy = svcRestart.getRollingRestartStrategy();
Map<Long, Long> instanceToStartCount = strategy.getInstanceToStartCount();
// compare its start_count with one set on the service restart field
for (Instance instance : instances) {
if (instanceToStartCount.containsKey(instance.getId())) {
Long previousStartCount = instanceToStartCount.get(instance.getId());
if (previousStartCount == instance.getStartCount()) {
toRestart.add(instance);
}
}
}
return toRestart;
}
代码示例来源:origin: rancher/cattle
this.start_count = instance.getStartCount();
this.state = instance.getState();
this.memory_reservation = instance.getMemoryReservation();
代码示例来源:origin: rancher/cattle
@Override
public Object resourceAction(String type, ApiRequest request, ResourceManager next) {
if (request.getAction().equals(ServiceConstants.ACTION_SERVICE_RESTART)) {
Service service = objectManager.loadResource(Service.class, request.getId());
ServiceRestart restart = jsonMapper.convertValue(request.getRequestObject(),
ServiceRestart.class);
RollingRestartStrategy strategy = restart.getRollingRestartStrategy();
if (strategy == null) {
ValidationErrorCodes.throwValidationError(ValidationErrorCodes.MISSING_REQUIRED,
"Restart strategy needs to be set");
}
Map<Long, Long> instanceToStartCount = new HashMap<>();
for (Instance instance : exposeMapDao.listServiceManagedInstances(service)) {
instanceToStartCount.put(instance.getId(), instance.getStartCount());
}
strategy.setInstanceToStartCount(instanceToStartCount);
restart.setRollingRestartStrategy(strategy);
request.setRequestObject(jsonMapper.writeValueAsMap(restart));
objectManager.persist(service);
}
return super.resourceAction(type, request, next);
}
}
代码示例来源:origin: rancher/cattle
setNetworkContainerId(from.getNetworkContainerId());
setHealthState(from.getHealthState());
setStartCount(from.getStartCount());
setCreateIndex(from.getCreateIndex());
setDeploymentUnitUuid(from.getDeploymentUnitUuid());
内容来源于网络,如有侵权,请联系作者删除!