存档

2009年8月 的存档

Weblogci10中关于managed、admin server之间Http连接超时的问题

2009年8月30日 admin 没有评论

客户提了这么个问题:admin server因为out of memory导致性能很差,此时managed server连接admin server的话,可能因为网络原因或者admin server因为OOM而导致的低性能,最终导致managed server很多线程挂死在socket read上。如果没有超时机制,这样的线程会一直挂着,如果这样的线程很多的话,系统线程资源逐渐会被消耗完,从而引起managed server无法提供响应。下面是这个客户的线程堆栈,

Thread-90 “[STUCK] ExecuteThread: ‘6′ for queue: ‘weblogic.kernel.Default (self-tuning)’” <alive, in native, suspended, priority=1, DAEMON> {
jrockit.net.SocketNativeIO.readBytesPinned(SocketNativeIO.java:???)
jrockit.net.SocketNativeIO.socketRead(SocketNativeIO.java:25)
java.net.SocketInputStream.socketRead0(SocketInputStream.java:???)
java.net.SocketInputStream.read(SocketInputStream.java:107)
java.io.BufferedInputStream.fill(BufferedInputStream.java:189)
java.io.BufferedInputStream.read(BufferedInputStream.java:234)
^– Holding  lock: java.io.BufferedInputStream@5cc3faf[thin lock]
weblogic.net.http.MessageHeader.isHTTP(MessageHeader.java:214)
weblogic.net.http.MessageHeader.parseHeader(MessageHeader.java:141)
weblogic.net.http.HttpClient.parseHTTP(HttpClient.java:477)
^– Holding lock: java.io.BufferedInputStream@5cc3faf[thin lock]
weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:329)
^– Holding lock: java.io.BufferedInputStream@5cc3faf[thin lock]
weblogic.rjvm.http.HTTPClientJVMConnection.connect(HTTPClientJVMConnection.java:161)
^– Holding lock: java.io.BufferedInputStream@5cc3faf[thin lock]
weblogic.rjvm.http.HTTPClientJVMConnection.createConnection(HTTPClientJVMConnection.java:86)
weblogic.rjvm.ConnectionManager.createConnection(ConnectionManager.java:1723)
weblogic.rjvm.ConnectionManager.findOrCreateConnection(ConnectionManager.java:1330)
^– Holding lock: java.io.BufferedInputStream@5cc3faf[thin lock]
^– Holding lock: weblogic.net.http.HttpClient@5cc3ea0[thin lock]
weblogic.rjvm.ConnectionManager.bootstrap(ConnectionManager.java:440)
weblogic.rjvm.ConnectionManager.bootstrap(ConnectionManager.java:315)
weblogic.rjvm.RJVMManager.findOrCreateRemoteInternal(RJVMManager.java:220)
^– Holding lock: java.io.BufferedInputStream@5cc3faf[thin lock]
weblogic.rjvm.RJVMManager.findOrCreate(RJVMManager.java:206)
weblogic.rjvm.RJVMFinder.findOrCreateRemoteServer(RJVMFinder.java:226)
weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:170)
^– Holding lock: java.io.BufferedInputStream@5cc3faf[thin lock]
weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:154)
weblogic.jndi.WLInitialContextFactoryDelegate.getInitialReference(WLInitialContextFactoryDelegate.java:384)
weblogic.jndi.Environment.getInitialReference(Environment.java:223)
weblogic.server.channels.RemoteChannelServiceImpl.registerInternal(RemoteChannelServiceImpl.java:153)
^– Holding lock: java.io.BufferedInputStream@5cc3faf[thin lock]
weblogic.server.channels.RemoteChannelServiceImpl.access$300(RemoteChannelServiceImpl.java:46)
weblogic.server.channels.RemoteChannelServiceImpl$TimerListenerImpl.timerExpired(RemoteChannelServiceImpl.java:101)
weblogic.timers.internal.TimerImpl.run(TimerImpl.java:253)
weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:464)
weblogic.work.ExecuteThread.execute(ExecuteThread.java:197)
weblogic.work.ExecuteThread.run(ExecuteThread.java:164)

现在的问题是,对于这种问题可不可以通过超时设定来释放线程。weblogic中, RJVM(即server之间,可能是admin-to-managed,也可能是managed-to-managed)之间,连接的协议有两类五种, 两类是http、t3,五种是http、https、t3、t3s、local。超时设定时协议层面的东西,所以我们这里只讨论http和t3。

对于t3,从上面的trace可以看到,连接的创建从ServerURL.findOrCreateRJVM()开始,这个方法有多种实现,不同的实现使 用不同的timeout,客户端程序可以通过向environment中set一个叫做weblogic.jndi.requestTimeout的变 量,如果不做设定,则使用系统默认的DEFAULT_CONNECTION_TIMEOUT,这是个静态值(0)。而在上面的stack trace中,我们可以看到,environment是在RemoteChannelServiceImpl中定义的,这个environment对于客 户而言是不可配置的,而weblogic自己的这个env中是不设定request timeotu的,也就是,无论哪种方式,connectionTimeout/readTimeout对于t3,都是不可配置的,而且默认是没有超时 的。

而对于http,HTTPClientJVMConnection在创建HttpURLConnection的时候,会读取系统环境变量中的如下两个变量,
weblogic.http.client.defaultReadTimeout
weblogic.http.client.defaultConnectTimeout
如果没有设定,这两个变量的默认值均为-1,即不做timeout。如果我们作了设定,这两个值即读超时、连接超时都会生效。这两个值可以用于解决上述的问题。

Popularity: unranked [?]

weblogic92连接池的连接数异常问题

2009年8月30日 admin 没有评论

有客户说,他们通过connection pool监控发现weblogic92连接池中当前连接数(current capacity)小于初始连接数(initial capacity)。从现象上来说,给客户的直觉是:连接池初始化有问题,没有帮助他们初始化他们需要的那么多连接。但他同时发现,几个 connection pool中,其他pool没有问题。拿到问题,我也怀疑这可能是weblogic的一个bug,但随后从客户发送过来的日志中发现出问题的 connection被disable过。调查后发现问题的确和这个pool被disable过有关,那么为什么pool被disable后,会出现这样 的问题呢?

首先我们看看这个pool为什么会被disable? 手工强制suspend连接池、数据库关闭、网络不稳定等因素都可能成为connection pool被disable的诱因。从客户的日志中,我能看到大量的如下异常,
1:java.net.SocketException: 管道已断开 (errno:32)
2:weblogic.common.resourcepool.ResourceDisabledException: Pool JDBC Data Source-0 is disabled, cannot allocate resources to applications.

根据上面的异常,首先跟客户确认是否存在过数据库关闭、强制disable connection的操作,这些都被客户否定了,那么最大可能的原因就是网络不稳定,网络是好时坏的话,很容易造成weblogic连接池中到 database server的连接中断,从而导致connection pool被disable。

那么为什么连接中断会引起connection pool被disable呢?这里要谈到两个参数:CountOfTestFailuresTillFlush、 CountOfRefreshFailuresTillDisable。这两个参数在weblogic连接池实现中由于控制是否、何时flush或 disable连接池,两个都是指连续几次失败操作(test、refresh)后去flush或disable connection pool。注意:这是说的是连续,而不是间断,每次成功操作(test、refresh)后,这两个值都会被reset成0。默认情况下这两个值均为2, 即连续失败3(2+1)次后,connection pool会被flush或disable。两者的区别在于,flush用于清空connection pool中的所有连接(通常都是中断的connection),当pool状态仍保持在running状态,而对于后者,connection pool将会变成suspend。前者对于客户端而言,还可以从pool中reserve connection,reserve时,weblogic会尝试重现创建连接,如果创建连接成功,那么客户端就可以拿到可用的连接。而对于一个处于 suspend状态,客户端reserve connection的请求会直接被拒绝,收到的异常如下:
weblogic.common.resourcepool.ResourceDisabledException: Pool JDBC Data Source-0 is disabled, cannot allocate resources to applications

一个被disable的connection pool我们需要手工resume吗?比如数据库因为某些原因而突发关闭,数据库恢复后,我们是否需要手工去resume这个pool?不需 要,weblogic内部实现了连接池的自我健康检查功能,对于disable的connection pool,weblogic会每隔5秒钟(DEFAULT_SCAN_UNIT)去做一次连接尝试(尝试创建一个物理连接,如果连接成功,那么这个连接会 被直接放入连接池中,我们的问题就处在这儿),我们通过下面的复现过程来看看具体原因:

1:配置一个datasource,connection的连接数具体配置如下:


2:weblogic启动后,我们可以看到current capacity为15,此时connection pool刚被初始化,weblogic会根据initial capacity去创建相应数量的连接。此时如果我们关闭数据库,然后通过测试程序去获取连接,你会看到我们无法拿到连接(注意我们要选上 TestOnReserve),重复三次,再次去监控connection pool。因为三次test失败后,connection pool会被disable(状态为suspend),如下:


3:重启database。由于weblogic内部实现了connection pool的自检功能,对于disabled的connection pool,weblogic每隔5秒钟去做一次连接尝试,如果连接创建成功,新建连接会被放入连接池,同时resume连接池。通过监控我们可以看到,连 接池状态变成running,同时current capacity变成1,

4:启动多线程测试程序,模拟2个用户并发。第一个用户可以从connection pool中成功拿到连接,而第二个用户因为连接池的current capacity为1,无法直接从pool中拿到连接,这是连接池需要做扩展,而扩展的个数就是我们设定的capacity increment(20)。再来监控connection pool,我们就会看到连接池的current capacity为21,如下:

那么我们能不能通过参数配置不让connection pool不作disable呢? 我们前面所提到的两个参数:CountOfTestFailuresTillFlush、 CountOfRefreshFailuresTillDisable,可以实现这样的要求:

1 <internal-properties>
2 <property>
3 <name>CountOfTestFailuresTillFlush</name>
4 <value>10</value>
5 </property>
6 <property>
7 <name>CountOfRefreshFailuresTillDisable</name>
8 <value>20</value>
9 </property>
10 </internal-properties>

internal-properties用于定义一些weblogic internal的参数,这些参数无法在console上做配置。除了上面的这两个参数,我们还可以通过internal-properties配置如下几个参数:
TestConnectionsOnCreate
TestConnectionsOnRelease
HighestNumUnavailable
SecurityCacheTimeoutSeconds

通过上述分析,我们可以看到这个问题不是weblogic的bug,而是因为网络问题导致connection pool被disable,要彻底解决这个问题,可以通过网络分析工具查出网络问题,进而解决我们看到的这种现象。

Popularity: unranked [?]

VMware以4.2亿美元收购SpringSource

2009年8月11日 admin 没有评论

8月11日消息,据国外媒体报道,商业软件公司VMware将以3.62亿美元现金和股票方式收购私企SpringSource,同时承担其5800万美元未发放股票和期权。这是迄今为止该公司最大一笔收购,预计收购将在第三季度完成。

该交易能进一步推进VMware深入新兴的“云”计算业务,包括在大型数据中心上开发和运行企业程序,并支持互联网应用。

SpringSource公司软件主要用于在线应用程序的开发和管理,竞争对手包括红帽等。VMware早期在虚拟化领域拥有优势,这也使其在大型数据中心底层的基础软件架构方面处于优势地位,而SpringSource的产品能很好的补充VMware。

VMware表示将支付3.62亿美元现金和股票,同时承担5800万美元未发放股票和期权。该公司预计收购协议将在第三季度完成。

2004年1月,EMC以6.25亿美元收购VMware。2007年年初EMC宣布将出让10%的VMware股票。2007年8月,VMware启动IPO。

Popularity: unranked [?]

ffmpeg的Java封装

2009年8月11日 admin 没有评论
JAVE (Java Audio Video Encoder) 类库是一个 ffmpeg 项目的 Java 语言封装。开发人员可以使用JAVE 在不同的格式间转换视频和音频。例如将 AVI 转成 MPEG 动画,等等 ffmpeg 中可以完成的在 JAVE 都有对应的方法。

Examples

From a generic AVI to a youtube-like FLV movie, with an embedded MP3 audio stream:

File source = new File("source.avi");
File target = new File("target.flv");
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame");
audio.setBitRate(new Integer(64000));
audio.setChannels(new Integer(1));
audio.setSamplingRate(new Integer(22050));
VideoAttributes video = new VideoAttributes();
video.setCodec("flv");
video.setBitRate(new Integer(160000));
video.setFrameRate(new Integer(15));
video.setSize(new VideoSize(400, 300));
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("flv");
attrs.setAudioAttributes(audio);
attrs.setVideoAttributes(video);
Encoder encoder = new Encoder();
encoder.encode(source, target, attrs);

Next lines extracts audio informations from an AVI and store them in a plain WAV file:

File source = new File("source.avi");
File target = new File("target.wav");
AudioAttributes audio = new AudioAttributes();
audio.setCodec("pcm_s16le");
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("wav");
attrs.setAudioAttributes(audio);
Encoder encoder = new Encoder();
encoder.encode(source, target, attrs);

Next example takes an audio WAV file and generates a 128 kbit/s, stereo, 44100 Hz MP3 file:

File source = new File("source.wav");
File target = new File("target.mp3");
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame");
audio.setBitRate(new Integer(128000));
audio.setChannels(new Integer(2));
audio.setSamplingRate(new Integer(44100));
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("mp3");
attrs.setAudioAttributes(audio);
Encoder encoder = new Encoder();
encoder.encode(source, target, attrs);

Next one decodes a generic AVI file and creates another one with the same video stream of the source and a re-encoded low quality MP3 audio stream:

File source = new File("source.avi");
File target = new File("target.avi");
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame");
audio.setBitRate(new Integer(56000));
audio.setChannels(new Integer(1));
audio.setSamplingRate(new Integer(22050));
VideoAttributes video = new VideoAttributes();
video.setCodec(VideoAttributes.DIRECT_STREAM_COPY);
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("avi");
attrs.setAudioAttributes(audio);
attrs.setVideoAttributes(video);
Encoder encoder = new Encoder();
encoder.encode(source, target, attrs);

Next one generates an AVI with MPEG 4/DivX video and OGG Vorbis audio:

File source = new File("source.avi");
File target = new File("target.avi");
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libvorbis");
VideoAttributes video = new VideoAttributes();
video.setCodec("mpeg4");
video.setTag("DIVX");
video.setBitRate(new Integer(160000));
video.setFrameRate(new Integer(30));
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("mpegvideo");
attrs.setAudioAttributes(audio);
attrs.setVideoAttributes(video);
Encoder encoder = new Encoder();
encoder.encode(source, target, attrs);

A smartphone suitable video:

File source = new File("source.avi");
File target = new File("target.3gp");
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libfaac");
audio.setBitRate(new Integer(128000));
audio.setSamplingRate(new Integer(44100));
audio.setChannels(new Integer(2));
VideoAttributes video = new VideoAttributes();
video.setCodec("mpeg4");
video.setBitRate(new Integer(160000));
video.setFrameRate(new Integer(15));
video.setSize(new VideoSize(176, 144));
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("3gp");
attrs.setAudioAttributes(audio);
attrs.setVideoAttributes(video);
Encoder encoder = new Encoder();
encoder.encode(source, target, attrs);

Popularity: unranked [?]

分类: JAVA, Red5 标签:

Red5 0.9下载

2009年8月11日 admin 1 条评论

Red5 0.9.0 RC1 提供下載,地址如下:

New Features:
- Added AVC/h.264 live streaming based on Tiago Jacobs patches
- Added enums for Audio and Video codec types
- Added capability to add IoFilters to RTMPConnection per application
- Added AAC live streaming code based on Wittawas Nakkasem’s IceSurf code

Bugfixes:
- Fixed bug with recording, where meta files were not removed when using the same name
- Changed VideoCodecFactory into a “true” factory class
- Applied patch for h.264 live stream packet handling from Dave Feltenberger
- Applied FP 10.0.32.18 patch from Ari-Pekka Viitanen

Popularity: unranked [?]

AIR 1.5.2发布及新特性和Api Examples

2009年8月4日 admin 没有评论

Despite the ‘.2′ naming this is a pretty cool release for Adobe AIR developers and there are a few important new APIs that I think you’ll find very useful as well as a big change that should make every developer’s life a lot easier.

Getting Set Up
The first thing you need to do is download the new SDK and replace the old AIR 1.5 or 1.5.1 SDK. It’s pretty easy and it just consists of dropping the new AIR SDK folder into your Flex SDK (back it up first). The ditto command on the Mac works beautifully. You also need to make sure to change the namespace in your appname-app.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://ns.adobe.com/air/application/1.5.2">

Catching the “ESC” Key in Full Screen Mode
Now you’re ready to go. One oft-requested feature for AIR (and Flash Player) is the ability to capture the “escape” key and not have it exit full screen mode. With AIR 1.5.2 this is easy. You set an event handler for the keyDown event and then inside of the event handler you call event.preventDefault(). Here’s a quick example:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication
	xmlns:fx="http://ns.adobe.com/mxml/2009"
	xmlns:s="library://ns.adobe.com/flex/spark"
	xmlns:mx="library://ns.adobe.com/flex/halo"
	keyDown="windowedapplication1_keyDownHandler(event)">

	<fx:Script>
		<![CDATA[

			protected function btn_fullScreen_clickHandler(event:MouseEvent):void
			{
				stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
				btn_fullScreen.label = "Try pushing escape!"

			}

			protected function windowedapplication1_keyDownHandler(event:KeyboardEvent):void
			{
				event.preventDefault();
				if( event.keyCode == Keyboard.ESCAPE )
				{
					btn_fullScreen.label = "Nope, escape won't work. Try pushing the Enter Key";
				}
				if( event.keyCode == Keyboard.ENTER )
				{
					stage.displayState = StageDisplayState.NORMAL;
					btn_fullScreen.label = "Go Full Screen!";
				}
			}

		]]>
	</fx:Script>

	<s:Button id="btn_fullScreen" label="Go Full Screen!" click="btn_fullScreen_clickHandler(event)" />
</s:WindowedApplication>

Once you call the event.preventDefault() method you can use the Escape keyCode like any other key.

Garbage Collection of XML Data
Another one that will be huge for performance optimization is the ability to mark an XML object for immediate garbage collection. To do this you can use the new System.disposeXML(xml:XML) method. Oliver Goldman gave me a great explanation of what’s happening.

Even then, the disposeXML() call doesn’t immediately dispose of the XML. The XML object is backed by a graph of objects with parent/child pointers between them. Those pointers make it difficult for the GC to collect all of those objects. The disposeXML() call traverses the graph, setting all of those pointers to null, and making it much easier for collection to occur. The objects still aren’t collected right away, however—that’s still pending on the GC activity.

To use the new API you just have to call the method and then null out your XML variable. That will make it easier for the garbage collector to clean up. In the example below I load in a big XML file, do some parsing to it so that it loads into memory, then call the System.disposeXML() method.

public var xml:XML;

protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
{
	var file:File = File.applicationDirectory.resolvePath("assets/Untitled.gpx");
	var stream:FileStream = new FileStream();
		stream.open(file,FileMode.READ);
	var str:String = stream.readUTFBytes(file.size);
		stream.close();
	xml = new XML(str);
}

protected function btn_loadXML_clickHandler(event:MouseEvent):void
{
	xml.normalize();
	var xmlList:XMLList = xml.children();
	var text:XMLList = xml.text();
	var xmlStr:String = xml.toString();
}

protected function btn_disposeXML_clickHandler(event:MouseEvent):void
{
	System.disposeXML( xml );
	xml = null;
}
Memory Profiler using the disposeXML() methodMemory Profiler using the disposeXML() method

You can see how this behaves in the profiler screenshot above. If you want to immediately garbage collect you can call System.gc() but if you use this often it can have negative performance implications (thanks to Ethan for the tip).

The last one I wanted to touch on was a new, friendlier install screen as blogged about by Joseph Labrecque and Oliver Goldman. We got rid of the “System Access: Unrestricted” for signed applications so that if you sign your app your end users will have a nicer install experience.

Adobe AIR 1.5.2 Signed App Install ScreenAdobe AIR 1.5.2 Signed App Install Screen

Those are three of the biggies. You can download the sample project here if you want to run the full screen example and the System.disposeXML() example.

Popularity: unranked [?]

Spring ActionScript 0.8 发布

2009年8月4日 admin 没有评论

IOC功能非常强大,不多说了,看看原文吧:

Dear Community,

I’m pleased to announce that the Spring ActionScript 0.8 release is now available.

DownloadAPI DocumentationHTML DocsPDF DocsChangelog

This release includes the Spring ActionScript framework, the Cairngorm extensions and the PureMVC extensions.

All libraries are available for download at the following Maven repository: http://projects.yoolab.org/maven/content/repositories/

From now on, we will regularly publish new snapshots of the libraries there.

Direct links to the libraries:
- Spring ActionScript 0.8
- Spring ActionScript Cairngorm 0.8
- Spring ActionScript PureMVC 0.8

Dependencies:
- AS3Commons Lang
- AS3Commons Logging
- AS3Commons Reflect

Note: AS3Commons Lang is a snapshot of 1.0. We will work with a release for the following releases of Spring ActionScript

Besides a series of bugfixes, optimizations and improvements, some of the major changes and enhancements include:

Autowiring support

Using autowiring allows you to inject objects managed by the container into view components and other objects. To autowire a property, annotate it with the [Autowired] metadata tag. The support we build in is pretty enhanced and allows you to customize the autowire behavior in many different ways. Within the Autowired metadata tag you can specify the object name and you can also configure the container to filter autowire candidates using your own filter specifications. Please see the documentation on autowiring for more info.

Custom Namespaces

The XML configuration now supports namespaces and allows you to create custom namespaces yourself. A few namespaces have been added to simplify the configuration of common objects for RMI and Messaging. More info on available namespaces and schemas and creating custom ones can be found in the documentation. The XSD schemas are available http://www.springactionscript.org/schema/

MXML Configuration

We now also support configuration through MXML. The markup is very similar to the regular XML config, but with some slight differences. Please see the documentation on MXML Configuration

AS3Commons

As a side project, we have started the AS3Commons project that offers reusable ActionScript 3.0 libraries. Most of the libraries currently available in AS3Commons are build using code from the Spring ActionScript framework. This means that a lot of code has been removed from Spring ActionScript and is now available for use in projects not using Spring ActionScript. Please note that you might have to update quite some import statements to refer to AS3Commons instead of Spring ActionScript. We apologize for any inconvenience this might cause, but this is only a one-time process.

We hope you find the AS3Commons libraries useful. All libraries (releases and snapshots) can also be found at the Maven repository.

Documentation

The documentation has been tremendously improved in this version. Next to the API documentation, we now provide a reference guide in HTML and PDF format. General info can be found at the project website: www.springactionscript.org

Last Words

If you feel like helping us out, we could certainly use your help. This project is entirely created on a volunteer basis and in our spare (and limited) free time so needless to say that the more people, the faster we can deliver new releases and guarantee the quality of the framework. So if you think you have someting to offer, be it as a developer, tester, documentation writer, sample creator, … please contact me (christophe [DOT] herreman [AT] gmail [DOT] com) or leave something in the comments. All help is more than welcome.

Enjoy this release and have fun coding!

Popularity: unranked [?]