Skip to content

Commit

Permalink
fix: set default database connection pool size (#593)
Browse files Browse the repository at this point in the history
Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>
  • Loading branch information
lizhanhui authored Nov 7, 2023
1 parent 52a7a0a commit 121e70c
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 2 deletions.
73 changes: 73 additions & 0 deletions broker/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->

<Configuration shutdownHook="disable">
<Properties>
<Property name="LOG_DIR">${sys:user.home}${sys:file.separator}logs${sys:file.separator}rocketmqlogs</Property>
</Properties>

<Appenders>
<RollingFile name="rollingFile" fileName="${LOG_DIR}/automq.log" filePattern="${LOG_DIR}/automq.%i.log">
<PatternLayout pattern = "%d{yyyy-MM-dd HH:mm:ss} %-5p %m%n"/>
<SizeBasedTriggeringPolicy size="100MB" />
<DefaultRolloverStrategy max="10"/>
</RollingFile>

<RollingFile name="controllerAppender" fileName="${LOG_DIR}/controller.log" filePattern="${LOG_DIR}/controller.%i.log">
<PatternLayout pattern = "%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %m%n"/>
<SizeBasedTriggeringPolicy size="100MB" />
<DefaultRolloverStrategy max="10"/>
</RollingFile>

<RollingFile name="mybatisAppender" fileName="${LOG_DIR}/mybatis.log" filePattern="${LOG_DIR}/mybatis.%i.log">
<PatternLayout pattern = "%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %m%n"/>
<SizeBasedTriggeringPolicy size="100MB" />
<DefaultRolloverStrategy max="2"/>
</RollingFile>

<RollingFile name="streamAppender" fileName="${LOG_DIR}/stream.log" filePattern="${LOG_DIR}/stream.%i.log">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %m%n"/>
<SizeBasedTriggeringPolicy size="100MB"/>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
</Appenders>

<Loggers>
<Logger name="com.automq.rocketmq.controller" level="info" additivity="false">
<AppenderRef ref="controllerAppender" />
</Logger>
<Logger name="com.automq.rocketmq.metadata" level="info" additivity="false">
<AppenderRef ref="controllerAppender" />
</Logger>
<Logger name="com.automq.stream" level="info" additivity="false">
<AppenderRef ref="streamAppender"/>
</Logger>
<Logger name="com.automq.rocketmq.metadata.mapper" level="trace" additivity="false">
<AppenderRef ref="mybatisAppender" />
</Logger>

<Logger name="com.zaxxer.hikari" level="debug" additivity="false">
<AppenderRef ref="mybatisAppender" />
</Logger>

<Root level="info">
<AppenderRef ref="rollingFile"/>
</Root>
</Loggers>

</Configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void setProperties(Properties properties) {
synchronized (HikariCPDataSourceFactory.class) {
if (null == dataSource) {
HikariConfig config = new HikariConfig(properties);
config.setMaximumPoolSize(10);
config.setMaximumPoolSize(20);
config.setAutoCommit(false);
dataSource = new HikariDataSource(config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@
import com.automq.rocketmq.store.api.LogicQueueManager;
import com.automq.rocketmq.store.api.S3ObjectOperator;
import com.automq.rocketmq.store.api.StreamStore;
import com.google.common.base.Stopwatch;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DataStoreFacade implements DataStore {

private static final Logger LOGGER = LoggerFactory.getLogger(DataStoreFacade.class);

private final StreamStore streamStore;
private final S3ObjectOperator s3ObjectOperator;
private final LogicQueueManager logicQueueManager;
Expand All @@ -49,6 +55,11 @@ public CompletableFuture<Void> trimStream(long streamId, long offset) {

@Override
public CompletableFuture<List<Long>> batchDeleteS3Objects(List<Long> objectIds) {
return s3ObjectOperator.delete(objectIds);
Stopwatch stopwatch = Stopwatch.createStarted();
CompletableFuture<List<Long>> future = s3ObjectOperator.delete(objectIds);
return future.thenApply(list -> {
LOGGER.info("batchDeleteS3Objects costs {}ms", stopwatch.elapsed(TimeUnit.MILLISECONDS));
return list;
});
}
}

0 comments on commit 121e70c

Please sign in to comment.