import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.Path;
import java.io.IOException;
public class HdfsClient {
public static void main(String[] args) {
try {
// Hadoop 설정
Configuration conf = new Configuration();
conf.set("fs.defaultFS", "hdfs://localhost:9000"); // HDFS 주소 설정
// HDFS에 연결
FileSystem fs = FileSystem.get(conf);
// 파일 및 디렉토리 목록 가져오기
FileStatus[] fileStatuses = fs.listStatus(new Path("/")); // HDFS 경로 설정
// 가져온 목록 출력
for (FileStatus status : fileStatuses) {
System.out.println(status.getPath().toString());
}
// 연결 종료
fs.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
================pom.xml=========================
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>3.3.1</version>
</dependency>
=======================
<template>
<div>
<select v-model="selectedItem">
<!-- 리스트 박스 옵션 -->
<option v-for="item in dataList" :value="item.id">{{ item.name }}</option>
</select>
<button @click="sendData">전송</button>
</div>
</template>
<script>
import axios from 'axios';
export default {
data() {
return {
dataList: [], // 서버에서 받은 데이터를 저장하는 배열
selectedItem: null // 선택된 항목의 값
};
},
mounted() {
// 서버에서 데이터를 가져오는 요청
axios.get('http://your-server/api/data')
.then(response => {
// 서버에서 받은 데이터를 dataList 배열에 저장
this.dataList = response.data;
})
.catch(error => {
console.error('Error fetching data:', error);
});
},
methods: {
sendData() {
// 선택된 값을 서버로 전송
axios.post('http://your-server/api/selected-data', { selectedItemId: this.selectedItem })
.then(response => {
console.log('Data sent successfully:', response.data);
// 서버로부터 받은 응답에 대한 처리
})
.catch(error => {
console.error('Error sending data:', error);
// 에러 처리
});
}
}
};
</script>
'직장' 카테고리의 다른 글
스마트폰바탕화면 (0) | 2024.04.30 |
---|---|
도전이 없는 삶 (0) | 2024.04.16 |
봄이 왔다 명이 나물 이야길 들었다. (0) | 2024.03.31 |
세어하우스할때 꼭 ㅡ 전세시세주의 (0) | 2024.03.18 |
스스로를 용서하라 (1) | 2024.03.01 |