genie python客户端。

nflx-genie-client的Python项目详细描述


=================== genie python客户端

此包提供了一个与现有GeIe服务交互的健壮客户端。其中包括 资源模型(应用程序、命令、集群、作业等)、异常和重试API调用的逻辑包装器。

有关genie及其可用api的更多文档,请参见Genie GitHub <http://netflix.github.io/genie/>页。

示例

配置服务示例


This example shows how to register a new application with a running Genie instance. Similar processes can be followed
for registering clusters and commands as well as relating all three to each other.

::

    import genie2.client.wrapper
    import genie2.model.Application

    # Create a Genie client which proxies API calls through wrapper which retries failures based on various return codes
    genie = genie2.client.wrapper.Genie2("http://localhost:7001/genie", genie2.client.wrapper.RetryPolicy(tries=8, none_on_404=True, no_retry_http_codes=range(400, 500)))

    # Create a new application instance and set required fields
    app = genie2.model.Application.Application()
    app.name = "exampleAppName"
    app.user = "exampleUser"
    app.version = "0.0.1"
    app.status = "ACTIVE"

    # Save the application to the service
    created_app = genie.createApplication(app)
    print created_app.id

    # Retrieve the application by ID
    got_app = genie.getApplication(created_app.id)
    print got_app.name

    # Delete the application by ID
    deleted_app = genie.deleteApplication(got_app.id)
    print deleted_app.id


Execution Service Example
~~~~~~~~~~~~~~~~~~~~~~~~~

This example shows how to execute a job on Genie. In this case it's running a `Presto <http://prestodb.io/>`_ query.
This assumes the Presto cluster has already been configured with Genie and the command registered.

::

    import genie2.client.wrapper
    import genie2.model.Job
    import genie2.model.ClusterCriteria

    # Create a Genie client which proxies API calls through wrapper which retries failures based on various return codes
    genie = genie2.client.wrapper.Genie2("http://localhost:7001/genie", genie2.client.wrapper.RetryPolicy(tries=8, none_on_404=True, no_retry_http_codes=range(400, 500)))

    # Create a job instance and fill in the required parameters
    job = genie2.model.Job.Job()
    job.name = "GeniePythonClientExampleJob"
    job.user = "tgianos"
    job.version = "0.0.1"

    # Create a list of cluster criterias which determine the cluster to run the job on
    cluster_criterias = list()
    cluster_criteria = genie2.model.ClusterCriteria.ClusterCriteria()
    criteria = set()
    criteria.add("presto")
    criteria.add("prod")
    cluster_criteria.tags = criteria
    cluster_criterias.append(cluster_criteria)
    job.clusterCriterias = cluster_criterias

    # Create the set of command criteria which will determine what command Genie executes for the job
    command_criteria = set()
    command_criteria.add("presto")
    job.commandCriteria = command_criteria

    # Any command line arguments to run along with the command. In this case it holds the actual query but this
    # could also be done via an attachment or file dependency.
    job.commandArgs = "--execute \"show tables;\""

    # Submit the job to Genie
    running_job = genie.submitJob(job)

    # Check on the status of the job
    job_status = genie.getJobStatus(running_job.id)
    print job_status




欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
安卓为什么Java AudioEffect不支持双簧管?   增加内存后出现java IntelliJ堆大小错误   在unix/linux中工作的java中将unicode字符串转换为ASCII   java是否缺少正确对齐输出的值?   java Spring 3 MVC:动态表单中的onetomany(创建/更新时添加/删除)   java在接口中创建两个通用参数   lambda使用Java 8从嵌套列表中使用forEach查找项的替代方法是什么?   Java正则表达式匹配10位电话号码,中间有空格   linux将log4j外部化。使用命令行Java的属性文件   带有SSL的java简单RMI服务器   java无法为事务[…]打开JPA EntityManager无法获取驱动程序类“null”和URL“null”的连接   Android设备上的java Oauth Foursquare   for循环的ImageButton名称的java骰子模拟浓缩   java有没有简单的1d条形码阅读器?   如何在调用resultset后解决“无效字符串或缓冲区长度”。从java到访问mdb的getString()连接   在Java8中,是否可以使用JVM参数来控制何时(或在什么条件下)卸载类?