Skip to content

Commit

Permalink
resolve conflict between live and reg crawler (#358)
Browse files Browse the repository at this point in the history
Signed-off-by: Tatsuhiro Chiba <[email protected]>
  • Loading branch information
tatsuhirochiba authored and sahilsuneja1 committed Feb 6, 2018
1 parent 791634a commit 6467ff2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion crawler/plugins/emitters/sas_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import json
import time
import sys

import requests

Expand Down Expand Up @@ -102,7 +103,6 @@ def gen_params(self, namespace='', features='', timestamp='',
# remove "icp/" string from namespace
namespace = namespace[4:]
assert namespace[0] != "/"
logger.info("emit frame (namespace=%s)", namespace)

params.update({'namespace': namespace})
params.update({'access_group': access_group})
Expand Down Expand Up @@ -162,6 +162,17 @@ def post(self, content='', metadata={}):
import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

# skip it in live-crawler if namespace includes reg-crawler format
if ':' in params.get('namespace') \
and params.get('source_type') == 'container':
logger.info("frame does not satisfy SAS required format")
logger.info("source_type=container, namespace=%s",
params.get('namespace'))
return

logger.info("emit frame (namespace=%s)", params.get('namespace'))
logger.info("content size: {0} byte".format(sys.getsizeof(content)))

# set interval to avoid burst emit
if int(self.emit_interval) > 0:
logger.debug("wait %s sec...", self.emit_interval)
Expand Down

0 comments on commit 6467ff2

Please sign in to comment.