org.apache.manifoldcf.crawler.connectors.rss
Class ThrottledFetcher.ThrottledInputstream

java.lang.Object
  extended by java.io.InputStream
      extended by org.apache.manifoldcf.crawler.connectors.rss.ThrottledFetcher.ThrottledInputstream
All Implemented Interfaces:
java.io.Closeable
Enclosing class:
ThrottledFetcher

protected static class ThrottledFetcher.ThrottledInputstream
extends java.io.InputStream

This class throttles an input stream based on the specified byte rate parameters. The throttling takes place across all streams that are open to the server in question.


Field Summary
protected  ThrottledFetcher.DataSession dataSession
           
protected  java.io.InputStream inputStream
          The stream we are wrapping.
protected  double minimumMillisecondsPerBytePerServer
          Stream throttling parameters
protected  ThrottledFetcher.Server server
          The server object we use to track throttling
protected  ThrottledFetcher.ThrottledConnection throttledConnection
          The throttled connection we belong to
 
Constructor Summary
ThrottledFetcher.ThrottledInputstream(ThrottledFetcher.ThrottledConnection connection, ThrottledFetcher.Server server, java.io.InputStream is, double minimumMillisecondsPerBytePerServer, ThrottledFetcher.DataSession dataSession)
          Constructor.
 
Method Summary
 int available()
          Get available.
protected  int basicRead(byte[] b, int off, int len, int totalSoFar)
          Basic read, which uses the server object to throttle activity.
 void close()
          Close.
 void mark(int readLimit)
          Mark.
 boolean markSupported()
          Check if mark is supported.
 int read()
          Read a byte.
 int read(byte[] b)
          Read lots of bytes.
 int read(byte[] b, int off, int len)
          Read lots of specific bytes.
 void reset()
          Reset.
 long skip(long n)
          Skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

minimumMillisecondsPerBytePerServer

protected double minimumMillisecondsPerBytePerServer
Stream throttling parameters


throttledConnection

protected ThrottledFetcher.ThrottledConnection throttledConnection
The throttled connection we belong to


server

protected ThrottledFetcher.Server server
The server object we use to track throttling


inputStream

protected java.io.InputStream inputStream
The stream we are wrapping.


dataSession

protected ThrottledFetcher.DataSession dataSession
Constructor Detail

ThrottledFetcher.ThrottledInputstream

public ThrottledFetcher.ThrottledInputstream(ThrottledFetcher.ThrottledConnection connection,
                                             ThrottledFetcher.Server server,
                                             java.io.InputStream is,
                                             double minimumMillisecondsPerBytePerServer,
                                             ThrottledFetcher.DataSession dataSession)
Constructor.

Method Detail

read

public int read()
         throws java.io.IOException
Read a byte.

Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Read lots of bytes.

Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Read lots of specific bytes.

Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

basicRead

protected int basicRead(byte[] b,
                        int off,
                        int len,
                        int totalSoFar)
                 throws java.io.IOException
Basic read, which uses the server object to throttle activity.

Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Skip

Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Get available.

Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException

mark

public void mark(int readLimit)
Mark.

Overrides:
mark in class java.io.InputStream

reset

public void reset()
           throws java.io.IOException
Reset.

Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException

markSupported

public boolean markSupported()
Check if mark is supported.

Overrides:
markSupported in class java.io.InputStream

close

public void close()
           throws java.io.IOException
Close.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException