25 lines
987 B
Python
Executable File
25 lines
987 B
Python
Executable File
"""Salin data mentah hasil ingestion (lokal) ke HDFS: data/raw -> hdfs://.../raw.
|
|
Jika STORAGE_BASE lokal, tidak ada yang perlu disalin."""
|
|
import config
|
|
from spark_jobs.session import get_spark
|
|
|
|
|
|
def main():
|
|
if not config.is_remote():
|
|
print(f"STORAGE_BASE lokal ({config.STORAGE_BASE}); raw sudah berada di {config.RAW_LOCAL_DIR}. Lewati.")
|
|
return
|
|
spark = get_spark("karhutla-upload-raw")
|
|
jvm = spark._jvm
|
|
conf = spark._jsc.hadoopConfiguration()
|
|
dest = config.uri("raw")
|
|
fs = jvm.org.apache.hadoop.fs.FileSystem.get(jvm.java.net.URI(dest), conf)
|
|
# overwrite=True agar idempoten; file raw berisi run_id unik sehingga data lama tidak hilang di sumber lokal
|
|
fs.copyFromLocalFile(False, True, jvm.org.apache.hadoop.fs.Path("file://" + str(config.RAW_LOCAL_DIR)),
|
|
jvm.org.apache.hadoop.fs.Path(dest))
|
|
print(f"raw disalin: {config.RAW_LOCAL_DIR} -> {dest}")
|
|
spark.stop()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|