Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Questdb
提交
8e6fc511
Q
Questdb
项目概览
jobily
/
Questdb
10 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
Questdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
8e6fc511
编写于
8月 03, 2020
作者:
V
Vlad Ilyushchenko
提交者:
GitHub
8月 03, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore(server): introduced version of web console and removed -f command line arg (#528)
上级
70d52faa
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
75 addition
and
64 deletion
+75
-64
core/src/main/java/io/questdb/ServerMain.java
core/src/main/java/io/questdb/ServerMain.java
+56
-43
core/src/main/java/io/questdb/cairo/TableReader.java
core/src/main/java/io/questdb/cairo/TableReader.java
+18
-20
core/src/main/java/io/questdb/cutlass/http/processors/StaticContentProcessor.java
...estdb/cutlass/http/processors/StaticContentProcessor.java
+1
-1
未找到文件。
core/src/main/java/io/questdb/ServerMain.java
浏览文件 @
8e6fc511
...
...
@@ -24,27 +24,6 @@
package
io.questdb
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.Inet4Address
;
import
java.net.InetAddress
;
import
java.net.NetworkInterface
;
import
java.net.SocketException
;
import
java.net.URL
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.Enumeration
;
import
java.util.Properties
;
import
java.util.ServiceLoader
;
import
java.util.concurrent.locks.LockSupport
;
import
java.util.jar.Attributes
;
import
java.util.jar.Manifest
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipInputStream
;
import
io.questdb.cairo.CairoEngine
;
import
io.questdb.cutlass.http.HttpServer
;
import
io.questdb.cutlass.line.tcp.LineTcpServer
;
...
...
@@ -59,15 +38,22 @@ import io.questdb.log.LogFactory;
import
io.questdb.log.LogRecord
;
import
io.questdb.mp.WorkerPool
;
import
io.questdb.network.NetworkError
;
import
io.questdb.std.CharSequenceObjHashMap
;
import
io.questdb.std.Chars
;
import
io.questdb.std.Misc
;
import
io.questdb.std.Os
;
import
io.questdb.std.Vect
;
import
io.questdb.std.*
;
import
io.questdb.std.time.Dates
;
import
sun.misc.Signal
;
import
java.io.*
;
import
java.net.*
;
import
java.util.*
;
import
java.util.concurrent.locks.LockSupport
;
import
java.util.jar.Attributes
;
import
java.util.jar.Manifest
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipInputStream
;
public
class
ServerMain
{
private
static
final
String
VERSION_TXT
=
"version.txt"
;
public
static
void
deleteOrException
(
File
file
)
{
if
(!
file
.
exists
())
{
return
;
...
...
@@ -107,7 +93,7 @@ public class ServerMain {
// -n = disables handling of HUP signal
final
String
rootDirectory
=
optHash
.
get
(
"-d"
);
extractSite
(
rootDirectory
,
optHash
.
get
(
"-f"
)
!=
null
,
log
);
extractSite
(
rootDirectory
,
log
);
final
Properties
properties
=
new
Properties
();
final
String
configurationFileName
=
"/server.conf"
;
final
File
configurationFile
=
new
File
(
new
File
(
rootDirectory
,
PropServerConfiguration
.
CONFIG_DIRECTORY
),
configurationFileName
);
...
...
@@ -291,29 +277,56 @@ public class ServerMain {
return
optHash
;
}
private
static
void
extractSite
(
String
dir
,
boolean
force
,
Log
log
)
throws
IOException
{
private
static
long
getPublicVersion
(
String
publicDir
)
throws
IOException
{
File
f
=
new
File
(
publicDir
,
VERSION_TXT
);
if
(
f
.
exists
())
{
try
(
FileInputStream
fis
=
new
FileInputStream
(
f
))
{
byte
[]
buf
=
new
byte
[
128
];
int
len
=
fis
.
read
(
buf
);
return
Long
.
parseLong
(
new
String
(
buf
,
0
,
len
));
}
}
return
Long
.
MIN_VALUE
;
}
private
static
void
setPublicVersion
(
String
publicDir
,
long
version
)
throws
IOException
{
File
f
=
new
File
(
publicDir
,
VERSION_TXT
);
try
(
FileOutputStream
fos
=
new
FileOutputStream
(
f
))
{
byte
[]
buf
=
Long
.
toString
(
version
).
getBytes
();
fos
.
write
(
buf
,
0
,
buf
.
length
);
}
}
private
static
void
extractSite
(
String
dir
,
Log
log
)
throws
IOException
{
final
String
publicZip
=
"/io/questdb/site/public.zip"
;
final
String
publicD
est
=
dir
+
"/public"
;
final
String
publicD
ir
=
dir
+
"/public"
;
final
byte
[]
buffer
=
new
byte
[
1024
*
1024
];
try
(
final
InputStream
is
=
ServerMain
.
class
.
getResourceAsStream
(
publicZip
))
{
if
(
is
!=
null
)
{
try
(
ZipInputStream
zip
=
new
ZipInputStream
(
is
))
{
ZipEntry
ze
;
while
((
ze
=
zip
.
getNextEntry
())
!=
null
)
{
final
File
dest
=
new
File
(
publicDest
,
ze
.
getName
());
if
(!
ze
.
isDirectory
())
{
copyInputStream
(
force
,
buffer
,
dest
,
zip
,
log
);
final
long
thisVersion
=
ServerMain
.
class
.
getResource
(
publicZip
).
openConnection
().
getLastModified
();
final
long
oldVersion
=
getPublicVersion
(
publicDir
);
if
(
thisVersion
>
oldVersion
)
{
try
(
final
InputStream
is
=
ServerMain
.
class
.
getResourceAsStream
(
publicZip
))
{
if
(
is
!=
null
)
{
try
(
ZipInputStream
zip
=
new
ZipInputStream
(
is
))
{
ZipEntry
ze
;
while
((
ze
=
zip
.
getNextEntry
())
!=
null
)
{
final
File
dest
=
new
File
(
publicDir
,
ze
.
getName
());
if
(!
ze
.
isDirectory
())
{
copyInputStream
(
true
,
buffer
,
dest
,
zip
,
log
);
}
zip
.
closeEntry
();
}
zip
.
closeEntry
();
}
}
else
{
log
.
error
().
$
(
"could not find site [resource="
).
$
(
publicZip
).
$
(
']'
).
$
();
}
}
else
{
log
.
error
().
$
(
"could not find site [resource="
).
$
(
publicZip
).
$
(
']'
).
$
();
}
setPublicVersion
(
publicDir
,
thisVersion
);
copyConfResource
(
dir
,
false
,
buffer
,
"conf/date.formats"
,
log
);
copyConfResource
(
dir
,
true
,
buffer
,
"conf/mime.types"
,
log
);
copyConfResource
(
dir
,
false
,
buffer
,
"conf/server.conf"
,
log
);
}
else
{
log
.
info
().
$
(
"web console is up to date"
).
$
();
}
copyConfResource
(
dir
,
false
,
buffer
,
"conf/date.formats"
,
log
);
copyConfResource
(
dir
,
force
,
buffer
,
"conf/mime.types"
,
log
);
copyConfResource
(
dir
,
false
,
buffer
,
"conf/server.conf"
,
log
);
}
private
static
void
copyConfResource
(
String
dir
,
boolean
force
,
byte
[]
buffer
,
String
res
,
Log
log
)
throws
IOException
{
...
...
core/src/main/java/io/questdb/cairo/TableReader.java
浏览文件 @
8e6fc511
...
...
@@ -30,6 +30,7 @@ import io.questdb.log.LogFactory;
import
io.questdb.std.*
;
import
io.questdb.std.microtime.Timestamps
;
import
io.questdb.std.str.Path
;
import
org.jetbrains.annotations.NotNull
;
import
java.io.Closeable
;
import
java.util.concurrent.locks.LockSupport
;
...
...
@@ -1039,16 +1040,7 @@ public class TableReader implements Closeable {
if
(
ff
.
exists
(
TableUtils
.
dFile
(
path
.
trimTo
(
plen
),
name
)))
{
if
(
mem1
!=
null
&&
mem1
!=
NullColumn
.
INSTANCE
)
{
mem1
.
of
(
ff
,
path
,
ff
.
getMapPageSize
(),
ff
.
length
(
path
));
}
else
{
if
(
lastPartition
)
{
mem1
=
new
ReadOnlyMemory
(
ff
,
path
,
ff
.
getMapPageSize
(),
0
);
}
else
{
mem1
=
new
OnePageMemory
(
ff
,
path
,
ff
.
length
(
path
));
}
columns
.
setQuick
(
primaryIndex
,
mem1
);
}
mem1
=
openOrCreateMemory
(
path
,
columns
,
lastPartition
,
primaryIndex
,
mem1
);
final
long
columnTop
=
TableUtils
.
readColumnTop
(
ff
,
path
.
trimTo
(
plen
),
name
,
plen
,
tempMem8b
);
final
int
type
=
metadata
.
getColumnType
(
columnIndex
);
...
...
@@ -1057,16 +1049,7 @@ public class TableReader implements Closeable {
case
ColumnType
.
BINARY
:
case
ColumnType
.
STRING
:
TableUtils
.
iFile
(
path
.
trimTo
(
plen
),
name
);
if
(
mem2
!=
null
&&
mem2
!=
NullColumn
.
INSTANCE
)
{
mem2
.
of
(
ff
,
path
,
ff
.
getMapPageSize
(),
ff
.
length
(
path
));
}
else
{
if
(
lastPartition
)
{
mem2
=
new
ReadOnlyMemory
(
ff
,
path
,
ff
.
getMapPageSize
(),
0
);
}
else
{
mem2
=
new
OnePageMemory
(
ff
,
path
,
ff
.
length
(
path
));
}
columns
.
setQuick
(
secondaryIndex
,
mem2
);
}
mem2
=
openOrCreateMemory
(
path
,
columns
,
lastPartition
,
secondaryIndex
,
mem2
);
growColumn
(
mem1
,
mem2
,
type
,
partitionRowCount
-
columnTop
);
break
;
default
:
...
...
@@ -1105,6 +1088,21 @@ public class TableReader implements Closeable {
}
}
@NotNull
private
ReadOnlyColumn
openOrCreateMemory
(
Path
path
,
ObjList
<
ReadOnlyColumn
>
columns
,
boolean
lastPartition
,
int
primaryIndex
,
ReadOnlyColumn
mem
)
{
if
(
mem
!=
null
&&
mem
!=
NullColumn
.
INSTANCE
)
{
mem
.
of
(
ff
,
path
,
ff
.
getMapPageSize
(),
ff
.
length
(
path
));
}
else
{
if
(
lastPartition
)
{
mem
=
new
ReadOnlyMemory
(
ff
,
path
,
ff
.
getMapPageSize
(),
0
);
}
else
{
mem
=
new
OnePageMemory
(
ff
,
path
,
ff
.
length
(
path
));
}
columns
.
setQuick
(
primaryIndex
,
mem
);
}
return
mem
;
}
private
void
reloadColumnChanges
()
{
// create transition index, which will help us reuse already open resources
long
pTransitionIndex
=
metadata
.
createTransitionIndex
();
...
...
core/src/main/java/io/questdb/cutlass/http/processors/StaticContentProcessor.java
浏览文件 @
8e6fc511
...
...
@@ -125,7 +125,7 @@ public class StaticContentProcessor implements HttpRequestProcessor, Closeable {
private
void
send
(
HttpConnectionContext
context
,
LPSZ
path
,
boolean
asAttachment
)
throws
PeerDisconnectedException
,
PeerIsSlowToReadException
{
int
n
=
Chars
.
lastIndexOf
(
path
,
'.'
);
if
(
n
==
-
1
)
{
LOG
.
info
().
$
(
"Missing extension: "
).
$
(
path
).
$
();
logInfoWithFd
(
context
).
$
(
"missing extension [file="
).
$
(
path
).
$
(
']'
).
$
();
sendStatusWithDefaultMessage
(
context
,
404
);
return
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录