mirror of
https://github.com/xcat2/confluent.git
synced 2025-01-28 11:57:37 +00:00
Revert "Attempt to mitigate memory consumption"
This reverts commit e746d0dd3b591a4b88cc456076a5edb1aa4bc2e7.
This commit is contained in:
parent
e746d0dd3b
commit
1d76dcf13d
@ -9,7 +9,6 @@
|
||||
#there should be no more than one handler per node
|
||||
import confluent.pluginapi as plugin
|
||||
import confluent.util as util
|
||||
from cStringIO import StringIO
|
||||
|
||||
_handled_consoles = {}
|
||||
|
||||
@ -35,6 +34,7 @@ class _ConsoleHandler(object):
|
||||
#also, timestamp data...
|
||||
|
||||
def get_console_output(self, data):
|
||||
self.buffer += data
|
||||
#TODO: analyze buffer for registered events, examples:
|
||||
# panics
|
||||
# certificate signing request
|
||||
@ -42,29 +42,24 @@ class _ConsoleHandler(object):
|
||||
#call to function to get generic data to log if applicable
|
||||
#and shrink buffer
|
||||
self.flushbuffer()
|
||||
bufidx = len(self.buffer)
|
||||
bufsz = len(data)
|
||||
self.buffer.extend(data)
|
||||
view = buffer(self.buffer, bufidx, bufsz)
|
||||
for rcpt in self.rcpts:
|
||||
rcpt(view)
|
||||
rcpt(data)
|
||||
|
||||
def get_recent(self):
|
||||
#this is one scheme to clear screen, move cursor then clear
|
||||
bflen = len(self.buffer)
|
||||
bgn = bflen - 512
|
||||
if bgn < 0:
|
||||
if len(self.buffer) > 512:
|
||||
bgn = -512
|
||||
else:
|
||||
bgn = 0
|
||||
#this covers the case of move cursor to begin, clear to end
|
||||
bufidx = self.buffer[bgn:].rfind('\x1b[H\x1b[J')
|
||||
if bufidx >= 0:
|
||||
return buffer(self.buffer,bufidx, bflen - bufidx)
|
||||
#this handles the 'clear all' control code, often used by firmware
|
||||
return str(self.buffer[bufidx:])
|
||||
#another scheme is the 2J scheme
|
||||
bufidx = self.buffer[bgn:].rfind('\x1b[2J')
|
||||
if bufidx >= 0:
|
||||
return buffer(self.buffer,bufidx, bflen - bufidx)
|
||||
return str(self.buffer[bufidx:])
|
||||
else:
|
||||
return buffer(self.buffer,bgn, bflen - bufidx)
|
||||
return str(self.buffer[bgn:])
|
||||
|
||||
def write(self, data):
|
||||
#TODO.... take note of data coming in from audit/log perspective?
|
||||
@ -92,7 +87,7 @@ class ConsoleSession(object):
|
||||
self.conshdl = _handled_consoles[node]
|
||||
self.write = _handled_consoles[node].write
|
||||
if datacallback is None:
|
||||
self.databuffers = [ _handled_consoles[node].get_recent() ]
|
||||
self.databuffer = _handled_consoles[node].get_recent()
|
||||
_handled_consoles[node].register_rcpt(self.got_data)
|
||||
else:
|
||||
_handled_consoles[node].register_rcpt(datacallback)
|
||||
@ -104,7 +99,7 @@ class ConsoleSession(object):
|
||||
If the caller does not provide a callback and instead will be polling
|
||||
for data, we must maintain data in a buffer until retrieved
|
||||
"""
|
||||
self.databuffers.append(data)
|
||||
self.databuffer += data
|
||||
|
||||
def get_next_output(self, timeout=45):
|
||||
"""Poll for next available output on this console.
|
||||
@ -114,15 +109,13 @@ class ConsoleSession(object):
|
||||
"""
|
||||
currtime = util.monotonic_time()
|
||||
deadline = currtime + 45
|
||||
while len(self.databuffers) == 0 and currtime < deadline:
|
||||
while len(self.databuffer) == 0 and currtime < deadline:
|
||||
timeo = deadline - currtime
|
||||
self.conshdl._console.wait_for_data(timeout=timeo)
|
||||
currtime = util.monotonic_time()
|
||||
retval = StringIO()
|
||||
for buf in self.databuffers:
|
||||
retval.write(buf)
|
||||
self.databuffers = []
|
||||
return retval.getvalue()
|
||||
retval = self.databuffer
|
||||
self.databuffer = ""
|
||||
return retval
|
||||
|
||||
|
||||
def handle_request(request=None, connection=None, releaseconnection=False):
|
||||
@ -130,7 +123,7 @@ def handle_request(request=None, connection=None, releaseconnection=False):
|
||||
Process a request from confluent.
|
||||
|
||||
:param request: For 'datagram' style console, this represents a wait for
|
||||
data or input.
|
||||
data or input.
|
||||
:param connection: For socket style console, this is a read/write socket
|
||||
that the caller has released from it's control and
|
||||
console plugin will do all IO
|
||||
|
@ -15,7 +15,6 @@ import confluent.pluginapi as pluginapi
|
||||
import confluent.httpapi as httpapi
|
||||
import confluent.sockapi as sockapi
|
||||
import eventlet
|
||||
import eventlet.backdoor as backdoor
|
||||
from eventlet.green import socket
|
||||
from eventlet import wsgi
|
||||
import multiprocessing
|
||||
@ -28,8 +27,6 @@ def run():
|
||||
webservice.start()
|
||||
sockservice = sockapi.SockApi()
|
||||
sockservice.start()
|
||||
#TODO: Unix domain socket instead
|
||||
eventlet.spawn(backdoor.backdoor_server, eventlet.listen(('localhost', 2121)))
|
||||
while (1):
|
||||
eventlet.sleep(100)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user