Skip to content

Commit

Permalink
periodical lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
mic authored and mic committed Feb 22, 2013
1 parent fbeb06c commit 9876634
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions blogracy-web/src/main/java/net/blogracy/WebServer.java
@@ -1,6 +1,7 @@
package net.blogracy;

import net.blogracy.model.users.User;
import net.blogracy.controller.DistributedHashTable;
import net.blogracy.controller.FileSharing;
import net.blogracy.config.Configurations;
import java.util.List;
Expand Down Expand Up @@ -28,12 +29,17 @@ public static void main(String[] args) throws Exception
int TOTAL_WAIT = 5 * 60 * 1000; // 5 minutes

while (true) {
List<User> friends = Configurations.getUserConfig().getFriends();
int wait = TOTAL_WAIT / friends.size();
for (User friend : friends) {
FileSharing.getFeed(friend.getHash().toString());
Thread.currentThread().sleep(wait);
}
FileSharing sharing = FileSharing.getSingleton();
String id = Configurations.getUserConfig().getUser().getHash().toString();
sharing.addFeedEntry(id, "" + new java.util.Date(), null);

List<User> friends = Configurations.getUserConfig().getFriends();
int wait = TOTAL_WAIT / friends.size();
for (User friend : friends) {
DistributedHashTable.getSingleton().lookup(friend.getHash().toString());
FileSharing.getFeed(friend.getHash().toString());
Thread.currentThread().sleep(wait);
}
}
}
}

0 comments on commit 9876634

Please sign in to comment.