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

x33g5p2x  于2022-01-16 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(131)

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

Agent.getId介绍

[英]Getter for cattle.agent.id.
[中]cattle.agent.id的Getter。

代码示例

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

protected String getAccountUuid(Agent agent) {
  return "agentAccount" + agent.getId();
}

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

protected String getAccountUuid(Agent agent, String role) {
  return "agentAccount" + agent.getId() + "-" + role;
}

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

public AgentResourceCreateLock(Agent agent) {
  super("AGENT.RESOUCE.CREATE." + agent.getId());
}

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

public AgentConnectionLockDefinition(Agent agent) {
  this(agent.getId());
}

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

@Override
public Host getHost(Object obj) {
  if (!(obj instanceof Agent)) {
    return null;
  }
  Agent agent = (Agent) obj;
  return objectManager.findAny(Host.class, HOST.AGENT_ID, agent.getId(), HOST.REMOVED, null);
}

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

public static Ping newPing(Agent agent) {
  if (agent == null) {
    return null;
  }
  return newPing(agent.getId());
}

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

protected EventService buildDelegate(long agentId) {
  Map<String, Object> instanceData = new LinkedHashMap<>();
  Agent hostAgent = getAgentForDelegate(agentId, instanceData);
  if (hostAgent == null) {
    return null;
  }
  String hostAgentUri = hostAgent.getUri();
  if (hostAgentUri != null && !hostAgentUri.startsWith(EVENTING)) {
    return null;
  }
  return new WrappedEventService(hostAgent.getId(), true, eventService, instanceData, jsonMapper, delegateDao);
}

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

protected Map<String, Object> createData(Agent agent, String uuid, Map<String, Object> data) {
  Map<String, Object> properties = new HashMap<>(data);
  properties.put(HostConstants.FIELD_REPORTED_UUID, uuid);
  properties.remove(ObjectMetaDataManager.UUID_FIELD);
  Long accountId = DataAccessor.fromDataFieldOf(agent).withKey(AgentConstants.DATA_AGENT_RESOURCES_ACCOUNT_ID).as(Long.class);
  if (accountId == null) {
    accountId = agent.getAccountId();
  }
  properties.put(ObjectMetaDataManager.ACCOUNT_FIELD, accountId);
  properties.put(AgentConstants.ID_REF, agent.getId());
  return properties;
}

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

@Override
  public Instance doWithLock() {
    Instance instance = factoryDao.getInstanceByAgent(agent.getId());
    if (instance == null) {
      instance = DeferredUtils.nest(new Callable<Instance>() {
        @Override
        public Instance call() throws Exception {
          return resourceDao.createAndSchedule(Instance.class, properties);
        }
      });
    }
    return instance;
  }
});

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

protected void pingSuccess(Agent agent, Ping pong) {
  status.getUnchecked(agent.getId()).success();
  agentResourceManager.processPingReply(pong);
  pingInstanceMonitor.pingReply(pong);
}

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

private Map<String, Object> getInstanceProperties(Agent agent, AgentInstanceBuilderImpl builder) {
  Map<Object, Object> properties = new HashMap<Object, Object>();
  properties.put(INSTANCE.ACCOUNT_ID, getAccountId(builder));
  properties.put(INSTANCE.AGENT_ID, agent.getId());
  properties.put(InstanceConstants.FIELD_IMAGE_UUID, builder.getImageUuid());
  properties.put(INSTANCE.NAME, builder.getName());
  properties.put(INSTANCE.ZONE_ID, agent.getZoneId());
  properties.put(INSTANCE.KIND, builder.getInstanceKind());
  properties.put(InstanceConstants.FIELD_PRIVILEGED, builder.isPrivileged());
  properties.put(InstanceConstants.FIELD_NETWORK_IDS, getNetworkIds(agent, builder));
  properties.putAll(builder.getParams());
  addAdditionalProperties(properties, agent, builder);
  return objectManager.convertToPropertiesFor(Instance.class, properties);
}

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

private Instance getInstance(Agent agent, AgentInstanceBuilderImpl builder) {
  Instance instance = factoryDao.getInstanceByAgent(agent.getId());
  if (instance != null) {
    return instance;
  }
  Map<String, Object> properties = getInstanceProperties(agent, builder);
  return createInstance(agent, properties, builder);
}

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

@Override
public HandlerResult handle(ProcessState state, ProcessInstance process) {
  Instance instance = (Instance)state.getResource();
  Agent agent = agentInstanceFactory.createAgent(instance);
  return agent == null ? null : new HandlerResult((Object)INSTANCE.AGENT_ID, agent.getId());
}

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

@Override
  public List<? extends Instance> getInstances(Object obj) {
    Host host = null;

    if (obj instanceof Agent) {
      Agent agent = (Agent) obj;
      host = objectManager.findAny(Host.class, HOST.AGENT_ID, agent.getId(), HOST.REMOVED, null);
    } else if (obj instanceof Host) {
      host = (Host) obj;
    }

    if (host == null) {
      return null;
    }
    return serviceDao.getInstancesWithHealtcheckEnabled(host.getAccountId());
  }
}

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

protected Agent getAgent() {
  Agent agent = objectManager.loadResource(Agent.class, ApiUtils.getPolicy().getOption(Policy.AGENT_ID));
  if (agent == null) {
    throw new ClientVisibleException(ResponseCodes.FORBIDDEN, VERIFY_AGENT);
  }
  return agentDao.getHostAgentForDelegate(agent.getId());
}

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

protected void validate(HostApiProxyToken proxyToken) {
    String reportedUuid = proxyToken.getReportedUuid();

    Policy policy = ApiUtils.getPolicy();
    Agent agent = objectManager.loadResource(Agent.class, policy.getOption(Policy.AGENT_ID));
    if (agent == null) {
      throw new ClientVisibleException(ResponseCodes.FORBIDDEN, VERIFY_AGENT);
    }
    Map<String, Host> hosts = agentDao.getHosts(agent.getId());
    Host host = hosts.get(reportedUuid);
    if (host == null) {
      throw new ValidationErrorException(ValidationErrorCodes.INVALID_REFERENCE, HostConstants.FIELD_REPORTED_UUID);
    }
  }
}

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

protected AgentAndHost loadAgentAndHostData(ImmutablePair<Long, String> agentIdAndHostUuid) {
  Long agentId = agentIdAndHostUuid.left;
  String hostUuid = agentIdAndHostUuid.right;
  Agent agent = objectManager.loadResource(Agent.class, agentId);
  Host host = null;
  Map<String, Host> hosts = null;
  if (agent != null) {
    hosts = agentDao.getHosts(agent.getId());
    host = hosts.get(hostUuid);
  }
  if (agent == null || agent.getAccountId() == null || host == null)
    throw new CantFindAgentAndHostException();
  return new AgentAndHost(agent.getAccountId(), host.getId());
}

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

public Event handle(Agent agent, Event event) throws IOException {
  ConfigUpdate update = jsonMapper.convertValue(event, ConfigUpdate.class);
  Map<String, Object> authMap = AgentUtils.getAgentAuth(agent, objectManager);
  if (authMap == null) {
    return null;
  }
  String auth = ObjectUtils.toString(authMap.get("CATTLE_AGENT_INSTANCE_AUTH"), null);
  if (auth == null) {
    throw new IllegalStateException("Failed to get auth for agent [" + agent.getId() + "]");
  }
  for (ConfigUpdateItem item : update.getData().getItems()) {
    downloadAndPost(auth, update.getData().getConfigUrl(), item);
  }
  return EventVO.reply(event);
}

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

protected ConfigUpdateRequest before(ConfigUpdateRequest request, Agent agent) {
  if (request == null) {
    request = ConfigUpdateRequest.forResource(Agent.class, agent.getId());
    for (String item : ITEMS.get()) {
      request.addItem(item).withIncrement(false).setCheckInSyncOnly(true);
    }
  }
  statusManager.updateConfig(request);
  return request;
}

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

@Override
public Instance getInstance(Agent agent) {
  return create()
      .selectFrom(INSTANCE)
      .where(INSTANCE.AGENT_ID.eq(agent.getId())
          .and(INSTANCE.REMOVED.isNull())
          .and(INSTANCE.STATE.notIn(InstanceConstants.STATE_ERROR, InstanceConstants.STATE_ERRORING,
              CommonStatesConstants.REMOVING)))
      .fetchOne();
}

相关文章