ITeye博客

lixjluck

lixjluck · 共 40 篇文章

JDBC的PrepareStatement在mysql下的实现

前言 前些天做项目的性能对比测试,发现新的性能比之前的性能下降了很多,百思不得其解;多方磨难,最后定位到我们使用了DBCP的connection pool,没有打开prepareStatement Cache,打开后,性能就上来了; 老的项目是使用c3p0,里面是使用到了prepareStatement Cache。 正文 今天有空,研究下mysql jdbc driver的实现,发现它内部也做了prepareStatement cache,而且还分server 和 client之分 Server 这里指的是Mysql db server做sql的解析,并返回给jdbc client;Cac…

2011-12-15 11:31 · jdbc · mysql · PrepareStatement · 评论(1)

天气API

http://m.weather.com.cn/data/101210101.html 中国天气提供的内部API,后面的ID还未知具体规则 返回的数据格式为json;

2011-10-18 14:13 · 评论(4)

一种无名的设计模式

问题 常见一个门面实现类,融合了N多的if/else,遂抽取了这种设计模式 类图 伪代码 //Facade public void process(String key, Object...){ DataHandler handler = dataHandlerFactory.factory(key); if (handler != null) { try { handler.handle(memberId, obj); } catch (Exception e) { log.error("Handle auth data sync", e); } } //DefaultHandlerFac…

2011-10-10 15:39 · 设计模式 · 评论(0)

DirectMemory实现方式

我们都知道Terracotta收购了EhCache,同时推出了基于off-heap技术的bigMemory,从而摆脱JVM GC带来的性能问题; 就Java 本地Cache(非分布式)而言,存在3个地方可以存放数据:Heap, OffHeap和Disk BigMemory非开源产品,所以其源码不能通过正常渠道拿到。 同时,有一个开源产品DirectMemory实现了类似BigMemory的Cache实现, https://github.com/raffaeleguidi/DirectMemory 它的类图: 使用: Cache.init(10, 100); Cache.put("test1"…

2011-09-09 17:30 · nio;off-heap;ByteBuffer · 评论(0)

Buffer的几个属性和方法速记

java.nio.Buffer 属性 mark position limit 一般情况下limit==catacity capacity 此属性一经设置,就不会改变 remaing limit-position address 查询类方法 remaining limit - position; hasRemaining limit < position; 改变类方法 mark mark=position; reset position=mark; clear position=0; limit=capacity; mark=-1; flip limit=position; position=…

2011-09-01 16:49 · Buffer · 评论(0)

mvn创建工程模板

创建模板工程 手工创建 已有工程创建 mvn archetype:create-from-project 然后到当前目前下的target/generated-sources/archetype寻找创建好的身影 如果无需修改任何东西,则 mvn install 最后在你要新建工程的目录下 mvn archetype:generate -DarchetypeCatalog=local 在提示下完成工程创建 或者已经存在模板,通过 mvn archetype:generate -B -DarchetypeGroupId=org.apache.maven.archetypes -Darchetype…

2011-08-26 18:01 · maven · 评论(0)

TCP的几个常用参数

<!--[if !supportMisalignedColumns]--><!--[endif]--> SO_LINGER Specify a linger-on-close timeout. This option disables/enables immediate return from a close()of a TCP Socket. Enabling this option with a non-zero Integer timeout means that a close() will block pending the transmission and acknowledge…

2011-08-26 17:48 · 日记 · tcp · 评论(0)

20110810

文武之道,一张一弛 java se6 性能改进 偏向锁 锁粗化 自适应旋转 Detecting Contention • IDEs, Profilers or 3rd party tools • Mpstat on Solaris – vctx rate • If suspected, sample process with pstack > Look near top of stack for threads blocked in monitorenter operations • JVMStat (jstat) counters > jstat -J-Djstat.showUnsuppo…

2011-08-10 22:14 · 日记 · 评论(0)

20110809

The maximum heap size of a Java application is limited by three factors 1、the process data model (32-bit or 64-bit) and the associated operating system limitations(what?) 2、the amount of virtual memory available on the system 3、the amount of physical memory available on the system Committing too mu…

2011-08-09 19:15 · 日记 · 评论(0)

20110806

IO 写道 Disk latency is around 13ms, but it depends on the quality and rotational speed of the hard drive. RAM latency is around 83 nanoseconds. 性能指标 IOPS (input/output operations per-second) iowait 写道 If your I/O wait percentage is greater than (1/# of CPU cores) then your CPUs are waiting a signifi…

2011-08-06 21:46 · 日记 · 评论(0)

20110802

Java & JVM 相关 买了一本书 , 深入理解java虚拟机 JMM jsr-133-faq jdk7 source code: http://download.java.net/openjdk/jdk7/ 分布式锁相关 拜占庭失效问题 Paxos算法, 分布式系统中消息传输一致性 算法 两个具体实现 google chubby http://news.cnblogs.com/n/86066/ zookeeper 其他 bigpipe研究

2011-08-02 17:38 · 日记 · 评论(0)

20110801

java se 7 AIO的实现 windows基于IOCP(input/output Completion Port,I/O完成端口) 它是应用程序使用线程池处理异步I/O请求的一种机制. linux基于epoll (EpollPort) 编程模型 AIO模型相对于之前的编程模型,更加简便,且把线程池隐藏在内部实现中。 服务器端 channelGroup = AsynchronousChannelGroup.withFixedThreadPool(Runtime.getRuntime().availableProcessors(), Executors.defaultThreadFacto…

2011-08-01 21:24 · 日记 · 评论(0)

20110731

java7 AIO 问题,是基于java concurrent Future+nio完成? 如AsynchronousSocketChannel,AsynchronousServerSocketChannel, AsynchronousFileChannel java7 自动资源关闭,实现AutoCloseable Grizlly http://grizzly.java.net/ use byte buffer pool

2011-07-31 21:26 · 日记 · 评论(0)

JAVA SE7 新特性

IO http://openjdk.java.net/projects/nio/ add java.nio.file package Defines interfaces and classes for the Java virtual machine to access files, file attributes, and file systems. The java.nio.file.spi.FileSystemProvider class allows you to develop a custom file system provider. A custom file system…

2011-07-30 20:16 · java · 评论(0)

20110729

java7 的特性 http://www.oracle.com/technetwork/java/javase/jdk7-relnotes-418459.html java7已经GA了 WTP3.3的dynamic web project的属性,和之前的版本不一样,而且还需要手工设置一下,默认的不生效。

2011-07-29 13:26 · 日记 · 评论(0)