Examples of HostDAO


Examples of com.cloud.host.dao.HostDao

public class ChildTestConfiguration extends TestConfiguration {

    @Override
    @Bean
    public HostDao hostDao() {
        HostDao dao = super.hostDao();
        HostDao nDao = Mockito.spy(dao);
        return nDao;
    }
View Full Code Here

Examples of com.cloud.host.dao.HostDao

public class ChildTestConfiguration extends TestConfiguration {

    @Override
    @Bean
    public HostDao hostDao() {
        HostDao dao = super.hostDao();
        HostDao nDao = Mockito.spy(dao);
        return nDao;
    }
View Full Code Here

Examples of com.cloud.host.dao.HostDao

      }
    }
  }
 
  public void sequence() {
    final HostDao hostDao = new HostDaoImpl();
    long seq = hostDao.getNextSequence(1);
    s_logger.info("******* seq : " + seq + " ********");
   
    HashMap<Long, Long> hashMap = new HashMap<Long, Long>();
    final Map<Long, Long> map = Collections.synchronizedMap(hashMap);
   
    s_count = 0;
    final long maxCount = 1000000// test one million times
   
    Thread t1 = new Thread(new Runnable() {
      public void run() {
        while(s_count < maxCount) {
          s_count++;
          long seq = hostDao.getNextSequence(1);
          Assert.assertTrue(map.put(seq, seq) == null);
        }
      }
    });
   
    Thread t2 = new Thread(new Runnable() {
      public void run() {
        while(s_count < maxCount) {
          s_count++;
          long seq = hostDao.getNextSequence(1);
          Assert.assertTrue(map.put(seq, seq) == null);
        }
      }
    });
   
View Full Code Here

Examples of com.cloud.host.dao.HostDao

    for(int i = 0; i < testThreads; i++) {
      final int current = i;
      threads[i] = new Thread(new Runnable() {
        public void run() {
         
          final HostDao hostDao = new HostDaoImpl();
          while(true) {
            Transaction txn = Transaction.currentTxn();
            try {
              HostVO host = hostDao.acquireInLockTable(getRandomLockId(), 10);
              if(host != null) {
                s_logger.info("Thread " + (current + 1) + " acquired lock");
               
                try { Thread.sleep(getRandomMilliseconds(1000, 5000)); } catch (InterruptedException e) {}
               
                s_logger.info("Thread " + (current + 1) + " released lock");
                hostDao.releaseFromLockTable(host.getId());
               
                try { Thread.sleep(getRandomMilliseconds(1000, 5000)); } catch (InterruptedException e) {}
              } else {
                s_logger.info("Thread " + (current + 1) + " is not able to acquire lock");
              }
View Full Code Here

Examples of com.cloud.host.dao.HostDao

            }
        }
    }

    public void sequence() {
        final HostDao hostDao = new HostDaoImpl();
        long seq = hostDao.getNextSequence(1);
        s_logger.info("******* seq : " + seq + " ********");

        HashMap<Long, Long> hashMap = new HashMap<Long, Long>();
        final Map<Long, Long> map = Collections.synchronizedMap(hashMap);

        s_count = 0;
        final long maxCount = 1000000// test one million times

        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                while(s_count < maxCount) {
                    s_count++;
                    long seq = hostDao.getNextSequence(1);
                    Assert.assertTrue(map.put(seq, seq) == null);
                }
            }
        });

        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                while(s_count < maxCount) {
                    s_count++;
                    long seq = hostDao.getNextSequence(1);
                    Assert.assertTrue(map.put(seq, seq) == null);
                }
            }
        });

View Full Code Here

Examples of com.cloud.host.dao.HostDao

            final int current = i;
            threads[i] = new Thread(new Runnable() {
                @Override
                public void run() {

                    final HostDao hostDao = new HostDaoImpl();
                    while(true) {
                        Transaction txn = Transaction.currentTxn();
                        try {
                            HostVO host = hostDao.acquireInLockTable(getRandomLockId(), 10);
                            if(host != null) {
                                s_logger.info("Thread " + (current + 1) + " acquired lock");

                                try { Thread.sleep(1000); } catch (InterruptedException e) {}

                                s_logger.info("Thread " + (current + 1) + " released lock");
                                hostDao.releaseFromLockTable(host.getId());

                                try { Thread.sleep(1000); } catch (InterruptedException e) {}
                            } else {
                                s_logger.info("Thread " + (current + 1) + " is not able to acquire lock");
                            }
View Full Code Here

Examples of com.cloud.host.dao.HostDao

public class ChildTestConfiguration extends TestConfiguration {
 
  @Override
  @Bean
  public HostDao hostDao() {
    HostDao dao = super.hostDao();
    HostDao nDao = Mockito.spy(dao);
    return nDao;
  }
View Full Code Here

Examples of com.cloud.host.dao.HostDao

public class ChildTestConfiguration extends TestConfiguration {
 
  @Override
  @Bean
  public HostDao hostDao() {
    HostDao dao = super.hostDao();
    HostDao nDao = Mockito.spy(dao);
    return nDao;
  }
View Full Code Here

Examples of org.apache.ambari.server.orm.dao.HostDAO

   
  private void persistComponentEntities(HostComponentStateEntity stateEntity, HostComponentDesiredStateEntity desiredStateEntity, ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity) {
    ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO = injector.getInstance(ServiceComponentDesiredStateDAO.class);
    HostComponentStateDAO hostComponentStateDAO = injector.getInstance(HostComponentStateDAO.class);
    HostComponentDesiredStateDAO hostComponentDesiredStateDAO = injector.getInstance(HostComponentDesiredStateDAO.class);
    HostDAO hostDAO = injector.getInstance(HostDAO.class);
   
    HostEntity hostEntity = hostDAO.findByName(stateEntity.getHostName());
    hostEntity.getHostComponentStateEntities().add(stateEntity);
    hostEntity.getHostComponentDesiredStateEntities().add(desiredStateEntity);

    serviceComponentDesiredStateEntity.getHostComponentDesiredStateEntities().add(desiredStateEntity);

    desiredStateEntity.setServiceComponentDesiredStateEntity(serviceComponentDesiredStateEntity);
    desiredStateEntity.setHostEntity(hostEntity);
    stateEntity.setServiceComponentDesiredStateEntity(serviceComponentDesiredStateEntity);
    stateEntity.setHostEntity(hostEntity);

    hostComponentStateDAO.create(stateEntity);
    hostComponentDesiredStateDAO.create(desiredStateEntity);

    serviceComponentDesiredStateDAO.create(serviceComponentDesiredStateEntity);
    hostDAO.merge(hostEntity);
  }
View Full Code Here

Examples of org.apache.ambari.server.orm.dao.HostDAO

      amc.deleteCluster(cr);

      assertNotNull(clusters.getHost(HOST1));
      assertNotNull(clusters.getHost(HOST2));

      HostDAO dao = injector.getInstance(HostDAO.class);

      assertNotNull(dao.findByName(HOST1));
      assertNotNull(dao.findByName(HOST2));

    } finally {
      injector.getInstance(PersistService.class).stop();
    }
  }
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.