예제 #1
0
class TestTwoPhaseCommit(unittest.TestCase):

    def __init__(self, *args, **kwargs):
        super(TestTwoPhaseCommit, self).__init__(*args, **kwargs)

    def setUp(self):
        print("test setup begins")
        self.coordinator = Coordinator(3)
        self.cohort1 = Cohort(COHORT1_ID, COHORT1_PORT)
        self.cohort2 = Cohort(COHORT2_ID, COHORT2_PORT)
        self.cohort3 = Cohort(COHORT3_ID, COHORT3_PORT)
        self.coordinator.start()
        self.coordinator.channel.queue_purge(queue = 'coordinatorQueue')
        self.coordinator.channel.queue_purge(queue='queue0')
        self.coordinator.channel.queue_purge(queue='queue1')
        self.coordinator.channel.queue_purge(queue='queue2')
        print("test setup successful")

    def db_clean_up(self):
        transaction_log_utils.clear_db()
        self.cohort1.dbCleanup()
        self.cohort2.dbCleanup()
        self.cohort3.dbCleanup()

    def test_1(self):
        self.db_clean_up()
        self.coordinator.set_test_name("test1")
        coordinator_process = Process(target=self.coordinator.run)
        cohort1_process = Process(target=self.cohort1.run)
        cohort2_process = Process(target=self.cohort2.run)
        cohort3_process = Process(target=self.cohort3.run)
        print("coordinator starting")
        coordinator_process.start()
        print("coordinator started")
        cohort1_process.start()
        print("1st cohort started")
        cohort2_process.start()
        print("2nd cohort started")
        cohort3_process.start()
        print("3rd cohort started")

        cohort_port_list = [COHORT1_PORT, COHORT2_PORT, COHORT3_PORT]
        verifier = DatabaseStateVerifier(COORDINATOR_PORT, cohort_port_list)
        time.sleep(10)
        while verifier.is_transaction_active_at_coordinator():
            time.sleep(1)
        self.assertTrue(verifier.is_aborted())

        print("Assets passed")
        coordinator_process.terminate()
        cohort1_process.terminate()
        cohort2_process.terminate()
        cohort3_process.terminate()
예제 #2
0
    ief = IndoorEnvironmentFetcher(dataCollection)
    ief.run()
    ief_job = scheduler.add_job(ief.run,
                                trigger='interval',
                                seconds=2,
                                id=IEF_JOB_ID)
    joblist[IEF_JOB_ID] = Job(ief_job, 2, 2)

    nf = NewsFetcher(dataCollection, config)
    nf.run()
    nf_job = scheduler.add_job(nf.run,
                               trigger='interval',
                               seconds=3600,
                               id=NF_JOB_ID)
    joblist[NF_JOB_ID] = Job(nf_job, 3600, 600)

    scheduler.add_listener(
        Listener(joblist).job_done_listener,
        EVENT_JOB_EXECUTED | EVENT_JOB_ERROR)

    scheduler.start()

    #    stopFlag = Event()

    cthread = Coordinator(dataCollection, config, scheduler)
    cthread.start()

    lthread = LedDisplayThread(dataCollection)
    lthread.start()
예제 #3
0
파일: run.py 프로젝트: bcdev-/NXTStorm
'''
           DO WHAT THE F**K YOU WANT TO PUBLIC LICENSE
                   Version 2, December 2004

Copyright (C) 2014 bcdev <*****@*****.**>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

           DO WHAT THE F**K YOU WANT TO PUBLIC LICENSE
  TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

 0. You just DO WHAT THE F**K YOU WANT TO.
'''

import sys
if sys.version_info < (3, 0):
    sys.stdout.write("Node requires Python 3.x\n")
    sys.exit(1)

import config
import time

from coordinator import Coordinator

coordinator = Coordinator()
coordinator.start()