Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Iotdb
提交
87a8dcf2
I
Iotdb
项目概览
apache
/
Iotdb
12 个月 前同步成功
通知
25
Star
3344
Fork
916
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Iotdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
87a8dcf2
编写于
4月 10, 2020
作者:
S
Sail
提交者:
GitHub
4月 10, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[IOTDB-573]Wrap Runnable (#1015)
* add WrappedRunnable class
上级
f2482b93
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
78 addition
and
23 deletion
+78
-23
server/src/main/java/org/apache/iotdb/db/concurrent/WrappedRunnable.java
.../java/org/apache/iotdb/db/concurrent/WrappedRunnable.java
+42
-0
server/src/main/java/org/apache/iotdb/db/cost/statistic/Measurement.java
.../java/org/apache/iotdb/db/cost/statistic/Measurement.java
+5
-4
server/src/main/java/org/apache/iotdb/db/engine/flush/FlushManager.java
...n/java/org/apache/iotdb/db/engine/flush/FlushManager.java
+4
-2
server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
...e/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
+1
-0
server/src/main/java/org/apache/iotdb/db/engine/upgrade/UpgradeTask.java
.../java/org/apache/iotdb/db/engine/upgrade/UpgradeTask.java
+3
-2
server/src/main/java/org/apache/iotdb/db/monitor/StatMonitor.java
...rc/main/java/org/apache/iotdb/db/monitor/StatMonitor.java
+3
-2
server/src/main/java/org/apache/iotdb/db/query/dataset/NonAlignEngineDataSet.java
.../apache/iotdb/db/query/dataset/NonAlignEngineDataSet.java
+3
-2
server/src/main/java/org/apache/iotdb/db/query/dataset/RawQueryDataSetWithoutValueFilter.java
...b/db/query/dataset/RawQueryDataSetWithoutValueFilter.java
+3
-2
server/src/main/java/org/apache/iotdb/db/service/MetricsService.java
...main/java/org/apache/iotdb/db/service/MetricsService.java
+3
-2
server/src/main/java/org/apache/iotdb/db/tools/memestimation/MemEstToolCmd.java
...rg/apache/iotdb/db/tools/memestimation/MemEstToolCmd.java
+3
-2
server/src/test/java/org/apache/iotdb/db/concurrent/IoTDBThreadPoolFactoryTest.java
...pache/iotdb/db/concurrent/IoTDBThreadPoolFactoryTest.java
+2
-2
server/src/test/java/org/apache/iotdb/db/conf/adapter/ActiveTimeSeriesCounterTest.java
...he/iotdb/db/conf/adapter/ActiveTimeSeriesCounterTest.java
+6
-3
未找到文件。
server/src/main/java/org/apache/iotdb/db/concurrent/WrappedRunnable.java
0 → 100644
浏览文件 @
87a8dcf2
/*
* 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.apache.iotdb.db.concurrent
;
import
com.google.common.base.Throwables
;
import
org.apache.iotdb.db.sync.receiver.load.FileLoaderManager
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
abstract
class
WrappedRunnable
implements
Runnable
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
WrappedRunnable
.
class
);
public
final
void
run
()
{
try
{
runMayThrow
();
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"error"
,
e
);
throw
Throwables
.
propagate
(
e
);
}
}
abstract
public
void
runMayThrow
()
throws
Exception
;
}
server/src/main/java/org/apache/iotdb/db/cost/statistic/Measurement.java
浏览文件 @
87a8dcf2
...
...
@@ -27,6 +27,7 @@ import java.util.concurrent.TimeUnit;
import
java.util.concurrent.locks.ReentrantLock
;
import
org.apache.iotdb.db.concurrent.IoTDBThreadPoolFactory
;
import
org.apache.iotdb.db.concurrent.ThreadName
;
import
org.apache.iotdb.db.concurrent.WrappedRunnable
;
import
org.apache.iotdb.db.conf.IoTDBConfig
;
import
org.apache.iotdb.db.conf.IoTDBConstant
;
import
org.apache.iotdb.db.conf.IoTDBDescriptor
;
...
...
@@ -380,18 +381,18 @@ public class Measurement implements MeasurementMBean, IService {
"================================================================================================================="
);
}
class
DisplayRunnable
implements
Runnable
{
class
DisplayRunnable
extends
Wrapped
Runnable
{
@Override
public
void
run
()
{
public
void
run
MayThrow
()
{
showMeasurements
();
}
}
class
QueueConsumerThread
implements
Runnable
{
class
QueueConsumerThread
extends
Wrapped
Runnable
{
@Override
public
void
run
()
{
public
void
run
MayThrow
()
{
consumer
();
}
...
...
server/src/main/java/org/apache/iotdb/db/engine/flush/FlushManager.java
浏览文件 @
87a8dcf2
...
...
@@ -20,6 +20,8 @@ package org.apache.iotdb.db.engine.flush;
import
java.util.concurrent.ConcurrentLinkedDeque
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
org.apache.iotdb.db.concurrent.WrappedRunnable
;
import
org.apache.iotdb.db.engine.flush.pool.FlushSubTaskPoolManager
;
import
org.apache.iotdb.db.engine.flush.pool.FlushTaskPoolManager
;
import
org.apache.iotdb.db.engine.storagegroup.TsFileProcessor
;
...
...
@@ -81,10 +83,10 @@ public class FlushManager implements FlushManagerMBean, IService {
return
FlushSubTaskPoolManager
.
getInstance
().
getWaitingTasksNumber
();
}
class
FlushThread
implements
Runnable
{
class
FlushThread
extends
WrappedRunnable
{
@Override
public
void
run
()
{
public
void
run
MayThrow
()
{
TsFileProcessor
tsFileProcessor
=
tsFileProcessorQueue
.
poll
();
tsFileProcessor
.
flushOneMemTable
();
tsFileProcessor
.
setManagedByFlushManager
(
false
);
...
...
server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
浏览文件 @
87a8dcf2
...
...
@@ -239,6 +239,7 @@ public class StorageGroupProcessor {
}
recover
();
}
private
void
recover
()
throws
StorageGroupProcessorException
{
...
...
server/src/main/java/org/apache/iotdb/db/engine/upgrade/UpgradeTask.java
浏览文件 @
87a8dcf2
...
...
@@ -18,6 +18,7 @@
*/
package
org.apache.iotdb.db.engine.upgrade
;
import
org.apache.iotdb.db.concurrent.WrappedRunnable
;
import
org.apache.iotdb.db.engine.storagegroup.TsFileResource
;
import
org.apache.iotdb.db.service.UpgradeSevice
;
import
org.apache.iotdb.db.utils.UpgradeUtils
;
...
...
@@ -25,7 +26,7 @@ import org.apache.iotdb.tsfile.fileSystem.FSFactoryProducer;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
UpgradeTask
implements
Runnable
{
public
class
UpgradeTask
extends
Wrapped
Runnable
{
private
final
TsFileResource
upgradeResource
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UpgradeTask
.
class
);
...
...
@@ -37,7 +38,7 @@ public class UpgradeTask implements Runnable {
}
@Override
public
void
run
()
{
public
void
run
MayThrow
()
{
try
{
upgradeResource
.
getWriteQueryLock
().
readLock
().
lock
();
String
tsfilePathBefore
=
upgradeResource
.
getFile
().
getAbsolutePath
();
...
...
server/src/main/java/org/apache/iotdb/db/monitor/StatMonitor.java
浏览文件 @
87a8dcf2
...
...
@@ -28,6 +28,7 @@ import java.util.concurrent.TimeUnit;
import
java.util.concurrent.atomic.AtomicLong
;
import
org.apache.iotdb.db.concurrent.IoTDBThreadPoolFactory
;
import
org.apache.iotdb.db.concurrent.ThreadName
;
import
org.apache.iotdb.db.concurrent.WrappedRunnable
;
import
org.apache.iotdb.db.conf.IoTDBConfig
;
import
org.apache.iotdb.db.conf.IoTDBDescriptor
;
import
org.apache.iotdb.db.engine.StorageEngine
;
...
...
@@ -333,12 +334,12 @@ public class StatMonitor implements IService {
private
static
final
StatMonitor
INSTANCE
=
new
StatMonitor
();
}
class
StatBackLoop
implements
Runnable
{
class
StatBackLoop
extends
Wrapped
Runnable
{
FileSize
fileSize
=
FileSize
.
getInstance
();
@Override
public
void
run
()
{
public
void
run
MayThrow
()
{
try
{
long
currentTimeMillis
=
System
.
currentTimeMillis
();
long
seconds
=
(
currentTimeMillis
-
runningTimeMillis
)
/
1000
;
...
...
server/src/main/java/org/apache/iotdb/db/query/dataset/NonAlignEngineDataSet.java
浏览文件 @
87a8dcf2
...
...
@@ -19,6 +19,7 @@
package
org.apache.iotdb.db.query.dataset
;
import
org.apache.iotdb.db.concurrent.WrappedRunnable
;
import
org.apache.iotdb.db.query.pool.QueryTaskPoolManager
;
import
org.apache.iotdb.db.query.reader.series.ManagedSeriesReader
;
import
org.apache.iotdb.db.tools.watermark.WatermarkEncoder
;
...
...
@@ -46,7 +47,7 @@ import java.util.concurrent.atomic.AtomicIntegerArray;
public
class
NonAlignEngineDataSet
extends
QueryDataSet
{
private
class
ReadTask
implements
Runnable
{
private
class
ReadTask
extends
Wrapped
Runnable
{
private
final
ManagedSeriesReader
reader
;
private
BlockingQueue
<
Pair
<
ByteBuffer
,
ByteBuffer
>>
blockingQueue
;
...
...
@@ -64,7 +65,7 @@ public class NonAlignEngineDataSet extends QueryDataSet {
}
@Override
public
void
run
()
{
public
void
run
MayThrow
()
{
PublicBAOS
timeBAOS
=
new
PublicBAOS
();
PublicBAOS
valueBAOS
=
new
PublicBAOS
();
try
{
...
...
server/src/main/java/org/apache/iotdb/db/query/dataset/RawQueryDataSetWithoutValueFilter.java
浏览文件 @
87a8dcf2
...
...
@@ -19,6 +19,7 @@
package
org.apache.iotdb.db.query.dataset
;
import
org.apache.iotdb.db.concurrent.WrappedRunnable
;
import
org.apache.iotdb.db.query.pool.QueryTaskPoolManager
;
import
org.apache.iotdb.db.query.reader.series.ManagedSeriesReader
;
import
org.apache.iotdb.db.tools.watermark.WatermarkEncoder
;
...
...
@@ -43,7 +44,7 @@ import java.util.concurrent.LinkedBlockingQueue;
public
class
RawQueryDataSetWithoutValueFilter
extends
QueryDataSet
{
private
static
class
ReadTask
implements
Runnable
{
private
static
class
ReadTask
extends
Wrapped
Runnable
{
private
final
ManagedSeriesReader
reader
;
private
final
String
pathName
;
...
...
@@ -57,7 +58,7 @@ public class RawQueryDataSetWithoutValueFilter extends QueryDataSet {
}
@Override
public
void
run
()
{
public
void
run
MayThrow
()
{
try
{
synchronized
(
reader
)
{
// if the task is submitted, there must be free space in the queue
...
...
server/src/main/java/org/apache/iotdb/db/service/MetricsService.java
浏览文件 @
87a8dcf2
...
...
@@ -26,6 +26,7 @@ import java.util.concurrent.ExecutorService;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.iotdb.db.concurrent.ThreadName
;
import
org.apache.iotdb.db.concurrent.WrappedRunnable
;
import
org.apache.iotdb.db.conf.IoTDBConfig
;
import
org.apache.iotdb.db.conf.IoTDBConstant
;
import
org.apache.iotdb.db.conf.IoTDBDescriptor
;
...
...
@@ -171,7 +172,7 @@ public class MetricsService implements MetricsServiceMBean, IService {
private
MetricsServiceHolder
()
{}
}
private
class
MetricsServiceThread
implements
Runnable
{
private
class
MetricsServiceThread
extends
Wrapped
Runnable
{
private
Server
server
;
...
...
@@ -180,7 +181,7 @@ public class MetricsService implements MetricsServiceMBean, IService {
}
@Override
public
void
run
()
{
public
void
run
MayThrow
()
{
try
{
Thread
.
currentThread
().
setName
(
ThreadName
.
METRICS_SERVICE
.
getName
());
server
.
start
();
...
...
server/src/main/java/org/apache/iotdb/db/tools/memestimation/MemEstToolCmd.java
浏览文件 @
87a8dcf2
...
...
@@ -20,6 +20,7 @@ package org.apache.iotdb.db.tools.memestimation;
import
io.airlift.airline.Command
;
import
io.airlift.airline.Option
;
import
org.apache.iotdb.db.concurrent.WrappedRunnable
;
import
org.apache.iotdb.db.conf.IoTDBConfig
;
import
org.apache.iotdb.db.conf.IoTDBConstant
;
import
org.apache.iotdb.db.conf.IoTDBDescriptor
;
...
...
@@ -28,7 +29,7 @@ import org.apache.iotdb.db.exception.ConfigAdjusterException;
import
org.apache.iotdb.db.metadata.MManager
;
@Command
(
name
=
"calmem"
,
description
=
"calculate minimum memory required for writing based on the number of storage groups and timeseries"
)
public
class
MemEstToolCmd
implements
Runnable
{
public
class
MemEstToolCmd
extends
Wrapped
Runnable
{
@Option
(
title
=
"storage group number"
,
name
=
{
"-sg"
,
"--storagegroup"
},
description
=
"Storage group number"
)
...
...
@@ -43,7 +44,7 @@ public class MemEstToolCmd implements Runnable {
private
String
maxTsNumString
=
"0"
;
@Override
public
void
run
()
{
public
void
run
MayThrow
()
{
// backup origin config parameters
IoTDBConfig
config
=
IoTDBDescriptor
.
getInstance
().
getConfig
();
long
memTableSize
=
config
.
getMemtableSizeThreshold
();
...
...
server/src/test/java/org/apache/iotdb/db/concurrent/IoTDBThreadPoolFactoryTest.java
浏览文件 @
87a8dcf2
...
...
@@ -202,7 +202,7 @@ public class IoTDBThreadPoolFactoryTest {
}
}
class
TestThread
implements
Runnable
{
class
TestThread
extends
Wrapped
Runnable
{
private
String
name
;
...
...
@@ -211,7 +211,7 @@ public class IoTDBThreadPoolFactoryTest {
}
@Override
public
void
run
()
{
public
void
run
MayThrow
()
{
throw
new
RuntimeException
(
name
);
}
...
...
server/src/test/java/org/apache/iotdb/db/conf/adapter/ActiveTimeSeriesCounterTest.java
浏览文件 @
87a8dcf2
...
...
@@ -23,6 +23,8 @@ import static org.junit.Assert.assertEquals;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
org.apache.iotdb.db.concurrent.WrappedRunnable
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -96,7 +98,7 @@ public class ActiveTimeSeriesCounterTest {
}
}
private
static
class
OfferThreads
implements
Runnable
{
private
static
class
OfferThreads
extends
Wrapped
Runnable
{
private
int
sensorNum
;
private
String
storageGroup
;
private
CountDownLatch
finished
;
...
...
@@ -108,15 +110,16 @@ public class ActiveTimeSeriesCounterTest {
}
@Override
public
void
run
()
{
public
void
run
MayThrow
()
{
try
{
for
(
int
j
=
0
;
j
<
sensorNum
;
j
++)
{
ActiveTimeSeriesCounter
.
getInstance
().
offer
(
storageGroup
,
"device_0"
,
"sensor_"
+
j
);
}
}
finally
{
}
finally
{
finished
.
countDown
();
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录