Examples of AgentInfo


Examples of org.ngrinder.model.AgentInfo

    agentManagerService.collectAgentSystemData();
  }

  @Test
  public void testSaveGetDeleteAgent() {
    AgentInfo agent = saveAgent("save");
    AgentInfo agent2 = agentManagerService.getOne(agent.getId());
    Assert.assertNotNull(agent2);

    List<AgentInfo> agentListDB = agentManagerService.getAllLocal();
    Assert.assertNotNull(agentListDB);
View Full Code Here

Examples of org.ngrinder.model.AgentInfo

    agent2 = agentManagerService.getOne(agent.getId());
    Assert.assertNull(agent2);
  }

  private AgentInfo saveAgent(String key) {
    AgentInfo agent = new AgentInfo();
    agent.setIp("1.1.1.1");
    agent.setName("TestRegion" + key);
    agent.setPort(8080);
    agent.setRegion("TestRegion" + key);
    agent.setState(AgentControllerState.BUSY);
    agentRepository.save(agent);
    return agent;
  }
View Full Code Here

Examples of org.ngrinder.model.AgentInfo

    assertThat(countMap.get(currRegion), notNullValue());
  }

  @Test
  public void testCheckAgentState() {
    AgentInfo agentInfo = new AgentInfo();
    agentInfo.setName("localhost");
    agentInfo.setRegion(spiedConfig.getRegion());
    agentInfo.setIp("127.127.127.127");
    agentInfo.setPort(1);
    agentInfo.setState(AgentControllerState.READY);
    agentRepository.save(agentInfo);
    agentManagerService.expireLocalCache();
    agentManagerService.checkAgentState();
    AgentInfo agentInDB = agentRepository.findOne(agentInfo.getId());
    assertThat(agentInDB.getIp(), is(agentInfo.getIp()));
    assertThat(agentInDB.getName(), is(agentInfo.getName()));
    assertThat(agentInDB.getState(), is(AgentControllerState.INACTIVE));
  }
View Full Code Here

Examples of org.ngrinder.model.AgentInfo

      }
    }

    for (Map.Entry<String, AgentInfo> each : agentInDBMap.entrySet()) {
      String agentKey = each.getKey();
      AgentInfo agentInfo = each.getValue();
      AgentControllerIdentityImplementation agentIdentity = attachedAgentMap.remove(agentKey);
      if (agentIdentity == null) {
        // this agent is not attached to controller
        agentInfo.setState(AgentControllerState.INACTIVE);
        stateUpdatedAgents.add(agentInfo);
      } else if (!hasSameInfo(agentInfo, agentIdentity)) {
        agentInfo.setRegion(agentIdentity.getRegion());
        agentInfo.setPort(agentManager.getAgentConnectingPort(agentIdentity));
        agentInfo.setVersion(agentManager.getAgentVersion(agentIdentity));
        updatedAgents.add(agentInfo);
      } else if (!hasSameState(agentInfo, agentIdentity)) {
        agentInfo.setState(agentManager.getAgentState(agentIdentity));
        stateUpdatedAgents.add(agentInfo);
      }
    }

    // step2. check all attached agents, whether they are new, and not saved
    // in DB.
    for (AgentControllerIdentityImplementation agentIdentity : attachedAgentMap.values()) {
      final AgentInfo agentInfo = fillUp(new AgentInfo(), agentIdentity);
      newAgents.add(agentInfo);
    }
    cachedLocalAgentService.updateAgents(newAgents, updatedAgents, stateUpdatedAgents, removedAgents);
    if (!newAgents.isEmpty() || !removedAgents.isEmpty()) {
      expireLocalCache();
View Full Code Here

Examples of org.ngrinder.model.AgentInfo

    return agents;
  }

  private AgentInfo createAgentInfo(AgentControllerIdentityImplementation agentIdentity,
                                    Map<String, AgentInfo> agentInfoMap) {
    AgentInfo agentInfo = agentInfoMap.get(createKey(agentIdentity));
    if (agentInfo == null) {
      agentInfo = new AgentInfo();
    }
    return fillUp(agentInfo, agentIdentity);
  }
View Full Code Here

Examples of org.ngrinder.model.AgentInfo

   * @see org.ngrinder.service.IAgentManagerService#getAll(long,
   * boolean)
   */
  @Override
  public AgentInfo getOne(Long id, boolean includeAgentIdentity) {
    AgentInfo findOne = agentManagerRepository.findOne(id);
    if (findOne == null) {
      return null;
    }
    if (includeAgentIdentity) {
      AgentControllerIdentityImplementation agentIdentityByIp = getAgentIdentityByIpAndName(findOne.getIp(),
          findOne.getName());
      return fillUp(findOne, agentIdentityByIp);
    } else {
      return findOne;
    }
  }
View Full Code Here

Examples of org.ngrinder.model.AgentInfo

   * @param id      id
   * @param approve true/false
   */
  @Transactional
  public AgentInfo approve(Long id, boolean approve) {
    AgentInfo found = agentManagerRepository.findOne(id);
    if (found != null) {
      found.setApproved(approve);
      agentManagerRepository.save(found);
      expireLocalCache();
    }
    return found;
  }
View Full Code Here

Examples of org.ngrinder.model.AgentInfo

   *
   * @param id identity of agent to stop.
   */
  @Transactional
  public void stopAgent(Long id) {
    AgentInfo agent = getOne(id, true);
    if (agent == null) {
      return;
    }
    getAgentManager().stopAgent(agent.getAgentIdentity());
  }
View Full Code Here

Examples of org.ngrinder.model.AgentInfo

   * org.ngrinder.service.IAgentManagerService#updateAgentLib
   * (java.lang.String)
   */
  @Override
  public void update(Long id) {
    AgentInfo agent = getOne(id, true);
    if (agent == null) {
      return;
    }
    updateAgent(agent.getAgentIdentity());
  }
View Full Code Here

Examples of org.ngrinder.model.AgentInfo

    }

    // step2. check all attached agents, whether they are new, and not saved
    // in DB.
    for (AgentControllerIdentityImplementation agentIdentity : attachedAgentMap.values()) {
      AgentInfo agentInfo = agentManagerRepository.findByIpAndHostName(
          agentIdentity.getIp(),
          agentIdentity.getName());
      if (agentInfo == null) {
        agentInfo = new AgentInfo();
        newAgents.add(fillUp(agentInfo, agentIdentity));
      } else {
        updatedAgents.add(fillUp(agentInfo, agentIdentity));
      }
      if (!isCurrentRegion(agentIdentity)) {
        agentInfo.setState(WRONG_REGION);
        agentInfo.setApproved(false);
      }
    }

    cachedLocalAgentService.updateAgents(newAgents, updatedAgents, stateUpdatedAgents, null);
    if (!newAgents.isEmpty() || !updatedAgents.isEmpty()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.