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

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

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

Agent.getState介绍

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

代码示例

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

private boolean isAgentDisconnected(Host host) {
  if (host == null) {
    return false;
  }
  Agent agent = context.objectManager.loadResource(Agent.class, host.getAgentId());
  if (agent != null && (AgentConstants.STATE_RECONNECTING.equals(agent.getState()) ||
      AgentConstants.STATE_DISCONNECTED.equals(agent.getState()) || AgentConstants.STATE_DISCONNECTING
        .equals(agent.getState()))) {
    return true;
  }
  return false;
}

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

@Override
protected Event callSync(RemoteAgent remoteAgent, Event event, EventCallOptions options) {
  Agent agent = loadResource(Agent.class, remoteAgent.getAgentId());
  if (agent != null && (AgentConstants.STATE_RECONNECTING.equals(agent.getState()) ||
      AgentConstants.STATE_DISCONNECTED.equals(agent.getState()))) {
    return null;
  }
  return super.callSync(remoteAgent, event, options);
}

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

@Override
public void deleteAgent(Instance instance) {
  if (!shouldCreateAgent(instance) || instance.getAgentId() == null) {
    return;
  }
  Agent agent = objectManager.loadResource(Agent.class, instance.getAgentId());
  if (agent == null) {
    return;
  }
  if (CommonStatesConstants.DEACTIVATING.equals(agent.getState())) {
    return;
  }
  try {
    processManager.scheduleStandardProcess(StandardProcess.DEACTIVATE, agent,
        ProcessUtils.chainInData(new HashMap<String, Object>(), AgentConstants.PROCESS_DEACTIVATE, AgentConstants.PROCESS_REMOVE));
  } catch (ProcessCancelException e) {
    try {
      processManager.scheduleStandardProcess(StandardProcess.REMOVE, agent, null);
    } catch (ProcessCancelException e1) {
    }
  }
}

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

protected void handleReconnecting(ProcessState state, Instance instance) {
  boolean reconnecting = false;
  InstanceHealthCheck healthCheck = DataAccessor.field(instance,
      InstanceConstants.FIELD_HEALTH_CHECK, jsonMapper, InstanceHealthCheck.class);
  for (InstanceHostMap map : mapDao.findNonRemoved(InstanceHostMap.class, Instance.class, instance.getId())) {
    Host host = objectManager.loadResource(Host.class, map.getHostId());
    Agent agent = host == null ? null : objectManager.loadResource(Agent.class, host.getAgentId());
    if (agent != null && (AgentConstants.STATE_RECONNECTING.equals(agent.getState()) ||
        AgentConstants.STATE_DISCONNECTED.equals(agent.getState()))) {
      reconnecting = true;
    } else {
      reconnecting = false;
      break;
    }
  }
  if (reconnecting && (healthCheck != null || instance.getFirstRunning() == null)) {
    getObjectProcessManager().scheduleProcessInstance(InstanceConstants.PROCESS_STOP, instance,
        CollectionUtils.asMap(InstanceConstants.REMOVE_OPTION, true));
  }
}

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

protected void pingFailure(Agent agent) {
  long count = status.getUnchecked(agent.getId()).failed();
  if (count < 3) {
    log.info("Missed ping from agent [{}] count [{}]", agent.getId(), count);
  } else {
    log.error("Failed to get ping from agent [{}] count [{}]", agent.getId(), count);
  }
  if (count >= BAD_PINGS.get()) {
    try {
      agent = objectManager.reload(agent);
      if (CommonStatesConstants.ACTIVE.equals(agent.getState())) {
        Host host = objectManager.findAny(Host.class, HOST.AGENT_ID, agent.getId());
        if (host != null) {
          log.error("Scheduling reconnect for agent [{}] host [{}] count [{}]", agent.getId(), host.getId(), count);
        } else {
          log.error("Scheduling reconnect for agent [{}] count [{}]", agent.getId(), count);
        }
        processManager.scheduleProcessInstance(AgentConstants.PROCESS_RECONNECT, agent, null);
      }
    } catch (ProcessInstanceException e) {
      if (e.getExitReason() != ExitReason.CANCELED) {
        throw e;
      }
    }
  }
}

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

protected Long getAgent() {
  ApiRequest request = ApiContext.getContext().getApiRequest();
  Long agentId = getRawAgentId();
  if (agentId != null) {
    return agentId;
  }
  String type = request.getSchemaFactory().getSchemaName(Agent.class);
  ResourceManager rm = getLocator().getResourceManagerByType(type);
  Long id = null;
  /*  This really isn't the best logic.  Basically we are looking for agents with state in STATES */
  for (Object obj : rm.list(type, null, Pagination.limit(2))) {
    if (!(obj instanceof Agent)) {
      continue;
    }
    Agent agent = (Agent)obj;
    if (STATES.contains(agent.getState())) {
      if (id != null) {
        throw new ValidationErrorException(ValidationErrorCodes.MISSING_REQUIRED, "agentId");
      } else {
        if (DISCONNECTED.contains(agent.getState())) {
          processManager.scheduleProcessInstance(AgentConstants.PROCESS_RECONNECT, agent, null);
        }
        id = agent.getId();
      }
    }
  }
  return id;
}

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

for (Host host : hosts) {
  Agent agent = objectManager.loadResource(Agent.class, host.getAgentId());
  if (agent == null || !CommonStatesConstants.ACTIVE.equals(agent.getState())) {
    continue;

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

if (agent == null || !CommonStatesConstants.ACTIVE.equals(agent.getState())) {
  throw new ClientVisibleException(ResponseCodes.SERVICE_UNAVAILABLE);

代码示例来源: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());
}

相关文章