5秒ごとに、ノードがサーバーにpingを実行します。pingが成功すると、ノードのタイムスタンプがサーバーデータベースに更新されます.3分ごとに、サーバーは3分より古いタイムスタンプがあるかどうかを確認します。見つかった場合は、データベースからノードを削除します。
今問題。このクエリを実装できません。たとえば、私はそれを次のようなかなり単純な方法で望んでいます:
// Get the server time-stamp in milliseconds
select LastPingedAt from JustPinged where LastPingedAt > 3 Minutes"
// If it finds any,delete each of them from the database.
The logic :
Let the server's time stamp at the point of checking be 'serverStamp'
Let the node's time stamp (time in milliseconds when it last pinged) in the
database's table be 'nodeStamp'.
If ( serverStamp - nodeStamp > 3 minutes)
// Delete those nodes
If( severStamp - nodeStamp < 3 minutes)
// retain those nodes
さらに実装するクエリを設計できません。
いつでも、JustPinged
テーブルは次のようになります。
--------------------------|----------------------
NodesThatJustPinged | LastPingedAt
--------------------------|-----------------------
xxx.xxx.xxx.xxx | 1355406367402
--------------------------|-----------------------
yyy.yyy.yyy.yyy | 1355406421277
--------------------------|-----------------------
時間はミリ秒単位new GregorianCalendar().getTimeInMillis()
です。