Package org.voltdb

Examples of org.voltdb.MockVoltDB$StartActionWatcher


    MockVoltDB m_voltdb;

    @Override
    protected void setUp()
    {
        m_voltdb = new MockVoltDB();
        m_voltdb.addTable(TABLE1, false);
        for (int i = 0; i < COLS.length; ++i)
        {
            m_voltdb.addColumnToTable(TABLE1, COLS[i], COLTYPES[i], false, "",
                                      COLTYPES[i]);
View Full Code Here


public class TestSiteTracker extends TestCase
{
    public void testNoReplication() throws Exception
    {
        MockVoltDB helper = new MockVoltDB();

        Long site1 = CoreUtils.getHSIdFromHostAndSite( 0, 1);
        Long site2 = CoreUtils.getHSIdFromHostAndSite( 0, 2);
        Long site101 = CoreUtils.getHSIdFromHostAndSite( 1, 101);
        Long site102 = CoreUtils.getHSIdFromHostAndSite( 1, 102);
        helper.addSite(site1, 0);
        helper.addSite(site2, 1);
        helper.addSite(site101, 2);
        helper.addSite(site102, 3);

        SiteTracker tracker = helper.getSiteTrackerForSnapshot();
        assertEquals(site1, tracker.getSitesForPartition(0).get(0));
        assertEquals(site2, tracker.getSitesForPartition(1).get(0));
        assertEquals(site101, tracker.getSitesForPartition(2).get(0));
        assertEquals(site102, tracker.getSitesForPartition(3).get(0));
        for (int i = 0; i < 4; i++)
        {
            assertEquals(1, tracker.getSitesForPartition(i).size());
        }
        long[] sites = tracker.getSitesForPartitionsAsArray(new int[] {1, 2, 3});
        assertEquals(3, sites.length);
        for (long site : sites)
        {
            assertTrue(site == site2 || site == site101 || site == site102);
        }
        assertEquals(0, tracker.getPartitionForSite(site1));
        assertEquals(1, tracker.getPartitionForSite(site2));
        assertEquals(2, tracker.getPartitionForSite(site101));
        assertEquals(3, tracker.getPartitionForSite(site102));

        helper.shutdown(null);
    }
View Full Code Here

        helper.shutdown(null);
    }

    public void testEasyReplication() throws Exception
    {
        MockVoltDB helper = new MockVoltDB();

        Long site1 = CoreUtils.getHSIdFromHostAndSite( 0, 1);
        Long site2 = CoreUtils.getHSIdFromHostAndSite( 0, 2);
        Long site101 = CoreUtils.getHSIdFromHostAndSite( 1, 101);
        Long site102 = CoreUtils.getHSIdFromHostAndSite( 1, 102);
        helper.addSite(site1, 0);
        helper.addSite(site2, 1);
        helper.addSite(site101, 0);
        helper.addSite(site102, 1);

        SiteTracker tracker = helper.getSiteTrackerForSnapshot();
        assertTrue(tracker.getSitesForPartition(0).contains(site1));
        assertTrue(tracker.getSitesForPartition(0).contains(site101));
        assertTrue(tracker.getSitesForPartition(1).contains(site2));
        assertTrue(tracker.getSitesForPartition(1).contains(site102));
        for (int i = 0; i < 2; i++)
        {
            assertEquals(2, tracker.getSitesForPartition(i).size());
        }
        long[] sites = tracker.getSitesForPartitionsAsArray(new int[] {0, 1});
        assertEquals(4, sites.length);
        for (long site : sites)
        {
            assertTrue(site == site1 || site == site2 || site == site101 || site == site102);
        }
        assertEquals(0, tracker.getPartitionForSite(site1));
        assertEquals(1, tracker.getPartitionForSite(site2));
        assertEquals(0, tracker.getPartitionForSite(site101));
        assertEquals(1, tracker.getPartitionForSite(site102));
        helper.shutdown(null);
    }
View Full Code Here

        helper.shutdown(null);
    }

    public void testHostToSites() throws Exception
    {
        MockVoltDB helper = new MockVoltDB();

        Long site0 = CoreUtils.getHSIdFromHostAndSite( 0, 0);
        Long site1 = CoreUtils.getHSIdFromHostAndSite( 0, 1);
        Long site2 = CoreUtils.getHSIdFromHostAndSite( 0, 2);
        Long site3 = CoreUtils.getHSIdFromHostAndSite( 0, 3);
        Long site100 = CoreUtils.getHSIdFromHostAndSite( 1, 100);
        Long site101 = CoreUtils.getHSIdFromHostAndSite( 1, 101);
        Long site102 = CoreUtils.getHSIdFromHostAndSite( 1, 102);
        Long site103 = CoreUtils.getHSIdFromHostAndSite( 1, 103);
        helper.addSite(site0, MailboxType.Initiator);
        helper.addSite(site1, 0);
        helper.addSite(site2, 1);
        helper.addSite(site3, 1);
        helper.addSite(site100, MailboxType.Initiator);
        helper.addSite(site101, 0);
        helper.addSite(site102, 1);
        helper.addSite(site103, 1);

        SiteTracker tracker = helper.getSiteTrackerForSnapshot();
        List<Long> host0 = tracker.getSitesForHost(0);
        assertFalse(host0.contains(site0));
        assertTrue(host0.contains(site1));
        assertTrue(host0.contains(site2));
        assertTrue(host0.contains(site3));
        assertFalse(host0.contains(site101));

        List<Long> host1 = tracker.getSitesForHost(1);
        assertFalse(host1.contains(site0));
        assertFalse(host1.contains(site1));
        assertTrue(host1.contains(site101));
        assertTrue(host1.contains(site102));
        assertTrue(host1.contains(site103));
        helper.shutdown(null);
    }
View Full Code Here

        helper.shutdown(null);
    }

    public void testExecutionSiteIds() throws Exception
    {
        MockVoltDB helper = new MockVoltDB();

        Long site0 = CoreUtils.getHSIdFromHostAndSite( 0, 0);
        Long site1 = CoreUtils.getHSIdFromHostAndSite( 0, 1);
        Long site2 = CoreUtils.getHSIdFromHostAndSite( 0, 2);
        Long site100 = CoreUtils.getHSIdFromHostAndSite( 1, 100);
        Long site101 = CoreUtils.getHSIdFromHostAndSite( 1, 101);
        Long site102 = CoreUtils.getHSIdFromHostAndSite( 1, 102);

        helper.addSite(site0, MailboxType.Initiator);
        helper.addSite(site1, 0);
        helper.addSite(site2, 1);
        helper.addSite(site100, MailboxType.Initiator);
        helper.addSite(site101, 0);
        helper.addSite(site102, 1);

        SiteTracker tracker = helper.getSiteTrackerForSnapshot();
        Set<Long> exec_sites = tracker.getAllSites();
        assertFalse(exec_sites.contains(site0));
        assertTrue(exec_sites.contains(site1));
        assertTrue(exec_sites.contains(site2));
        assertFalse(exec_sites.contains(site100));
        assertTrue(exec_sites.contains(site101));
        assertTrue(exec_sites.contains(site102));
        assertEquals(site1, tracker.getLowestSiteForHost(0));
        assertEquals(site101, tracker.getLowestSiteForHost(1));

        helper.shutdown(null);
    }
View Full Code Here

TOP

Related Classes of org.voltdb.MockVoltDB$StartActionWatcher

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.