Example HTTP Connector

The Example HTTP connector has a simple goal: it reads comma-separated data over HTTP. For example, if you have a large amount of data in a CSV format, you can point the example HTTP connector at this data and write a SQL query to process it.


The Example HTTP connector can be found in the presto-example-http directory in the root of the openLooKeng source tree.

Plugin Implementation

The plugin implementation in the Example HTTP connector looks very similar to other plugin implementations. Most of the implementation is devoted to handling optional configuration and the only function of interest is the following:

public Iterable<ConnectorFactory> getConnectorFactories()
    return ImmutableList.of(new ExampleConnectorFactory());

Note that the ImmutableList class is a utility class from Guava.

As with all connectors, this plugin overrides the getConnectorFactories() method and returns an ExampleConnectorFactory.

ConnectorFactory Implementation

In openLooKeng, the primary object that handles the connection between openLooKeng and a particular type of data source is the Connector object, which are created using ConnectorFactory.

This implementation is available in the class ExampleConnectorFactory. The first thing the connector factory implementation does is specify the name of this connector. This is the same string used to reference this connector in openLooKeng configuration.

public String getName()
    return "example-http";

The real work in a connector factory happens in the create() method. In the ExampleConnectorFactory class, the create() method configures the connector and then asks Guice to create the object. This is the meat of the create() method without parameter validation and exception handling:

// A plugin is not required to use Guice; it is just very convenient
Bootstrap app = new Bootstrap(
        new JsonModule(),
        new ExampleModule(catalogName));

Injector injector = app

return injector.getInstance(ExampleConnector.class);

Connector: ExampleConnector

This class allows openLooKeng to obtain references to the various services provided by the connector.

Metadata: ExampleMetadata

This class is responsible for reporting table names, table metadata, column names, column metadata and other information about the schemas that are provided by this connector. ConnectorMetadata is also called by openLooKeng to ensure that a particular connector can understand and handle a given table name.

The ExampleMetadata implementation delegates many of these calls to ExampleClient, a class that implements much of the core functionality of the connector.

Split Manager: ExampleSplitManager

The split manager partitions the data for a table into the individual chunks that openLooKeng will distribute to workers for processing. In the case of the Example HTTP connector, each table contains one or more URIs pointing at the actual data. One split is created per URI.

Record Set Provider: ExampleRecordSetProvider

The record set provider creates a record set which in turn creates a record cursor that returns the actual data to openLooKeng. ExampleRecordCursor reads data from a URI via HTTP. Each line corresponds to a single row. Lines are split on comma into individual field values which are then returned to openLooKeng.






● 拼写,格式,无效链接等错误;

● 技术原理、功能、规格等描述和软件不一致,存在错误;

● 原理图、架构图等存在错误;

● 版本号不匹配:文档版本或内容描述和实际软件不一致;

● 对重要数据或系统存在风险的操作,缺少安全提示;

● 排版不美观,影响阅读;


● 描述存在歧义;

● 图形、表格、文字等晦涩难懂;

● 逻辑不清晰,该分类、分项、分步骤的没有给出;


● 很难通过搜索引擎,openLooKeng官网,相关博客找到所需内容;


● 命令、命令参数等错误;

● 命令无法执行或无法完成对应功能;


● 关键步骤错误或缺失,无法指导用户完成任务,比如安装、配置、部署等;

● 逻辑不清晰,该分类、分项、分步骤的没有给出

● 图形、表格、文字等晦涩难懂

● 缺少必要的前提条件、注意事项等;

● 描述存在歧义