public class Router extends Object implements RouterClock.ClockShiftListener
Modifier and Type | Field and Description |
---|---|
static char |
CAPABILITY_BW12 |
static char |
CAPABILITY_BW128 |
static char |
CAPABILITY_BW256 |
static char |
CAPABILITY_BW32 |
static char |
CAPABILITY_BW64 |
static char |
CAPABILITY_NEW_TUNNEL
Deprecated.
unused
|
static char |
CAPABILITY_REACHABLE |
static char |
CAPABILITY_UNREACHABLE |
static long |
CLOCK_FUDGE_FACTOR
let clocks be off by 1 minute
|
static int |
COALESCE_TIME
coalesce stats this often - should be a little less than one minute, so the graphs get updated
|
static int |
DEFAULT_SHARE_PERCENTAGE |
static String |
DNS_CACHE_TIME |
static int |
EXIT_GRACEFUL |
static int |
EXIT_GRACEFUL_RESTART |
static int |
EXIT_HARD |
static int |
EXIT_HARD_RESTART |
static int |
EXIT_OOM |
(package private) static long |
LIVELINESS_DELAY |
static int |
NETWORK_ID
used to differentiate routerInfo files on different networks
|
static String |
PROP_BANDWIDTH_SHARE_PERCENTAGE |
static String |
PROP_CONFIG_FILE |
static String |
PROP_DYNAMIC_KEYS |
static String |
PROP_FORCE_BWCLASS |
static String |
PROP_FORCE_UNREACHABLE |
static String |
PROP_HIDDEN
this puts an 'H' in your routerInfo
|
static String |
PROP_HIDDEN_HIDDEN
this does not put an 'H' in your routerInfo
|
static String |
PROP_SHUTDOWN_IN_PROGRESS |
Object |
routerInfoFileLock |
static String |
UPDATE_FILE |
Constructor and Description |
---|
Router()
Instantiation only.
|
Router(Properties envProps)
Instantiation only.
|
Router(String configFilename)
Instantiation only.
|
Router(String configFilename,
Properties envProps)
Instantiation only.
|
Modifier and Type | Method and Description |
---|---|
void |
addCapabilities(RouterInfo ri) |
void |
cancelGracefulShutdown()
Cancel any prior request to shut the router down gracefully.
|
static void |
clearCaches() |
void |
clockShift(long delta)
The clock shift listener.
|
EventLog |
eventLog() |
int |
get15sRate() |
int |
get15sRate(boolean outboundOnly) |
int |
get15sRateIn() |
int |
get1mRate() |
int |
get1mRate(boolean outboundOnly) |
int |
get1mRateIn() |
int |
get1sRate() |
int |
get1sRate(boolean outboundOnly) |
int |
get1sRateIn() |
int |
get5mRate() |
int |
get5mRate(boolean outboundOnly) |
String |
getConfigFilename() |
Map<String,String> |
getConfigMap() |
String |
getConfigSetting(String name) |
Set<String> |
getConfigSettings() |
RouterContext |
getContext() |
boolean |
getHigherVersionSeen()
Deprecated.
unused
|
boolean |
getKillVMOnEnd()
Deprecated.
unused
|
RouterInfo |
getRouterInfo()
Warning, may be null if called very early
|
double |
getSharePercentage()
What fraction of the bandwidth specified in our bandwidth limits should
we allow to be consumed by participating tunnels?
|
long |
getShutdownTimeRemaining()
How long until the graceful shutdown will kill us?
|
long |
getUptime()
wall clock uptime
|
long |
getWhenStarted() |
boolean |
gracefulShutdownInProgress()
Is a graceful shutdown in progress? This may be cancelled.
|
boolean |
isAlive() |
boolean |
isFinalShutdownInProgress()
Is a final shutdown in progress? This may not be cancelled.
|
boolean |
isHidden() |
void |
killKeys() |
static void |
main(String[] args)
Usage: Router [rebuild]
No other options allowed, for now
Instantiates Router(), and either installs updates and exits,
or calls runRouter().
|
void |
readConfig()
This updates the config with all settings found in the file.
|
void |
rebuildNewIdentity()
Rebuild a new identity the hard way - delete all of our old identity
files, then reboot the router.
|
void |
rebuildRouterInfo()
Rebuild and republish our routerInfo since something significant
has changed.
|
void |
rebuildRouterInfo(boolean blockingRebuild) |
void |
removeConfigSetting(String name)
Warning, race between here and saveConfig(),
saveConfig(String name, String value) or saveConfig(Map toAdd, Set toRemove) is recommended.
|
void |
restart()
A "soft" restart, primarily of the comm system, after
a port change or large step-change in system time.
|
void |
runRouter()
This must be called after instantiation.
|
boolean |
saveConfig()
Save the current config options (returning true if save was
successful, false otherwise)
Synchronized with file read in getConfig()
|
boolean |
saveConfig(Map toAdd,
Collection<String> toRemove)
Updates the current config and then saves it.
|
boolean |
saveConfig(String name,
String value)
Updates the current config and then saves it.
|
int |
scheduledGracefulExitCode()
What exit code do we plan on using when we shut down (or -1, if there isn't a graceful shutdown planned)
|
void |
setConfigFilename(String filename)
Deprecated.
unused
|
void |
setConfigSetting(String name,
String value)
Warning, race between here and saveConfig(),
saveConfig(String name, String value) or saveConfig(Map toAdd, Set toRemove) is recommended.
|
void |
setHigherVersionSeen(boolean seen)
Deprecated.
unused
|
void |
setIsAlive()
Only for Restarter
|
void |
setKillVMOnEnd(boolean shouldDie)
Configure the router to kill the JVM when the router shuts down, as well
as whether to explicitly halt the JVM during the hard fail process.
|
void |
setRouterInfo(RouterInfo info)
Caller must ensure info is valid - no validation done here
|
void |
shutdown(int exitCode)
Shutdown with no chance of cancellation
|
void |
shutdown2(int exitCode)
Cancel the JVM runtime hook before calling this.
|
void |
shutdownGracefully()
Call this if we want the router to kill itself as soon as we aren't
participating in any more tunnels (etc).
|
void |
shutdownGracefully(int exitCode)
Call this with EXIT_HARD or EXIT_HARD_RESTART for a non-blocking,
hard, non-graceful shutdown with a brief delay to allow a UI response
|
public final Object routerInfoFileLock
public static final String PROP_CONFIG_FILE
public static final long CLOCK_FUDGE_FACTOR
public static final int NETWORK_ID
public static final int COALESCE_TIME
public static final String PROP_HIDDEN
public static final String PROP_HIDDEN_HIDDEN
public static final String PROP_DYNAMIC_KEYS
public static final String PROP_SHUTDOWN_IN_PROGRESS
public static final String DNS_CACHE_TIME
public static final char CAPABILITY_BW12
public static final char CAPABILITY_BW32
public static final char CAPABILITY_BW64
public static final char CAPABILITY_BW128
public static final char CAPABILITY_BW256
public static final String PROP_FORCE_BWCLASS
public static final char CAPABILITY_REACHABLE
public static final char CAPABILITY_UNREACHABLE
public static final String PROP_FORCE_UNREACHABLE
public static final char CAPABILITY_NEW_TUNNEL
public static final int EXIT_GRACEFUL
public static final int EXIT_HARD
public static final int EXIT_OOM
public static final int EXIT_HARD_RESTART
public static final int EXIT_GRACEFUL_RESTART
public static final String UPDATE_FILE
static final long LIVELINESS_DELAY
public static final String PROP_BANDWIDTH_SHARE_PERCENTAGE
public static final int DEFAULT_SHARE_PERCENTAGE
public Router()
public Router(Properties envProps)
public Router(String configFilename)
public Router(String configFilename, Properties envProps)
public static final void clearCaches()
public void setKillVMOnEnd(boolean shouldDie)
public boolean getKillVMOnEnd()
public String getConfigFilename()
public void setConfigFilename(String filename)
public void setConfigSetting(String name, String value)
public void removeConfigSetting(String name)
public RouterInfo getRouterInfo()
public void setRouterInfo(RouterInfo info)
public boolean getHigherVersionSeen()
public void setHigherVersionSeen(boolean seen)
public long getWhenStarted()
public long getUptime()
public RouterContext getContext()
public void runRouter()
public void readConfig()
public boolean isAlive()
public void rebuildRouterInfo()
public void rebuildRouterInfo(boolean blockingRebuild)
public void addCapabilities(RouterInfo ri)
public boolean isHidden()
public EventLog eventLog()
public void killKeys()
public void rebuildNewIdentity()
public void shutdown(int exitCode)
public void shutdown2(int exitCode)
public void shutdownGracefully()
shutdown(int)
. If you want to cancel
the graceful shutdown (prior to actual shutdown ;), call
cancelGracefulShutdown()
.public void shutdownGracefully(int exitCode)
public void cancelGracefulShutdown()
public int scheduledGracefulExitCode()
public boolean gracefulShutdownInProgress()
public boolean isFinalShutdownInProgress()
public long getShutdownTimeRemaining()
public boolean saveConfig()
public boolean saveConfig(String name, String value)
name
- setting to add/change/remove before savingvalue
- if non-null, updated value; if null, setting will be removedpublic boolean saveConfig(Map toAdd, Collection<String> toRemove)
toAdd
- settings to add/change before saving, may be null or emptytoRemove
- settings to remove before saving, may be null or emptypublic void clockShift(long delta)
clockShift
in interface RouterClock.ClockShiftListener
delta
- The system clock and adjusted clock just changed by this much,
in milliseconds (approximately)public void restart()
public void setIsAlive()
public static void main(String[] args)
args
- null okIllegalArgumentException
public double getSharePercentage()
public int get1sRate()
public int get1sRate(boolean outboundOnly)
public int get1sRateIn()
public int get15sRate()
public int get15sRate(boolean outboundOnly)
public int get15sRateIn()
public int get1mRate()
public int get1mRate(boolean outboundOnly)
public int get1mRateIn()
public int get5mRate()
public int get5mRate(boolean outboundOnly)