io.cattle.platform.core.model.Instance.getKind()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(144)

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

Instance.getKind介绍

[英]Getter for cattle.instance.kind.
[中]cattle.instance.kind的Getter。

代码示例

代码示例来源:origin: rancher/cattle

protected String key(Instance instance) {
  Object resourceId = context.idFormatter.formatId(instance.getKind(), instance.getId());
  return String.format("%s:%s", instance.getKind(), resourceId);
}

代码示例来源:origin: rancher/cattle

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void process(Object obj, String type, Map<String, Object> data) {
  if (!(obj instanceof Instance))
    return;
  Instance instance = (Instance) obj;
  if (!InstanceConstants.CONTAINER_LIKE.contains(instance.getKind()))
    return;
  List volumesFromContainerIds = DataAccessor.fields(instance).withKey(DockerInstanceConstants.FIELD_VOLUMES_FROM).as(jsonMapper, List.class);
  List<Instance> containers = null;
  if (volumesFromContainerIds != null && !volumesFromContainerIds.isEmpty()) {
    Condition condition = new Condition(ConditionType.IN, volumesFromContainerIds);
    containers = objectManager.find(Instance.class, INSTANCE.ID, condition);
  }
  if (containers == null)
    containers = new ArrayList<Instance>();
  data.put(DockerInstanceConstants.EVENT_FIELD_VOLUMES_FROM, containers);
  List<Volume>volumes = InstanceHelpers.extractVolumesFromMounts(instance, objectManager);
  data.put(DockerInstanceConstants.EVENT_FIELD_VOLUMES_FROM_DVM, volumes);
}

代码示例来源:origin: rancher/cattle

protected void setDns(Instance instance, Map<String, Object> labels, Map<Object, Object> data) {
  if (!InstanceConstants.KIND_CONTAINER.equals(instance.getKind())) {
    return;

代码示例来源:origin: rancher/cattle

protected void processPorts(Instance instance) {
  Set<String> portSpecs = new HashSet<>();
  for (Port port : objectManager.children(instance, Port.class)) {
    if (port.getRemoved() != null) {
      continue;
    }
    portSpecs.add(new PortSpec(port).toSpec());
  }
  objectManager.setFields(instance, InstanceConstants.FIELD_PORTS, new ArrayList<>(portSpecs));
  Event event = EventVO.newEvent(IaasEvents.INVALIDATE_INSTANCE_DATA_CACHE)
      .withResourceType(instance.getKind())
      .withResourceId(instance.getId().toString());
  eventService.publish(event);
}

代码示例来源:origin: rancher/cattle

public HandlerResult handle(ProcessState state, ProcessInstance process) {
  Instance instance = (Instance)state.getResource();
  if (!InstanceConstants.CONTAINER_LIKE.contains(instance.getKind())) {
    return null;

代码示例来源:origin: rancher/cattle

private void updateInstanceWithNewPorts(Instance instance) {
  List<Port> toUpdate = objectManager.find(Port.class, PORT.INSTANCE_ID, instance.getId(), PORT.REMOVED, null);
  List<String> toUpdatePortDefs = new ArrayList<>();
  for (Port port : toUpdate) {
    PortSpec portSpec = new PortSpec(port);
    toUpdatePortDefs.add(portSpec.toSpec());
  }
  instance = objectManager.setFields(instance, InstanceConstants.FIELD_PORTS, toUpdatePortDefs);
  // trigger instance/metadata update
  Event event = EventVO.newEvent(IaasEvents.INVALIDATE_INSTANCE_DATA_CACHE)
      .withResourceType(instance.getKind())
      .withResourceId(instance.getId().toString());
  eventService.publish(event);
  return;
}

代码示例来源:origin: rancher/cattle

@Override
  public HandlerResult handle(ProcessState state, ProcessInstance process) {
    Instance instance = (Instance)state.getResource();
    if (!InstanceConstants.CONTAINER_LIKE.contains(instance.getKind())) {
      return null;
    }

    Image image = objectManager.loadResource(Image.class, instance.getImageId());
    if (image == null) {
      return null;
    }

    DockerBuild build = DataAccessor.field(instance, DockerInstanceConstants.FIELD_BUILD,
        jsonMapper, DockerBuild.class);

    if (build == null) {
      return null;
    }

    String imageUuid = DataAccessor.fieldString(instance, InstanceConstants.FIELD_IMAGE_UUID);
    if (imageUuid != null) {
      String tag = StringUtils.removeStart(imageUuid, "docker:");
      build.setTag(tag);
    }

    objectManager.setFields(image, DockerInstanceConstants.FIELD_BUILD, build);

    return null;
  }
}

代码示例来源:origin: rancher/cattle

@Override
public HandlerResult handle(ProcessState state, ProcessInstance process) {
  Instance instance = (Instance)state.getResource();
  if (!InstanceConstants.CONTAINER_LIKE.contains(instance.getKind())) {
    return null;

代码示例来源:origin: rancher/cattle

@Override
public HandlerResult handle(ProcessState state, ProcessInstance process) {
  Instance instance = (Instance)state.getResource();
  if (!InstanceConstants.KIND_VIRTUAL_MACHINE.equals(instance.getKind())) {
    return null;

代码示例来源:origin: rancher/cattle

hostStats = true;
  containerStats = true;
} else if (original instanceof Instance && InstanceConstants.CONTAINER_LIKE.contains(((Instance) original).getKind())) {
  containerStats = true;
  add = true;

代码示例来源:origin: rancher/cattle

@Override
public HandlerResult handle(ProcessState state, ProcessInstance process) {
  Instance instance = (Instance)state.getResource();
  if (!InstanceConstants.CONTAINER_LIKE.contains(instance.getKind())) {
    return null;
  }
  Map<String, Object> labels = DataAccessor.fieldMap(instance, InstanceConstants.FIELD_LABELS);
  Account account = objectManager.loadResource(Account.class, instance.getAccountId());
  Map<Object, Object> data = new HashMap<>();
  setAgentVolumes(instance, labels, data);
  setName(instance, labels, data);
  setDns(instance, labels, data);
  setLogConfig(instance, data);
  setSecrets(instance, data);
  setSystemLabel(instance, labels);
  setEnvironmentLabel(labels, account);
  if (!data.isEmpty()) {
    return new HandlerResult(data);
  }
  return null;
}

代码示例来源:origin: rancher/cattle

.withResourceType(instance.getKind())
        .withResourceId(instance.getId().toString());
    eventService.publish(event);
    .withResourceType(instance.getKind())
    .withResourceId(instance.getId().toString());
eventService.publish(event);

代码示例来源:origin: rancher/cattle

@SuppressWarnings("unchecked")
@Override
public HandlerResult handle(ProcessState state, ProcessInstance process) {
  InstanceHostMap map = (InstanceHostMap)state.getResource();
  Instance instance = getObjectManager().loadResource(Instance.class, map.getInstanceId());
  Host host = getObjectManager().loadResource(Host.class, map.getHostId());
  String dockerIp = DockerProcessUtils.getDockerIp(instance);
  Nic nic = nicDao.getPrimaryNic(instance);
  IpAddress hostIpAddress = hostDao.getIpAddressForHost(host.getId());
  IpAddress primaryIp = ipAddressDao.getInstancePrimaryIp(instance);
  List<String> ports = DataAccessor.fields(instance).withKey(DockerInstanceConstants.FIELD_DOCKER_PORTS).as(jsonMapper, List.class);
  if (dockerIp != null) {
    primaryIp = processDockerIp(instance, nic, primaryIp, dockerIp);
  }
  if (hostIpAddress != null && ports != null) {
    processPorts(primaryIp, hostIpAddress, ports, instance, nic, host);
  }
  processVolumes(instance, host, state);
  processLabels(instance);
  nativeDockerBackPopulate(instance);
  Event event = EventVO.newEvent(IaasEvents.INVALIDATE_INSTANCE_DATA_CACHE)
      .withResourceType(instance.getKind())
      .withResourceId(instance.getId().toString());
  eventService.publish(event);
  return null;
}

代码示例来源:origin: rancher/cattle

setName(from.getName());
setAccountId(from.getAccountId());
setKind(from.getKind());
setUuid(from.getUuid());
setDescription(from.getDescription());

相关文章