dk.netarkivet.archive.arcrepositoryadmin
Class ArcRepositoryEntry

java.lang.Object
  extended by dk.netarkivet.archive.arcrepositoryadmin.ArcRepositoryEntry

public class ArcRepositoryEntry
extends java.lang.Object

This class contains the information that we keep about each file in the arcrepository: Checksum and the store states for all bitarchives. TODO Maybe don't have the store state info for fully completed stores, or else use a slimmer map for it.


Field Summary
(package private) static java.lang.String ENTRY_COMPONENT_SEPARATOR_STRING
          String used to separate the different parts of the arcRepositoryEntry, when we write the entry to persistent storage.
 
Constructor Summary
ArcRepositoryEntry(java.lang.String filename, java.lang.String md5sum, StoreMessage replyInfo)
          Create a new entry with given checksum and replyinfo.
 
Method Summary
(package private)  StoreMessage getAndRemoveReplyInfo()
          Get the reply info and remove it from the entry.
 java.lang.String getChecksum()
          Get the checksum for this entry.
(package private)  java.lang.String getFilename()
          Get the filename for this entry.
 ArchiveStoreState getGeneralStoreState()
          Get the ArchiveStoreState for the entry in general.
 ReplicaStoreState getStoreState(java.lang.String baId)
          Get the StoreState for this entry for a given bitarchive or null if none.
(package private)  boolean hasReplyInfo()
          Returns information of whether a ReplyInfo object has been stored with this entry.
(package private)  boolean hasStoreState(java.lang.String bitArchive)
          Check, if a given bitArchive has a StoreState connected to it.
(package private)  void output(java.io.PrintWriter o)
          Write this object to persistent storage.
(package private)  void setChecksum(java.lang.String checksum)
          Set the checksum for this entry.
(package private)  void setReplyInfo(StoreMessage replyInfo)
          Set the replyInfo instance variable.
(package private)  void setStoreState(java.lang.String ba, ReplicaStoreState state)
          Set the StoreState for a specific bitarchive (set timestamp for last update to NOW).
(package private)  void setStoreState(java.lang.String baId, ReplicaStoreState state, java.util.Date lastchanged)
          Set the StoreState for a specific bitarchive (set timestamp for last update to lastchanged).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENTRY_COMPONENT_SEPARATOR_STRING

static final java.lang.String ENTRY_COMPONENT_SEPARATOR_STRING
String used to separate the different parts of the arcRepositoryEntry, when we write the entry to persistent storage. Make package private, so accessable from AdminData

See Also:
Constant Field Values
Constructor Detail

ArcRepositoryEntry

public ArcRepositoryEntry(java.lang.String filename,
                          java.lang.String md5sum,
                          StoreMessage replyInfo)
Create a new entry with given checksum and replyinfo.

Parameters:
filename - The filename for this entry
md5sum - The checksum for this entry
replyInfo - The one-use-only reply info chunk
Method Detail

getGeneralStoreState

public ArchiveStoreState getGeneralStoreState()
Get the ArchiveStoreState for the entry in general. This is computed from the ArchiveStoreStates for the bitarchives.
1. If no information about the bitarchives are available, the state UPLOAD_FAILED with timestamp=NOW is returned
2. If there are information about one bitarchive, the state of this bitarchive is returned.
3. If there are information from more than one bitarchive, A. if the state of one of the bitarchives equals UPLOAD_FAILED, the state UPLOAD_FAILED with the latest timestamp is returned B. else, find the lowest state of the N bitarchives: return this state together with the the latest timestamp

Note that the storestate and the timestamp might not come from the same bitarchive.

Returns:
the current ArchiveStoreState for the entry in general

setStoreState

void setStoreState(java.lang.String ba,
                   ReplicaStoreState state)
Set the StoreState for a specific bitarchive (set timestamp for last update to NOW).

Parameters:
ba - a bitarchive
state - the new StoreState for this bitarchive.

setStoreState

void setStoreState(java.lang.String baId,
                   ReplicaStoreState state,
                   java.util.Date lastchanged)
Set the StoreState for a specific bitarchive (set timestamp for last update to lastchanged).

Parameters:
baId - a bitarchive
state - the new StoreState for this bitarchive.
lastchanged - the time for when the state was changed

getStoreState

public ReplicaStoreState getStoreState(java.lang.String baId)
Get the StoreState for this entry for a given bitarchive or null if none.

Parameters:
baId - a bitarchive id
Returns:
the StoreState for a given bitarchive.

getFilename

java.lang.String getFilename()
Get the filename for this entry.

Returns:
the filename for this entry

setChecksum

void setChecksum(java.lang.String checksum)
Set the checksum for this entry.

Parameters:
checksum - the new checksum for this entry

getChecksum

public java.lang.String getChecksum()
Get the checksum for this entry.

Returns:
the stored checksum for this entry

getAndRemoveReplyInfo

StoreMessage getAndRemoveReplyInfo()
Get the reply info and remove it from the entry.

Returns:
A reply info object that nobody else has gotten or will get.

hasReplyInfo

boolean hasReplyInfo()
Returns information of whether a ReplyInfo object has been stored with this entry.

Returns:
true, if replyInfo is not null.

output

void output(java.io.PrintWriter o)
Write this object to persistent storage.

Parameters:
o - A stream to write to.

hasStoreState

boolean hasStoreState(java.lang.String bitArchive)
Check, if a given bitArchive has a StoreState connected to it.

Parameters:
bitArchive - a given bitarchive
Returns:
true, if the given bitArchive has a StoreState connected to it.

setReplyInfo

void setReplyInfo(StoreMessage replyInfo)
Set the replyInfo instance variable.

Parameters:
replyInfo - The new value for the replyInfo variable.