Package com.cloud.cluster.dao

Examples of com.cloud.cluster.dao.StackMaidDao


      final int threadNum = i+1;
      threads[i] = new Thread(new Runnable() {
        public void run() {
          Transaction txn = Transaction.open(Transaction.CLOUD_DB);
         
          StackMaidDao dao = new StackMaidDaoImpl();
          dao.pushCleanupDelegate(1L, 0, "delegate-" + threadNum, "Hello, world");
          dao.pushCleanupDelegate(1L, 1, "delegate-" + threadNum, new Long(100));
          dao.pushCleanupDelegate(1L, 2, "delegate-" + threadNum, null);
         
          txn.close();
        }
      });
     
      threads[i].start();
    }
   
    for(int i = 0; i < 3; i++) {
      try {
        threads[i].join();
      } catch (InterruptedException e) {
      }
    }

   
    Transaction txn = Transaction.open(Transaction.CLOUD_DB);
   
    StackMaidDao dao = new StackMaidDaoImpl();
    List<CheckPointVO> l = dao.listLeftoversByMsid(1L);
    for(CheckPointVO maid : l) {
      s_logger.info("" + maid.getThreadId() + " " + maid.getDelegate() + " " + maid.getContext());
    }
   
    txn.close();
View Full Code Here


       
        MockMaid delegate = new MockMaid();
        delegate.setValue("first");
        long taskId = taskMgr.pushCheckPoint(delegate);
       
        StackMaidDao maidDao = locator.getDao(StackMaidDao.class);
        CheckPointVO task = maidDao.findById(taskId);
       
        assertEquals(task.getDelegate(), MockMaid.class.getName());
        MockMaid retrieved = (MockMaid)SerializerHelper.fromSerializedString(task.getContext());
        assertEquals(retrieved.getValue(), delegate.getValue());
       
        delegate.setValue("second");
        taskMgr.updateCheckPointState(taskId, delegate);

        task = maidDao.findById(taskId);
        assertEquals(task.getDelegate(), MockMaid.class.getName());
        retrieved = (MockMaid)SerializerHelper.fromSerializedString(task.getContext());
        assertEquals(retrieved.getValue(), delegate.getValue());
       
        taskMgr.popCheckPoint(taskId);
        assertNull(maidDao.findById(taskId));
    }
View Full Code Here

       
        MockMaid maid = new MockMaid();
        maid.setValue("first");
        long taskId = taskMgr.pushCheckPoint(maid);
       
        StackMaidDao maidDao = locator.getDao(StackMaidDao.class);
        CheckPointVO task = maidDao.findById(taskId);
       
        assertEquals(task.getDelegate(), MockMaid.class.getName());
        MockMaid retrieved = (MockMaid)SerializerHelper.fromSerializedString(task.getContext());
        assertEquals(retrieved.getValue(), maid.getValue());
View Full Code Here

       
        MockMaid delegate = new MockMaid();
        delegate.setValue("first");
        long taskId = taskMgr.pushCheckPoint(delegate);
       
        StackMaidDao maidDao = locator.getDao(StackMaidDao.class);
        CheckPointVO task = maidDao.findById(taskId);
       
        assertEquals(task.getDelegate(), MockMaid.class.getName());
        MockMaid retrieved = (MockMaid)SerializerHelper.fromSerializedString(task.getContext());
        assertEquals(retrieved.getValue(), delegate.getValue());
View Full Code Here

  */
 
  public void testMaid() {
    Transaction txn = Transaction.open(Transaction.CLOUD_DB);
   
    StackMaidDao dao = new StackMaidDaoImpl();
    dao.pushCleanupDelegate(1L, 0, "delegate1", "Hello, world");
    dao.pushCleanupDelegate(1L, 1, "delegate2", new Long(100));
    dao.pushCleanupDelegate(1L, 2, "delegate3", null);
   
    CheckPointVO item = dao.popCleanupDelegate(1L);
    Assert.assertTrue(item.getDelegate().equals("delegate3"));
    Assert.assertTrue(item.getContext() == null);
   
    item = dao.popCleanupDelegate(1L);
    Assert.assertTrue(item.getDelegate().equals("delegate2"));
    s_logger.info(item.getContext());

    item = dao.popCleanupDelegate(1L);
    Assert.assertTrue(item.getDelegate().equals("delegate1"));
    s_logger.info(item.getContext());
   
    txn.close();
  }
View Full Code Here

  }
 
  public void testMaidClear() {
    Transaction txn = Transaction.open(Transaction.CLOUD_DB);
   
    StackMaidDao dao = new StackMaidDaoImpl();
    dao.pushCleanupDelegate(1L, 0, "delegate1", "Hello, world");
    dao.pushCleanupDelegate(1L, 1, "delegate2", new Long(100));
    dao.pushCleanupDelegate(1L, 2, "delegate3", null);
   
    dao.clearStack(1L);
    Assert.assertTrue(dao.popCleanupDelegate(1L) == null);
    txn.close();
  }
View Full Code Here

     */

    public void testMaid() {
        Transaction txn = Transaction.open(Transaction.CLOUD_DB);

        StackMaidDao dao = new StackMaidDaoImpl();
        dao.pushCleanupDelegate(1L, 0, "delegate1", "Hello, world");
        dao.pushCleanupDelegate(1L, 1, "delegate2", new Long(100));
        dao.pushCleanupDelegate(1L, 2, "delegate3", null);

        CheckPointVO item = dao.popCleanupDelegate(1L);
        Assert.assertTrue(item.getDelegate().equals("delegate3"));
        Assert.assertTrue(item.getContext() == null);

        item = dao.popCleanupDelegate(1L);
        Assert.assertTrue(item.getDelegate().equals("delegate2"));
        s_logger.info(item.getContext());

        item = dao.popCleanupDelegate(1L);
        Assert.assertTrue(item.getDelegate().equals("delegate1"));
        s_logger.info(item.getContext());

        txn.close();
    }
View Full Code Here

    }

    public void testMaidClear() {
        Transaction txn = Transaction.open(Transaction.CLOUD_DB);

        StackMaidDao dao = new StackMaidDaoImpl();
        dao.pushCleanupDelegate(1L, 0, "delegate1", "Hello, world");
        dao.pushCleanupDelegate(1L, 1, "delegate2", new Long(100));
        dao.pushCleanupDelegate(1L, 2, "delegate3", null);

        dao.clearStack(1L);
        Assert.assertTrue(dao.popCleanupDelegate(1L) == null);
        txn.close();
    }
View Full Code Here

            threads[i] = new Thread(new Runnable() {
                @Override
                public void run() {
                    Transaction txn = Transaction.open(Transaction.CLOUD_DB);

                    StackMaidDao dao = new StackMaidDaoImpl();
                    dao.pushCleanupDelegate(1L, 0, "delegate-" + threadNum, "Hello, world");
                    dao.pushCleanupDelegate(1L, 1, "delegate-" + threadNum, new Long(100));
                    dao.pushCleanupDelegate(1L, 2, "delegate-" + threadNum, null);

                    txn.close();
                }
            });

            threads[i].start();
        }

        for(int i = 0; i < 3; i++) {
            try {
                threads[i].join();
            } catch (InterruptedException e) {
            }
        }


        Transaction txn = Transaction.open(Transaction.CLOUD_DB);

        StackMaidDao dao = new StackMaidDaoImpl();
        List<CheckPointVO> l = dao.listLeftoversByMsid(1L);
        for(CheckPointVO maid : l) {
            s_logger.info("" + maid.getThreadId() + " " + maid.getDelegate() + " " + maid.getContext());
        }

        txn.close();
View Full Code Here

TOP

Related Classes of com.cloud.cluster.dao.StackMaidDao

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.