On Wed, Jun 17, 2009 at 5:46 PM, Michael Ossareh<[email protected]> wrote: > On Thu, Jun 11, 2009 at 2:17 AM, GAGAN ARORA<[email protected]> wrote: >> Hi >> I have a requirement in which I to upload file contents on a server and at >> the same time uploaded data is to be downloaded by no of clients listening >> to server. What would be the best way to achieve this using Apache Mina so >> that I can have maximum performance with no latency? >> >> Thanks >> Gagan Arora >> > > Hi Gagan, > > Your question is pretty abstract, some more details would definitely > help you get better quality answers. Right now I think you want: > > a) source to start upload > b) file lands on server > c) clients read from server as file is written to disk. > > I'd suggest that you start by writing a daemon for the server, as it > receives bytes it writes them to disk, followed by writing them to the > sockets of connected clients. When a client connects it can read the > already processed bytes either by reading from disk, or if the data is > small enough from an in-memory buffer. When they're up to speed with > the live stream they can switch over to it. > > In MINA I'd start off by creating a Server which listens on two ports > - one port for uploaded content, the other for content clients. Each > upload should have a tag - as the upload client sends the file the > bytes get written to a buffer which flushes to disk (size of buffer > dependent on what you're trying to achieve). Clients that want the > content connect to their port and specify the same tag. > > You might want your content consuming clients to use UDP if you can > stand losing data (i.e. like streaming video or something). > > Best of luck, > > mike > > -- > god loves atheists, Fact: http://www.mrwiggleslovesyou.com/comics/rehab477.jpg >
ah - also check out the proxy example they have - you probably just want that and then add something (a filter I believe is the MINA term) which passes over inbound packets and writes them to a file. http://mina.apache.org/report/trunk/xref/org/apache/mina/example/proxy/ -- god loves atheists, Fact: http://www.mrwiggleslovesyou.com/comics/rehab477.jpg
