美文网首页
presto(四)——服务的启动

presto(四)——服务的启动

作者: hello高world | 来源:发表于2017-02-15 22:27 被阅读0次

    接上一篇博文,遗留了三个问题。第一个问题客户端请求的http://localhost:8080/v1/statement
    地址的服务是什么时候起来的

    1、寻找服务器代码

    只有xml文件

    一开始以为在这个项目内。打开看了下,只有presto.xml文件

      <!-- Server -->
        <artifactSet to="lib">
            <artifact id="${project.groupId}:presto-main:${project.version}" />
        </artifactSet>
    
        <!-- Plugins -->
        <artifactSet to="plugin/resource-group-managers">
            <artifact id="${project.groupId}:presto-resource-group-managers:zip:${project.version}">
                <unpack />
            </artifact>
        </artifactSet>
    

    从xml文件中看到俩个注释:<sever>和<plugins>

    2、presto-main模块入口

    1、在这个模块中找到了(/v1/statement),这个应该是restful api接收上一cli的请求。

    package com.facebook.presto.server;
    
    @Path("/v1/statement")
    public class StatementResource
    

    问题:是谁加载了这个类,让http可以找到这个类?

    2、CoordinatorModule协调器模块加载各个资源,并对外服务

    package com.facebook.presto.server;
    
    public class CoordinatorModule
            extends AbstractConfigurationAwareModule
    {
        @Override
        protected void setup(Binder binder)
        {
            httpServerBinder(binder).bindResource("/", "webapp").withWelcomeFile("index.html");
    
            // presto coordinator announcement
            discoveryBinder(binder).bindHttpAnnouncement("presto-coordinator");
    
            // statement resource
            jaxrsBinder(binder).bind(StatementResource.class);
    

    这里涉及到google的inject项目——注入框架
    和 airlift的restful服务框架

    3、最开始的地方

    public class PrestoServer
            implements Runnable
    {
        public static void main(String[] args)
        {
            new PrestoServer().run();
        }
    

    3、PrestoServer启动

    问题:

    1、为什么在presto-server项目内使用xml这种方式。
    2、注解的两个<server>和<plugins>什么意思?作用是干嘛的呢?

    待续~~~

    相关文章

      网友评论

          本文标题:presto(四)——服务的启动

          本文链接:https://www.haomeiwen.com/subject/clhcwttx.html