Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.klomp.snark
Class Snark

    java.lang.Object
      org.klomp.snark.Snark

All Implemented Interfaces:
  CoordinatorListener, ShutdownListener, StorageListener

    public class Snark

extends Object
implements StorageListener, CoordinatorListener, ShutdownListener

Main Snark program startup class.

Author:
  Mark Wielaard (mark@klomp.org)

Nested Class Summary
`static interface` | `Snark.CompleteListener`

Field Summary
`I2PSnarkUtil` | `_util`
`ConnectionAcceptor` | `acceptor`
`(package private) String` | `activity`
`static int` | `ALL`
`(package private) boolean` | `allChecked`
`(package private) boolean` | `allocating`
`(package private) boolean` | `checking`
`Snark.CompleteListener` | `completeListener`
`PeerCoordinator` | `coordinator`
`static int` | `DEBUG`
`static int` | `ERROR`
`(package private) byte[]` | `id`
`static int` | `INFO`
`(package private) static int` | `MAX_TOTAL_UPLOADERS`
`MetaInfo` | `meta`
`(package private) static int` | `MIN_TOTAL_UPLOADERS` Maintain a configurable total uploader cap coordinatorListener
`static int` | `NOTICE`
`(package private) boolean` | `prechecking`
`static String` | `PROP_MAX_CONNECTIONS`
`String` | `rootDataDir`
`boolean` | `stopped`
`Storage` | `storage`
`String` | `torrent`
`TrackerClient` | `trackerclient`
`static int` | `WARNING`

Constructor Summary
`Snark(I2PAppContext ctx, Properties opts, String torrent, StorageListener slistener, boolean start, String rootDir)` single torrent - via router
`Snark(I2PSnarkUtil util, String torrent, String ip, int user_port, StorageListener slistener, CoordinatorListener clistener)` from main() via parseArguments() single torrent
`Snark(I2PSnarkUtil util, String torrent, String ip, int user_port, StorageListener slistener, CoordinatorListener clistener, Snark.CompleteListener complistener, PeerCoordinatorSet peerCoordinatorSet, ConnectionAcceptor connectionAcceptor, boolean start, String rootDir)` multitorrent

Method Summary
`void` | `fatal(String s)` Aborts program abnormally.
`void` | `fatal(String s, Throwable t)` Aborts program abnormally.
`static void` | `main(String[] args)`
`boolean` | `overUpBWLimit()`
`boolean` | `overUpBWLimit(long total)`
`boolean` | `overUploadLimit(int uploaders)`
`(package private) static Snark` | `parseArguments(String[] args)`
`(package private) static Snark` | `parseArguments(String[] args, StorageListener slistener, CoordinatorListener clistener)` Sets debug, ip and torrent variables then creates a Snark instance.
`void` | `peerChange(PeerCoordinator coordinator, Peer peer)` coordinatorListener
`void` | `setWantedPieces(Storage storage)` Reset the peer's wanted pieces table Call after the storage double-check fails
`void` | `shutdown()` Called when the SnarkShutdown hook has finished shutting down all subcomponents.
`void` | `startTorrent()` Start up contacting peers and querying the tracker
`void` | `stopTorrent()` Stop contacting the tracker and talking with peers
`void` | `storageAllChecked(Storage storage)` Called when all pieces in the storage have been checked.
`void` | `storageAllocated(Storage storage, long length)` Called to indicate that length bytes have been allocated.
`void` | `storageChecked(Storage storage, int num, boolean checked)` Called when storage is being checked and the num piece of that total pieces has been checked.
`void` | `storageCompleted(Storage storage)` Called the one time when the data is completely received and checked.
`void` | `storageCreateFile(Storage storage, String name, long length)` Called when the storage creates a new file of a given length.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### ERROR

    public static final int ERROR

See Also:
  Constant Field Values

### WARNING

    public static final int WARNING

See Also:
  Constant Field Values

### NOTICE

    public static final int NOTICE

See Also:
  Constant Field Values

### INFO

    public static final int INFO

See Also:
  Constant Field Values

### DEBUG

    public static final int DEBUG

See Also:
  Constant Field Values

### ALL

    public static final int ALL

See Also:
  Constant Field Values

### activity

    String activity

### PROP_MAX_CONNECTIONS

    public static final String PROP_MAX_CONNECTIONS

See Also:
  Constant Field Values

### torrent

    public String torrent

### meta

    public MetaInfo meta

### storage

    public Storage storage

### coordinator

    public PeerCoordinator coordinator

### acceptor

    public ConnectionAcceptor acceptor

### trackerclient

    public TrackerClient trackerclient

### rootDataDir

    public String rootDataDir

### completeListener

    public Snark.CompleteListener completeListener

### stopped

    public boolean stopped

### id

    byte[] id

### _util

    public I2PSnarkUtil _util

### allocating

    boolean allocating

### allChecked

    boolean allChecked

### checking

    boolean checking

### prechecking

    boolean prechecking

### MIN_TOTAL_UPLOADERS

    static final int MIN_TOTAL_UPLOADERS

  Maintain a configurable total uploader cap coordinatorListener

  See Also:
    Constant Field Values

### MAX_TOTAL_UPLOADERS

    static final int MAX_TOTAL_UPLOADERS

See Also:
  Constant Field Values

Constructor Detail

### Snark

    Snark(I2PSnarkUtil util,
          String torrent,
          String ip,
          int user_port,
          StorageListener slistener,
          CoordinatorListener clistener)

  from main() via parseArguments() single torrent

### Snark

    public Snark(I2PAppContext ctx,
                 Properties opts,
                 String torrent,
                 StorageListener slistener,
                 boolean start,
                 String rootDir)

  single torrent - via router

### Snark

    public Snark(I2PSnarkUtil util,
                 String torrent,
                 String ip,
                 int user_port,
                 StorageListener slistener,
                 CoordinatorListener clistener,
                 Snark.CompleteListener complistener,
                 PeerCoordinatorSet peerCoordinatorSet,
                 ConnectionAcceptor connectionAcceptor,
                 boolean start,
                 String rootDir)

  multitorrent

Method Detail

### main

    public static void main(String[] args)

### startTorrent

    public void startTorrent()

  Start up contacting peers and querying the tracker

### stopTorrent

    public void stopTorrent()

  Stop contacting the tracker and talking with peers

### parseArguments

    static Snark parseArguments(String[] args)

### parseArguments

    static Snark parseArguments(String[] args,
                                StorageListener slistener,
                                CoordinatorListener clistener)

  Sets debug, ip and torrent variables then creates a Snark instance. Calls usage(), which terminates the program, if non-valid argument list. The given listeners will be passed to all components that take one.

### fatal

    public void fatal(String s)

  Aborts program abnormally.

### fatal

    public void fatal(String s,
                      Throwable t)

  Aborts program abnormally.

### peerChange

    public void peerChange(PeerCoordinator coordinator,
                           Peer peer)

  coordinatorListener

  Specified by:
    `peerChange` in interface `CoordinatorListener`

### storageCreateFile

    public void storageCreateFile(Storage storage,
                                  String name,
                                  long length)

  Description copied from interface: `StorageListener`
  Called when the storage creates a new file of a given length.

  Specified by:
    `storageCreateFile` in interface `StorageListener`

### storageAllocated

    public void storageAllocated(Storage storage,
                                 long length)

  Description copied from interface: `StorageListener`
  Called to indicate that length bytes have been allocated.

  Specified by:
    `storageAllocated` in interface `StorageListener`

### storageChecked

    public void storageChecked(Storage storage,
                               int num,
                               boolean checked)

  Description copied from interface: `StorageListener`
  Called when storage is being checked and the num piece of that total pieces has been checked. When the piece hash matches the expected piece hash checked will be true, otherwise it will be false.

  Specified by:
    `storageChecked` in interface `StorageListener`

### storageAllChecked

    public void storageAllChecked(Storage storage)

  Description copied from interface: `StorageListener`
  Called when all pieces in the storage have been checked. Does not mean that the storage is complete, just that the state of the storage is known.

  Specified by:
    `storageAllChecked` in interface `StorageListener`

### storageCompleted

    public void storageCompleted(Storage storage)

  Description copied from interface: `StorageListener`
  Called the one time when the data is completely received and checked.

  Specified by:
    `storageCompleted` in interface `StorageListener`

### setWantedPieces

    public void setWantedPieces(Storage storage)

  Description copied from interface: `StorageListener`
  Reset the peer's wanted pieces table Call after the storage double-check fails

  Specified by:
    `setWantedPieces` in interface `StorageListener`

### shutdown

    public void shutdown()

  Description copied from interface: `ShutdownListener`
  Called when the SnarkShutdown hook has finished shutting down all subcomponents.

  Specified by:
    `shutdown` in interface `ShutdownListener`

### overUploadLimit

    public boolean overUploadLimit(int uploaders)

  Specified by:
    `overUploadLimit` in interface `CoordinatorListener`

### overUpBWLimit

    public boolean overUpBWLimit()

  Specified by:
    `overUpBWLimit` in interface `CoordinatorListener`

### overUpBWLimit

    public boolean overUpBWLimit(long total)

  Specified by:
    `overUpBWLimit` in interface `CoordinatorListener`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD