# Path: tensor/protocol/elasticsearch.py
# class ElasticSearch(object):
#     def __init__(self, url='http://localhost:9200', user=None, password=None,
#                  index='tensor-%Y.%m.%d'):
#     def _get_index(self):
#     def _request(self, path, data=None, method='GET'):
#     def _gen_id(self):
#     def stats(self):
#     def node_stats(self):
#     def insertIndex(self, type, data):
#     def bulkIndex(self, data):
# 
# Path: tensor/objects.py
# class Output(object):
#     """Output parent class
# 
#     Outputs can inherit this object which provides a construct
#     for a working output
# 
#     :param config: Dictionary config for this queue (usually read from the
#              yaml configuration)
#     :param tensor: A TensorService object for interacting with the queue manager
#     """
#     def __init__(self, config, tensor):
#         self.config = config
#         self.tensor = tensor
# 
#     def createClient(self):
#         """Deferred which sets up the output
#         """
#         pass
# 
#     def eventsReceived(self):
#         """Receives a list of events and processes them
# 
#         Arguments:
#         events -- list of `tensor.objects.Event`
#         """
#         pass
# 
#     def stop(self):
#         """Called when the service shuts down
#         """
#         pass


import time
import json
import datetime
from twisted.internet import reactor, defer, task
from twisted.python import log
    from OpenSSL import SSL
    from twisted.internet import ssl
from tensor.protocol import elasticsearch
from tensor.objects import Output
    """
    def __init__(self, *a):
        Output.__init__(self, *a)
        self.events = []
        self.t = task.LoopingCall(self.tick)

        self.inter = float(self.config.get('interval', 1.0))  # tick interval
        self.maxsize = int(self.config.get('maxsize', 250000))

        self.user = self.config.get('user')
        self.password = self.config.get('password')

        self.url = self.config.get('url', 'http://localhost:9200')

        maxrate = int(self.config.get('maxrate', 100))

        self.index = self.config.get('index', 'tensor-%Y.%m.%d')

        if maxrate > 0:
            self.queueDepth = int(maxrate * self.inter)
        else:
            self.queueDepth = None

    def createClient(self):
        """Sets up HTTP connector and starts queue timer
        """

        server = self.config.get('server', 'localhost')
        port = int(self.config.get('port', 9200))


# Path: tensor/protocol/elasticsearch.py
# class ElasticSearch(object):
#     def __init__(self, url='http://localhost:9200', user=None, password=None,
#                  index='tensor-%Y.%m.%d'):
#     def _get_index(self):
#     def _request(self, path, data=None, method='GET'):
#     def _gen_id(self):
#     def stats(self):
#     def node_stats(self):
#     def insertIndex(self, type, data):
#     def bulkIndex(self, data):
# 
# Path: tensor/objects.py
# class Output(object):
#     """Output parent class
# 
#     Outputs can inherit this object which provides a construct
#     for a working output
# 
#     :param config: Dictionary config for this queue (usually read from the
#              yaml configuration)
#     :param tensor: A TensorService object for interacting with the queue manager
#     """
#     def __init__(self, config, tensor):
#         self.config = config
#         self.tensor = tensor
# 
#     def createClient(self):
#         """Deferred which sets up the output
#         """
#         pass
# 
#     def eventsReceived(self):
#         """Receives a list of events and processes them
# 
#         Arguments:
#         events -- list of `tensor.objects.Event`
#         """
#         pass
# 
#     def stop(self):
#         """Called when the service shuts down
#         """
#         pass


# Path: tensor/outputs/elasticsearch.py
import time
import json
import datetime
from twisted.internet import reactor, defer, task
from twisted.python import log
    from OpenSSL import SSL
    from twisted.internet import ssl
from tensor.protocol import elasticsearch
from tensor.objects import Output

    """
    def __init__(self, *a):
        Output.__init__(self, *a)
        self.events = []
        self.t = task.LoopingCall(self.tick)

        self.inter = float(self.config.get('interval', 1.0))  # tick interval
        self.maxsize = int(self.config.get('maxsize', 250000))

        self.user = self.config.get('user')
        self.password = self.config.get('password')

        self.url = self.config.get('url', 'http://localhost:9200')

        maxrate = int(self.config.get('maxrate', 100))

        self.index = self.config.get('index', 'tensor-%Y.%m.%d')

        if maxrate > 0:
            self.queueDepth = int(maxrate * self.inter)
        else:
            self.queueDepth = None

    def createClient(self):
        """Sets up HTTP connector and starts queue timer
        """

        server = self.config.get('server', 'localhost')
        port = int(self.config.get('port', 9200))


        self.client = elasticsearch.ElasticSearch(self.url, self.user,