这里将简单介绍一个样例应用来帮助我们了解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 Enco