Package com.cloud.host.dao

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


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

      }
    }
  }
 
  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

    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

            }
        }
    }

    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

            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

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

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

TOP

Related Classes of com.cloud.host.dao.HostDao

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.