com.aragost.javahg.internals
Class ServerPool

java.lang.Object
  extended by com.aragost.javahg.internals.ServerPool

public class ServerPool
extends Object

A pool of Server instances. Use take(AbstractCommand) and put(Server). Contains up to maxServers servers. When the maximum number of servers are running commands are queued and queued commands may be cancelled.


Constructor Summary
ServerPool(RepositoryConfiguration conf, File directory, boolean performInit, String cloneUrl)
           
 
Method Summary
 void decrementRefCount()
          Decrement the refCount.
 HgVersion getHgVersion(Repository repo)
           
 int getNumIdleServers()
           
 List<Server> getServers()
           
 void incrementRefCount()
          Increment the refCount for this server pool.
 CharsetDecoder newDecoder()
           
 void put(Server server)
          Return the server to the pool of available servers.
 Server take(AbstractCommand command)
          Get a server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerPool

public ServerPool(RepositoryConfiguration conf,
                  File directory,
                  boolean performInit,
                  String cloneUrl)
Method Detail

incrementRefCount

public void incrementRefCount()
Increment the refCount for this server pool.


decrementRefCount

public void decrementRefCount()
Decrement the refCount. If it reaches 0 then the server pool is stopped.


newDecoder

public CharsetDecoder newDecoder()

take

public Server take(AbstractCommand command)
            throws InterruptedException
Get a server. If there are fewer than maxServers a new server is started. If no servers are available the thread blocks until there is a server available. Caller must call put(Server) after command is completed.

Returns:
The next available server
Throws:
InterruptedException - If interrupted while waiting for a server to become free or the command was cancelled.
See Also:
put(Server)

put

public void put(Server server)
Return the server to the pool of available servers.

Parameters:
server - The server to return
See Also:
take(AbstractCommand), abort(Server)

getHgVersion

public HgVersion getHgVersion(Repository repo)

getServers

public List<Server> getServers()

getNumIdleServers

public int getNumIdleServers()


Copyright © 2011-2013 aragost Trifork ag. All Rights Reserved.