input
stringlengths 10
828
| output
stringlengths 5
107
|
|---|---|
public xmlbinding service
|
default ctor does nothing
|
public void write writer writer object object throws marshal exception validation exception ioexception marshaller marshaller new marshaller writer marshaller marshal object
|
serializes an object to a writer as xml
|
public void init failover string hostname if document server get document server use failover switch to failover host hostname for entry string inet address fo host failover hosts entry set try if fo host get value is reachable 100 logger debug host fo host get key is not reachable too switch to failover host fo host get key else logger debug host fo host get key is reachable catch ioexception e logger error e
|
switches the faild host to its failover pendant and checks every host
|
public boolean exec throws ioexception load props logger debug props loaded init logger debug init pool siz pool size accept loop logger debug accept loop destroy logger debug destroyed return true
|
this method manages the life cycle of the application
|
public void resolve dynamic values xmltools resolve dynamic values this document
|
resolves all the macro values in the underlying xml document
|
public void init throws ioexception create server socket create worker pool
|
initialzie the server
|
protected void create server socket throws ioexception println creating new server on port get port server socket new server socket get port server socket set so timeout get so timeout
|
creates the server socket
|
protected void create worker pool for int i 0 i get pool size i create new worker
|
creates the worker pool
|
public void accept loop throws ioexception while is running if process next connection println connection not handled break println exiting accept loop
|
this is the main loop of the server
|
protected boolean process next connection throws ioexception try socket client accept connection if null client return false handle client client catch interrupted ioexception iie this is ok return true return true
|
calls the server sockets accept and invokes the client handler
|
public void destroy throws ioexception shutdown the server socket server socket close set is stopped true while 0 ready workers size http worker w ready workers remove 0 w set is running false w set socket null
|
destructor for the server
|
public void handle client socket client http worker w get next worker from pool w set socket client
|
obtains the next ready http worker and hands off the socket connection
|
public http worker get next worker from pool http worker w null synchronized ready workers if 0 num ready workers println create another worker create new worker return the 1st ready worer w get next ready worker return w
|
retreives the next ready worker from the pool
|
public int num ready workers return ready workers size
|
get the number of workers available in the pool
|
protected void create new worker println creating new worker http worker w new worker ready workers add w thread t new thread http threads w integer to string w get worker id t start if worker id 10 0 int tc http threads active count logger info threads in group tc worker id worker id
|
create a new worker add it to the pool and start it
|
protected http worker new worker return new http worker get next id
|
derived classes should override this method to provide their own workers
|
protected http worker get next ready worker http worker w ready workers remove 0 return w
|
returns the next ready worker from the pool
|
public socket accept connection throws ioexception return get server socket accept this blocks
|
invokes the server sockets accept method
|
public void set exit code int exit code exit code exit code
|
accessort the exit code
|
public void set pool size int size pool size size
|
set the maximum pool size
|
public void set is stopped boolean flag is stopped flag
|
set the stopped flag
|
public void set is running boolean flag is running flag
|
set the is running flag
|
public void set so timeout int t so timeout t
|
accessor for the socket timeout
|
public int get next id return worker id
|
computes and returns the next new worker id
|
public boolean exec throws ioexception load props println props loaded init println init accept loop println accept loop destroy println destroyed return true
|
this method manages the life cycle of the application
|
private void load props if document root null document root equals document root system get property user dir if so timeout 1000 so timeout 5000 if pool size 1 pool size 25
|
set default properties if none are specified
|
public void destroy throws ioexception shutdown the server socket if server socket null server socket is closed server socket close set is stopped true while 0 ready workers size httpworker w ready workers remove 0 w set is running false w set socket null
|
destructor for the server
|
public void handle client socket client httpworker w get next worker from pool w set socket client
|
obtains the next ready http worker and hands off the socket connection
|
public httpworker get next worker from pool httpworker w null synchronized ready workers if 0 num ready workers create another worker create new worker return the 1st ready worer w get next ready worker return w
|
retreives the next ready worker from the pool
|
protected void create new worker println creating new worker httpworker w new worker ready workers add w new thread http threads w w get worker id start
|
create a new worker add it to the pool and start it
|
protected httpworker new worker return new httpworker this get next id
|
derived classes should override this method to provide their own workers
|
protected httpworker get next ready worker httpworker w ready workers remove 0 return w
|
returns the next ready worker from the pool
|
public server socket get server socket if server socket null server socket is closed try create server socket catch ioexception e e print stack trace return server socket
|
accessor for the server socket
|
public string get next id return new integer worker id to string
|
computes and returns the next new worker id
|
public void new message message m
|
method is called when a new message is created
|
public void message transfer started message m dtnhost from dtnhost to
|
method is called when a messages transfer is started
|
public void message deleted message m dtnhost where boolean dropped
|
method is called when a message is deleted
|
public void message transfer aborted message m dtnhost from dtnhost to
|
method is called when a messages transfer was aborted before
|
protected void increase time count double time int index int time this granularity if index this nrof contacts size if biggest index so far fill array with nulls up to index 2 to keep the last time count always zero this nrof contacts set size index 2 integer cur value this nrof contacts get index if cur value null no value found put the first this nrof contacts set index 1 else value found increase the number by one this nrof contacts set index cur value 1
|
increases the amount of times a certain time value has been seen
|
public void connection end this end time get sim time
|
should be called when the connection ended to record the time
|
public double get connection time if this end time 1 return get sim time this start time else return this end time this start time
|
returns the time that passed between creation of this info
|
public boolean equals object other if other instanceof connection info return false connection info ci connection info other if h1 ci h1 h2 ci h2 return true else if h1 ci h2 h2 ci h1 bidirectional connection the other way return true return false
|
returns true if the other connection info contains the same hosts
|
private void check dir existence string out file name file out file new file out file name file out dir out file get parent file if out dir null out dir exists if create dirs out dir throw new sim error couldn t create report directory out dir get absolute path
|
checks that a directory for a file exists or creates the directory
|
public int hash code string host string if this h1 compare to this h2 0 host string h1 to string h2 to string else host string h2 to string h1 to string return host string hash code
|
returns the same hash for connection infos that have the
|
public string to string return this h1 this h2 this start time this end time 0 this end time n a
|
returns a string representation of the info object
|
private boolean create dirs file directory if directory null return true if directory exists return true else if create dirs directory get parent file return false if directory mkdir return false else return true
|
recursively creates a directory structure
|
public void updated list dtnhost hosts double sim time get sim time if sim time last write granularity is warmup return shouldn t report yet last write sim time count also the times for connections that are still up double others time 0 for connection info oth this connections values others time oth get connection time double total time old contact times others time if last reported time total time return don t report duplicate times write format sim time format total time last reported time total time
|
reports total contact time if more time than defined with setting
|
public void set all hosts collection dtnhost hosts this all hosts hosts
|
sets all hosts that should be in the graph at least once
|
protected void init this last report time get sim time if output interval 0 create suffixed output out file name else create output out file name
|
intializes the report output
|
public void updated list dtnhost hosts double sim time get sim time creates a snapshot once every granularity seconds if sim time last update granularity create snapshot hosts this last update sim time sim time granularity
|
creates a new snapshot of the message locations if granularity
|
private void create snapshot list dtnhost hosts boolean is first message string report line write int get sim time write sim time stamp for dtnhost host hosts is first message true report line for message m host get message collection if this reported messages contains m get id if is first message report line host get location to string is first message false report line m get id if report line length 0 write report line write coordinate and message ids
|
creates a snapshot of message locations
|
private void create output string out file name try this out new print writer new file writer out file name catch ioexception e throw new sim error couldn t open file out file name for report output n e get message e
|
creates a new output file
|
public void updated list dtnhost hosts double sim time get sim time if is warmup return warmup period is on creates a snapshot once every granularity seconds if sim time last update granularity create snapshot hosts this last update sim time sim time granularity
|
creates a new snapshot of the energy levels if granularity
|
private void create snapshot list dtnhost hosts write int get sim time simulation time stamp for dtnhost h hosts if this reported nodes null this reported nodes contains h get address continue node not in the list write h to string format double h get com bus get property routing energy aware router energy value id
|
creates a snapshot of energy levels
|
private void report values double prob 1 0 delivered created write format get sim time created delivered format prob
|
writes the current values to report file
|
private void create suffixed output string out file name string suffix string format intervalled format this last output suffix create output out file name suffix this last output suffix
|
creates a number suffixed output file with increasing number suffix
|
public void new message message m if is warmup add warmup id m get id return this creation infos put m get id new info tuple get sim time m get from get location clone m get to get location clone
|
this is called when a new message is created
|
protected void new event if this output interval 0 return if get sim time this last report time this output interval done finalize the old file init init the new file
|
this method should be called before every new complete event the
|
private void print header write scenario get scenario name write syntax
|
writes an informative header in the beginning of the file
|
private string fix double val val val 0 epsilon val return string format coord format val
|
fixes and formats coordinate values suitable for ns2 module
|
private string create time stamp return string format 2f get sim time
|
creates and returns a
|
protected void write string txt if out null init out println prefix txt
|
writes a line to report using defined prefix and
|
private string connection string dtnhost h1 dtnhost h2 if h1 get address h2 get address return h1 h2 else return h2 h1
|
creates and returns a string presentation of the connection where the
|
protected string format double value return string format precision f value
|
formats a double value according to current precision setting see
|
private string connection string dtnhost h1 dtnhost h2 if h1 get address h2 get address return h1 get address h2 get address else return h2 get address h1 get address
|
creates and returns a string presentation of the connection where the
|
protected void set prefix string txt this prefix txt
|
sets a prefix that will be inserted before every line in the report
|
protected string get scenario name return this scenario name
|
returns the name of the scenario as read from the settings
|
protected void check creates int nrof for int i 0 i nrof i assert true mc next assert equals mc type create mc get last type assert false mc contained mc get last type mc next
|
checks that mc contains only nrof create events and nothing else
|
public dtnhost create host coord loc string name movement model mm proto new stationary movement loc return create host mm proto name
|
creates a host to a location with stationary movement model and
|
protected double get sim time return sim clock get time
|
returns the current simulation time from the sim clock
|
public dtnhost create host coord loc return this create host loc null
|
creates a host to a location with stationary movement model and
|
public dtnhost create host return this create host new coord 0 0
|
creates a host to location 0 0 with stationary movement model
|
protected boolean is warmup return this warmup time sim clock get time
|
returns true if the warm up period is still ongoing sim time warmup
|
protected void add warmup id string id if this warmup ids null lazy creation of the set this warmup ids new hash set string this warmup ids add id
|
adds a new id to the warm up id set
|
protected boolean is warmup id string id if this warmup ids null return false return this warmup ids contains id
|
returns true if the given id is in the warm up id set
|
protected settings get settings settings s new settings this get class get simple name s set secondary namespace report ns return s
|
returns a settings object initialized for the report class name space
|
public void done out close
|
called when the simulation is done user requested
|
public string get int average list integer values list double d values new array list double values size for int i values d values add double i return get average d values
|
returns the average of integer values stored in a list
|
public string get median list double values if values size 0 return nan collections sort values return format values get values size 2
|
returns the median of double values stored in a list
|
public void put setting string key string value if props null try init null catch settings error e e print stack trace system exit 1 props put key value
|
put a new setting or override an existing setting
|
public int get int median list integer values if values size 0 return 0 collections sort values return values get values size 2
|
returns the median of integer values stored in a list
|
public void test full prob throws exception run test poi selection new double 1 0 0 0 0 0 0 run test poi selection new double 0 0 1 0 0 0 0 run test poi selection new double 0 0 0 0 1 0 0 all pois nodes are random nodes run test poi selection new double 0 0 0 0 0 0 0
|
tests full probability for one node group
|
public void load tag set set tag tags throws sqlexception connection driver manager get connection sql settings statement stmt connection create statement result set rs stmt execute query select t tag from tags 5 t sample s where t userid s userid and s mac is not null group by t tag let s build up a common shared between all hosts tag pool while rs next tags add new tag rs get string tag rs close rs close
|
loads all the unique tags
|
public void update meeting prob for integer index this last update time sim clock get time if probs size 0 first entry probs put index 1 0 return double new value get prob for index 1 probs put index new value now the sum of all entries is 2 normalize to one by dividing all the entries by 2 for map entry integer double entry probs entry set entry set value entry get value 2 0
|
updates meeting probability for the given node index
|
public double get prob for integer index if probs contains key index return probs get index else the node with the given index has not been met return 0 0
|
returns the current delivery probability value for the given node index
|
private void init with integer first hop this unvisited new priority queue integer pq init size new distance comparator this visited new hash set integer this prev nodes new hash map integer integer this distances from start new distance map set distance to source 0 and initialize unvisited queue this distances from start put first hop 0 this unvisited add first hop
|
initializes a new search with the first hop router node
|
public double get last update time return this last update time
|
returns the time when this probability set was last updated
|
public void test empty run index string rs run setting settings s new settings ns s set secondary namespace def ns assert equals s get int rs 1 settings set run index 1 assert equals s get int rs 1 settings set run index 2 assert equals s get int rs 2 the only defined value settings set run index 3 assert equals s get int rs 1
|
test filling empty values of run index from secondary namespace
|
public meeting probability set replicate meeting probability set replicate new meeting probability set do a deep copy for map entry integer double e probs entry set replicate probs put e get key e get value double value replicate last update time this last update time return replicate
|
returns a deep copy of the probability set
|
private void relax integer node double node dist distances from start get node collection integer neighbors if this probs contains key node return node s neighbors are not known neighbors this probs get node get all probs key set for integer n neighbors if visited contains n continue skip visited nodes n node s distance from path s source node double n dist node dist get distance node n if distances from start get n n dist stored distance found dist update prev nodes put n node for debugging set distance n n dist
|
relaxes the neighbors of a node updates the shortest distances
|
public string to string return probs this probs to string
|
returns a string presentation of the probabilities
|
public void init dtnhost host list message listener m listeners this incoming messages new hash map string message this messages new hash map string message this delivered messages new hash map string message this m listeners m listeners this host host
|
initializes the router i
|
private void set distance integer n double distance unvisited remove n remove node from old place in the queue distances from start put n distance update distance unvisited add n insert node to the new place in the queue
|
sets the distance from source node to a node
|
private double get distance integer from integer to assert probs contains key from node from has not met to it has met nodes probs key set return 1 probs get from get prob for to
|
returns the distance between two nodes i
|
public int compare integer node1 integer node2 double dist1 distances from start get node1 double dist2 distances from start get node2 if dist1 dist2 return 1 else if dist1 dist2 return 1 else return node1 compare to node2
|
compares two map nodes by their distance from the source node
|
protected message get message string id return this messages get id
|
returns a message by id
|
public double get integer node double value map get node if value null return value else return infinity
|
returns the distance to a node
|
public void put integer node double distance map put node distance
|
puts a new distance value for a map node
|
protected boolean has message string id return this messages contains key id
|
checks if this router has a message with certain id buffered
|
public void add more info routing info info if this more info null lazy creation this more info new array list routing info this more info add info
|
adds child info object for this routing info
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.