Esempio n. 1
0
def _client(pipeline: IPipeline) -> _StreamSetsApiClient:
    if not pipeline.get_streamsets():
        raise StreamsetsException(
            f'Pipeline `{pipeline.get_id()}` does not belong to any StreamSets'
        )
    if pipeline.get_streamsets().get_id() not in _clients:
        _clients[pipeline.get_streamsets().get_id()] = _StreamSetsApiClient(
            pipeline.get_streamsets())
    return _clients[pipeline.get_streamsets().get_id()]
Esempio n. 2
0
def create(pipeline: IPipeline):
    # todo remove this if check and make streamsets mandatory after that fix todos above
    if not pipeline.get_streamsets():
        pipeline.set_streamsets(
            balancer.least_loaded_streamsets(
                balancer.get_streamsets_pipelines()))
    try:
        _client(pipeline).create_pipeline(pipeline.get_id())
    except ApiClientException as e:
        raise StreamsetsException(str(e))
    try:
        _update_pipeline(pipeline, set_offset=True)
    except ApiClientException as e:
        delete(pipeline)
        raise StreamsetsException(str(e))
    except Exception:
        delete(pipeline)
        raise