from config.servers import servers from config.networkParams import * from config.host import * from config.messageHeads import * import src.util.network as network import src.util.server as server import src.util.logger as logger import src.util.stats as statLib import src.connectedSubgraph.initTasks as initTasks import src.util.primes as primes import src.graph.graph as graph from random import randint import time import threading log = logger.getLogger("Master-Main") taskCounterLock = threading.Lock() class Main: ''' This Main class of Master server is intended for following tasks: - Functions for acting on messages received by the listener - Passing graph, config informations to slaves - Collecting results - Receiving heartbeats - Allocating initial tasks to slaves ''' def __init__(self): self.servers = getServersAfterPingTests(servers) self.graph = None self.aliveSlaves = filter(lambda s: s.role=='slave' and s.alive, self.servers) self.m = len(self.aliveSlaves)
import socket from config.networkParams import * from config.messageHeads import * from config.host import * import src.util.logger as logger import time log = logger.getLogger("Network-Util") def messageLength(message): if len(message) >= 10**MESSAGE_LENGTH_DIGITS: log.error("Message length exceeds network limit", exc_info=True) return str(('%0'+str(MESSAGE_LENGTH_DIGITS)+'d')%len(message)) def sendToIP(IP, port, message): try: s = socket.socket() s.settimeout(SOCKET_TIMEOUT) s.connect((IP, port)) s.send(messageLength(message)) s.send(message) # log.info("Message sent to IP " + IP + ':' + str(port)) s.close() except Exception, e: log.error("Error in send (IP): " + str(e) + ". Retrying...") time.sleep(WAIT_AFTER_TIMEOUT_EXCEPTION) sendToIP(IP, port, message) def send(sock, message): sock.send(messageLength(message)) sock.send(message)
from config.servers import servers from config.networkParams import * from config.host import * from config.messageHeads import * import src.util.network as network import src.util.server as server import src.util.logger as logger import src.util.stats as statLib import src.connectedSubgraph.initTasks as initTasks import src.util.primes as primes import src.graph.graph as graph from random import randint import time import threading log = logger.getLogger("Master-Main") taskCounterLock = threading.Lock() class Main: ''' This Main class of Master server is intended for following tasks: - Functions for acting on messages received by the listener - Passing graph, config informations to slaves - Collecting results - Receiving heartbeats - Allocating initial tasks to slaves ''' def __init__(self): self.servers = getServersAfterPingTests(servers) self.graph = None self.aliveSlaves = filter(lambda s: s.role == 'slave' and s.alive,
from src.util.bloom import BloomFilter from src.util.stats import Stats from src.connectedSubgraph.extendSubgraph import ExtendSubgraph from config.networkParams import * from config.host import * from config.messageHeads import * from random import randint import src.util.logger as logger import time import Queue # TODO save a graph to a persistent file before pushing it into the task queue TaskQueue = Queue.Queue() BloomHashFilter = BloomFilter(10**7, 1e-7) log = logger.getLogger("Slave-Main") stats = Stats(HOST_ID) class Main: ''' This Main class of Slave server is intended for following tasks: - Functions for acting on messages received by the listener - Receiving graph, config informations from master - Sending heartbeats - Processing tasks - Storing and sending result - ### ''' def __init__(self): self.p = None self.m = None self.aliveSlaves = []
import src.util.logger as logger log = logger.getLogger("Log Test") try: a = 1/0 except: log.error("Div by 0", exc_info=True) log.info("Info log test") log.debug("Debug log test")
from src.util.bloom import BloomFilter from src.util.stats import Stats from src.connectedSubgraph.extendSubgraph import ExtendSubgraph from config.networkParams import * from config.host import * from config.messageHeads import * from random import randint import src.util.logger as logger import time import Queue # TODO save a graph to a persistent file before pushing it into the task queue TaskQueue = Queue.Queue() BloomHashFilter = BloomFilter(10**7, 1e-7) log = logger.getLogger("Slave-Main") stats = Stats(HOST_ID) class Main: ''' This Main class of Slave server is intended for following tasks: - Functions for acting on messages received by the listener - Receiving graph, config informations from master - Sending heartbeats - Processing tasks - Storing and sending result - ### ''' def __init__(self): self.p = None self.m = None
import src.util.logger as logger log = logger.getLogger("Log Test") try: a = 1 / 0 except: log.error("Div by 0", exc_info=True) log.info("Info log test") log.debug("Debug log test")