Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve frame sending conflict between live and reg crawler #358

Merged
merged 2 commits into from
Feb 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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