def main():
    try:
        KBob = DKB.get_by_alias("DKB")
    except Exception:
        KBob = DKB()
        KBob.make_persistent(alias="DKB")

    minutes_to_sleep = 15
    while True:
        print("Checking Events Snapshot received...")
        kb = KBob.kb
        last_timestamp = 0
        if len(kb) > 0:
            last_timestamp = next(reversed(sorted(list(kb.keys()))))
        print(
            f"Number of snapshots {len(list(kb.keys()))} and number of objects {len(list(KBob.objects.keys()))} and "
            f"last timestamp {last_timestamp}")
        """
        for timestamp in list(kb.keys()):
            ts = timestamp
            eventSnap = kb[timestamp]
            current_snap_alias = eventSnap.snap_alias
            print("Snapshot " + current_snap_alias + " found.")
            for event in eventSnap.events:
                obj = event.detected_object
                print(obj)
            print("#################")
        """
        time.sleep(minutes_to_sleep * 60)
        if len(kb) > 0:
            KBob.remove_old_snapshots_and_objects(last_timestamp, False)
Exemplo n.º 2
0
 def __init__(self, alias="DKB"):
     print("in DataclayObjectManager.__init__")
     self.backend_id = get_backend_id_by_name("DS1")
     try:
         self.KB = DKB.get_by_alias(alias)
     except Exception:
         self.KB = DKB()
         self.KB.cloud_backend_id = self.backend_id
         self.KB.make_persistent(alias="DKB")
Exemplo n.º 3
0
    def __init__(self, alias):
        self.backend_id = get_backend_id_by_name("DS1")

        try:
            self.KB = DKB.get_by_alias(alias)
        except Exception:
            self.KB = DKB()
            self.KB.cloud_backend_id = self.backend_id
            self.KB.make_persistent(alias="DKB")

        self.objectsDKB = DKB.get_by_alias(alias)
        self.backend_id = get_backend_id_by_name("DS1")
def main():
    import sys
    import time
    from dataclay.api import init, finish
    from dataclay.exceptions.exceptions import DataClayException

    mqtt_wait = False
    if len(sys.argv) == 2:
        mqtt_wait = (sys.argv[1] != "False")

    init()
    from CityNS.classes import DKB, ListOfObjects

    # Register MQTT client to subscribe to MQTT server in 192.168.7.42
    if mqtt_wait:
        client = register_mqtt()
        client.loop_start()

    # initialize all computing units in all workers
    num_cus = 8
    for i in range(num_cus):
        init_task()
    compss_barrier()

    # Publish to the MQTT broker that the execution has started
    if mqtt_wait:
        publish_mqtt(client)

    try:
        kb = DKB.get_by_alias("DKB")
    except DataClayException:
        kb = DKB()
        list_objects = ListOfObjects()
        list_objects.make_persistent()
        kb.list_objects = list_objects
        kb.make_persistent("DKB")

    start_time = time.time()
    # execute_trackers(["192.168.50.103"], kb)
    execute_trackers([("/tmp/pipe_yolo2COMPSs", "/tmp/pipe_COMPSs2yolo")], kb)
    # pipe_paths = [("/tmp/pipe_yolo2COMPSs", "/tmp/pipe_COMPSs2yolo"), ("/tmp/pipe_write",  "/tmp/pipe_read")]
    # print("ExecTime: " + str(time.time() - start_time))
    # print("ExecTime per Iteration: " + str((time.time() - start_time) / NUM_ITERS))

    if mqtt_wait:
        while CD_PROC < NUM_ITERS:
            pass
    print("Exiting Application...")
    finish()
Exemplo n.º 5
0
 def __init__(self, alias="DKB"):
     print("in DataclayObjectManager.__init__")
     self.backend_id = get_backend_id_by_name("DS1")
     print("1")
     try:
         print(2)
         self.KB = DKB.get_by_alias(alias)
         print(3)
     except Exception:
         print(4)
         self.KB = DKB()
         print(5)
         self.KB.cloud_backend_id = self.backend_id
         print(6)
         self.KB.make_persistent(alias="DKB")
         print(7)
     print("after DataclayObjectManager.__init__")
Exemplo n.º 6
0
def main():
    import sys
    import time
    from dataclay.api import init, register_dataclay, finish
    from dataclay.exceptions.exceptions import DataClayException

    init()
    from CityNS.classes import DKB
    # register_dataclay("192.168.7.32", 11034)
    try:
        DKB.get_by_alias("DKB")
    except DataClayException:
        DKB().make_persistent("DKB")

    start_time = time.time()
    execute_trackers()
    print("ExecTime: " + str(time.time() - start_time))

    print("Exiting Application...")
    finish()
def init_task():
    import uuid
    from CityNS.classes import DKB, Event, Object, EventsSnapshot, ListOfObjects, FederationInfo
    kb = DKB()
    kb.make_persistent("FAKE_" + str(uuid.uuid4()))
    kb.get_objects_from_dkb()
    snap = EventsSnapshot("FAKE_SNAP_" + str(uuid.uuid4()))
    snap.make_persistent("FAKE_SNAP_" + str(uuid.uuid4()))
    snap.get_objects_refs()
    event = Event(None, None, None, None, None, None, None)
    event.make_persistent("FAKE_EVENT_" + str(uuid.uuid4()))
    obj = Object("FAKE_OBJ_" + str(uuid.uuid4()), "FAKE", 0, 0, 0, 0)
    obj.make_persistent("FAKE_OBJ_" + str(uuid.uuid4()))
    obj.get_events_history(20)
    list_objs = ListOfObjects()
    list_objs.make_persistent("FAKE_LISTOBJ_" + str(uuid.uuid4()))
    list_objs.get_or_create("FAKE_LISTOBJ_" + str(uuid.uuid4()), "FAKE", 0, 0,
                            0, 0)
    federation_info = FederationInfo([snap])
    federation_info.make_persistent()
    federation_info.objects_per_snapshot  # to load dataclay class and libraries
Exemplo n.º 8
0
            event = Event()
            event.initialize(eventObject,
                             row["timestamp"], float(row["speed"]),
                             float(row["yaw"]), float(row["lon"]),
                             float(row["lat"]), row['x'], row['y'], row['w'],
                             row['h'])
            eventObject.geohash = row["geohash"][0:7]
            eventsSnapshot.timestamp = row["timestamp"]
            eventsSnapshot.add_event(event)
            eventObject.add_event(event)


#        import pdb;pdb.set_trace()
        eventsSnapshot.make_persistent("events_" + str(name))
        KB.add_events_snapshot(eventsSnapshot)

if __name__ == "__main__":
    try:
        #        import pdb;pdb.set_trace()
        KB = DKB.get_by_alias("DKB")
        # KB.reset_dkb()
    except Exception:
        KB = DKB()
        #        KBob.cloud_backend_id = backend_id
        KB.make_persistent(alias="DKB")
#    import pdb;pdb.set_trace()
    createDCObjects(KB)
    finish()
    exit(0)