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

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

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

Agent.getUri介绍

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

代码示例

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

protected EventService getWrappedEventService(long agentId) {
  Agent agent = objectManager.loadResource(Agent.class, agentId);
  if (agent == null) {
    return null;
  }
  String uri = agent.getUri();
  if (uri != null && !uri.startsWith(EVENTING)) {
    return null;
  }
  return new WrappedEventService(agentId, false, eventService, null, jsonMapper, delegateDao);
}

代码示例来源: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

private void cleanAgents(HashSet<String> existingLinks) {
  List<Agent> agents = objectManager.find(Agent.class, AGENT.REMOVED, new Condition(ConditionType.NULL),
      AGENT.EXTERNAL_ID, new Condition(ConditionType.NOTNULL));
  
  if(agents.size() > 0) { 
    for(Agent agent : agents) {
      try {
        String[] uri = agent.getUri().substring(RegionUtil.EXTERNAL_AGENT_URI_PREFIX.length()).split("_");
        String regionEnv = String.format("%s:%s", uri[0], uri[1]);
        if (existingLinks.contains(regionEnv)) {
          continue;
        }
        cleanupAgent(agent);
      } catch (Exception ex) {
        log.warn(String.format("Fail to remove agent ", agent.getId(), ex));
      }
    }
  }
}

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

protected Instance createInstance(final Agent agent, final Map<String, Object> properties, final AgentInstanceBuilderImpl builder) {
  return lockManager.lock(new AgentInstanceAgentCreateLock(agent.getUri()), new LockCallback<Instance>() {
    @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 Simulator makeSimulator(String agentId) {
  Agent agent = objectManager.loadResource(Agent.class, agentId);
  if (agent == null) {
    return NULL_SIMULATOR;
  }
  String uri = agent.getUri();
  if (uri == null) {
    return NULL_SIMULATOR;
  }
  if (uri.startsWith("sim://")) {
    return new AgentConnectionSimulator(objectManager, agent, processors);
  }
  Map<String, Object> instanceData = new LinkedHashMap<>();
  Agent hostAgent = agentLocator.getAgentForDelegate(Long.parseLong(agentId), instanceData);
  if (hostAgent == null) {
    return NULL_SIMULATOR;
  }
  Simulator target = cache.getUnchecked(hostAgent.getId().toString());
  if (target == null) {
    return NULL_SIMULATOR;
  }
  return new DelegateSimulator(target, instanceData);
}

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

String uri = agent.getUri();
if (uri != null && !uri.startsWith(DELEGATE)) {
  return null;
  log.error("Failed to find instance to delegate to for agent [{}] uri [{}]", agent.getId(), agent.getUri());
  throw new IllegalStateException("Delegate [" + agent.getUri() + "] has no instance associated");
  log.error("Failed to find host to delegate to for agent [{}] uri [{}]", agent.getId(), agent.getUri());
  return null;

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

@Override
public Event handle(AgentConnectionSimulator simulator, Event event) throws Exception {
  if (!FrameworkEvents.PING.equals(event.getName()))
    return null;
  Agent agent = simulator.getAgent();
  Ping ping = jsonMapper.convertValue(event, Ping.class);
  Ping pong = jsonMapper.convertValue(EventVO.reply(event).withData(ping.getData()), Ping.class);
  if (ping.getOption(Ping.RESOURCES) && !agent.getUri().startsWith("delegate://")) {
    addResources(pong, agent);
  }
  if (ping.getOption(Ping.INSTANCES) && !agent.getUri().startsWith("delegate://")) {
    addInstances(simulator, pong, agent);
  }
  return pong;
}

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

@Override
public Object create(String type, ApiRequest request, ResourceManager next) {
  String ip = request.getClientIp();
  Agent agent = request.proxyRequestObject(Agent.class);
  /*
   * This ensures that the accountId is always set from the request and
   * never overwritten by the default accountId setting logic. In the
   * situation in which the client doesn't have access to the accountId
   * field, the result will be null, which is correct. You want it to be
   * null so that the AgentCreate logic will create an account for this
   * Agent
   */
  agent.setAccountId(agent.getAccountId());
  String uri = agent.getUri();
  String user = DataUtils.getFieldFromRequest(request, AgentConstants.USER, String.class);
  if (uri == null) {
    uri = getUri(user, ip);
    if (uri != null) {
      isUnique(uri);
      agent.setUri(uri);
    }
  }
  return super.create(type, request, next);
}

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

if (agent.getUri() == null || agent.getUri().startsWith(prefix)) {
  return new HandlerResult();

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

/**
 * {@inheritDoc}
 */
@Override
public void from(io.cattle.platform.core.model.Agent from) {
  setId(from.getId());
  setName(from.getName());
  setAccountId(from.getAccountId());
  setKind(from.getKind());
  setUuid(from.getUuid());
  setDescription(from.getDescription());
  setState(from.getState());
  setCreated(from.getCreated());
  setRemoved(from.getRemoved());
  setRemoveTime(from.getRemoveTime());
  setData(from.getData());
  setUri(from.getUri());
  setManagedConfig(from.getManagedConfig());
  setZoneId(from.getZoneId());
  setExternalId(from.getExternalId());
}

相关文章