三十八、一致性模型和nn、2nn工作机制

版权声明:本文为博主原创文章,未经博主允许欢迎转载,请注明原文链接。一起交流,共同进步。 https://blog.csdn.net/newbie_907486852/article/details/83069155

                                             一致性模型


1、一致性模型

@Test
public void writeFile() throws Exception{
	// 1 创建配置信息对象
	Configuration configuration = new Configuration();
	fs = FileSystem.get(configuration);
	
	// 2 创建文件输出流
	Path path = new Path("hdfs://hadoop102:9000/user/atguigu/hello.txt");
	FSDataOutputStream fos = fs.create(path);
	
	// 3 写数据
	fos.write("hello".getBytes());
       // 4 一致性刷新
	fos.hflush();
	
	fos.close();
}

总结:写入数据时,如果希望数据被其他client立即可见,调用如下方法

FsDataOutputStream. hflush ();		//清理客户端缓冲区数据,被其他client立即可见

猜你喜欢

转载自blog.csdn.net/newbie_907486852/article/details/83069155