def main(): """ bootstrap function """ params = sys.argv[1:] parser = argparse.ArgumentParser(description="Log producer with embedded https server ") parser.add_argument( "-z", "--zkServer", help="address of the zookeeper server", default="localhost:2181", required=True ) parser.add_argument( "-a", "--host", help="the hostname/ip to bind to, defaults to localhost", default="localhost", required=False ) parser.add_argument("-p", "--port", help="the port to listen in", type=int, default="8991", required=False) parser.add_argument( "-c", "--certDir", help="the directory to store https certificat and key", default="/tmp/", required=False ) args = parser.parse_args(params) zkAddr = args.zkServer host = args.host port = args.port certDir = args.certDir try: zc = RetryClient(ZookeeperClient(zkAddr)) d = zc.connect() d.addCallback(cb_connected, zc, host, port, certDir) d.addErrback(log.msg) except: print "Can't connect to Zookeeper!" return reactor.run()
def main(): """ bootstrap function """ params = sys.argv[1:] parser = argparse.ArgumentParser(description='A log consumer') parser.add_argument('-z', '--zkServer', help='address of the zookeeper server', default="fd88:9fde:bd6e:f57a:0:1d7b:9dea:802:29017", required=True) parser.add_argument('-n', '--normalizer', help=' path to pylogs parser normalizers', default="/home/lahoucine/src/pylogsparser/normalizers", required=True) args = parser.parse_args(params) zkAddr = args.zkServer normalizer = args.normalizer try: zc = RetryClient(ZookeeperClient(zkAddr)) d = zc.connect() d.addCallback(cb_connected, zc, normalizer) d.addErrback(log.msg) except: print "Can't connect to Zookeeper" return reactor.run()
class RetryClientTests(test_client.ClientTests): """Run the full client test suite against the retry facade. """ def setUp(self): super(RetryClientTests, self).setUp() self.client = RetryClient(ZookeeperClient("127.0.0.1:2181", 3000)) self.client2 = None def tearDown(self): if self.client.connected: utils.deleteTree(handle=self.client.handle) self.client.close() if self.client2 and self.client2.connected: self.client2.close() super(RetryClientTests, self).tearDown() def test_wb_connect_after_timeout(self): """white box tests disabled for retryclient.""" def test_wb_reconnect_after_timeout_and_close(self): """white box tests disabled for retryclient.""" def test_exists_with_error(self): """White box tests disabled for retryclient."""
def main(): """ bootstrap function """ params = sys.argv[1:] parser = argparse.ArgumentParser(description='Log producer with embedded https server ') parser.add_argument('-z','--zkServer',help='address of the zookeeper server', default="localhost:2181", required=True) parser.add_argument('-a','--host',help='the hostname/ip to bind to, defaults to localhost', default="localhost", required = False) parser.add_argument('-p','--port',help='the port to listen in', type=int, default="8991", required=False) parser.add_argument('-c','--certDir',help='the directory to store https certificat and key', default="/tmp/", required=False) args = parser.parse_args(params) zkAddr = args.zkServer host = args.host port = args.port certDir = args.certDir try: zc = RetryClient(ZookeeperClient(zkAddr)) d = zc.connect() d.addCallback(cb_connected, zc, host, port, certDir) d.addErrback(log.msg) except: print "Can't connect to Zookeeper!" return reactor.run()
def main(): """ the aim of this code is to start an instance of mongo, and publishing its configuration (address + port) into the configuration tree managed by Zookeeper. the znode created for this configuration must be an Ephemeral. with that type of znode, the configuration added exist only if the client is up. """ params = sys.argv[1:] parser = argparse.ArgumentParser(description='mongo bootstrap') parser.add_argument('-z','--zkaddr',help='zookeeper address', required=True) parser.add_argument('-b','--bin',help='mongodb bin', required=True) parser.add_argument('-c','--config',help=' path to configuration file of mongodb', default = "", required=False) parser.add_argument('-i','--bind_ip',help='bind ip', required=True) parser.add_argument('-p','--port',help='listen port', required=True) args = parser.parse_args(params) zk = args.zkaddr mongod = args.bin conf = args.config ip = args.bind_ip port = args.port try: zc = RetryClient(ZookeeperClient(zk)) d = zc.connect() d.addCallback(cb_connected, zc, mongod, ip, port, conf) d.addErrback(log.msg) except: print "Can't connect to zookeeper!" return reactor.run()
def main(): """ bootstrap function """ params = sys.argv[1:] parser = argparse.ArgumentParser(description="A log consumer") parser.add_argument( "-z", "--zkServer", help="address of the zookeeper server", default="fd88:9fde:bd6e:f57a:0:1d7b:9dea:802:29017", required=True, ) parser.add_argument( "-n", "--normalizer", help=" path to pylogs parser normalizers", default="/home/lahoucine/src/pylogsparser/normalizers", required=True, ) args = parser.parse_args(params) zkAddr = args.zkServer normalizer = args.normalizer try: zc = RetryClient(ZookeeperClient(zkAddr)) d = zc.connect() d.addCallback(cb_connected, zc, normalizer) d.addErrback(log.msg) except: print "Can't connect to Zookeeper" return reactor.run()
def main(): """ the aim of this code is to start an instance of solr, and publishing its configuration (address + port) into the configuration tree managed by Zookeeper. the znode created for this configuration must be a Ephemeral. with that type of znode, the configuration added exist only if the client is up. """ params = sys.argv[1:] parser = argparse.ArgumentParser(description='Solr bootstrap') parser.add_argument('-z', '--zkaddr', help='zookeeper address', required=True) parser.add_argument('-c', '--cores', help='cores path', required=False) #TO DO a remplacer par conf parser.add_argument('-m', '--solrhome', help='solr home', required=True) #TO DO a remplacer par conf parser.add_argument('-s', '--solrpath', help='solr path', required=True) parser.add_argument('-p', '--port', help='listening port', required=True) parser.add_argument('-i', '--ip', help='listening ip', required=True) parser.add_argument('-j', '--java', help='java home', required=True) parser.add_argument('-n', '--numshard', help='number shard', required=False) args = parser.parse_args(params) zk = args.zkaddr cores = args.cores solrpath = args.solrpath solrhome = args.solrhome port = args.port ip = args.ip java = args.java numsh = args.numshard try: zc = RetryClient(ZookeeperClient(zk)) d = zc.connect() d.addCallback(cb_connected, zc, cores, solrpath, solrhome, numsh, port, ip, java, zk) d.addErrback(log.msg) except: print "Can't connect to Zokeeper!" return reactor.run()
def main(): """ the aim of this code is to start an instance of solr, and publishing its configuration (address + port) into the configuration tree managed by Zookeeper. the znode created for this configuration must be a Ephemeral. with that type of znode, the configuration added exist only if the client is up. """ params = sys.argv[1:] parser = argparse.ArgumentParser(description='Solr bootstrap') parser.add_argument('-z', '--zkaddr', help='zookeeper address', required=True) parser.add_argument('-c', '--cores', help='cores path', required=False) #TO DO a remplacer par conf parser.add_argument('-m', '--solrhome', help='solr home', required=True) #TO DO a remplacer par conf parser.add_argument('-s', '--solrpath', help='solr path', required=True) parser.add_argument('-p','--port', help='listening port', required=True) parser.add_argument('-i','--ip', help='listening ip', required=True) parser.add_argument('-j','--java',help='java home', required=True) parser.add_argument('-n','--numshard',help='number shard', required=False) args = parser.parse_args(params) zk = args.zkaddr cores = args.cores solrpath = args.solrpath solrhome = args.solrhome port = args.port ip = args.ip java = args.java numsh = args.numshard try: zc = RetryClient(ZookeeperClient(zk)) d = zc.connect() d.addCallback(cb_connected, zc, cores, solrpath, solrhome, numsh, port, ip, java, zk) d.addErrback(log.msg) except: print "Can't connect to Zokeeper!" return reactor.run()
def setUp(self): super(RetryClientConnectionLossTest, self).setUp() from twisted.internet import reactor self.proxy = ProxyFactory("127.0.0.1", 2181) self.proxy_port = reactor.listenTCP(0, self.proxy) host = self.proxy_port.getHost() self.proxied_client = RetryClient(ZookeeperClient( "%s:%s" % (host.host, host.port))) self.direct_client = ZookeeperClient("127.0.0.1:2181", 3000) self.session_events = [] def session_event_collector(conn, event): self.session_events.append(event) self.proxied_client.set_session_callback(session_event_collector) return self.direct_client.connect()
class RetryClientConnectionLossTest(ZookeeperTestCase): def setUp(self): super(RetryClientConnectionLossTest, self).setUp() from twisted.internet import reactor self.proxy = ProxyFactory("127.0.0.1", 2181) self.proxy_port = reactor.listenTCP(0, self.proxy) host = self.proxy_port.getHost() self.proxied_client = RetryClient(ZookeeperClient( "%s:%s" % (host.host, host.port))) self.direct_client = ZookeeperClient("127.0.0.1:2181", 3000) self.session_events = [] def session_event_collector(conn, event): self.session_events.append(event) self.proxied_client.set_session_callback(session_event_collector) return self.direct_client.connect() @inlineCallbacks def tearDown(self): import zookeeper zookeeper.set_debug_level(0) if self.proxied_client.connected: yield self.proxied_client.close() if not self.direct_client.connected: yield self.direct_client.connect() utils.deleteTree(handle=self.direct_client.handle) yield self.direct_client.close() self.proxy.lose_connection() yield self.proxy_port.stopListening() @inlineCallbacks def test_get_children_and_watch(self): yield self.proxied_client.connect() # Setup tree cpath = "/test-tree" yield self.direct_client.create(cpath) # Block the request (drops all packets.) self.proxy.set_blocked(True) child_d, watch_d = self.proxied_client.get_children_and_watch(cpath) # Unblock and disconnect self.proxy.set_blocked(False) self.proxy.lose_connection() # Call goes through self.assertEqual((yield child_d), []) self.assertEqual(len(self.session_events), 2) # And we have reconnect events self.assertEqual(self.session_events[-1].state_name, "connected") yield self.direct_client.create(cpath + "/abc") # The original watch is still active yield watch_d @inlineCallbacks def test_exists_and_watch(self): yield self.proxied_client.connect() cpath = "/test-tree" # Block the request self.proxy.set_blocked(True) exists_d, watch_d = self.proxied_client.exists_and_watch(cpath) # Create the node yield self.direct_client.create(cpath) # Unblock and disconnect self.proxy.set_blocked(False) self.proxy.lose_connection() # Call gets retried, see the latest state self.assertTrue((yield exists_d)) self.assertEqual(len(self.session_events), 2) # And we have reconnect events self.assertEqual(self.session_events[-1].state_name, "connected") yield self.direct_client.delete(cpath) # The original watch is still active yield watch_d @inlineCallbacks def test_get_and_watch(self): yield self.proxied_client.connect() # Setup tree cpath = "/test-tree" yield self.direct_client.create(cpath) # Block the request (drops all packets.) self.proxy.set_blocked(True) get_d, watch_d = self.proxied_client.get_and_watch(cpath) # Unblock and disconnect self.proxy.set_blocked(False) self.proxy.lose_connection() # Call goes through content, stat = yield get_d self.assertEqual(content, '') self.assertEqual(len(self.session_events), 2) # And we have reconnect events self.assertEqual(self.session_events[-1].state_name, "connected") yield self.direct_client.delete(cpath) # The original watch is still active yield watch_d @inlineCallbacks def test_set(self): yield self.proxied_client.connect() # Setup tree cpath = "/test-tree" yield self.direct_client.create(cpath, json.dumps({"a": 1, "c": 2})) def update_node(content, stat): data = json.loads(content) data["a"] += 1 data["b"] = 0 return json.dumps(data) # Block the request (drops all packets.) self.proxy.set_blocked(True) mod_d = retry_change(self.proxied_client, cpath, update_node) # Unblock and disconnect self.proxy.set_blocked(False) self.proxy.lose_connection() # Call goes through, contents verified. yield mod_d content, stat = yield self.direct_client.get(cpath) self.assertEqual(json.loads(content), {"a": 2, "b": 0, "c": 2})
def setUp(self): super(RetryClientTests, self).setUp() self.client = RetryClient(ZookeeperClient("127.0.0.1:2181", 3000)) self.client2 = None