At present, there are several presto nodejs clients. In order to facilitate the connection of presto-gateway, an existing nodejs client is modified. It can be easily connected to presto-gateway
Principle
Because it is called through the rest api, it is directly added to the original http header X-Presto-Routing-Group
Refer to the modified presto client
The modified place headers.js
< div class="CodeMirror-scroll">
Headers.ROUTING_GROUP = 'X-Presto-Routing-Group';
< /div>
index.js Add routingGroup for query support
< div id="wiz_cm_1566615616977_503" class="wiz-code-container" data-mode="JavaScript" d ata-theme="default">
Description Already Push the npm warehouse
How to use
Installation dependencies
Refer to docker-compose operating environment
< div id="wiz_cm_1566615616953_9627" class="wiz-code-container" data-mode="JavaScript" data-theme="default">
< div class="CodeMirror-scroll">
name: prestoRouter < /pre> cacheDir: /var/ log/prestoproxy/cache
routingGroup: < span class="cm-variable">adhoc
< div>
proxyTo: http:
< span class="cm-variable">sender: presto-gw-monitor-noreply@< span class="cm-variable">lyft.com
- < span class="cm-variable">prestodev@yourorg.com span>
?
- com.lyft.data.gateway.module.ProxyBackendProviderModule
- com.lyft.data.gateway.module.GatewayProviderModule < pre class=" CodeMirror-line "> – com.lyft.data.gateway.module.NotifierModule span>
- com.lyft.data.gateway.GatewayManagedApp
< span> - com.lyft.data.gateway.ActiveClusterMonitor
# The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
< div>
?
# Logger-specific levels.
< span class="cm-variable">loggers:
com.lyft: DEBUG
div>
< span class="cm-variable">currentLogFilename: /var/log/prestoproxy/prestoproxy-java.log
archivedLogFilenamePattern: /var/log/prestoproxy/prestoproxy-java-%d{ yyyy-MM-dd}-%i.log.gz
参考资料
https://github.com/tagomoris/presto-client-node https://github.com/rongfengliang/presto-client-node
https:
Headers.ROUTING_GROUP = ‘X-Presto-Routing-Group‘;
Headers.ROUTING_GROUP = ‘X-Presto-Routing-Group‘;
Headers.ROUTING_GROUP = ‘X-Presto-Routing-Group‘;
Headers.ROUTING_GROUP = ‘X-Presto-Routing-Group‘;
Headers.ROUTING_GROUP = ‘X-Presto-Routing-Group‘;
Headers.ROUTING_GROUP = ‘X-Presto-Routing-Group‘;
Headers.ROUTING_GROUP = ‘X-Presto-Routing-Group‘;
< div class="CodeMirror cm-s-default" data-id="wiz_cm_1566615616977_503">
Client.prototype.statementResource = function(opts) {
var columns = null; < /span>
if (!opts.catalog && !this.catalog)
throw {message: "catalog not specified"};
if (!opts.schema && !this.schema)
throw {message: "schema not specified"};
if (!opts.success && !opts.callback)
throw {message: "callback function ‘success‘ (or ‘callback‘) not specified"};
header[Headers.CATALOG] = opts.catalog || this.catalog;
header[Headers.SCHEMA] = opts.schema || th is.schema;
header[Headers.SESSION] = opts.session;
header[Headers.TIME_ZONE] = opts.timezone;
header[Headers.ROUTING_GROUP] = opts.routingGroup;
Client.prototype.statementResource = function(opts) {
if (!opts.catalog && !this.catalog)
throw {message: "catalog not specified"};
if (!opts.schema && !this.schema)
throw {message: "schema not specified"};
if (!opts.success && !opts.callback)
throw {message: "callback function ‘success‘ (or ‘callback‘) not specified"};
header[Headers.CATALOG] = opts.catalog || this.catalog;
header[Headers.SCHEMA] = opts.schema || this.schema;
header[Headers.SESSION] = opts.session;
header[Headers.TIME_ZONE] = opts.timezone;
header[Headers.ROUTING_GROUP] = opts.routingGroup;
Client.prototype.statementResource = function(opts) {
if (!opts.catalog && !this.catalog)
throw {message: "catalog not specified"};
if (!opts.schema && !this.schema)
throw {message: "schema not specified"};
if (!opts.success && !opts.callback)
throw {message: "callback function ‘success‘ (or ‘callback‘) not specified"};
header[Headers.CATALOG] = opts.catalog || this.catalog;
header[Headers.SCHEMA] = opts.schema || this.schema;
header[Headers.SESS ION] = opts.session;
header[Headers.TIME_ZONE] = opts.timezone;
header[Heade rs.ROUTING_GROUP] = opts.routingGroup;
Client.prototype.statementResource = function(opts) {
if (!opts.catalog && !this.catalog)
throw {message: "catalog not specified"};
if (!opts.schema && !this.schema)
throw {message: "schema not specified"};
if (!opts.success && !opts.callback)
throw {message: "callback function ‘success‘ (or ‘callback‘) not specified"};
header[Headers.CATALOG] = opts.catalog || this.catalog;
header[Headers.SCHEMA] = opts.schema || this.schema;
header[Headers.SESSION] = opts.session;
header[ Headers.TIME_ZONE] = opts.timezone;
header[Headers.ROUTING_GROUP] = opts.routingGroup;
Client.prototype.statementResource = function(opts) {
if (!opts.catalog && !this.catalog)
throw {message: "catalog not specified"};
if (!opts.schema && !this.schema)
throw {message: "schema not specified"};
if (!opts.s uccess && !opts.callback)
throw {message: "callback function ‘success‘ (or ‘callback‘) not specified"};
header[Headers.CATALOG] = opts.catalog || this.catalog;
header[Headers.SCHEMA] = opts.schema || this.schema;
header[Headers.SESSION] = opts.session;
header[Headers.TIME_ZONE] = opts.timezone;
header[Headers.ROUTING_GROUP] = opts.routingGroup;
Client.prototype.statementResource = function(opts) {
if (!opts.catalog && !this.catalog)
throw {message: "catalog not specified"};
if (!opts.schema && !this.schema)
throw {message: "schema not specified"};
if (!opts.success && !opts.callback)
throw {message: "callback function ‘success‘ (or ‘callback‘) not specified"};
header[Headers.CATALOG] = opts.catalog || this.catalog;
header[Headers.SCHEMA] = opts.schema || this.schema;
header[Headers.SESSION] = opts.session;
header[Headers.TIME_ZONE] = opts.timezone;
header[Headers.ROUTING_GROUP] = opts.routingGroup;
Client.prototype.statementResource = function(opts) {
var client = this;
var columns = null;
?
if (!opts.catalog && !this.catalog)
throw {message: "catalog not specified"};
if (!opts.schema && !this.schema)
throw {message: "schema not specified"};
if (!opts.success && !opts.callback)
throw {message: "callback function ‘success‘ (or ‘callbac k‘) not specified"};
?
var header = {};
header[Headers.CATALOG] = opts.catalog || this.catalog;
header[Headers.SCHEMA] = opts.schema || this.schema;
?
if (opts.session)
header[Headers.SESSION] = opts.session;
if (opts.timezone)
header[Headers.TIME_ZONE] = opts.timezone;
if (opts.routingGroup)
header[Headers.ROUTING_GROUP] = opts.routingGroup;
?
npm install @dalongrong/presto-client
npm install @dalongrong/presto-client
npm install @dalongrong/presto-client
npm install @dalongrong/presto-client
npm install @dalongrong/presto-client
npm install @dalongrong/presto-client
npm install @dalongrong/presto-client
image: dalongrong/presto-gateway:1.6.1
- "./config.yml.templat e:/config.yml.template"
image: starburstdata/presto
image: starburstdata/presto
image: dalongrong/presto-gateway:1.6.1
volumes:
- "./config.yml.template:/config.yml.template"
image: starburstdata/presto
image: starburstdata/presto
image: dalongrong/presto-gateway:1.6.1
- "./config.yml.template:/config.yml.template"
image: starburstdata/presto
image: starburstdata/presto
image: dalongrong/presto-gateway:1.6.1
- "./config.yml.template:/config.yml.template"
image: starburstdata/presto
image: starburstdata/presto
image: dalongrong/presto-gateway:1.6.1
- "./config.yml.template:/config.yml.template"
image: starburstdata/presto
image: starburstdata/presto
image: dalongrong/presto-gateway:1.6.1
- "8083:8083"
- "./config.yml.template:/config.yml.template"
image: starburstdata/presto
image: starburstdata/presto
version: "3"
services:
proxy:
image: dalongrong/presto-gateway:1.6.1
ports:
- "8888:8888"
- "8082:8082"
- "8083:8083"
build: ./
volumes:
- "./config.yml.template:/config.yml.template"
presto1:
image: starburstdata/presto
ports:
- "8080:8080"
presto2:
image: starburstdata/presto
ports:
- "8081:8080"
cacheDir: /var/log/prestoproxy/cache
sender: presto-gw-monitor-noreply@lyft.com
- com.lyft.data.gateway.module.ProxyBackendProviderModule
- com.lyft.data.gateway.module.GatewayProviderModule
- com.lyft.data.gateway.module.NotifierModule
- com.lyft.data.gateway.GatewayManagedApp
- com.lyft.data.gateway.ActiveClusterMonitor
# The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
# Logger-specific levels.
currentLogFilename: /var/log/prestoproxy/prestoproxy-java.log
archivedLogFilenamePattern: /var/log/prestoproxy/prestoproxy-java-%d{yyyy-MM-dd}-%i.log.gz
name: prestoRouter< /span>
cacheDir: /var/log/prestoproxy/cache
sender: presto-gw-monitor-noreply@lyft.com
- com.lyft.data.gateway.module.ProxyBackendProviderModule
- com.lyft.data.gateway.module.GatewayProviderModule
- com.lyft.data.gateway.module.NotifierModule
- com.lyft.data.gateway.GatewayManagedApp
- com.lyft.data.gateway.ActiveClusterMonitor
# The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
# Logger-specific levels.
currentLogFilename: /var/log/prestoproxy/prestoproxy-java.log
archivedLogFilenamePattern: /var/log/prestoproxy/prestoproxy-java-%d{yyyy-MM-dd}-%i.log.gz
cacheDir: /var/log/prestoproxy/cache
sender: presto-gw-monitor-noreply@lyft.com
- com.lyft.data.gateway.module.ProxyBackendProviderModule
- com.lyft.data.gateway.module.GatewayProviderModule
- com.lyft.data.gateway.module.NotifierModule
- com.lyft.data.gateway.GatewayManagedApp
- com.lyft.data.gateway.ActiveClusterMonitor
# The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
# Logger-specific levels.
< pre class=" CodeMirror-line "> loggers:
currentLogFilename: /var/log/prestoproxy/prestoproxy-java.log
archivedLogFilenamePattern: /var/log/prestoproxy/prestoproxy-java-%d{yyyy-MM-dd}-%i.log.gz
cacheDir: /var/log/prestoproxy/cache
sender: presto-gw-monitor-noreply@lyft.com
- com.lyft.data.gateway.module.ProxyBackendProviderModule
- com.lyft.data.gateway.module.GatewayProviderModule
- com.lyft.data.gateway.module.NotifierModule
- com.lyft.data.gateway.GatewayManagedApp
- com.lyft.data.gateway.ActiveClusterMonitor
# The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
# Logger-specific levels.
currentLogFilename: /var/log/prestoproxy/prestoproxy-java.log
archivedLogFilenamePattern: /var/log/prestoproxy/prestoproxy-java-%d{yyyy-MM-dd}-%i.log.gz
archivedFileCount: 7
cacheDir: /var/log/prestoproxy/cache
sender: presto-gw-monitor-noreply@lyft.com
- com.lyft.data.gateway.module.ProxyBackendProviderModule
- com.lyft.data.gateway.module.GatewayProviderModule
- com.lyft.data.gateway.module.NotifierModule
- com.lyft.data.gateway.GatewayManagedApp
- com.lyft.data.gateway.ActiveClusterMonitor
# T he default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
# Logger-specific levels.
currentLogFilename: /var/log/prestoproxy/prestoproxy-java.log
archivedLogFilenamePattern: /var/log/prestoproxy/prestoproxy-java-%d{yyyy-MM-dd}-%i.log.gz
cacheDir: /var/log/prestoproxy/cache
sender: presto-gw-monitor-noreply@lyft.com
- com.lyft.data.gateway.module.ProxyBackendProviderModule
- com.lyft.data.gateway.module.GatewayProviderModule
- com.lyft.data.gateway.module.NotifierModule
- com.lyft.data.gateway.GatewayManagedApp
- com.lyft.data.gateway.ActiveClus terMonitor
# The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
# Logger-specific levels.
currentLogFilename: /var/log/prestoproxy/prestoproxy-java.log
archivedLogFilenamePattern: /var/log/prestoproxy/prestoproxy-java-%d{yyyy-MM-dd}-%i.log.gz
requestRouter:
port: 8888
name: prestoRouter
cacheDir: /var/log/prestoproxy/cache
historySize: 1000
?
backends:
- localPort: 8082
name: presto1
proxyTo: http:
routingGroup: adhoc
?
- localPort: 8083
name: presto2
proxyTo: http:
routingGroup: scheduled
?
server:
applicationConnectors:
- type: http
port: 8090
adminConnectors:
- type: http
port: 8091
?
notifier:
smtpHost: localhost
smtpPort: 587
sender: presto-gw-monitor-noreply@lyft.com
recipients:
- prestodev@yourorg.com
?
modules:
- com.lyft.data.gateway.module.ProxyBackendProviderModule
- com.lyft.data.gateway.module.GatewayProviderModule < /span>
- com.lyft.data.gateway.module.NotifierModule
?
managedApps:
- com.lyft.data.gateway.GatewayManagedApp
- com.lyft. data.gateway.ActiveClusterMonitor
?
# Logging settings.
logging:
# The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
level: INFO
?
# Logger-specific levels.
loggers:
com.lyft: DEBUG
?
appenders:
- type: console
- type: file
currentLogFilename: /var/log/prestoproxy/prestoproxy-java.log
archivedLogFilenamePattern: /var/log/prestoproxy/prestoproxy-java-%d{yyyy-MM-dd}-%i.log.gz
archivedFileCount: 7
timeZone: UTC
maxFileSize: 100MB
var presto = require(‘@dalongrong/presto-client‘);
var client = new presto.Client({
query: ‘select * from nation2‘,
routingGroup: ‘scheduled‘,
state: function (error, query_id, stats) {
message: "status changed",
columns: function (error, data) {
data: function (error, data, columns, stats) {
success: function (error, stats) {
error: function (error) {
var presto = require(‘@dalongrong/presto-client‘);
var client = new presto.Client({ span>
query: ‘select * from nation2‘,
routingGroup: ‘scheduled‘,
state: function (error, query_id, stats) {
message: "status changed",
columns: function (error, data) {
data: function (error, data, columns, stats) { span>
success: function (error, stats) {
error: function (error) {
var presto = require(‘@dalongrong/presto-client‘);
var client = new presto.Client({
query: ‘select * from nation2‘,
routingGroup: ‘scheduled‘,
state: function (error, query_id, stats) { span>
message: "status changed",
columns: function (error, data) {
data: function (error, data, columns, stats) {
success: function (error, stats) {
error: function (error) {
var presto = require(‘@dalongrong/presto-client‘);
var client = new presto.Client({
query: ‘select * from nation2‘,
routingGroup: ‘scheduled‘,
state: function (error, query_id, stats) { < /span>
message: "status changed",
columns: function (error, data) {
data: function (error, data, columns, stats) {
success: function (error, stats) {
error: function (error) {
var presto = require(‘@dalongrong/presto-client‘);
var client = new presto.Client({
query: ‘select * from nation2‘,
routingGroup: ‘scheduled‘,
state: function (error, query_id, stats) {
message: "status changed",
columns: function (error, data) {
data: function (error, data, columns, stats) {
success: function (error, stats) {
error: function (error) {
var presto = require(‘@dalongrong/presto-client‘);
var client = new presto.Client({
query: ‘select * from nation2‘,
routingGroup: ‘scheduled‘,
state: function (error, query_id, stats) {
message: "status changed",
columns: function (error, data) {
data: function (error, data, columns, stats) {
success: function (error, stats) {
error: function (error) {
var presto = require(‘@dalongrong/presto-client‘);
var client = new presto.Client({
query: ‘select * from nation2‘,
routingGroup: ‘scheduled‘,
state: function (error, query_id, stats) {
message: "status changed",
columns: function (error, data) {
data: function (error, data, columns, stats) {
success: function (error, stats) {
error: function (error) {
var presto = require(‘@dalongrong/presto-client‘);
var client = new presto.Client({
user: ‘appdemo‘,
host: " localhost",
port: 8888
});
?
client.execute({
query: ‘select * from nation2‘,
catalog: ‘memory‘,
schema: ‘default‘,
source: ‘nodejs-client‘,
routingGroup: ‘scheduled‘,
state: function (error, query_id, stats) {
console.log(error)
console.log({
message: "status changed",
id: query_id,
stats: stats
});
},
columns: function (error, data) {
console.log({
resultColumns: data
});
},
data: function (error, data, columns, stats) {
console.log(data);
},
success: function (error, stats) {
console.log(stats)
},
error: function (error) {
console.log(error)
}
});
Post navigation
WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1661 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC