Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
399cf85a
Unverified
Commit
399cf85a
authored
Nov 10, 2023
by
ZackYoung
Committed by
GitHub
Nov 10, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature]Add paimon cache (#2513)
* add_paimon_cache * add_paimon_cache * add_paimon_cache * add_paimon_cache * add_paimon_cache * add_paimon_cache * add_paimon_cache
parent
9e599960
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
633 additions
and
67 deletions
+633
-67
pom.xml
dinky-admin/pom.xml
+1
-1
CacheConfiguration.java
...in/java/org/dinky/configure/cache/CacheConfiguration.java
+32
-0
PaimonCache.java
.../src/main/java/org/dinky/configure/cache/PaimonCache.java
+131
-0
PaimonCacheManager.java
...in/java/org/dinky/configure/cache/PaimonCacheManager.java
+44
-0
MetricsContextHolder.java
...src/main/java/org/dinky/context/MetricsContextHolder.java
+15
-1
TokenController.java
...n/src/main/java/org/dinky/controller/TokenController.java
+1
-0
MetricsVO.java
dinky-admin/src/main/java/org/dinky/data/vo/MetricsVO.java
+26
-6
JobMetricsHandler.java
...rc/main/java/org/dinky/job/handler/JobMetricsHandler.java
+4
-3
MonitorServiceImpl.java
.../main/java/org/dinky/service/impl/MonitorServiceImpl.java
+2
-1
PaimonTypeUtil.java
...y-admin/src/main/java/org/dinky/utils/PaimonTypeUtil.java
+50
-0
PaimonUtil.java
dinky-admin/src/main/java/org/dinky/utils/PaimonUtil.java
+112
-52
Option.java
...c/main/java/org/dinky/data/annotations/paimon/Option.java
+35
-0
Options.java
.../main/java/org/dinky/data/annotations/paimon/Options.java
+33
-0
PartitionKey.java
.../java/org/dinky/data/annotations/paimon/PartitionKey.java
+32
-0
PrimaryKey.java
...in/java/org/dinky/data/annotations/paimon/PrimaryKey.java
+31
-0
PaimonTableConstant.java
...ain/java/org/dinky/data/constant/PaimonTableConstant.java
+26
-0
CacheData.java
...common/src/main/java/org/dinky/data/paimon/CacheData.java
+55
-0
index.tsx
...b/src/pages/DataStudio/LeftContainer/DataSource/index.tsx
+2
-2
route.tsx
dinky-web/src/pages/DataStudio/route.tsx
+1
-1
No files found.
dinky-admin/pom.xml
View file @
399cf85a
...
@@ -310,7 +310,7 @@
...
@@ -310,7 +310,7 @@
<dependency>
<dependency>
<groupId>
org.apache.paimon
</groupId>
<groupId>
org.apache.paimon
</groupId>
<artifactId>
paimon-bundle
</artifactId>
<artifactId>
paimon-bundle
</artifactId>
<version>
0.
4
.0-incubating
</version>
<version>
0.
5
.0-incubating
</version>
<exclusions>
<exclusions>
<exclusion>
<exclusion>
<groupId>
org.slf4j
</groupId>
<groupId>
org.slf4j
</groupId>
...
...
dinky-admin/src/main/java/org/dinky/configure/cache/CacheConfiguration.java
0 → 100644
View file @
399cf85a
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org
.
dinky
.
configure
.
cache
;
import
org.springframework.cache.CacheManager
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
public
class
CacheConfiguration
{
@Bean
public
CacheManager
cacheManager
()
{
return
new
PaimonCacheManager
();
}
}
dinky-admin/src/main/java/org/dinky/configure/cache/PaimonCache.java
0 → 100644
View file @
399cf85a
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org
.
dinky
.
configure
.
cache
;
import
org.dinky.data.constant.PaimonTableConstant
;
import
org.dinky.data.paimon.CacheData
;
import
org.dinky.utils.PaimonUtil
;
import
org.apache.paimon.data.BinaryString
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.concurrent.Callable
;
import
org.springframework.cache.support.AbstractValueAdaptingCache
;
import
com.alibaba.fastjson2.JSON
;
import
com.alibaba.fastjson2.JSONReader
;
import
com.alibaba.fastjson2.JSONWriter
;
import
cn.hutool.cache.impl.TimedCache
;
import
cn.hutool.core.convert.Convert
;
public
class
PaimonCache
extends
AbstractValueAdaptingCache
{
private
static
final
Class
<
CacheData
>
clazz
=
CacheData
.
class
;
private
final
String
cacheName
;
private
static
final
String
TABLE_NAME
=
PaimonTableConstant
.
DINKY_CACHE
;
/**
* TIMEOUT CACHE
*/
private
final
cn
.
hutool
.
cache
.
Cache
<
Object
,
Object
>
cache
=
new
TimedCache
<>(
1000
*
60
*
30
);
public
PaimonCache
(
String
cacheName
)
{
super
(
true
);
this
.
cacheName
=
cacheName
;
}
@Override
public
String
getName
()
{
return
cacheName
;
}
@Override
public
Object
getNativeCache
()
{
return
this
;
}
@Override
public
<
T
>
T
get
(
Object
key
,
Class
<
T
>
type
)
{
return
(
T
)
get
(
key
).
get
();
}
@Override
protected
Object
lookup
(
Object
key
)
{
String
strKey
=
Convert
.
toStr
(
key
);
Object
o
=
cache
.
get
(
strKey
);
if
(
o
==
null
)
{
PaimonUtil
.
createOrGetTable
(
TABLE_NAME
,
clazz
);
List
<
CacheData
>
cacheData
=
PaimonUtil
.
batchReadTable
(
TABLE_NAME
,
clazz
,
x
->
Arrays
.
asList
(
x
.
equal
(
x
.
indexOf
(
"cache_name"
),
BinaryString
.
fromString
(
cacheName
)),
x
.
equal
(
x
.
indexOf
(
"key"
),
BinaryString
.
fromString
(
strKey
))));
if
(
cacheData
.
isEmpty
())
{
return
null
;
}
return
deserialize
(
cacheData
.
get
(
0
).
getData
());
}
return
o
;
}
@Override
public
<
T
>
T
get
(
Object
key
,
Callable
<
T
>
valueLoader
)
{
return
(
T
)
get
(
key
).
get
();
}
@Override
public
void
put
(
Object
key
,
Object
value
)
{
String
strKey
=
Convert
.
toStr
(
key
);
cache
.
put
(
strKey
,
value
);
PaimonUtil
.
createOrGetTable
(
TABLE_NAME
,
clazz
);
CacheData
cacheData
=
CacheData
.
builder
()
.
cacheName
(
cacheName
)
.
key
(
strKey
)
.
data
(
serialize
(
value
))
.
build
();
PaimonUtil
.
write
(
TABLE_NAME
,
Collections
.
singletonList
(
cacheData
),
clazz
);
}
@Override
public
void
evict
(
Object
key
)
{
String
strKey
=
Convert
.
toStr
(
key
);
cache
.
remove
(
strKey
);
CacheData
cacheData
=
CacheData
.
builder
().
cacheName
(
cacheName
).
key
(
strKey
).
data
(
""
).
build
();
PaimonUtil
.
write
(
TABLE_NAME
,
Collections
.
singletonList
(
cacheData
),
clazz
);
}
@Override
public
void
clear
()
{
cache
.
clear
();
PaimonUtil
.
dropTable
(
TABLE_NAME
);
}
public
String
serialize
(
Object
object
)
{
return
JSON
.
toJSONString
(
object
,
JSONWriter
.
Feature
.
WriteClassName
);
}
public
Object
deserialize
(
String
json
)
{
return
JSON
.
parseObject
(
json
,
Object
.
class
,
JSONReader
.
Feature
.
SupportAutoType
);
}
}
dinky-admin/src/main/java/org/dinky/configure/cache/PaimonCacheManager.java
0 → 100644
View file @
399cf85a
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org
.
dinky
.
configure
.
cache
;
import
java.util.Collection
;
import
java.util.LinkedHashSet
;
import
org.springframework.cache.Cache
;
import
org.springframework.cache.support.AbstractCacheManager
;
public
class
PaimonCacheManager
extends
AbstractCacheManager
{
@Override
protected
Collection
<?
extends
Cache
>
loadCaches
()
{
Collection
<
Cache
>
caches
=
new
LinkedHashSet
<>();
for
(
String
cacheName
:
this
.
getCacheNames
())
{
Cache
cache
=
this
.
getCache
(
cacheName
);
caches
.
add
(
cache
);
}
return
caches
;
}
@Override
protected
Cache
getMissingCache
(
String
name
)
{
return
new
PaimonCache
(
name
);
}
}
dinky-admin/src/main/java/org/dinky/context/MetricsContextHolder.java
View file @
399cf85a
...
@@ -19,16 +19,21 @@
...
@@ -19,16 +19,21 @@
package
org
.
dinky
.
context
;
package
org
.
dinky
.
context
;
import
org.dinky.data.constant.PaimonTableConstant
;
import
org.dinky.data.enums.SseTopic
;
import
org.dinky.data.enums.SseTopic
;
import
org.dinky.data.vo.MetricsVO
;
import
org.dinky.data.vo.MetricsVO
;
import
org.dinky.utils.PaimonUtil
;
import
org.dinky.utils.PaimonUtil
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.CompletableFuture
;
import
cn.hutool.core.text.StrFormatter
;
import
cn.hutool.core.text.StrFormatter
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.json.JSONUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
/**
/**
...
@@ -58,7 +63,7 @@ public class MetricsContextHolder {
...
@@ -58,7 +63,7 @@ public class MetricsContextHolder {
long
duration
=
System
.
currentTimeMillis
()
-
lastDumpTime
;
long
duration
=
System
.
currentTimeMillis
()
-
lastDumpTime
;
synchronized
(
metricsVOS
)
{
synchronized
(
metricsVOS
)
{
if
(
metricsVOS
.
size
()
>
1000
||
duration
>
1000
*
5
)
{
if
(
metricsVOS
.
size
()
>
1000
||
duration
>
1000
*
5
)
{
PaimonUtil
.
writeMetrics
(
metricsVOS
);
writeMetrics
(
metricsVOS
);
metricsVOS
.
clear
();
metricsVOS
.
clear
();
}
}
}
}
...
@@ -66,4 +71,13 @@ public class MetricsContextHolder {
...
@@ -66,4 +71,13 @@ public class MetricsContextHolder {
SseSessionContextHolder
.
sendTopic
(
topic
,
o
);
SseSessionContextHolder
.
sendTopic
(
topic
,
o
);
});
});
}
}
private
static
synchronized
void
writeMetrics
(
List
<
MetricsVO
>
metricsList
)
{
ObjectUtil
.
clone
(
metricsList
).
forEach
(
metrics
->
{
LocalDateTime
now
=
metrics
.
getHeartTime
();
metrics
.
setDate
(
now
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
)));
metrics
.
setContent
(
JSONUtil
.
toJsonStr
(
metrics
.
getContent
()));
});
PaimonUtil
.
write
(
PaimonTableConstant
.
DINKY_METRICS
,
metricsList
,
MetricsVO
.
class
);
}
}
}
dinky-admin/src/main/java/org/dinky/controller/TokenController.java
View file @
399cf85a
...
@@ -89,6 +89,7 @@ public class TokenController {
...
@@ -89,6 +89,7 @@ public class TokenController {
value
=
{
PermissionConstants
.
AUTH_TOKEN_ADD
,
PermissionConstants
.
AUTH_TOKEN_EDIT
},
value
=
{
PermissionConstants
.
AUTH_TOKEN_ADD
,
PermissionConstants
.
AUTH_TOKEN_EDIT
},
mode
=
SaMode
.
OR
)
mode
=
SaMode
.
OR
)
public
Result
<
Void
>
saveOrUpdateToken
(
@RequestBody
SysToken
sysToken
)
{
public
Result
<
Void
>
saveOrUpdateToken
(
@RequestBody
SysToken
sysToken
)
{
sysToken
.
setSource
(
SysToken
.
Source
.
CUSTOM
);
return
tokenService
.
saveOrUpdate
(
sysToken
)
return
tokenService
.
saveOrUpdate
(
sysToken
)
?
Result
.
succeed
(
Status
.
SAVE_SUCCESS
)
?
Result
.
succeed
(
Status
.
SAVE_SUCCESS
)
:
Result
.
failed
(
Status
.
SAVE_FAILED
);
:
Result
.
failed
(
Status
.
SAVE_FAILED
);
...
...
dinky-admin/src/main/java/org/dinky/data/vo/MetricsVO.java
View file @
399cf85a
...
@@ -19,6 +19,12 @@
...
@@ -19,6 +19,12 @@
package
org
.
dinky
.
data
.
vo
;
package
org
.
dinky
.
data
.
vo
;
import
org.dinky.data.annotations.paimon.Option
;
import
org.dinky.data.annotations.paimon.Options
;
import
org.dinky.data.annotations.paimon.PartitionKey
;
import
org.dinky.data.annotations.paimon.PrimaryKey
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
...
@@ -37,20 +43,34 @@ import lombok.NoArgsConstructor;
...
@@ -37,20 +43,34 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
@ApiModel
(
value
=
"MetricsVO"
,
description
=
"Metrics Value Object"
)
@ApiModel
(
value
=
"MetricsVO"
,
description
=
"Metrics Value Object"
)
public
class
MetricsVO
{
@Options
({
@ApiModelProperty
(
value
=
"Content of metrics"
,
dataType
=
"Object"
,
notes
=
"Content of the metrics data."
)
@Option
(
key
=
"file.format"
,
value
=
"parquet"
),
private
Object
content
;
@Option
(
key
=
"snapshot.time-retained"
,
value
=
"10 s"
),
@Option
(
key
=
"partition.expiration-time"
,
value
=
"7d"
),
@ApiModelProperty
(
value
=
"Model name"
,
dataType
=
"String"
,
notes
=
"Name of the model."
)
@Option
(
key
=
"partition.expiration-check-interval"
,
value
=
"1d"
),
private
String
model
;
@Option
(
key
=
"partition.timestamp-formatter"
,
value
=
"yyyy-MM-dd"
),
@Option
(
key
=
"partition.timestamp-pattern"
,
value
=
"$date"
),
})
public
class
MetricsVO
implements
Serializable
{
@JsonDeserialize
(
using
=
LocalDateTimeDeserializer
.
class
)
@JsonDeserialize
(
using
=
LocalDateTimeDeserializer
.
class
)
@JsonSerialize
(
using
=
LocalDateTimeSerializer
.
class
)
@JsonSerialize
(
using
=
LocalDateTimeSerializer
.
class
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@PrimaryKey
@ApiModelProperty
(
@ApiModelProperty
(
value
=
"Timestamp of heartbeart"
,
value
=
"Timestamp of heartbeart"
,
dataType
=
"LocalDateTime"
,
dataType
=
"LocalDateTime"
,
notes
=
"Timestamp of the heartbeat data."
,
notes
=
"Timestamp of the heartbeat data."
,
example
=
"2023-09-15 14:30:00"
)
example
=
"2023-09-15 14:30:00"
)
private
LocalDateTime
heartTime
;
private
LocalDateTime
heartTime
;
@ApiModelProperty
(
value
=
"Model name"
,
dataType
=
"String"
,
notes
=
"Name of the model."
)
@PartitionKey
private
String
model
;
@ApiModelProperty
(
value
=
"Content of metrics"
,
dataType
=
"Object"
,
notes
=
"Content of the metrics data."
)
private
Object
content
;
@PartitionKey
private
String
date
;
}
}
dinky-admin/src/main/java/org/dinky/job/handler/JobMetricsHandler.java
View file @
399cf85a
...
@@ -49,7 +49,6 @@ public class JobMetricsHandler {
...
@@ -49,7 +49,6 @@ public class JobMetricsHandler {
* Use concurrent programming to get the data of each indicator through asynchronous requests. </br>
* Use concurrent programming to get the data of each indicator through asynchronous requests. </br>
* Send to MetricsContextHolder asynchronously at the end of the method. </br>
* Send to MetricsContextHolder asynchronously at the end of the method. </br>
* Thus, the operation of writing the Flink indicator is completed. </br>
* Thus, the operation of writing the Flink indicator is completed. </br>
*
*/
*/
public
static
void
writeFlinkMetrics
(
JobInfoDetail
jobInfoDetail
)
{
public
static
void
writeFlinkMetrics
(
JobInfoDetail
jobInfoDetail
)
{
Map
<
String
,
Map
<
String
,
String
>>
customMetricsList
=
jobInfoDetail
.
getCustomMetricsMap
();
Map
<
String
,
Map
<
String
,
String
>>
customMetricsList
=
jobInfoDetail
.
getCustomMetricsMap
();
...
@@ -64,8 +63,10 @@ public class JobMetricsHandler {
...
@@ -64,8 +63,10 @@ public class JobMetricsHandler {
.
toArray
(
CompletableFuture
[]::
new
);
.
toArray
(
CompletableFuture
[]::
new
);
// Wait for all Completable Future executions to finish
// Wait for all Completable Future executions to finish
AsyncUtil
.
waitAll
(
array
);
AsyncUtil
.
waitAll
(
array
);
MetricsVO
metricsVO
=
new
MetricsVO
();
MetricsVO
metricsVO
=
new
MetricsVO
(
customMetricsList
,
jobId
,
LocalDateTime
.
now
());
metricsVO
.
setContent
(
customMetricsList
);
metricsVO
.
setHeartTime
(
LocalDateTime
.
now
());
metricsVO
.
setModel
(
jobId
);
MetricsContextHolder
.
getInstances
().
sendAsync
(
metricsVO
.
getModel
(),
metricsVO
);
MetricsContextHolder
.
getInstances
().
sendAsync
(
metricsVO
.
getModel
(),
metricsVO
);
}
}
...
...
dinky-admin/src/main/java/org/dinky/service/impl/MonitorServiceImpl.java
View file @
399cf85a
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
package
org
.
dinky
.
service
.
impl
;
package
org
.
dinky
.
service
.
impl
;
import
org.dinky.data.constant.PaimonTableConstant
;
import
org.dinky.data.dto.MetricsLayoutDTO
;
import
org.dinky.data.dto.MetricsLayoutDTO
;
import
org.dinky.data.exception.DinkyException
;
import
org.dinky.data.exception.DinkyException
;
import
org.dinky.data.metrics.Jvm
;
import
org.dinky.data.metrics.Jvm
;
...
@@ -81,7 +82,7 @@ public class MonitorServiceImpl extends ServiceImpl<MetricsMapper, Metrics> impl
...
@@ -81,7 +82,7 @@ public class MonitorServiceImpl extends ServiceImpl<MetricsMapper, Metrics> impl
return
CollUtil
.
newArrayList
(
local
,
greaterOrEqual
,
lessOrEqual
);
return
CollUtil
.
newArrayList
(
local
,
greaterOrEqual
,
lessOrEqual
);
};
};
List
<
MetricsVO
>
metricsVOList
=
List
<
MetricsVO
>
metricsVOList
=
PaimonUtil
.
batchReadTable
(
Paimon
Util
.
METRICS_IDENTIFIER
,
MetricsVO
.
class
,
filter
);
PaimonUtil
.
batchReadTable
(
Paimon
TableConstant
.
DINKY_METRICS
,
MetricsVO
.
class
,
filter
);
return
metricsVOList
.
stream
()
return
metricsVOList
.
stream
()
.
filter
(
x
->
x
.
getHeartTime
().
isAfter
(
startTS
.
toLocalDateTime
()))
.
filter
(
x
->
x
.
getHeartTime
().
isAfter
(
startTS
.
toLocalDateTime
()))
.
filter
(
x
->
x
.
getHeartTime
().
isBefore
(
endTS
.
toLocalDateTime
()))
.
filter
(
x
->
x
.
getHeartTime
().
isBefore
(
endTS
.
toLocalDateTime
()))
...
...
dinky-admin/src/main/java/org/dinky/utils/PaimonTypeUtil.java
0 → 100644
View file @
399cf85a
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org
.
dinky
.
utils
;
import
org.apache.paimon.types.DataType
;
import
org.apache.paimon.types.DataTypes
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.util.Date
;
import
java.util.Map
;
import
cn.hutool.core.map.MapUtil
;
public
class
PaimonTypeUtil
{
private
static
final
Map
<
Class
<?>,
DataType
>
TYPE_MAP
=
MapUtil
.<
Class
<?>,
DataType
>
builder
(
String
.
class
,
DataTypes
.
STRING
())
.
put
(
Integer
.
class
,
DataTypes
.
INT
())
.
put
(
Long
.
class
,
DataTypes
.
BIGINT
())
.
put
(
Double
.
class
,
DataTypes
.
DOUBLE
())
.
put
(
Float
.
class
,
DataTypes
.
FLOAT
())
.
put
(
Boolean
.
class
,
DataTypes
.
BOOLEAN
())
.
put
(
Byte
.
class
,
DataTypes
.
TINYINT
())
.
put
(
Short
.
class
,
DataTypes
.
SMALLINT
())
.
put
(
BigDecimal
.
class
,
DataTypes
.
DECIMAL
(
30
,
4
))
.
put
(
Date
.
class
,
DataTypes
.
TIMESTAMP
(
3
))
.
put
(
LocalDateTime
.
class
,
DataTypes
.
TIMESTAMP
(
3
))
.
build
();
public
static
DataType
classToDataType
(
Class
<?>
clazz
)
{
return
TYPE_MAP
.
getOrDefault
(
clazz
,
DataTypes
.
STRING
());
}
}
dinky-admin/src/main/java/org/dinky/utils/PaimonUtil.java
View file @
399cf85a
...
@@ -19,7 +19,12 @@
...
@@ -19,7 +19,12 @@
package
org
.
dinky
.
utils
;
package
org
.
dinky
.
utils
;
import
org.dinky.data.vo.MetricsVO
;
import
static
org
.
dinky
.
data
.
constant
.
PaimonTableConstant
.
DINKY_DB
;
import
org.dinky.data.annotations.paimon.Option
;
import
org.dinky.data.annotations.paimon.Options
;
import
org.dinky.data.annotations.paimon.PartitionKey
;
import
org.dinky.data.annotations.paimon.PrimaryKey
;
import
org.dinky.function.constant.PathConstant
;
import
org.dinky.function.constant.PathConstant
;
import
org.apache.paimon.catalog.Catalog
;
import
org.apache.paimon.catalog.Catalog
;
...
@@ -29,6 +34,7 @@ import org.apache.paimon.catalog.Identifier;
...
@@ -29,6 +34,7 @@ import org.apache.paimon.catalog.Identifier;
import
org.apache.paimon.data.BinaryRow
;
import
org.apache.paimon.data.BinaryRow
;
import
org.apache.paimon.data.BinaryRowWriter
;
import
org.apache.paimon.data.BinaryRowWriter
;
import
org.apache.paimon.data.BinaryString
;
import
org.apache.paimon.data.BinaryString
;
import
org.apache.paimon.data.BinaryWriter
;
import
org.apache.paimon.data.InternalRow
;
import
org.apache.paimon.data.InternalRow
;
import
org.apache.paimon.data.Timestamp
;
import
org.apache.paimon.data.Timestamp
;
import
org.apache.paimon.fs.Path
;
import
org.apache.paimon.fs.Path
;
...
@@ -44,20 +50,26 @@ import org.apache.paimon.table.sink.CommitMessage;
...
@@ -44,20 +50,26 @@ import org.apache.paimon.table.sink.CommitMessage;
import
org.apache.paimon.table.source.ReadBuilder
;
import
org.apache.paimon.table.source.ReadBuilder
;
import
org.apache.paimon.table.source.Split
;
import
org.apache.paimon.table.source.Split
;
import
org.apache.paimon.table.source.TableRead
;
import
org.apache.paimon.table.source.TableRead
;
import
org.apache.paimon.types.DataTypes
;
import
org.apache.paimon.types.DataField
;
import
org.apache.paimon.types.DataType
;
import
org.apache.paimon.types.DataTypeRoot
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
cn.hutool.cache.Cache
;
import
cn.hutool.cache.CacheUtil
;
import
cn.hutool.core.annotation.AnnotationUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.TimeInterval
;
import
cn.hutool.core.date.TimeInterval
;
import
cn.hutool.core.map.MapUtil
;
import
cn.hutool.core.util.ModifierUtil
;
import
cn.hutool.core.util.ReflectUtil
;
import
cn.hutool.core.util.ReflectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.URLUtil
;
import
cn.hutool.core.util.URLUtil
;
...
@@ -66,12 +78,10 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -66,12 +78,10 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Slf4j
public
class
PaimonUtil
{
public
class
PaimonUtil
{
private
static
final
String
DINKY_DB
=
"dinky_db"
;
private
static
final
Cache
<
Class
<?>,
Schema
>
SCHEMA_CACHE
=
CacheUtil
.
newLRUCache
(
100
);
private
static
final
Map
<
Identifier
,
Schema
>
SCHEMA_MAP
=
new
HashMap
<>();
private
static
final
CatalogContext
CONTEXT
=
private
static
final
CatalogContext
CONTEXT
=
CatalogContext
.
create
(
new
Path
(
URLUtil
.
toURI
(
URLUtil
.
url
(
PathConstant
.
TMP_PATH
+
"paimon"
))));
CatalogContext
.
create
(
new
Path
(
URLUtil
.
toURI
(
URLUtil
.
url
(
PathConstant
.
TMP_PATH
+
"paimon"
))));
private
static
final
Catalog
CATALOG
=
CatalogFactory
.
createCatalog
(
CONTEXT
);
private
static
final
Catalog
CATALOG
=
CatalogFactory
.
createCatalog
(
CONTEXT
);
public
static
final
Identifier
METRICS_IDENTIFIER
=
Identifier
.
create
(
DINKY_DB
,
"dinky_metrics"
);
static
{
static
{
try
{
try
{
...
@@ -79,47 +89,55 @@ public class PaimonUtil {
...
@@ -79,47 +89,55 @@ public class PaimonUtil {
}
catch
(
Catalog
.
DatabaseAlreadyExistException
e
)
{
}
catch
(
Catalog
.
DatabaseAlreadyExistException
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
Map
<
String
,
String
>
options
=
new
HashMap
<>();
}
options
.
put
(
"partition.expiration-time"
,
"7d"
);
options
.
put
(
"partition.expiration-check-interval"
,
"1d"
);
public
static
void
dropTable
(
String
table
)
{
options
.
put
(
"partition.timestamp-formatter"
,
"yyyy-MM-dd"
);
Identifier
identifier
=
Identifier
.
create
(
DINKY_DB
,
table
);
options
.
put
(
"partition.timestamp-pattern"
,
"$date"
);
if
(
CATALOG
.
tableExists
(
identifier
))
{
options
.
put
(
"file.format"
,
"parquet"
);
try
{
options
.
put
(
"snapshot.time-retained"
,
"10 s"
);
CATALOG
.
dropTable
(
identifier
,
true
);
}
catch
(
Exception
e
)
{
Schema
.
Builder
schemaBuilder
=
Schema
.
newBuilder
();
throw
new
RuntimeException
(
e
);
schemaBuilder
.
primaryKey
(
"heart_time"
,
"model"
,
"date"
);
}
schemaBuilder
.
partitionKeys
(
"model"
,
"date"
);
}
schemaBuilder
.
column
(
"heart_time"
,
DataTypes
.
TIMESTAMP_MILLIS
());
}
schemaBuilder
.
column
(
"model"
,
DataTypes
.
STRING
());
schemaBuilder
.
column
(
"content"
,
DataTypes
.
STRING
());
public
static
<
T
>
void
write
(
String
table
,
List
<
T
>
dataList
,
Class
<?>
clazz
)
{
schemaBuilder
.
column
(
"date"
,
DataTypes
.
STRING
());
if
(
CollUtil
.
isEmpty
(
dataList
))
{
schemaBuilder
.
options
(
options
);
Schema
schema
=
schemaBuilder
.
build
();
SCHEMA_MAP
.
put
(
METRICS_IDENTIFIER
,
schema
);
}
public
static
synchronized
void
writeMetrics
(
List
<
MetricsVO
>
metricsList
)
{
if
(
CollUtil
.
isEmpty
(
metricsList
))
{
return
;
return
;
}
}
Table
metricsTable
=
createOrGetMetricsTable
(
);
Table
paimonTable
=
createOrGetTable
(
table
,
null
);
BatchWriteBuilder
writeBuilder
=
metrics
Table
.
newBatchWriteBuilder
();
BatchWriteBuilder
writeBuilder
=
paimon
Table
.
newBatchWriteBuilder
();
// 2. Write records in distributed tasks
// 2. Write records in distributed tasks
try
(
BatchTableWrite
write
=
writeBuilder
.
newWrite
())
{
try
(
BatchTableWrite
write
=
writeBuilder
.
newWrite
())
{
for
(
MetricsVO
metrics
:
metricsList
)
{
Schema
schema
=
getSchemaByClass
(
clazz
);
LocalDateTime
now
=
metrics
.
getHeartTime
();
List
<
DataField
>
fields
=
schema
.
fields
();
for
(
T
t
:
dataList
)
{
BinaryRow
row
=
new
BinaryRow
(
30
);
BinaryRow
row
=
new
BinaryRow
(
fields
.
size
()
);
BinaryRowWriter
writer
=
new
BinaryRowWriter
(
row
);
BinaryRowWriter
writer
=
new
BinaryRowWriter
(
row
);
writer
.
writeTimestamp
(
0
,
Timestamp
.
fromLocalDateTime
(
now
),
3
);
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
writer
.
writeString
(
1
,
BinaryString
.
fromString
(
metrics
.
getModel
()));
DataField
dataField
=
fields
.
get
(
i
);
writer
.
writeString
(
2
,
BinaryString
.
fromString
(
JSONUtil
.
toJsonStr
(
metrics
.
getContent
())));
DataType
type
=
dataField
.
type
();
writer
.
writeString
(
3
,
BinaryString
.
fromString
(
now
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
))));
String
fieldName
=
StrUtil
.
toCamelCase
(
dataField
.
name
());
if
(
type
.
getTypeRoot
()
==
DataTypeRoot
.
VARCHAR
)
{
BinaryWriter
.
write
(
writer
,
i
,
BinaryString
.
fromString
(
JSONUtil
.
toJsonStr
(
ReflectUtil
.
getFieldValue
(
t
,
fieldName
))),
type
,
null
);
}
else
if
(
type
.
getTypeRoot
()
==
DataTypeRoot
.
TIME_WITHOUT_TIME_ZONE
)
{
Timestamp
timestamp
=
Timestamp
.
fromLocalDateTime
((
LocalDateTime
)
ReflectUtil
.
getFieldValue
(
t
,
fieldName
));
BinaryWriter
.
write
(
writer
,
i
,
timestamp
,
type
,
null
);
}
else
{
BinaryWriter
.
write
(
writer
,
i
,
ReflectUtil
.
getFieldValue
(
t
,
fieldName
),
type
,
null
);
}
}
write
.
write
(
row
);
write
.
write
(
row
);
}
}
List
<
CommitMessage
>
messages
=
write
.
prepareCommit
();
List
<
CommitMessage
>
messages
=
write
.
prepareCommit
();
// 3. Collect all CommitMessages to a global node and commit
// 3. Collect all CommitMessages to a global node and commit
...
@@ -132,17 +150,17 @@ public class PaimonUtil {
...
@@ -132,17 +150,17 @@ public class PaimonUtil {
}
}
}
}
public
static
<
T
>
List
<
T
>
batchReadTable
(
Identifier
identifier
,
Class
<
T
>
clazz
)
{
public
static
<
T
>
List
<
T
>
batchReadTable
(
String
table
,
Class
<
T
>
clazz
)
{
return
batchReadTable
(
identifier
,
clazz
,
null
);
return
batchReadTable
(
table
,
clazz
,
null
);
}
}
public
static
<
T
>
List
<
T
>
batchReadTable
(
public
static
<
T
>
List
<
T
>
batchReadTable
(
Identifier
identifier
,
Class
<
T
>
clazz
,
Function
<
PredicateBuilder
,
List
<
Predicate
>>
filter
)
{
String
table
,
Class
<
T
>
clazz
,
Function
<
PredicateBuilder
,
List
<
Predicate
>>
filter
)
{
Identifier
identifier
=
getIdentifier
(
table
);
TimeInterval
timer
=
DateUtil
.
timer
();
TimeInterval
timer
=
DateUtil
.
timer
();
List
<
T
>
dataList
=
new
ArrayList
<>();
List
<
T
>
dataList
=
new
ArrayList
<>();
PredicateBuilder
builder
=
PredicateBuilder
builder
=
new
PredicateBuilder
(
getSchemaByClass
(
clazz
).
rowType
());
new
PredicateBuilder
(
SCHEMA_MAP
.
get
(
identifier
).
rowType
());
ReadBuilder
readBuilder
;
ReadBuilder
readBuilder
;
try
{
try
{
...
@@ -167,7 +185,7 @@ public class PaimonUtil {
...
@@ -167,7 +185,7 @@ public class PaimonUtil {
TableRead
read
=
readBuilder
.
newRead
();
TableRead
read
=
readBuilder
.
newRead
();
try
(
RecordReader
<
InternalRow
>
reader
=
read
.
createReader
(
splits
))
{
try
(
RecordReader
<
InternalRow
>
reader
=
read
.
createReader
(
splits
))
{
Schema
schema
=
SCHEMA_MAP
.
get
(
METRICS_IDENTIFIER
);
Schema
schema
=
getSchemaByClass
(
clazz
);
reader
.
forEachRemaining
(
x
->
{
reader
.
forEachRemaining
(
x
->
{
T
t
=
ReflectUtil
.
newInstance
(
clazz
);
T
t
=
ReflectUtil
.
newInstance
(
clazz
);
schema
.
fields
().
forEach
(
f
->
{
schema
.
fields
().
forEach
(
f
->
{
...
@@ -192,16 +210,58 @@ public class PaimonUtil {
...
@@ -192,16 +210,58 @@ public class PaimonUtil {
return
dataList
;
return
dataList
;
}
}
public
static
Table
createOrGet
MetricsTable
(
)
{
public
static
Table
createOrGet
Table
(
String
tableName
,
Class
<?>
clazz
)
{
try
{
try
{
if
(
CATALOG
.
tableExists
(
METRICS_IDENTIFIER
))
{
Identifier
identifier
=
Identifier
.
create
(
DINKY_DB
,
tableName
);
return
CATALOG
.
getTable
(
METRICS_IDENTIFIER
);
if
(
CATALOG
.
tableExists
(
identifier
))
{
return
CATALOG
.
getTable
(
identifier
);
}
}
CATALOG
.
createTable
(
identifier
,
getSchemaByClass
(
clazz
),
false
);
CATALOG
.
createTable
(
METRICS_IDENTIFIER
,
SCHEMA_MAP
.
get
(
METRICS_IDENTIFIER
),
false
);
return
CATALOG
.
getTable
(
identifier
);
return
CATALOG
.
getTable
(
METRICS_IDENTIFIER
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
}
}
public
static
Schema
getSchemaByClass
(
Class
<?>
clazz
)
{
return
SCHEMA_CACHE
.
get
(
clazz
,
()
->
{
List
<
String
>
primaryKeys
=
new
ArrayList
<>();
List
<
String
>
partitionKeys
=
new
ArrayList
<>();
Schema
.
Builder
builder
=
Schema
.
newBuilder
();
Field
[]
fields
=
ReflectUtil
.
getFields
(
clazz
,
field
->
!
ModifierUtil
.
isStatic
(
field
));
for
(
Field
field
:
fields
)
{
String
fieldName
=
StrUtil
.
toUnderlineCase
(
field
.
getName
());
if
(
field
.
getAnnotations
().
length
>
0
)
{
if
(
AnnotationUtil
.
hasAnnotation
(
field
,
PartitionKey
.
class
))
{
partitionKeys
.
add
(
fieldName
);
}
if
(
AnnotationUtil
.
hasAnnotation
(
field
,
PrimaryKey
.
class
))
{
primaryKeys
.
add
(
fieldName
);
}
}
Class
<?>
type
=
field
.
getType
();
DataType
dataType
=
PaimonTypeUtil
.
classToDataType
(
type
);
builder
.
column
(
fieldName
,
dataType
);
}
// get options
Options
options
=
AnnotationUtil
.
getAnnotation
(
clazz
,
Options
.
class
);
if
(
options
!=
null
)
{
for
(
Option
option
:
options
.
value
())
{
builder
.
option
(
option
.
key
(),
option
.
value
());
}
}
else
{
// default options
Map
<
String
,
String
>
defaultOptions
=
MapUtil
.
builder
(
"file.format"
,
"parquet"
).
build
();
builder
.
options
(
defaultOptions
);
}
// builder schema;
return
builder
.
partitionKeys
(
partitionKeys
).
primaryKey
(
primaryKeys
).
build
();
});
}
public
static
Identifier
getIdentifier
(
String
tableName
)
{
return
Identifier
.
create
(
DINKY_DB
,
tableName
);
}
}
}
dinky-common/src/main/java/org/dinky/data/annotations/paimon/Option.java
0 → 100644
View file @
399cf85a
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org
.
dinky
.
data
.
annotations
.
paimon
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Inherited
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
@Target
(
ElementType
.
ANNOTATION_TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Inherited
public
@interface
Option
{
String
key
();
String
value
();
}
dinky-common/src/main/java/org/dinky/data/annotations/paimon/Options.java
0 → 100644
View file @
399cf85a
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org
.
dinky
.
data
.
annotations
.
paimon
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Inherited
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Inherited
public
@interface
Options
{
Option
[]
value
();
}
dinky-common/src/main/java/org/dinky/data/annotations/paimon/PartitionKey.java
0 → 100644
View file @
399cf85a
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org
.
dinky
.
data
.
annotations
.
paimon
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Inherited
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
@Target
(
ElementType
.
FIELD
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Inherited
@PrimaryKey
public
@interface
PartitionKey
{}
dinky-common/src/main/java/org/dinky/data/annotations/paimon/PrimaryKey.java
0 → 100644
View file @
399cf85a
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org
.
dinky
.
data
.
annotations
.
paimon
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Inherited
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
@Target
({
ElementType
.
FIELD
,
ElementType
.
ANNOTATION_TYPE
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Inherited
public
@interface
PrimaryKey
{}
dinky-common/src/main/java/org/dinky/data/constant/PaimonTableConstant.java
0 → 100644
View file @
399cf85a
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org
.
dinky
.
data
.
constant
;
public
final
class
PaimonTableConstant
{
public
static
final
String
DINKY_DB
=
"dinky_db"
;
public
static
final
String
DINKY_CACHE
=
"dinky_cache"
;
public
static
final
String
DINKY_METRICS
=
"dinky_metrics"
;
}
dinky-common/src/main/java/org/dinky/data/paimon/CacheData.java
0 → 100644
View file @
399cf85a
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org
.
dinky
.
data
.
paimon
;
import
org.dinky.data.annotations.paimon.Option
;
import
org.dinky.data.annotations.paimon.Options
;
import
org.dinky.data.annotations.paimon.PartitionKey
;
import
org.dinky.data.annotations.paimon.PrimaryKey
;
import
java.io.Serializable
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Options
({
@Option
(
key
=
"file.format"
,
value
=
"parquet"
),
@Option
(
key
=
"snapshot.time-retained"
,
value
=
"10 s"
),
})
public
class
CacheData
implements
Serializable
{
@PartitionKey
private
String
cacheName
;
@PrimaryKey
private
String
key
;
/**
* Serialized json data
*/
private
String
data
;
}
dinky-web/src/pages/DataStudio/LeftContainer/DataSource/index.tsx
View file @
399cf85a
...
@@ -88,10 +88,10 @@ const DataSource = (props: any) => {
...
@@ -88,10 +88,10 @@ const DataSource = (props: any) => {
onRefreshTreeData
(
value
);
onRefreshTreeData
(
value
);
};
};
BtnRoute
[
'menu.datastudio.
metadata
'
][
0
].
onClick
=
()
=>
{
BtnRoute
[
'menu.datastudio.
datasource
'
][
0
].
onClick
=
()
=>
{
setShowCreate
(
true
);
setShowCreate
(
true
);
};
};
BtnRoute
[
'menu.datastudio.
metadata
'
][
1
].
onClick
=
()
=>
{
BtnRoute
[
'menu.datastudio.
datasource
'
][
1
].
onClick
=
()
=>
{
if
(
!
selectDatabaseId
)
return
;
if
(
!
selectDatabaseId
)
return
;
setIsLoadingDatabase
(
true
);
setIsLoadingDatabase
(
true
);
clearDataSourceTable
(
selectDatabaseId
).
then
(()
=>
{
clearDataSourceTable
(
selectDatabaseId
).
then
(()
=>
{
...
...
dinky-web/src/pages/DataStudio/route.tsx
View file @
399cf85a
...
@@ -228,7 +228,7 @@ export const LeftBottomMoreTabs: { [c: string]: TabProp[] } = {
...
@@ -228,7 +228,7 @@ export const LeftBottomMoreTabs: { [c: string]: TabProp[] } = {
// btn route
// btn route
export
const
BtnRoute
:
{
[
c
:
string
]:
CircleDataStudioButtonProps
[]
}
=
{
export
const
BtnRoute
:
{
[
c
:
string
]:
CircleDataStudioButtonProps
[]
}
=
{
'menu.datastudio.
metadata
'
:
[
'menu.datastudio.
datasource
'
:
[
{
{
icon
:
<
PlusOutlined
/>,
icon
:
<
PlusOutlined
/>,
title
:
l
(
'button.create'
),
title
:
l
(
'button.create'
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment