OSDN Git Service

Move network stats to FileRotator pattern.
authorJeff Sharkey <jsharkey@android.com>
Thu, 12 Jan 2012 02:38:16 +0000 (18:38 -0800)
committerJeff Sharkey <jsharkey@android.com>
Tue, 24 Jan 2012 19:13:14 +0000 (11:13 -0800)
commit63abc37356728c0575d6a62a203102ae6d97953b
treec828ee65a2764be6307c704fa3dee8c1606c126d
parentcf5c78f209a34bae4a049ff2370252be8598d034
Move network stats to FileRotator pattern.

Split existing network stats into two separate classes: a recorder
which generates historical data based on periodic counter snapshots,
and a collection of historical data with persistance logic.

Recorder keeps a pending history in memory until outstanding data
crosses a specific threshold.  Persisting is handled through a given
FileRotator.  This pattern significantly reduces disk churn and
memory overhead.  Separate UID data from UID tag data, enabling a
shorter rotation cycle.  Migrate existing stats into new structure.

Remove "xt" stats until iptables hooks are ready.  Avoid consuming
Entry values when recording into NetworkStatsHistory.  Assign
operation counts to default route interface.

Introduce "Rewriter" interface in FileRotator with methods to enable
rewriteAll().  Introduce IndentingPrintWriter to handle indenting in
dump() methods.

Bug: 5386531
Change-Id: Ibe086230a17999a197206ca62d45f266225fdff1
16 files changed:
core/java/android/net/NetworkStats.java
core/java/android/net/NetworkStatsHistory.java
core/java/android/net/TrafficStats.java
core/java/android/provider/Settings.java
core/java/com/android/internal/util/ArrayUtils.java
core/java/com/android/internal/util/FileRotator.java
core/java/com/android/internal/util/IndentingPrintWriter.java [new file with mode: 0644]
services/java/com/android/server/EventLogTags.logtags
services/java/com/android/server/net/NetworkPolicyManagerService.java
services/java/com/android/server/net/NetworkStatsCollection.java [new file with mode: 0644]
services/java/com/android/server/net/NetworkStatsRecorder.java [new file with mode: 0644]
services/java/com/android/server/net/NetworkStatsService.java
services/tests/servicestests/res/raw/netstats_uid_v4 [new file with mode: 0644]
services/tests/servicestests/res/raw/netstats_v1 [new file with mode: 0644]
services/tests/servicestests/src/com/android/server/NetworkStatsServiceTest.java
services/tests/servicestests/src/com/android/server/net/NetworkStatsCollectionTest.java [new file with mode: 0644]