Search is not available for this dataset
text stringlengths 75 104k |
|---|
def read_file(file_path):
'''
read file
'''
lines = []
with open(file_path, "r") as tf:
lines = [line.strip("\n") for line in tf.readlines() if not line.startswith("#")]
# filter empty lines
lines = [line for line in lines if line]
return lines |
def call_editor(file_path):
'''
call editor
'''
EDITOR = os.environ.get('EDITOR', 'vim')
with open(file_path, 'r+') as tf:
call([EDITOR, tf.name]) |
def get_remote_home(host, cl_args):
'''
get home directory of remote host
'''
cmd = "echo ~"
if not is_self(host):
cmd = ssh_remote_execute(cmd, host, cl_args)
pid = subprocess.Popen(cmd,
shell=True,
stdout=subprocess.PIPE,
stder... |
def get_hostname(ip_addr, cl_args):
'''
get host name of remote host
'''
if is_self(ip_addr):
return get_self_hostname()
cmd = "hostname"
ssh_cmd = ssh_remote_execute(cmd, ip_addr, cl_args)
pid = subprocess.Popen(ssh_cmd,
shell=True,
stdout=subprocess.... |
def is_self(addr):
'''
check if this host is this addr
'''
ips = []
for i in netifaces.interfaces():
entry = netifaces.ifaddresses(i)
if netifaces.AF_INET in entry:
for ipv4 in entry[netifaces.AF_INET]:
if "addr" in ipv4:
ips.append(ipv4["addr"])
return addr in ips or addr ==... |
def log(self, message, level=None):
"""Log message, optionally providing a logging level
It is compatible with StreamParse API.
:type message: str
:param message: the log message to send
:type level: str
:param level: the logging level,
one of: trace (=debug), debug, info, wa... |
def load_py_instance(self, is_spout):
"""Loads user defined component (spout/bolt)"""
try:
if is_spout:
spout_proto = self.pplan_helper.get_my_spout()
py_classpath = spout_proto.comp.class_name
self.logger.info("Loading Spout from: %s", py_classpath)
else:
bolt_proto ... |
def get(self):
""" get method """
# Get all the values for parameter "cluster".
clusters = self.get_arguments(constants.PARAM_CLUSTER)
# Get all the values for parameter "environ".
environs = self.get_arguments(constants.PARAM_ENVIRON)
# Get role
role = self.get_argument_role()
ret = {}... |
def dereference_symlinks(src):
"""
Resolve all symbolic references that `src` points to. Note that this
is different than `os.path.realpath` as path components leading up to
the final location may still be symbolic links.
"""
while os.path.islink(src):
src = os.path.join(os.path.dirname... |
def get(self):
""" get method """
clusters = [statemgr.name for statemgr in self.tracker.state_managers]
self.write_success_response(clusters) |
def get_cluster_role_env_topologies(cluster, role, env):
'''
Get the list of topologies given a cluster submitted by a given role under a given environment
:param cluster:
:param role:
:param env:
:return:
'''
return _get_topologies(cluster, role=role, env=env) |
def get_execution_state(cluster, environ, topology, role=None):
'''
Get the execution state of a topology in a cluster
:param cluster:
:param environ:
:param topology:
:param role:
:return:
'''
params = dict(cluster=cluster, environ=environ, topology=topology)
if role is not None:
params['role']... |
def get_logical_plan(cluster, environ, topology, role=None):
'''
Get the logical plan state of a topology in a cluster
:param cluster:
:param environ:
:param topology:
:param role:
:return:
'''
params = dict(cluster=cluster, environ=environ, topology=topology)
if role is not None:
params['role']... |
def get_comps(cluster, environ, topology, role=None):
'''
Get the list of component names for the topology from Heron Nest
:param cluster:
:param environ:
:param topology:
:param role:
:return:
'''
params = dict(cluster=cluster, environ=environ, topology=topology)
if role is not None:
params['ro... |
def get_instances(cluster, environ, topology, role=None):
'''
Get the list of instances for the topology from Heron Nest
:param cluster:
:param environ:
:param topology:
:param role:
:return:
'''
params = dict(cluster=cluster, environ=environ, topology=topology)
if role is not None:
params['role... |
def get_physical_plan(cluster, environ, topology, role=None):
'''
Get the physical plan state of a topology in a cluster from tracker
:param cluster:
:param environ:
:param topology:
:param role:
:return:
'''
params = dict(cluster=cluster, environ=environ, topology=topology)
if role is not None:
... |
def get_scheduler_location(cluster, environ, topology, role=None):
'''
Get the scheduler location of a topology in a cluster from tracker
:param cluster:
:param environ:
:param topology:
:param role:
:return:
'''
params = dict(cluster=cluster, environ=environ, topology=topology)
if role is not None:... |
def get_component_exceptionsummary(cluster, environ, topology, component, role=None):
'''
Get summary of exception for a component
:param cluster:
:param environ:
:param topology:
:param component:
:param role:
:return:
'''
params = dict(
cluster=cluster,
environ=environ,
topology=... |
def get_component_exceptions(cluster, environ, topology, component, role=None):
'''
Get exceptions for 'component' for 'topology'
:param cluster:
:param environ:
:param topology:
:param component:
:param role:
:return:
'''
params = dict(
cluster=cluster,
environ=environ,
topology=t... |
def get_comp_instance_metrics(cluster, environ, topology, component,
metrics, instances, time_range, role=None):
'''
Get the metrics for some instances of a topology from tracker
:param cluster:
:param environ:
:param topology:
:param component:
:param metrics: dict of di... |
def get_comp_metrics(cluster, environ, topology, component,
instances, metricnames, time_range, role=None):
'''
Get the metrics for all the instances of a topology from Heron Nest
:param cluster:
:param environ:
:param topology:
:param component:
:param instances:
:param metricnames... |
def get_metrics(cluster, environment, topology, timerange, query, role=None):
'''
Get the metrics for a topology from tracker
:param cluster:
:param environment:
:param topology:
:param timerange:
:param query:
:param role:
:return:
'''
params = dict(
cluster=cluster,
environ=environme... |
def get_comp_metrics_timeline(cluster, environ, topology, component,
instances, metricnames, time_range, role=None):
'''
Get the minute-by-minute metrics for all instances of a topology from tracker
:param cluster:
:param environ:
:param topology:
:param component:
:param ins... |
def get_topology_info(cluster, environ, topology, role=None):
'''
:param cluster:
:param environ:
:param topology:
:param role:
:return:
'''
params = dict(
cluster=cluster,
environ=environ,
topology=topology)
if role is not None:
params['role'] = role
request_url = tornado.ht... |
def get_instance_pid(cluster, environ, topology, instance, role=None):
'''
:param cluster:
:param environ:
:param topology:
:param instance:
:param role:
:return:
'''
params = dict(
cluster=cluster,
environ=environ,
topology=topology,
instance=instance)
if role is not None:
... |
def get_instance_jstack(cluster, environ, topology, instance, role=None):
'''
:param cluster:
:param environ:
:param topology:
:param instance:
:param role:
:return:
'''
params = dict(
cluster=cluster,
environ=environ,
topology=topology,
instance=instance)
if role is not Non... |
def get_instance_mem_histogram(cluster, environ, topology, instance, role=None):
'''
:param cluster:
:param environ:
:param topology:
:param instance:
:param role:
:return:
'''
params = dict(
cluster=cluster,
environ=environ,
topology=topology,
instance=instance)
if role is ... |
def run_instance_jmap(cluster, environ, topology, instance, role=None):
'''
:param cluster:
:param environ:
:param topology:
:param instance:
:param role:
:return:
'''
params = dict(
cluster=cluster,
environ=environ,
topology=topology,
instance=instance)
if role is not None:... |
def get_container_file_download_url(cluster, environ, topology, container,
path, role=None):
'''
:param cluster:
:param environ:
:param topology:
:param container:
:param path:
:param role:
:return:
'''
params = dict(
cluster=cluster,
environ=environ,
... |
def get_container_file_data(cluster, environ, topology, container,
path, offset, length, role=None):
'''
:param cluster:
:param environ:
:param topology:
:param container:
:param path:
:param offset:
:param length:
:param role:
:return:
'''
params = dict(
cluste... |
def get_filestats(cluster, environ, topology, container, path, role=None):
'''
:param cluster:
:param environ:
:param topology:
:param container:
:param path:
:param role:
:return:
'''
params = dict(
cluster=cluster,
environ=environ,
topology=topology,
container=container,
... |
def fetch(self, cluster, metric, topology, component, instance, timerange, environ=None):
'''
:param cluster:
:param metric:
:param topology:
:param component:
:param instance:
:param timerange:
:param environ:
:return:
'''
components = [component] if component != "*" else (y... |
def fetch_max(self, cluster, metric, topology, component, instance, timerange, environ=None):
'''
:param cluster:
:param metric:
:param topology:
:param component:
:param instance:
:param timerange:
:param environ:
:return:
'''
components = [component] if component != "*" els... |
def fetch_backpressure(self, cluster, metric, topology, component, instance, \
timerange, is_max, environ=None):
'''
:param cluster:
:param metric:
:param topology:
:param component:
:param instance:
:param timerange:
:param isMax:
:param environ:
:return:
'''
instanc... |
def compute_max(self, multi_ts):
'''
:param multi_ts:
:return:
'''
if len(multi_ts) > 0 and len(multi_ts[0]["timeline"]) > 0:
keys = multi_ts[0]["timeline"][0]["data"].keys()
timelines = ([res["timeline"][0]["data"][key] for key in keys] for res in multi_ts)
values = (max(v) for v ... |
def get_metric_response(self, timerange, data, isMax):
'''
:param timerange:
:param data:
:param isMax:
:return:
'''
if isMax:
return dict(
status="success",
starttime=timerange[0],
endtime=timerange[1],
result=dict(timeline=[dict(data=data)])
... |
def get_query(self, metric, component, instance):
'''
:param metric:
:param component:
:param instance:
:return:
'''
q = queries.get(metric)
return q.format(component, instance) |
def to_table(result):
''' normalize raw result to table '''
max_count = 20
table, count = [], 0
for role, envs_topos in result.items():
for env, topos in envs_topos.items():
for topo in topos:
count += 1
if count > max_count:
continue
else:
table.append([rol... |
def show_cluster(cl_args, cluster):
''' print topologies information to stdout '''
try:
result = tracker_access.get_cluster_topologies(cluster)
if not result:
Log.error('No topologies in cluster \'%s\'' % cluster)
return False
result = result[cluster]
except Exception:
Log.error("Fail ... |
def show_cluster_role(cl_args, cluster, role):
''' print topologies information to stdout '''
try:
result = tracker_access.get_cluster_role_topologies(cluster, role)
if not result:
Log.error('Unknown cluster/role \'%s\'' % '/'.join([cluster, role]))
return False
result = result[cluster]
ex... |
def show_cluster_role_env(cl_args, cluster, role, env):
''' print topologies information to stdout '''
try:
result = tracker_access.get_cluster_role_env_topologies(cluster, role, env)
if not result:
Log.error('Unknown cluster/role/env \'%s\'' % '/'.join([cluster, role, env]))
return False
re... |
def run(command, parser, cl_args, unknown_args):
""" run command """
location = cl_args['cluster/[role]/[env]'].split('/')
if len(location) == 1:
return show_cluster(cl_args, *location)
elif len(location) == 2:
return show_cluster_role(cl_args, *location)
elif len(location) == 3:
return show_clust... |
def heron_class(class_name, lib_jars, extra_jars=None, args=None, java_defines=None):
'''
Execute a heron class given the args and the jars needed for class path
:param class_name:
:param lib_jars:
:param extra_jars:
:param args:
:param java_defines:
:return:
'''
# default optional params to empty l... |
def heron_tar(class_name, topology_tar, arguments, tmpdir_root, java_defines):
'''
:param class_name:
:param topology_tar:
:param arguments:
:param tmpdir_root:
:param java_defines:
:return:
'''
# Extract tar to a tmp folder.
tmpdir = tempfile.mkdtemp(dir=tmpdir_root, prefix='tmp')
with contextli... |
def get(self, cluster, environ, topology, comp_name):
'''
:param cluster:
:param environ:
:param topology:
:param comp_name:
:return:
'''
start_time = time.time()
comp_names = []
if comp_name == "All":
lplan = yield access.get_logical_plan(cluster, environ, topology)
... |
def get(self):
'''
:return:
'''
# get all the topologies from heron nest
topologies = yield access.get_topologies_states()
result = dict()
# now convert some of the fields to be displayable
for cluster, cluster_value in topologies.items():
result[cluster] = dict()
for envir... |
def get(self, cluster, environ, topology):
'''
:param cluster:
:param environ:
:param topology:
:return:
'''
start_time = time.time()
lplan = yield access.get_logical_plan(cluster, environ, topology)
# construct the result
result = dict(
status="success",
messag... |
def get(self, cluster, environ, topology):
'''
:param cluster:
:param environ:
:param topology:
:return:
'''
start_time = time.time()
pplan = yield access.get_physical_plan(cluster, environ, topology)
result_map = dict(
status="success",
message="",
version=... |
def get(self, cluster, environ, topology, component):
'''
:param cluster:
:param environ:
:param topology:
:param component:
:return:
'''
start_time = time.time()
futures = yield access.get_component_exceptions(cluster, environ, topology, component)
result_map = dict(
sta... |
def get(self, cluster, environ, topology, instance):
'''
:param cluster:
:param environ:
:param topology:
:param instance:
:return:
'''
pplan = yield access.get_physical_plan(cluster, environ, topology)
host = pplan['stmgrs'][pplan['instances'][instance]['stmgrId']]['host']
resul... |
def add_context(self, err_context, succ_context=None):
""" Prepend msg to add some context information
:param pmsg: context info
:return: None
"""
self.err_context = err_context
self.succ_context = succ_context |
def renderProcessStdErr(self, stderr_line):
""" render stderr of shelled-out process
stderr could be error message of failure of invoking process or
normal stderr output from successfully shelled-out process.
In the first case, ``Popen'' should fail fast and we should be able to
get ... |
def renderProcessStdOut(self, stdout):
""" render stdout of shelled-out process
stdout always contains information Java process wants to
propagate back to cli, so we do special rendering here
:param stdout: all lines from shelled-out process
:return:
"""
# since we render stdout line... |
def is_host_port_reachable(self):
"""
Returns true if the host is reachable. In some cases, it may not be reachable a tunnel
must be used.
"""
for hostport in self.hostportlist:
try:
socket.create_connection(hostport, StateManager.TIMEOUT_SECONDS)
return True
except:
... |
def pick_unused_port(self):
""" Pick an unused port. There is a slight chance that this wont work. """
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('127.0.0.1', 0))
_, port = s.getsockname()
s.close()
return port |
def establish_ssh_tunnel(self):
"""
Establish an ssh tunnel for each local host and port
that can be used to communicate with the state host.
"""
localportlist = []
for (host, port) in self.hostportlist:
localport = self.pick_unused_port()
self.tunnel.append(subprocess.Popen(
... |
def delete_topology_from_zk(self, topologyName):
"""
Removes the topology entry from:
1. topologies list,
2. pplan,
3. execution_state, and
"""
self.delete_pplan(topologyName)
self.delete_execution_state(topologyName)
self.delete_topology(topologyName) |
def monitor(self):
"""
Monitor the rootpath and call the callback
corresponding to the change.
This monitoring happens periodically. This function
is called in a seperate thread from the main thread,
because it sleeps for the intervals between each poll.
"""
def trigger_watches_based_on... |
def get_topologies(self, callback=None):
"""get topologies"""
if callback:
self.topologies_watchers.append(callback)
else:
topologies_path = self.get_topologies_path()
return filter(lambda f: os.path.isfile(os.path.join(topologies_path, f)),
os.listdir(topologies_path)) |
def get_topology(self, topologyName, callback=None):
"""get topology"""
if callback:
self.topology_watchers[topologyName].append(callback)
else:
topology_path = self.get_topology_path(topologyName)
with open(topology_path) as f:
data = f.read()
topology = Topology()
... |
def get_packing_plan(self, topologyName, callback=None):
""" get packing plan """
if callback:
self.packing_plan_watchers[topologyName].append(callback)
else:
packing_plan_path = self.get_packing_plan_path(topologyName)
with open(packing_plan_path) as f:
data = f.read()
pac... |
def get_pplan(self, topologyName, callback=None):
"""
Get physical plan of a topology
"""
if callback:
self.pplan_watchers[topologyName].append(callback)
else:
pplan_path = self.get_pplan_path(topologyName)
with open(pplan_path) as f:
data = f.read()
pplan = Physica... |
def get_execution_state(self, topologyName, callback=None):
"""
Get execution state
"""
if callback:
self.execution_state_watchers[topologyName].append(callback)
else:
execution_state_path = self.get_execution_state_path(topologyName)
with open(execution_state_path) as f:
d... |
def get_tmaster(self, topologyName, callback=None):
"""
Get tmaster
"""
if callback:
self.tmaster_watchers[topologyName].append(callback)
else:
tmaster_path = self.get_tmaster_path(topologyName)
with open(tmaster_path) as f:
data = f.read()
tmaster = TMasterLocation... |
def get_scheduler_location(self, topologyName, callback=None):
"""
Get scheduler location
"""
if callback:
self.scheduler_location_watchers[topologyName].append(callback)
else:
scheduler_location_path = self.get_scheduler_location_path(topologyName)
with open(scheduler_location_pat... |
def get(self, pid):
''' get method '''
body = utils.str_cmd(['jmap', '-histo', pid], None, None)
self.content_type = 'application/json'
self.write(json.dumps(body))
self.finish() |
def create_socket_options():
"""Creates SocketOptions object from a given sys_config dict"""
sys_config = system_config.get_sys_config()
opt_list = [const.INSTANCE_NETWORK_WRITE_BATCH_SIZE_BYTES,
const.INSTANCE_NETWORK_WRITE_BATCH_TIME_MS,
const.INSTANCE_NETWORK_READ_BATCH_SIZE_BYTES,
... |
def class_dict_to_specs(mcs, class_dict):
"""Takes a class `__dict__` and returns `HeronComponentSpec` entries"""
specs = {}
for name, spec in class_dict.items():
if isinstance(spec, HeronComponentSpec):
# Use the variable name as the specification name.
if spec.name is None:
... |
def class_dict_to_topo_config(mcs, class_dict):
"""
Takes a class `__dict__` and returns a map containing topology-wide
configuration.
The returned dictionary is a sanitized `dict` of type `<str ->
(str|object)>`.
This classmethod firsts insert default topology configuration and then
overr... |
def init_topology(mcs, classname, class_dict):
"""Initializes a topology protobuf"""
if classname == 'Topology':
# Base class can't initialize protobuf
return
heron_options = TopologyType.get_heron_options_from_env()
initial_state = heron_options.get("cmdline.topology.initial.state", "RUNNIN... |
def get_heron_options_from_env():
"""Retrieves heron options from the `HERON_OPTIONS` environment variable.
Heron options have the following format:
cmdline.topologydefn.tmpdirectory=/var/folders/tmpdir
cmdline.topology.initial.state=PAUSED
In this case, the returned map will contain:
... |
def add_spec(self, *specs):
"""Add specs to the topology
:type specs: HeronComponentSpec
:param specs: specs to add to the topology
"""
for spec in specs:
if not isinstance(spec, HeronComponentSpec):
raise TypeError("Argument to add_spec needs to be HeronComponentSpec, given: %s"
... |
def add_spout(self, name, spout_cls, par, config=None, optional_outputs=None):
"""Add a spout to the topology"""
spout_spec = spout_cls.spec(name=name, par=par, config=config,
optional_outputs=optional_outputs)
self.add_spec(spout_spec)
return spout_spec |
def add_bolt(self, name, bolt_cls, par, inputs, config=None, optional_outputs=None):
"""Add a bolt to the topology"""
bolt_spec = bolt_cls.spec(name=name, par=par, inputs=inputs, config=config,
optional_outputs=optional_outputs)
self.add_spec(bolt_spec)
return bolt_spec |
def set_config(self, config):
"""Set topology-wide configuration to the topology
:type config: dict
:param config: topology-wide config
"""
if not isinstance(config, dict):
raise TypeError("Argument to set_config needs to be dict, given: %s" % str(config))
self._topology_config = config |
def build_and_submit(self):
"""Builds the topology and submits to the destination"""
class_dict = self._construct_topo_class_dict()
topo_cls = TopologyType(self.topology_name, (Topology,), class_dict)
topo_cls.write() |
def fetch_url_as_json(fetch_url, default_value=None):
'''
Fetch the given url and convert the response to json.
:param fetch_url: URL to fetch
:param default_value: value to return in case of failure
:return:
'''
# assign empty dict for optional param
if default_value is None:
default_value = dict()... |
def create_parser(subparsers):
""" create parser """
parser = subparsers.add_parser(
'version',
help='Display version',
usage="%(prog)s",
add_help=False)
args.add_titles(parser)
parser.set_defaults(subcommand='version')
return parser |
def queries_map():
"""map from query parameter to query name"""
qs = _all_metric_queries()
return dict(zip(qs[0], qs[1]) + zip(qs[2], qs[3])) |
def get_clusters():
"""Synced API call to get all cluster names"""
instance = tornado.ioloop.IOLoop.instance()
# pylint: disable=unnecessary-lambda
try:
return instance.run_sync(lambda: API.get_clusters())
except Exception:
Log.debug(traceback.format_exc())
raise |
def get_logical_plan(cluster, env, topology, role):
"""Synced API call to get logical plans"""
instance = tornado.ioloop.IOLoop.instance()
try:
return instance.run_sync(lambda: API.get_logical_plan(cluster, env, topology, role))
except Exception:
Log.debug(traceback.format_exc())
raise |
def get_topology_info(*args):
"""Synced API call to get topology information"""
instance = tornado.ioloop.IOLoop.instance()
try:
return instance.run_sync(lambda: API.get_topology_info(*args))
except Exception:
Log.debug(traceback.format_exc())
raise |
def get_component_metrics(component, cluster, env, topology, role):
"""Synced API call to get component metrics"""
all_queries = metric_queries()
try:
result = get_topology_metrics(cluster, env, topology, component, [],
all_queries, [0, -1], role)
return result["metrics"]... |
def configure(level=logging.INFO, logfile=None):
""" Configure logger which dumps log on terminal
:param level: logging level: info, warning, verbose...
:type level: logging level
:param logfile: log file name, default to None
:type logfile: string
:return: None
:rtype: None
"""
# Remove all the exi... |
def init_rotating_logger(level, logfile, max_files, max_bytes):
"""Initializes a rotating logger
It also makes sure that any StreamHandler is removed, so as to avoid stdout/stderr
constipation issues
"""
logging.basicConfig()
root_logger = logging.getLogger()
log_format = "[%(asctime)s] [%(levelname)s] ... |
def set_logging_level(cl_args):
"""simply set verbose level based on command-line args
:param cl_args: CLI arguments
:type cl_args: dict
:return: None
:rtype: None
"""
if 'verbose' in cl_args and cl_args['verbose']:
configure(logging.DEBUG)
else:
configure(logging.INFO) |
def _get_spout(self):
"""Returns Spout protobuf message"""
spout = topology_pb2.Spout()
spout.comp.CopyFrom(self._get_base_component())
# Add output streams
self._add_out_streams(spout)
return spout |
def _get_bolt(self):
"""Returns Bolt protobuf message"""
bolt = topology_pb2.Bolt()
bolt.comp.CopyFrom(self._get_base_component())
# Add streams
self._add_in_streams(bolt)
self._add_out_streams(bolt)
return bolt |
def _get_base_component(self):
"""Returns Component protobuf message"""
comp = topology_pb2.Component()
comp.name = self.name
comp.spec = topology_pb2.ComponentObjectSpec.Value("PYTHON_CLASS_NAME")
comp.class_name = self.python_class_path
comp.config.CopyFrom(self._get_comp_config())
return ... |
def _get_comp_config(self):
"""Returns component-specific Config protobuf message
It first adds ``topology.component.parallelism``, and is overriden by
a user-defined component-specific configuration, specified by spec().
"""
proto_config = topology_pb2.Config()
# first add parallelism
key... |
def _sanitize_config(custom_config):
"""Checks whether ``custom_config`` is sane and returns a sanitized dict <str -> (str|object)>
It checks if keys are all strings and sanitizes values of a given dictionary as follows:
- If string, number or boolean is given as a value, it is converted to string.
... |
def _add_in_streams(self, bolt):
"""Adds inputs to a given protobuf Bolt message"""
if self.inputs is None:
return
# sanitize inputs and get a map <GlobalStreamId -> Grouping>
input_dict = self._sanitize_inputs()
for global_streamid, gtype in input_dict.items():
in_stream = bolt.inputs.... |
def _sanitize_inputs(self):
"""Sanitizes input fields and returns a map <GlobalStreamId -> Grouping>"""
ret = {}
if self.inputs is None:
return
if isinstance(self.inputs, dict):
# inputs are dictionary, must be either <HeronComponentSpec -> Grouping> or
# <GlobalStreamId -> Grouping>
... |
def _add_out_streams(self, spbl):
"""Adds outputs to a given protobuf Bolt or Spout message"""
if self.outputs is None:
return
# sanitize outputs and get a map <stream_id -> out fields>
output_map = self._sanitize_outputs()
for stream_id, out_fields in output_map.items():
out_stream = ... |
def _sanitize_outputs(self):
"""Sanitizes output fields and returns a map <stream_id -> list of output fields>"""
ret = {}
if self.outputs is None:
return
if not isinstance(self.outputs, (list, tuple)):
raise TypeError("Argument to outputs must be either list or tuple, given: %s"
... |
def get_out_streamids(self):
"""Returns a set of output stream ids registered for this component"""
if self.outputs is None:
return set()
if not isinstance(self.outputs, (list, tuple)):
raise TypeError("Argument to outputs must be either list or tuple, given: %s"
% str(typ... |
def _get_stream_id(comp_name, stream_id):
"""Returns a StreamId protobuf message"""
proto_stream_id = topology_pb2.StreamId()
proto_stream_id.id = stream_id
proto_stream_id.component_name = comp_name
return proto_stream_id |
def _get_stream_schema(fields):
"""Returns a StreamSchema protobuf message"""
stream_schema = topology_pb2.StreamSchema()
for field in fields:
key = stream_schema.keys.add()
key.key = field
key.type = topology_pb2.Type.Value("OBJECT")
return stream_schema |
def component_id(self):
"""Returns component_id of this GlobalStreamId
Note that if HeronComponentSpec is specified as componentId and its name is not yet
available (i.e. when ``name`` argument was not given in ``spec()`` method in Bolt or Spout),
this property returns a message with uuid. However, thi... |
def write_error(self, status_code, **kwargs):
'''
:param status_code:
:param kwargs:
:return:
'''
if "exc_info" in kwargs:
exc_info = kwargs["exc_info"]
error = exc_info[1]
errormessage = "%s: %s" % (status_code, error)
self.render("error.html", errormessage=errormessage... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.