简体   繁体   中英

How should I make the server check, if the time stamp made by the node is less than or more than five minutes old?

In my web-app server keeps the list of all the nodes that are connected to it (in the database). Just to ensure that it doesn't keep the node information that are not connected to it anymore,after a certain interval it deletes the node from the database. Each node connected pings to the server after every 10 seconds and there is an entry made, that this particular node pinged the server at this time.

Problem :

  • When a node pings the server, server manages to store the node information but it ( I ) doesn't know how to make a time stamp in the database, so that after the server time out (lets say 5 minutes) it deletes the node information.

Please help me with some inputs, as to how should I manage this ? If I make a time stamp, like :

new GregorianCalendar().getTimeInMillis();

after every 10 seconds on the server how should the server check,if the time stamp is 5 minutes old or not ? Or may be there is an all together another way.

boolean isOld = System.currentTimeMillis() = someDate.getTime() > 300000; // 5 mins in ms

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM