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

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


  @Inject
  EngineHostDao _hostDao;

    @Before
  public void setUp() {
  EngineDataCenterVO dc = new EngineDataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null,  "10.0.0.1/24",
        null, null, NetworkType.Basic, null, null, true,  true, null, null);
    Mockito.when(dcDao.findByUuid(Mockito.anyString())).thenReturn(dc);
    Mockito.when(dcDao.persist((EngineDataCenterVO) Mockito.anyObject())).thenReturn(dc);

    EngineHostPodVO pod = new EngineHostPodVO("lab", 123, "10.0.0.1", "10.0.0.1", 24, "test");
View Full Code Here


    protected StateMachine2<State, Event, DataCenterResourceEntity> _stateMachine = DataCenterResourceEntity.State.s_fsm;

  @Override
  public EngineDataCenterVO loadDataCenter(String dataCenterId) {
  EngineDataCenterVO dataCenterVO = _dataCenterDao.findByUuid(dataCenterId);
  if(dataCenterVO == null){
    throw new InvalidParameterValueException("Zone does not exist");
  }
  return dataCenterVO;
  }
View Full Code Here

        return dcs;
    }

    @Override
    public EngineDataCenterVO findByTokenOrIdOrName(String tokenOrIdOrName) {
        EngineDataCenterVO result = findByToken(tokenOrIdOrName);
        if (result == null) {
            result = findByName(tokenOrIdOrName);
            if (result == null) {
                try {
                    Long dcId = Long.parseLong(tokenOrIdOrName);
View Full Code Here

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

        update(id, zone);

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


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

        EngineDataCenterVO vo = findById(zoneEntity.getId());

        Date oldUpdatedTime = vo.getLastUpdated();

        SearchCriteria<EngineDataCenterVO> 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()) {
            EngineDataCenterVO dbDC = findByIdIncludingRemoved(vo.getId());
            if (dbDC != null) {
                StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
                str.append(": DB Data={id=").append(dbDC.getId()).append("; state=").append(dbDC.getState()).append(";updatedTime=")
                .append(dbDC.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

    EngineHostDao _hostDao;

    @Override
    @Before
    public void setUp() {
        EngineDataCenterVO dc =
            new EngineDataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Basic, null, null,
                true, true, null, null);
        Mockito.when(dcDao.findByUuid(Matchers.anyString())).thenReturn(dc);
        Mockito.when(dcDao.persist((EngineDataCenterVO)Matchers.anyObject())).thenReturn(dc);

        EngineHostPodVO pod = new EngineHostPodVO("lab", 123, "10.0.0.1", "10.0.0.1", 24, "test");
View Full Code Here

        return dcs;
    }

    @Override
    public EngineDataCenterVO findByTokenOrIdOrName(String tokenOrIdOrName) {
        EngineDataCenterVO result = findByToken(tokenOrIdOrName);
        if (result == null) {
            result = findByName(tokenOrIdOrName);
            if (result == null) {
                try {
                    Long dcId = Long.parseLong(tokenOrIdOrName);
View Full Code Here

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

        update(id, zone);

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

    }

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

        EngineDataCenterVO vo = findById(zoneEntity.getId());

        Date oldUpdatedTime = vo.getLastUpdated();

        SearchCriteria<EngineDataCenterVO> 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()) {
            EngineDataCenterVO dbDC = findByIdIncludingRemoved(vo.getId());
            if (dbDC != null) {
                StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
                str.append(": DB Data={id=").append(dbDC.getId()).append("; state=").append(dbDC.getState()).append(";updatedTime=").append(dbDC.getLastUpdated());
                str.append(": New Data={id=")
                    .append(vo.getId())
                    .append("; state=")
                    .append(nextState)
                    .append("; event=")
View Full Code Here

    protected StateMachine2<State, Event, DataCenterResourceEntity> _stateMachine = DataCenterResourceEntity.State.s_fsm;

    @Override
    public EngineDataCenterVO loadDataCenter(String dataCenterId) {
        EngineDataCenterVO dataCenterVO = _dataCenterDao.findByUuid(dataCenterId);
        if (dataCenterVO == null) {
            throw new InvalidParameterValueException("Zone does not exist");
        }
        return dataCenterVO;
    }
View Full Code Here

TOP

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

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.