diff options
author | Dileep Ranganathan <dileep.ranganathan@intel.com> | 2019-05-30 12:38:37 -0700 |
---|---|---|
committer | Dileep Ranganathan <dileep.ranganathan@intel.com> | 2019-05-30 21:11:52 +0000 |
commit | 3d5a3e06530c1250d48f7d838c619f3bfbcd019d (patch) | |
tree | 349e370c43ce7318b3f7eb7736345de6872cbef2 /vnfs/DAaaS/microservices/GoApps/src/hdfs-writer | |
parent | 31802660dfe74a8671ae29789f0018f0f887ea1a (diff) |
Refactor Distributed Analytics project structure
Modified the project structure to improve maintainability and to add future CI and
integration test support.
Change-Id: Id30bfb1f83f23785a6b5f99e81f42f752d59c0f8
Issue-ID: ONAPARC-280
Signed-off-by: Dileep Ranganathan <dileep.ranganathan@intel.com>
Diffstat (limited to 'vnfs/DAaaS/microservices/GoApps/src/hdfs-writer')
5 files changed, 117 insertions, 0 deletions
diff --git a/vnfs/DAaaS/microservices/GoApps/src/hdfs-writer/.gitignore b/vnfs/DAaaS/microservices/GoApps/src/hdfs-writer/.gitignore new file mode 100644 index 00000000..ad4781d2 --- /dev/null +++ b/vnfs/DAaaS/microservices/GoApps/src/hdfs-writer/.gitignore @@ -0,0 +1,40 @@ +# Common +.DS_Store +.vscode +*-workspace +.tox/ +.*.swp +*.log +coverage.html +docs/build +.Makefile.bk + +# Directories +pkg +bin +target +src/github.com +src/golang.org +src/k8splugin/vendor +src/k8splugin/.vendor-new/ +src/k8splugin/kubeconfig/* +deployments/k8plugin + +# Binaries +*.so +src/k8splugin/csar/mock_plugins/*.so +src/k8splugin/plugins/**/*.so + +# Tests +*.test +*.out + +# KRD +.vagrant/ +kud/hosting_providers/vagrant/inventory/hosts.ini +kud/hosting_providers/vagrant/inventory/artifacts +kud/hosting_providers/vagrant/inventory/group_vars/all.yml +kud/hosting_providers/vagrant/config/pdf.yml +kud/hosting_providers/vagrant/sources.list +*.retry +*.vdi
\ No newline at end of file diff --git a/vnfs/DAaaS/microservices/GoApps/src/hdfs-writer/Makefile b/vnfs/DAaaS/microservices/GoApps/src/hdfs-writer/Makefile new file mode 100644 index 00000000..e3f21405 --- /dev/null +++ b/vnfs/DAaaS/microservices/GoApps/src/hdfs-writer/Makefile @@ -0,0 +1,35 @@ +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2019 Intel Corporation +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +GOPATH := $(shell realpath "$(PWD)/../../") +#export GOPATH=/Users/rajamoha/projects/demo/vnfs/DAaaS/GoApps +export GOPATH ... +export GO111MODULE=on + + + +all: + echo $$GOPATH + GOOS=linux GOARCH=amd64 + @go build -tags netgo -o ./bin/hdfs-writer ./cmd/main.go + +build: + echo $$GOPATH + GOOS=linux GOARCH=amd64 + @go build -tags netgo -o ./bin/hdfs-writer ./cmd/main.go + +.PHONY: format +format: + @go fmt ./... + +.PHONY: clean +clean: + @find . -name "*so" -delete + @rm -f ./bin/hdfs-writer diff --git a/vnfs/DAaaS/microservices/GoApps/src/hdfs-writer/README.md b/vnfs/DAaaS/microservices/GoApps/src/hdfs-writer/README.md new file mode 100644 index 00000000..453b842d --- /dev/null +++ b/vnfs/DAaaS/microservices/GoApps/src/hdfs-writer/README.md @@ -0,0 +1,14 @@ +<!-- Copyright 2019 Intel Corporation. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. --> + +# HDFS-writer + +Read a topic in kafka and write into HDFS directory.
\ No newline at end of file diff --git a/vnfs/DAaaS/microservices/GoApps/src/hdfs-writer/cmd/main.go b/vnfs/DAaaS/microservices/GoApps/src/hdfs-writer/cmd/main.go new file mode 100644 index 00000000..11350f0b --- /dev/null +++ b/vnfs/DAaaS/microservices/GoApps/src/hdfs-writer/cmd/main.go @@ -0,0 +1,25 @@ +package main + +import ( + "os" + "fmt" + "log" + "github.com/colinmarc/hdfs/v2" +) + +func main() { + log.Println("Starting the HDFS writer") + localSourceFile := os.Args[1] + hdfsDestination := os.Args[2] + + log.Println("localSourceFile:: "+localSourceFile) + log.Println("hdfsDestination:: "+hdfsDestination) + + client, _ := hdfs.New("hdfs://hdfs-1-namenode-1.hdfs-1-namenode.hdfs1.svc.cluster.local:8020") + file, _ := client.Open("/kafka.txt") + + buf := make([]byte, 59) + file.ReadAt(buf, 48847) + fmt.Println(string(buf)) + +} diff --git a/vnfs/DAaaS/microservices/GoApps/src/hdfs-writer/go.mod b/vnfs/DAaaS/microservices/GoApps/src/hdfs-writer/go.mod new file mode 100644 index 00000000..b2855127 --- /dev/null +++ b/vnfs/DAaaS/microservices/GoApps/src/hdfs-writer/go.mod @@ -0,0 +1,3 @@ +module hdfs-writer + +require github.com/colinmarc/hdfs/v2 v2.0.0 // indirect |