This commit is contained in:
MrBesen 2018-10-08 11:22:45 +02:00
parent 0aa196339b
commit c47ab96996
2 changed files with 24 additions and 0 deletions

View File

@ -316,6 +316,7 @@ public class Crawler implements Runnable {
out += "\nRandomBuffer: " + db.getRandomCount();
out += "\nRuntime: " + runtimem + "min and " + crawlcount + " videos crawled. ( " + vidps + " v/s )";
out += "\nState: " + currentstate;
out += "\nDBSize: " + db.getDBSize();
out += "\nThread Nr, todo size, requested, crawledsize, foundsize";
for (int i = 0; i < threads.size(); i++) {
CrawlerThread thre = threads.get(i);

View File

@ -25,6 +25,7 @@ public class DB implements Runnable {
private Random rand = new Random();
private Server serv = new Server(this);
private Thread randomrefill = null;
private int dbsize = 0;
public DB() {
try {
@ -54,10 +55,31 @@ public class DB implements Runnable {
serv.start();
refillbuffer();
//get db size
dbsize();
} catch (SQLException e) {
log.error("Error while connecting to the database! ", e);
}
}
private void dbsize() {
try {
ResultSet set = query("SELECT count(*) as count FROM `videos`;");
if(set != null) {
if(set.next()) {
dbsize = set.getInt(1);
}
}
} catch(SQLException e) {
e.printStackTrace();
}
}
public int getDBSize() {
return dbsize;
}
private void connect(boolean selectdb) {
try {
@ -100,6 +122,7 @@ public class DB implements Runnable {
public void addVideos(List<Video> input) {
//log.info("add " + input.size() + " videos");
if(input.size() > 0) {
dbsize += input.size();
StringBuilder sb = new StringBuilder();
for(int i = 0; i< input.size(); i++) {
if(i > 0)