
2008年6月18日星期三
2008年6月16日星期一
how to package a jar including its dependencies
使用maven的时候,想生成jar,并且包含项目依赖的components,可以使用shade plugin,简单又方便。
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
2008年6月2日星期一
如何减少Berkeley DB Log File占用磁盘的空间
我的应用程序在缺省配置的情况下,5百多万条记录,Log File占用了532M的硬盘空间。仔细看了下文档,发现Berkeley DB日志文件占用的空间,有很大的弹性。Berkeley DB一直会以append的方式增加log文件,同时有clean log thread负责清理无用的log。为了更高的程序性能,Berkeley DB会根据参数的配置,允许已经失效的log存在于log file中,这样可以减少cleanLog thread和其他thread锁的竞争。而我希望提高log file的利用率,减少log占用的硬盘空间,并且能够容忍这样做带来的性能损失。因此修改了je.properties,定义je.cleaner.minUtilization为90(缺省为50),同时在关闭environment的时候,强制执行cleanLog:
boolean anyCleaned = false;
while (dbenv.cleanLog() > 0) {
anyCleaned = true;
}
if (anyCleaned) {
CheckpointConfig force = new CheckpointConfig();
force.setForce(true);
dbenv.checkpoint(force);
}
调整后,log file占用的空间下降为309M,效果非常明显。
je.properties
# maximum starting size of a JE log buffer
# 32M
je.log.bufferSize=33554432
# The number of JE log buffers
# minimum = 2
je.log.numBuffers=2
# The total memory taken by log buffers, in bytes. If 0, use
# 7% of je.maxMemory
# minimum = 6144
# 32M * 2
je.log.totalBufferBytes=67108864
# By default, JE sizes the cache as a percentage of the maximum
# memory available to the JVM. For example, if the JVM is
# started with -Xmx128M, the cache size will be
# (je.maxMemoryPercent * 128M) / 100
# Setting je.maxMemory to an non-zero value will override
# je.maxMemoryPercent
# minimum = 1
# maximum = 90
je.maxMemoryPercent=80
# If true (the default), use an LRU-only policy to select nodes for
# eviction. If false, select by Btree level first, and then by LRU.
je.evictor.lruOnly=false
# The number of nodes in one evictor scan
# minimum = 1
# maximum = 1000
je.evictor.nodesPerScan=100
# The cleaner will keep the total disk space utilization percentage
# above this value. The default is set to 50 percent.
# minimum = 0
# maximum = 90
je.cleaner.minUtilization=90
boolean anyCleaned = false;
while (dbenv.cleanLog() > 0) {
anyCleaned = true;
}
if (anyCleaned) {
CheckpointConfig force = new CheckpointConfig();
force.setForce(true);
dbenv.checkpoint(force);
}
调整后,log file占用的空间下降为309M,效果非常明显。
je.properties
# maximum starting size of a JE log buffer
# 32M
je.log.bufferSize=33554432
# The number of JE log buffers
# minimum = 2
je.log.numBuffers=2
# The total memory taken by log buffers, in bytes. If 0, use
# 7% of je.maxMemory
# minimum = 6144
# 32M * 2
je.log.totalBufferBytes=67108864
# By default, JE sizes the cache as a percentage of the maximum
# memory available to the JVM. For example, if the JVM is
# started with -Xmx128M, the cache size will be
# (je.maxMemoryPercent * 128M) / 100
# Setting je.maxMemory to an non-zero value will override
# je.maxMemoryPercent
# minimum = 1
# maximum = 90
je.maxMemoryPercent=80
# If true (the default), use an LRU-only policy to select nodes for
# eviction. If false, select by Btree level first, and then by LRU.
je.evictor.lruOnly=false
# The number of nodes in one evictor scan
# minimum = 1
# maximum = 1000
je.evictor.nodesPerScan=100
# The cleaner will keep the total disk space utilization percentage
# above this value. The default is set to 50 percent.
# minimum = 0
# maximum = 90
je.cleaner.minUtilization=90
订阅:
博文 (Atom)