Пример #1
0
    def __init__(self,
                 inMemory,
                 port=None,
                 cachePathOverride='',
                 maxOpenFiles=256,
                 inMemChannelFactoryFactory=None,
                 maxLogFileSizeMb=10,
                 pingInterval=None):

        self.inMemory = inMemory
        self.manager = None
        self.callbackScheduler = CallbackScheduler.singletonForTesting()

        if self.inMemory:
            self.manager = SharedStateService.KeyspaceManager(
                10001,
                1,
                cachePathOverride=cachePathOverride,
                pingInterval=IN_MEMORY_HARNESS_PING_INTERVAL
                if pingInterval is None else pingInterval,
                maxOpenFiles=maxOpenFiles,
                maxLogFileSizeMb=maxLogFileSizeMb)

            #although named otherwise InMemoryChannelFactory is actually a factory for a channelFactory
            # or a channelFactoryFactory

            channelFactoryFactory = inMemChannelFactoryFactory if inMemChannelFactoryFactory is not None \
                    else InMemoryChannelFactory.InMemoryChannelFactory

            logging.info(channelFactoryFactory)
            self.channelFactory = channelFactoryFactory(
                self.callbackScheduler, self.manager)
            self.viewFactory = ViewFactory.ViewFactory(self.channelFactory)
        else:

            class Settings(object):
                callbackScheduler = self.callbackScheduler

            assert port is not None

            self.service = SharedStateService.SharedStateService(
                self.callbackScheduler,
                cachePathOverride=cachePathOverride,
                port=port)

            self.service.startService()
            self.service.blockUntilListening()

            self.viewFactory = ViewFactory.ViewFactory.TcpViewFactory(
                self.callbackScheduler, "localhost", port)
 def setUp(self):
     self.harness = SharedStateTestHarness.SharedStateTestHarness(True)
     self.manager = SharedStateService.KeyspaceManager(10001,1, pingInterval=1)
     self.introKeyspace = SharedState.getClientInfoKeyspace()
     self.introRange = SharedState.KeyRange(self.introKeyspace, 1, None, None, True, False)
     self.views = []
     self.maxDiff = None
Пример #3
0
def createInMemorySharedStateViewFactory(callbackSchedulerToUse=None):
    if callbackSchedulerToUse is None:
        callbackSchedulerToUse = CallbackScheduler.singletonForTesting()

    sharedStateManager = SharedStateService.KeyspaceManager(
        10001,
        1,
        cachePathOverride="",
        pingInterval=IN_MEMORY_CLUSTER_SS_PING_INTERVAL,
        maxOpenFiles=100)

    sharedStateChannelFactory = (
        InMemorySharedStateChannelFactory.InMemoryChannelFactory(
            callbackSchedulerToUse.getFactory().createScheduler(
                "SharedState", 1), sharedStateManager))

    return ViewFactory.ViewFactory(sharedStateChannelFactory)
Пример #4
0
    def __init__(self,
            cumulusVectorRamCacheSizeOverride = DEFAULT_VECTOR_RAM_CACHE_SIZE,
            cumulusMaxRamCacheSizeOverride = DEFAULT_MAX_RAM_CACHE_SIZE,
            cumulusThreadCountOverride = DEFAULT_THREAD_COUNT,
            remoteGatewayRamCacheSizeOverride = DEFAULT_MAX_RAM_CACHE_SIZE,
            perMachineThroughput = DEFAULT_PER_MACHINE_THROUGHPUT
            ):
        self.cumulusMaxRamCacheSizeOverride = cumulusMaxRamCacheSizeOverride
        self.cumulusVectorRamCacheSizeOverride = cumulusVectorRamCacheSizeOverride

        self.callbackSchedulerFactory = CallbackScheduler.createSimpleCallbackSchedulerFactory()
        self.callbackScheduler = self.callbackSchedulerFactory.createScheduler("InMemoryCluster", 1)

        self.cumulusThreadCountOverride = cumulusThreadCountOverride
        self.remoteGatewayCacheSize = remoteGatewayRamCacheSizeOverride

        self.sharedStateManager = SharedStateService.KeyspaceManager(
            10001,
            1,
            cachePathOverride="",
            pingInterval = IN_MEMORY_CLUSTER_SS_PING_INTERVAL,
            maxOpenFiles=100
            )

        self.sharedStateChannelFactory = (
            InMemorySharedStateChannelFactory.InMemoryChannelFactory(
                self.callbackScheduler,
                self.sharedStateManager
                )
            )

        self.sharedStateViewFactory = ViewFactory.ViewFactory(self.sharedStateChannelFactory)

        self.client = InMemoryClient(self)
        self.cumuli = []
        self.nextCumulusAddress = 0

        self.channelManager = InMemoryChannelManager(self.callbackScheduler, perMachineThroughput)

        self.inMemoryDemuxingChannel = \
            InMemorySharedStateChannelFactory.SerializedToManagerChannelFactory(
                self.callbackScheduler,
                self.sharedStateManager,
                "SharedState"
                )
Пример #5
0
    def startSharedState(args):
        if parsed.cacheDir:
            logging.info("Shared state cache directory: %s", parsed.cacheDir)
            Setup.config().sharedStateCache = parsed.cacheDir

        service = SharedStateService.SharedStateService(callbackScheduler)

        service.startService()
        service.blockUntilListening()

        def handleSigTerm(signum, frame):
            logging.info("SIGTERM received - shutting down")
            service.stopService()

        signal.signal(signal.SIGTERM, handleSigTerm)

        signal.pause()
        logging.info("process exiting")
Пример #6
0
 def createSocketChannel(self, sock):
     return SharedStateService.createClientSocketMessageChannel(
         self.callbackScheduler, sock)
Пример #7
0
 def createSocketChannel(self, sock):
     return SharedStateService.createClientSocketMessageChannel(self.callbackScheduler, sock)
Пример #8
0
 def onConnect(self, sock, address):
     channel = SharedStateService.createServerSocketChannel(
         callbackScheduler, sock)
     channel.write(SharedState.MessageIn.MinimumId(0, 0))
     self.serverChannel = channel
     self.serverChannelEvent.set()
Пример #9
0
 def connectToServer(self):
     sock = SimpleServer.SimpleServer.connect('localhost', self.port)
     return SharedStateService.createClientSocketMessageChannel(
         callbackScheduler, sock)
Пример #10
0
 def createSocketChannels(self, scheduler):
     clientSock = SimpleServer.SimpleServer.connect('localhost', self.port)
     serverSock = self.q.get()
     return (SharedStateService.createClientSocketMessageChannel(scheduler, clientSock),
                 SharedStateService.createServerSocketChannel(scheduler, serverSock))
Пример #11
0
 def createSocketChannels(self, scheduler):
     clientSock = SimpleServer.SimpleServer.connect('localhost', self.port)
     serverSock = self.q.get()
     return (SharedStateService.createClientSocketMessageChannel(scheduler, clientSock),
                 SharedStateService.createServerSocketChannel(scheduler, serverSock))
Пример #12
0
 def onConnect(self, sock, address):
     channel = SharedStateService.createServerSocketChannel(callbackScheduler, sock)
     channel.write(SharedState.MessageIn.MinimumId(0, 0))
     self.serverChannel = channel
     self.serverChannelEvent.set()
Пример #13
0
 def connectToServer(self):
     sock = SimpleServer.SimpleServer.connect("localhost", self.port)
     return SharedStateService.createClientSocketMessageChannel(callbackScheduler, sock)