예제 #1
0
 def test_delete(self):
     value1 = {"f": "create", "a": {"id": "123"}}
     consume(value1)
     value2 = {"f": "delete", "a": {"id": "123"}}
     consume(value2)
     value3 = {"f": "get", "a": {"id": "123"}}
     result = consume(value3)
     self.assertEqual(result, None)
예제 #2
0
 def test_update(self):
     value1 = {"f": "create", "a": {"id": "123"}}
     consume(value1)
     value2 = {"f": "update", "a": {"id": "123", "name": "test"}}
     consume(value2)
     value3 = {"f": "get", "a": {"id": "123"}}
     result = consume(value3)
     self.assertEqual(json.loads(result)["name"], "test")
예제 #3
0
def main():

    component_map = {"pup": maps.PUP, "hbi": maps.HBI}
    logger.info("Starting Component Tester")
    config.log_config()

    if config.ROLE == "consume":
        data = component_map[config.COMPONENT]
        consumer.consume(data["consume_topic"])
    elif config.ROLE == "produce":
        data = component_map[config.COMPONENT]
        producer.produce(data["produce_topic"], data["msg"])
    else:
        logger.error("Role not recognized: %s", config.ROLE)
            'nodes': rnn_data['nodes'],
            'scale': rnn_data['scale']
            }
    else:
        autoScaleData ={
            'peak_value': rnn_data['peak_value'],
            'average_value': rnn_data['average_value'],
            'nodes': rnn_data['nodes'],
            'scale': rnn_data['scale']
            }

    print("********************************************")
    print("The autoscale message sent to Scaling engine:")
    print(json.dumps(autoScaleData))
    return send_data_producer(autoScaleData)

def send_data_producer(result):
   return producer.producer(result)


while True:
    df,memory_host=consumer.consume()
    predict(df,memory_host)
    for remaining in range(420, 0, -1):
        sys.stdout.write("\r")
        sys.stdout.write("{:2d} seconds remaining.".format(remaining))
        sys.stdout.flush()
        time.sleep(1)

    sys.stdout.write("\rStarting Prediction Engine ......... \n")
예제 #5
0
def consume():
    commit = request.args.get('auto_commit')
    topic = request.args.get('topic')
    return_ = consumer.consume(auto_commit=commit, topic=topic)
    return Response(json.dumps(return_),  mimetype='application/json')
예제 #6
0
 def test_create(self):
     value = {"f": "create", "a": {"id": "123"}}
     result = consume(value)
예제 #7
0
 def test_get(self):
     value1 = {"f": "create", "a": {"id": "123"}}
     consume(value1)
     value2 = {"f": "get", "a": {"id": "123"}}
     result = consume(value2)
     self.assertEqual(json.loads(result)["id"], "123")
예제 #8
0
def worker(q):
  consumer.consume()
예제 #9
0
from consumer import consume

if __name__ == '__main__':
    consume()