input
stringlengths
10
828
output
stringlengths
5
107
private string bc anchor string href string pretty text return a href new href href class class crumbs pretty text a gt
set up a bread crumb anchor
public void send v1 lcap message msg archival unit au throws ioexception drouter send msg au
multicast a message to all peers
private string bc terminate string pretty text return span class class crumbs pretty text span font
set up bread crumb span text final component of a bread crumb trail
public void store throws ioexception store false
store the set and retain in memory
public void store boolean release throws ioexception if m is in memory internal store this writes to m file peer id if release release
store the set and optionally remove from memory
public void release m is in memory false m set peer id null
release resources without saving
protected void new password prompt table table string pw text string confirm text new password prompt table pw text confirm text false
standard 3 column prompt for password and confirmation
public void send v1 lcap message msg archival unit au throws ioexception check stale partners msg set hop count initial hop count log debug2 send msg if orig msg rate limiter is event ok lockss datagram dg new lockss datagram lockss datagram protocol lcap msg encode msg do multicast dg orig pkt rate limiter au do unicast dg orig pkt rate limiter null null orig msg rate limiter event else log debug orig msg rate limited
multicast a message to all caches holding the archival unit
public long get data size check has data return payload length
return the size of the data
protected void post unmarshal lockss app lockss context m file new file m file path
automagically restore file object following deserialization
public vote block get vote block string url vote blocks iterator iter null try iter iterator while iter has next vote block vb iter next if url equals vb get url return vb return null catch ioexception ex log error ioexception while searching for vote block url ex return null finally if iter null iter release
search the collection for the requested vote block
public long get data size check has data return file size
return the size of the data
protected table new3 column form table return new3 column form table 25
start a fresh form with an embedded three column table
protected table new3 column form table string first column width return new3 column form table first column width standard padding
start a fresh form with an embedded three column table
public void stop service try store identities catch protocol exception ex super stop service get daemon get status service unregister status accessor identities vote set identity manager null lcap message set identity manager null
p stops the identity manager
private peer identity status find peer identity status peer identity id peer identity status status null synchronized the lcap identities status the lcap identities get id if status null lcap identity lcap id find lcap identity id id get id string log debug2 making new peer identity status for id status new peer identity status lcap id return status
p finds or creates unique instances of both peer identity and
public void message received lcap message msg int msg op code msg get opcode total messages set last message op code msg op code set last message time time base now ms if msg instanceof v3 lcap message message received v3 lcap message msg
signal the receipt of a message from the given peer
protected void new3 column row table table string label object value table new row table new cell align right nowrap table add label table add table new cell table new cell align left nowrap table add value
render one three column table row
public void invited peer total poll invitations set last poll invitation time time base now ms
signal that we have invited this peer to participate in a poll
protected void new3 colspan centered row table table object value table new row table new cell colspan 3 align center nowrap table add value
render one three column table row colspan 3
protected table new anchor page table form form table table form new form table new table 0 standard table align center form add table add to page form return table
start a fresh anchor page table
protected form new form return new form null
standard form setup
public lcap identity find lcap identity peer identity pid string key synchronized the lcap identities peer identity status status the lcap identities get pid if status null log debug2 making new peer identity status for pid status new peer identity status new lcap identity pid key the lcap identities put pid status return status get lcap identity
p finds or creates unique instances of lcap identity
protected form new form string command form form new form form action is to invoke the cluster control servlet form action ccp controller name save the command name sent to the server on submission form add new input input hidden ccp param command command null command command debug form method get return form
standard form setup
protected tag new button string label tag button new tag input button attribute type button button attribute value label return button
set up a button not directly supported via input
public peer identity get peer return peer
return our peer or null if not known yet
protected tag new on click button string label string script tag button new button label button attribute on click script return button
create a new button with javascript onclick functionality
public peer identity get local peer identity int poll version peer identity pid null try pid local peer identities poll version catch array index out of bounds exception e fall through if pid null throw new illegal argument exception illegal poll version poll version return pid
returns the local peer identity
public void start incoming if state trans channel state accepted channel state starting start incoming try start connected channel catch ioexception e abort channel e
start threads in response to incoming connection
public ipaddr get local ipaddr return the local ipaddr
p returns the ipaddr of the local peer
public boolean is local identity peer identity id return id is local identity
p determines if this peer identity is the same as the local
public boolean is local identity string id str try return is local identity string to peer identity id str catch identity manager malformed identity key exception e return false
p determines if this peer identity is the same as the local
public void remember event peer identity id int event lcap message msg lcap identity lid the lcap identities get id get lcap identity if lid null lid remember event event msg
p associates the event with the peer identity
protected table new rule string width return new rule width 1
construct a table for use as an html rule hr element
public int get max reputation return reputation numerator
p returns the max value of an identitys reputation
public int get reputation peer identity id int ret 0 lcap identity lid the lcap identities get id get lcap identity if lid null log error can t find lcap identity for id to string else ret lid get reputation return ret
p returns the reputation of the peer
public void cancel timeout if timer req null timer queue cancel timer req
cancel any timeout waiting to interrupt this thread
protected table new rule string width string height table table new table 0 standard table width width align center table new row table new cell height height bgcolor standard rule color return table
construct a table for use as an html rule hr element
protected int get reputation delta int change kind int ret 1 if change kind 0 change kind reputation deltas length ret reputation deltas change kind return ret
p returns the amount of reputation change that reflects the
protected int new shaded row table table int row count if row count 2 0 table new row bgcolor standard shaded color else table new row return row count 1
add a new table row shade every other row
private object serializer make identity list serializer xstream serializer serializer new xstream serializer get daemon return serializer
p builds an object serializer suitable for storing identity
public void write identity db to output stream out throws ioexception xxx hokey way to have the acceess performed by the object that has the appropriate lock if setup iddb file null return if iddb file exists synchronized iddb file input stream in new buffered input stream new file input stream iddb file try stream util copy in out finally ioutil safe close in
p copies the identity database file to the stream
protected composite new active cluster link string url composite composite new composite string target target ccp command setactivecluster ap e target java net urlencoder encode url composite add select a nbsp composite add new link target lockss cluster composite add nbsp for administration return composite
set up a link to the set active cluster page
public collection get udp peer identities collection ret val new array list for peer identity id pid set if id get peer address instanceof peer address udp id is local identity ret val add id return ret val
p return a collection o all v1 style peer identities
protected string html encode string raw text return html util html encode raw text
html entity encoding
public collection get tcp peer identities return get tcp peer identities predicate utils true predicate
p return a collection of all v3 style peer identities
protected string pad and encode select text string text return pad and encode select text text standard select length
generate html encoded text with blank padding to a fixed length
public collection get tcp peer identities predicate peer predicate collection ret val new array list for peer identity id pid set if id get peer address instanceof peer address tcp id is local identity peer predicate evaluate id ret val add id return ret val
return a filtered collection of v3 style peer identities
private serializable wrap map the identities return serializable the identities
p castor xstream transition helper method that wraps the
public ipaddr get sender if sender null sender new ipaddr packet get address return sender
return the senders ipaddr
public int get protocol throws protocol exception if payload null decode packet return protocol
return the protocol from the received packet
protected string pad and encode select text string text int pad to length string buffer result new string buffer int length pad to length text length if length 0 for int i 0 i length i result append nbsp return html encode text result to string
generate html encoded text with blank padding to a fixed length
public boolean is multicast return multicast
return true iff the packet was a multicast packet
public boolean is compressed byte data packet get data int magic int data 1 0xff 8 int data 0 0xff return magic gzipinput stream gzip magic
return true if the data in the packet is compressed
private hash map unwrap object obj return hash map obj
p castor xstream transition helper method that unwraps the
public boolean equals object o if o instanceof lockss received datagram lockss received datagram d lockss received datagram o datagram packet opacket d get packet return multicast d multicast packet get port opacket get port packet get length opacket get length packet get offset opacket get offset packet get address equals opacket get address arrays equals packet get data opacket get data return false
return true iff the underlying packets are the same ignoring the
public int hash code if hash 1 hash 0 byte b packet get data int len b length for int ix 0 ix len ix hash 31 hash b ix hash packet get address hash code packet get port 15 packet get length 3 packet get offset 8 return hash
hash the packet contents and address info
public void signal agreed peer identity pid archival unit au signal agreed pid au time base now ms 1 0f
p signals that weve agreed with pid on a top level poll on
protected iterator empty iterator return collections empty set iterator
fetch an empty iterator
protected void poll closed active info null
discard the information no longer needed after the poll has finished
public peer identity get voter identity return voter id
return the identity key of the voter
public float get percent agreement peer identity pid archival unit au map map find au agree map au synchronized map identity agreement ida identity agreement map get pid if ida null return 1 0f else return ida get percent agreement
get the percent agreement for a v3 poll on a given au
public boolean is agree vote return agree
return whether we agreed or disagreed with this vote
public string get challenge string string ret null if active info null ret string value of b64 code encode active info get challenge return ret
return the challenge bytes as a string
public string get hash string string ret null if active info null byte hash active info get hash if hash null ret string value of b64 code encode hash return ret
return the hash bytes as a string
public string get verifier string string ret null if active info null byte verifier active info get verifier ret string value of b64 code encode verifier return ret
return the verifier bytes as a string
public int get err if is error state return poll m pollstate return 0
get the error state for this poll
public void start replay deadline deadline original votes poll votes poll votes new array list original votes size replay iter original votes iterator replay deadline deadline num agree 0 num disagree 0 wt agree 0 wt disagree 0 replay next vote
replay all of the votes in a previously held poll
public boolean state is active return result result polling
true if the poll is active
public float get percent agreement hint peer identity pid archival unit au map map find au agree map au synchronized map identity agreement ida identity agreement map get pid if ida null return 1 0f else return ida get percent agreement hint
get the percent agreement hint for a v3 poll on a given au
public boolean state is finished return result state suspended result result polling
true if the poll has finshed
public boolean state is suspended return result state suspended
true if the poll is suspended
public void set state suspended result state suspended
set the poll state to suspended
protected void receive message lcap message msg log debug receiving verify message msg to string int opcode msg get opcode if opcode v1 lcap message verify poll rep start vote check msg
handle a message which may be a incoming vote
public void start poll log debug starting new verify poll m key if id mgr is local identity m caller id long now time base now ms long remaining time m deadline get remaining time long min time now remaining time 2 remaining time 4 long max time now remaining time 2 remaining time 4 m vote time deadline at random range min time max time log debug scheduling verify vote for m vote time m pollstate ps wait vote schedule vote timer queue schedule m deadline new poll timer callback this
start the poll
public int get type return poll v1 verify poll
return the type of the poll poll
protected void receive message lcap message msg int opcode msg get opcode if m msg null m msg msg log debug setting message for this from msg if opcode v1 lcap message content poll rep start vote check msg
handle a message which may be a incoming vote
public void timer expired object cookie log debug verify timer callback called checking if i should verify if m pollstate ps wait hash log debug i should verify v1 lcap message msg v1 lcap message cookie perform hash msg stop vote check
called when the timer expires
public int get type return poll v1 content poll
return the type of the poll poll
public poll tally get vote tally return m tally
get the vote tally for this poll
public void signal disagreed peer identity pid archival unit au signal disagreed pid au time base now ms 0 0f
p signals that weve disagreed with pid on any level poll on
public string to string string poll type unk if this instanceof v1 name poll poll type name if this instanceof v1 content poll poll type content if this instanceof v1 verify poll poll type verify string buffer sb new string buffer poll sb append poll type sb append url set sb append sb append m cus to string sb append if m msg null sb append m msg get opcode string sb append key sb append m key sb append return sb to string
create a human readable string representation of this poll
public iterator get lockss title iterator throws sqlexception return get lockss title iterator null
get an iterator to the list of configured lockss titles
public void start poll if m pollstate ps initing return m pollstate ps wait hash if schedule our hash m pollstate err schedule hash log debug couldn t schedule our hash m vote time stopping poll stop poll return log debug3 scheduling poll to complete by m deadline timer queue schedule m deadline new poll timer callback this
start the poll
private cached url set check for conflicts cached url set cus poll manager pm return check for conflicts cus pm null
check for conflicts between the poll defined by the message and any
public void set message lcap message msg if m msg null this m msg msg log debug setting message for this from msg
set the message that created this poll
protected boolean is error state return m pollstate 0
is our poll currently in an error condition
public void stop poll if is error state log debug poll stopped with error error strings m pollstate else m pollstate ps complete m pollmanager close the poll m key log debug3 closed the poll m key
finish the poll once the deadline has expired
public list get caches to repair from archival unit au if au null throw new illegal argument exception called with null au map map find au agree map au list res new linked list synchronized map for iterator it map entry set iterator it has next map entry ent map entry it next identity agreement ida identity agreement ent get value if ida has agreed if ida get last disagree ida get last agree res add ent get key else res add 0 ent get key return res
p peers with whom we have had any disagreement since the last
protected void stop vote check m pending votes log debug3 number pending votes m pending votes
stop and record a vote cast in this poll
public boolean is my poll boolean ret id mgr is local identity m caller id if log is debug2 log debug2 is my poll m caller id to string ret return ret
returns true if the poll belongs to this identity
public message digest get message digest lcap message msg message digest digest null string algorithm if msg null algorithm lcap message get default hash algorithm else algorithm msg get hash algorithm try digest message digest get instance algorithm catch no such algorithm exception ex the log error unable to run no message digest return digest
return a message digest needed to hash this message
public peer identity get caller id return m caller id
returns the id key for the peer that called the poll
public void stop log debug terminating poll runner tasks queued executor executor shutdown now executor null
terminate background thread even if it is currently processing a task
public void run task poll runner task task try log debug starting task task executor execute task catch interrupted exception ex don t want to ignore these yet but they must be handled we ll log for now log warning caught interrupted exception while running task task ex
request a task be run
public string get poll id return poll id
return the id of the poll this task is associated with
public poll spec get poll spec return m pollspec
return the poll spec used by this poll
public iterator get ip group name iterator throws sqlexception return get ip group name iterator null
get an iterator to the list of configured ip groups
public int get version return m pollspec get protocol version
return the poll version of this poll
public v1 poll factory get poll factory return v1 poll factory m pollmanager get poll factory m pollspec
return the poll factory for this poll version