-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
/
prestodb.rb
124 lines (104 loc) 路 4.37 KB
/
prestodb.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
class Prestodb < Formula
include Language::Python::Shebang
desc "Distributed SQL query engine for big data"
homepage "https://prestodb.io"
url "https://search.maven.org/remotecontent?filepath=com/facebook/presto/presto-server/0.287/presto-server-0.287.tar.gz"
sha256 "c16ef78d56820a16fec6918a439b26121a78eb3cc50fdcd7bee93a1211347f8f"
license "Apache-2.0"
# Upstream has said that we should check Maven for Presto version information
# and the highest version found there is newest:
# https://github.com/prestodb/presto/issues/16200
livecheck do
url "https://search.maven.org/remotecontent?filepath=com/facebook/presto/presto-server/"
regex(%r{href=["']?v?(\d+(?:\.\d+)+)/?["' >]}i)
end
bottle do
sha256 cellar: :any_skip_relocation, sonoma: "458069d52d46aad32bba940785141f5208b384c9c815397fe1d4e7091459c8ff"
sha256 cellar: :any_skip_relocation, ventura: "e5fa4d5f984956b935d50a64f0b58b313507c299273133b1f58a11e41a4569c4"
sha256 cellar: :any_skip_relocation, monterey: "e503a128447aa3c3ad99b658a0d10ca3179a6e67207e953d46f6092e9524416c"
sha256 cellar: :any_skip_relocation, x86_64_linux: "1ef3cea970014fddda02a98b41cedcdeac7defd108bbd3180b92de0a692540de"
end
# https://github.com/prestodb/presto/issues/17146
depends_on arch: :x86_64
depends_on "openjdk@11"
depends_on "python@3.12"
resource "presto-cli" do
url "https://search.maven.org/remotecontent?filepath=com/facebook/presto/presto-cli/0.287/presto-cli-0.287-executable.jar"
sha256 "ff91091dae44976266625476e5f4dc483273324433e36ef209154ce947e34c90"
end
def install
odie "presto-cli resource needs to be updated" if version != resource("presto-cli").version
libexec.install Dir["*"]
(libexec/"etc/node.properties").write <<~EOS
node.environment=production
node.id=ffffffff-ffff-ffff-ffff-ffffffffffff
node.data-dir=#{var}/presto/data
EOS
(libexec/"etc/jvm.config").write <<~EOS
-server
-Xmx16G
-XX:+UseG1GC
-XX:G1HeapRegionSize=32M
-XX:+UseGCOverheadLimit
-XX:+ExplicitGCInvokesConcurrent
-XX:+HeapDumpOnOutOfMemoryError
-XX:+ExitOnOutOfMemoryError
-Djdk.attach.allowAttachSelf=true
EOS
(libexec/"etc/config.properties").write <<~EOS
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8080
query.max-memory=5GB
query.max-memory-per-node=1GB
discovery-server.enabled=true
discovery.uri=http://localhost:8080
EOS
(libexec/"etc/log.properties").write "com.facebook.presto=INFO"
(libexec/"etc/catalog/jmx.properties").write "connector.name=jmx"
rewrite_shebang detected_python_shebang, libexec/"bin/launcher.py"
env = Language::Java.overridable_java_home_env("11")
env["PATH"] = "$JAVA_HOME/bin:$PATH"
(bin/"presto-server").write_env_script libexec/"bin/launcher", env
resource("presto-cli").stage do
libexec.install "presto-cli-#{version}-executable.jar"
bin.write_jar_script libexec/"presto-cli-#{version}-executable.jar", "presto", java_version: "11"
end
# Remove incompatible pre-built binaries
libprocname_dirs = libexec.glob("bin/procname/*")
# Keep the Linux-x86_64 directory to make bottles identical
libprocname_dirs.reject! { |dir| dir.basename.to_s == "Linux-x86_64" }
libprocname_dirs.reject! { |dir| dir.basename.to_s == "#{OS.kernel_name}-#{Hardware::CPU.arch}" }
libprocname_dirs.map(&:rmtree)
end
def post_install
(var/"presto/data").mkpath
end
def caveats
<<~EOS
Add connectors to #{opt_libexec}/etc/catalog/. See:
https://prestodb.io/docs/current/connector.html
EOS
end
service do
run [opt_bin/"presto-server", "run"]
working_dir opt_libexec
end
test do
port = free_port
cp libexec/"etc/config.properties", testpath/"config.properties"
inreplace testpath/"config.properties", "8080", port.to_s
server = fork do
exec bin/"presto-server", "run", "--verbose",
"--data-dir", testpath,
"--config", testpath/"config.properties"
end
sleep 45
query = "SELECT state FROM system.runtime.nodes"
output = shell_output(bin/"presto --debug --server localhost:#{port} --execute '#{query}'")
assert_match "\"active\"", output
ensure
Process.kill("TERM", server)
Process.wait server
end
end