Package org.apache.cloudstack.engine.datacenter.entity.api.db

Examples of org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO


    @Override
    public boolean remove(Long id) {
        Transaction txn = Transaction.currentTxn();
        txn.start();
        EngineClusterVO cluster = createForUpdate();
        cluster.setName(null);
        cluster.setGuid(null);

        update(id, cluster);

        boolean result = super.remove(id);
        txn.commit();
View Full Code Here


    }

  @Override
  public boolean updateState(State currentState, Event event, State nextState, DataCenterResourceEntity clusterEntity, Object data) {

    EngineClusterVO vo = findById(clusterEntity.getId());

    Date oldUpdatedTime = vo.getLastUpdated();

        SearchCriteria<EngineClusterVO> sc = StateChangeSearch.create();
        sc.setParameters("id", vo.getId());
        sc.setParameters("state", currentState);

        UpdateBuilder builder = getUpdateBuilder(vo);
        builder.set(vo, "state", nextState);
        builder.set(vo, "lastUpdated", new Date());

        int rows = update(vo, sc);

        if (rows == 0 && s_logger.isDebugEnabled()) {
            EngineClusterVO dbCluster = findByIdIncludingRemoved(vo.getId());
            if (dbCluster != null) {
                StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
                str.append(": DB Data={id=").append(dbCluster.getId()).append("; state=").append(dbCluster.getState()).append(";updatedTime=")
                .append(dbCluster.getLastUpdated());
                str.append(": New Data={id=").append(vo.getId()).append("; state=").append(nextState).append("; event=").append(event).append("; updatedTime=").append(vo.getLastUpdated());
                str.append(": stale Data={id=").append(vo.getId()).append("; state=").append(currentState).append("; event=").append(event).append("; updatedTime=").append(oldUpdatedTime);
            } else {
                s_logger.debug("Unable to update dataCenter: id=" + vo.getId() + ", as there is no such dataCenter exists in the database anymore");
            }
View Full Code Here

    EngineHostPodVO pod = new EngineHostPodVO("lab", 123, "10.0.0.1", "10.0.0.1", 24, "test");
    Mockito.when(_podDao.findByUuid(Mockito.anyString())).thenReturn(pod);
    Mockito.when(_podDao.persist((EngineHostPodVO) Mockito.anyObject())).thenReturn(pod);

  EngineClusterVO cluster = new EngineClusterVO();
    Mockito.when(_clusterDao.findByUuid(Mockito.anyString())).thenReturn(cluster);
    Mockito.when(_clusterDao.persist((EngineClusterVO) Mockito.anyObject())).thenReturn(cluster);

    EngineHostVO host = new EngineHostVO("68765876598");
    Mockito.when(_hostDao.findByUuid(Mockito.anyString())).thenReturn(host);
View Full Code Here

    return pod;
  }

  @Override
  public EngineClusterVO loadCluster(String uuid) {
    EngineClusterVO cluster = _clusterDao.findByUuid(uuid);
  if(cluster == null){
    throw new InvalidParameterValueException("Pod does not exist");
  }
    return cluster;
  }
View Full Code Here

        EngineHostPodVO pod = new EngineHostPodVO("lab", 123, "10.0.0.1", "10.0.0.1", 24, "test");
        Mockito.when(_podDao.findByUuid(Matchers.anyString())).thenReturn(pod);
        Mockito.when(_podDao.persist((EngineHostPodVO)Matchers.anyObject())).thenReturn(pod);

        EngineClusterVO cluster = new EngineClusterVO();
        Mockito.when(_clusterDao.findByUuid(Matchers.anyString())).thenReturn(cluster);
        Mockito.when(_clusterDao.persist((EngineClusterVO)Matchers.anyObject())).thenReturn(cluster);

        EngineHostVO host = new EngineHostVO("68765876598");
        Mockito.when(_hostDao.findByUuid(Matchers.anyString())).thenReturn(host);
View Full Code Here

    @Override
    public boolean remove(Long id) {
        TransactionLegacy txn = TransactionLegacy.currentTxn();
        txn.start();
        EngineClusterVO cluster = createForUpdate();
        cluster.setName(null);
        cluster.setGuid(null);

        update(id, cluster);

        boolean result = super.remove(id);
        txn.commit();
View Full Code Here

    }

    @Override
    public boolean updateState(State currentState, Event event, State nextState, DataCenterResourceEntity clusterEntity, Object data) {

        EngineClusterVO vo = findById(clusterEntity.getId());

        Date oldUpdatedTime = vo.getLastUpdated();

        SearchCriteria<EngineClusterVO> sc = StateChangeSearch.create();
        sc.setParameters("id", vo.getId());
        sc.setParameters("state", currentState);

        UpdateBuilder builder = getUpdateBuilder(vo);
        builder.set(vo, "state", nextState);
        builder.set(vo, "lastUpdated", new Date());

        int rows = update(vo, sc);

        if (rows == 0 && s_logger.isDebugEnabled()) {
            EngineClusterVO dbCluster = findByIdIncludingRemoved(vo.getId());
            if (dbCluster != null) {
                StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
                str.append(": DB Data={id=")
                    .append(dbCluster.getId())
                    .append("; state=")
                    .append(dbCluster.getState())
                    .append(";updatedTime=")
                    .append(dbCluster.getLastUpdated());
                str.append(": New Data={id=")
                    .append(vo.getId())
                    .append("; state=")
                    .append(nextState)
                    .append("; event=")
View Full Code Here

        return pod;
    }

    @Override
    public EngineClusterVO loadCluster(String uuid) {
        EngineClusterVO cluster = _clusterDao.findByUuid(uuid);
        if (cluster == null) {
            throw new InvalidParameterValueException("Pod does not exist");
        }
        return cluster;
    }
View Full Code Here

   
    EngineHostPodVO pod = new EngineHostPodVO("lab", 123, "10.0.0.1", "10.0.0.1", 24, "test");
    Mockito.when(_podDao.findByUuid(Mockito.anyString())).thenReturn(pod);
    Mockito.when(_podDao.persist((EngineHostPodVO) Mockito.anyObject())).thenReturn(pod);           
   
      EngineClusterVO cluster = new EngineClusterVO();
    Mockito.when(_clusterDao.findByUuid(Mockito.anyString())).thenReturn(cluster);
    Mockito.when(_clusterDao.persist((EngineClusterVO) Mockito.anyObject())).thenReturn(cluster);
   
    EngineHostVO host = new EngineHostVO("68765876598");
    Mockito.when(_hostDao.findByUuid(Mockito.anyString())).thenReturn(host);
View Full Code Here

    @Override
    public boolean remove(Long id) {
        TransactionLegacy txn = TransactionLegacy.currentTxn();
        txn.start();
        EngineClusterVO cluster = createForUpdate();
        cluster.setName(null);
        cluster.setGuid(null);

        update(id, cluster);

        boolean result = super.remove(id);
        txn.commit();
View Full Code Here

TOP

Related Classes of org.apache.cloudstack.engine.datacenter.entity.api.db.EngineClusterVO

Copyright © 2018 www.massapicom. 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.