这里将简单介绍一个样例应用来帮助我们了解IceGrid的功能。我们的应用是从CD光盘上面rips音轨,然后把它们压缩成为MP3文件,就像图35.3里面演示的那样。
The Ripper Application
rip整张CD通常需要几分钟的时间,因为MP3压缩需要消耗大量的CPU资源。我们的分布式ripper应用要通过利用远程Ice服务器上的CPU资源来加快这个过程,让我们同时压缩多个歌曲成为可能。
MP3编码器的Slice的接口看上去很简单:
module Ripper {
exception EncodingFailedException {
string reason;
};
sequence<short> Samples;
interface Mp3Encoder {
// Input: PCM samples for left and right channels
// Output: MP3 frame(s).
Ice::ByteSeq encode(Samples leftSamples, Samples rightSamples)
throws EncodingFailedException;
// You must flush to get the last frame(s). Flush also
// destroys the encoder object.
Ice::ByteSeq flush()
throws EncodingFailedException;
};
interface Mp3EncoderFactory {
Mp3Encoder* createEncoder();
};
};
MP3编码的算法实现与我们这次的讨论无关,我们需要关注的是IceGrid的特性——即应用的不断增长和改进。
1架构
我们的应用架构是非常简单的,我们人工启动注册表和节点构成的IceGrid。下图显示了客户端通过EncoderFactory代理发出的一个请