-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b6e7b8
commit a3e091a
Showing
3 changed files
with
96 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
#################################### | ||
## Local data repos at NFS | ||
#################################### | ||
|
||
DATA_FTP='/mnt/omnidata' | ||
|
||
WIFI_TRAFFIC_PATH=$DATA_FTP/SJTU/wifi-archive | ||
|
||
WIFI_SYSLOG_PATH=$DATA_FTP/SJTU/wifi-syslog | ||
|
||
HZ_MOBILE_PATH=$DATA_FTP/NetworkTraffic/mobilelogs-hz2012/Original | ||
|
||
|
||
#################################### | ||
## Data repos on HDFS | ||
#################################### | ||
|
||
HDFS_WIFI_TRAFFIC='/user/omnilab/warehouse/WifiTraffic' | ||
|
||
HDFS_WIFI_SYSLOG='/user/omnilab/warehouse/WifiSyslog' | ||
|
||
HDFS_HZ_MOBILE='/user/omnilab/warehouse/HzMobile' | ||
|
||
HDFS_D4D_SENEGAL='/user/omnilab/warehouse/Senegal' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
|
||
function clean_trash () { | ||
hadoop fs -rm -r .Trash/Current > /dev/null | ||
} | ||
|
||
function die () { | ||
echo "${@}" | ||
exit 1 | ||
} | ||
|
||
# Global vars | ||
BASEDIR=$(dirname $0)/.. | ||
source $BASEDIR/global_config.sh | ||
|
||
# Cleansing tools | ||
BINJAR=$BASEDIR/etlers/ArubaSyslog/target/scala-2.10/ArubaSyslog-assembly-1.0.jar | ||
CLSNAME="cn.edu.sjtu.omnilab.odh.spark.CleanseWifiLogs" | ||
|
||
TEMPWP=$HDFS_WIFI_SYSLOG/_temp | ||
hadoop fs -rm -r $TEMPWP | ||
hadoop fs -mkdir -p $TEMPWP | ||
|
||
# Process yesterday's file | ||
for rawfile in `ls $WIFI_SYSLOG_PATH`; do | ||
|
||
rfname=${rawfile%.*} | ||
|
||
year=`echo $rfname | cut -d "-" -f1 | sed -e 's/wifilog\([0-9]*\)/\1/g'` | ||
month=`echo $rfname | cut -d "-" -f2` | ||
day=`echo $rfname | cut -d "-" -f3` | ||
|
||
if [ $year$month$day == $(date -d "yesterday" '+%Y%m%d') ]; then | ||
|
||
if ! hadoop fs -test -e $HDFS_WIFI_SYSLOG/$rfname/_SUCCESS; then | ||
|
||
# Decompress file | ||
if ! hadoop fs -test -e $TEMPWP/$rfname; then | ||
gunzip -c $WIFI_SYSLOG_PATH/$rawfile | hadoop fs -put - $TEMPWP/$rfname | ||
fi | ||
|
||
# Cleanse wifilog | ||
hadoop fs -rm -r $HDFS_WIFI_SYSLOG/$rfname | ||
spark-submit2 --class $CLSNAME $BINJAR $TEMPWP/$rfname $HDFS_WIFI_SYSLOG/$rfname | ||
|
||
fi | ||
fi | ||
|
||
done | ||
|
||
hadoop fs -rm -r $TEMPWP | ||
|
||
clean_trash | ||
|
||
exit 0; |