#!/bin/bash

time=$1

echo "data time is "${time}

year=${time:0:4}

month=${time:4:2}

day=${time:6:2}

canDir=/spark/nrmv_can/

canYearDir=${canDir}${year}

hadoop fs -fs hdfs://nameservice1 -test -e ${canYearDir}

if [ $? -ne 0 ] ; then
  hadoop fs -fs hdfs://nameservice1 -mkdir ${canYearDir}
fi

canMonthDir=${canYearDir}"/"${month}

hadoop fs -fs hdfs://nameservice1 -test -e ${canMonthDir}

if [ $? -ne 0 ] ; then
  hadoop fs -fs hdfs://nameservice1 -mkdir ${canMonthDir}
fi

canDayDir=${canMonthDir}"/"${day}

echo "can dir is "${canDayDir}

hadoop fs -fs hdfs://nameservice1 -test -e ${canDayDir}

if [ $? -ne 0 ] ; then
  hadoop fs -fs hdfs://nameservice1 -mkdir ${canDayDir}
fi
