class ProfilePersistenceHelper extends Object
| Modifier and Type | Field and Description |
|---|---|
static String | DEFAULT_PEER_PROFILE_DIRDEFAULT_PEER_PROFILE_DIR. |
static String | PROP_PEER_PROFILE_DIRPROP_PEER_PROFILE_DIR. |
| Constructor and Description |
|---|
ProfilePersistenceHelper(RouterContext ctx)ProfilePersistenceHelper. |
| Modifier and Type | Method and Description |
|---|---|
int | deleteOldProfiles(long age)Delete profile files with timestamps older than 'age' ago |
(package private) static long | getLong(Properties props,
String key)Parse a long value from the properties, or 0 if missing or invalid. |
int | getStoredProfileCount()Last known number of profile files on disk, from the most recent load,
stale-profile cleanup, or purge. |
void | purgeExcessProfiles(Set<Hash> keepPeers,
int maxProfiles)Delete profile files not in 'keepPeers', if total file count > maxProfiles. |
PeerProfile | readProfile(File file,
long cutoff)Read and parse a single stored profile. |
List<PeerProfile> | readProfiles()Load all existing profiles from the profile directory. |
void | setUs(Hash routerIdentHash)Store the local router identity hash for filtering out the router's own profile. |
boolean | writeProfile(PeerProfile profile)Write the data from the profile to the file |
void | writeProfile(PeerProfile profile,
OutputStream out)Write the data from the profile to the stream
includes comments |
void | writeProfile(PeerProfile profile,
OutputStream out,
boolean addComments)Write the data from the profile to the stream |
public static final String DEFAULT_PEER_PROFILE_DIR
public static final String PROP_PEER_PROFILE_DIR
public ProfilePersistenceHelper(RouterContext ctx)
public int deleteOldProfiles(long age)
static long getLong(Properties props, String key)
public int getStoredProfileCount()
public void purgeExcessProfiles(Set<Hash> keepPeers, int maxProfiles)
public PeerProfile readProfile(File file, long cutoff)
cutoff - delete and return null if older than this (absolute time)public List<PeerProfile> readProfiles()
public void setUs(Hash routerIdentHash)
public boolean writeProfile(PeerProfile profile)
public void writeProfile(PeerProfile profile, OutputStream out) throws IOException
IOExceptionpublic void writeProfile(PeerProfile profile, OutputStream out, boolean addComments) throws IOException
addComments - add comment lines to the outputIOException