[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] [metrics-db/master] Add stats to RelayDescriptorDatabaseImporter.
commit 4e739616f919a44dd69701d7ad7e6068c11d896c
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Fri Jan 14 11:07:52 2011 +0100
Add stats to RelayDescriptorDatabaseImporter.
---
.../ernie/db/RelayDescriptorDatabaseImporter.java | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/org/torproject/ernie/db/RelayDescriptorDatabaseImporter.java b/src/org/torproject/ernie/db/RelayDescriptorDatabaseImporter.java
index be30ea2..b023227 100644
--- a/src/org/torproject/ernie/db/RelayDescriptorDatabaseImporter.java
+++ b/src/org/torproject/ernie/db/RelayDescriptorDatabaseImporter.java
@@ -369,7 +369,6 @@ public final class RelayDescriptorDatabaseImporter {
rrsCount++;
if (rrsCount % autoCommitCount == 0) {
this.conn.commit();
- rrsCount = 0;
}
}
}
@@ -456,7 +455,6 @@ public final class RelayDescriptorDatabaseImporter {
rdsCount++;
if (rdsCount % autoCommitCount == 0) {
this.conn.commit();
- rdsCount = 0;
}
}
}
@@ -519,7 +517,6 @@ public final class RelayDescriptorDatabaseImporter {
resCount++;
if (resCount % autoCommitCount == 0) {
this.conn.commit();
- resCount = 0;
}
}
}
@@ -622,7 +619,6 @@ public final class RelayDescriptorDatabaseImporter {
rhsCount++;
if (rhsCount % autoCommitCount == 0) {
this.conn.commit();
- rhsCount = 0;
}
}
}
@@ -669,7 +665,6 @@ public final class RelayDescriptorDatabaseImporter {
rcsCount++;
if (rcsCount % autoCommitCount == 0) {
this.conn.commit();
- rcsCount = 0;
}
}
}
@@ -717,7 +712,6 @@ public final class RelayDescriptorDatabaseImporter {
rvsCount++;
if (rvsCount % autoCommitCount == 0) {
this.conn.commit();
- rvsCount = 0;
}
}
}
@@ -777,7 +771,6 @@ public final class RelayDescriptorDatabaseImporter {
rbsCount++;
if (rbsCount % autoCommitCount == 0) {
this.conn.commit();
- rbsCount = 0;
}
}
} catch (SQLException e) {
@@ -840,7 +833,6 @@ public final class RelayDescriptorDatabaseImporter {
rqsCount++;
if (rqsCount % autoCommitCount == 0) {
this.conn.commit();
- rqsCount = 0;
}
}
}
@@ -874,6 +866,14 @@ public final class RelayDescriptorDatabaseImporter {
*/
public void closeConnection() {
+ /* Log stats about imported descriptors. */
+ this.logger.info(String.format("Finished importing relay "
+ + "descriptors: %d consensuses, %d network status entries, %d "
+ + "votes, %d server descriptors, %d extra-info descriptors, %d "
+ + "bandwidth history elements, %d dirreq stats elements, and %d "
+ + "conn-bi-direct stats lines", rcsCount, rrsCount, rvsCount,
+ rdsCount, resCount, rhsCount, rqsCount, rbsCount));
+
/* Commit any stragglers before closing. */
if (this.conn != null) {
try {
From e41b07580bc556a50208756d6d2f580e550ccf31 Mon Sep 17 00:00:00 2001
Patch-Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Subject: [metrics-db/master] Make refresh script part of the database schema.
commit e41b07580bc556a50208756d6d2f580e550ccf31
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Fri Jan 14 11:09:53 2011 +0100
Make refresh script part of the database schema.
---
db/refresh.sql | 24 ------------------------
db/tordir.sql | 17 +++++++++++++++++
2 files changed, 17 insertions(+), 24 deletions(-)
diff --git a/db/refresh.sql b/db/refresh.sql
deleted file mode 100644
index ce732c4..0000000
--- a/db/refresh.sql
+++ /dev/null
@@ -1,24 +0,0 @@
--- Copyright 2010 The Tor Project
--- See LICENSE for licensing information
-
--- REFRESH.SQL
--- This script should be run every time ernie is run to keep data sinks
--- up to date by calling the refresh functions.
-
--- Make this script a transaction, in case we need to roll-back changes.
-BEGIN;
-
-SELECT * FROM refresh_relay_statuses_per_day();
-SELECT * FROM refresh_network_size();
-SELECT * FROM refresh_network_size_hour();
-SELECT * FROM refresh_relay_platforms();
-SELECT * FROM refresh_relay_versions();
-SELECT * FROM refresh_total_bandwidth();
-SELECT * FROM refresh_total_bwhist();
-SELECT * FROM refresh_user_stats();
-
--- Clear the updates table, since we have just updated everything.
-DELETE FROM updates;
-
--- Commit the transaction.
-COMMIT;
diff --git a/db/tordir.sql b/db/tordir.sql
index 40afb32..a69ddba 100644
--- a/db/tordir.sql
+++ b/db/tordir.sql
@@ -806,3 +806,20 @@ CREATE TABLE gettor_stats (
CONSTRAINT gettor_stats_pkey PRIMARY KEY("date", bundle)
);
+-- FUNCTION refresh_all()
+-- This function refreshes all statistics in the database.
+CREATE OR REPLACE FUNCTION refresh_all() RETURNS INTEGER AS $$
+ BEGIN
+ PERFORM refresh_relay_statuses_per_day();
+ PERFORM refresh_network_size();
+ PERFORM refresh_network_size_hour();
+ PERFORM refresh_relay_platforms();
+ PERFORM refresh_relay_versions();
+ PERFORM refresh_total_bandwidth();
+ PERFORM refresh_total_bwhist();
+ PERFORM refresh_user_stats();
+ DELETE FROM updates;
+ RETURN 1;
+ END;
+$$ LANGUAGE plpgsql;
+