def test_schedulerEventsAreSerializable(self):
        s3 = InMemoryS3Interface.InMemoryS3InterfaceFactory()

        result, simulation = self.computeUsingSeveralWorkers("""
                sum(0,10**10)
                """, s3, 4, timeout=240, returnSimulation=True
                )

        try:
            someHadEvents = False

            for worker, vdm, eventHandler in simulation.workersVdmsAndEventHandlers:
                events = eventHandler.extractEvents()

                events2 = pickle.loads(pickle.dumps(events))

                print len(events), "events"
                print len(pickle.dumps(events)), " bytes"
                print len(pickle.dumps(events)) / len(events), " bytes per event."

                self.assertTrue(len(events2) == len(events))

                if len(events):
                    someHadEvents = True

                CumulusNative.replayCumulusWorkerEventStream(events, True)

            self.assertTrue(someHadEvents)

            worker = None
            vdm = None
            eventHandler = None
        finally:
            simulation.teardown()
def main(parsedArguments):
    try:
        eventSets = pickle.load(open(parsedArguments.file, "r"))
    except:
        eventSets = None

    if eventSets is not None:
        for events in eventSets:
            logging.warn("**********************************************")
            if len(events):
                logging.warn("validating %s", events[0])
            logging.warn("")

            CumulusNative.replayCumulusWorkerEventStream(events, parsedArguments.validation)
    else:
        CumulusNative.replayCumulusWorkerEventStreamFromFile(
            parsedArguments.file, 
            parsedArguments.validation
            )

    return 0
def extractEventSets(parsedArguments):
    if len(parsedArguments.files) == 1 and 'scheduler_events' in parsedArguments.files[0]:
        return pickle.load(open(parsedArguments.files[0],"r"))
    else:
        result = []

        for filename in parsedArguments.files:
            result.append(
                CumulusNative.extractCumulusWorkerEventsFromFile(filename)
                )

        return result
def summarize(filenames):
    for filename in filenames:
        print "*********************************************************************************"
        print filename
        print "*********************************************************************************"

        events = CumulusNative.extractCumulusWorkerEventsFromFile(filename)

        print events[0]
        print "timestamps: ", events[0].timestamp, events[-1].timestamp
        print "timestamps: ", formatTimestamp(events[0].timestamp), formatTimestamp(events[-1].timestamp)
        print
        print