mogilefs文件系统TestCase
来源:互联网 发布:冰川网络vr游戏 编辑:程序博客网 时间:2024/05/24 01:08
mogilefs文件系统TestCase
去年架设了mogilefs文件系统,采用主从式双机(程序只访问主机,主机会自动将文件同步到从机上),运行一年多以来比较稳定。于是,前期有个涉及附件(主要是word等office文档)上传、下载的项目也打算采用mogilefs文件系统。由于mogilefs文件系统服务器进行了严格的IP地址和端口控制,因此为了访问mogilefs文件系统服务器就必须开通IP地址和端口访问权限。为此,我给几个开发人员申请了相应的访问权限,但是发布成web应用测试的时候,老是程序报错,无奈又给写了一个最简单的mogilefs文件TestCase。
/**
* bighrose
*/
package com.mogilefs;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.junit.Test;
import com.guba.mogilefs.PooledMogileFSImpl;
import com.guba.mogilefs.MogileFS;
public class TestMogileFS{
private String domain = "tstdomain";
private String server = "ip:6001";
private String storageClass = "tstclass";
private String fileName = "d://ADempiere_new.pdf";
// @Test
//上传文件
public void testUpload(){
try{
MogileFS mfs = new PooledMogileFSImpl(domain,
new String[] { server }, 0, 1, 10000);
File file = new File("d://ADempiere.pdf");
if(file.exists()){
String fileKey = "ADempiere"+System.currentTimeMillis()+".pdf";
OutputStream out = mfs.newFile(fileKey, storageClass, file.length());
FileInputStream in = new FileInputStream(file);
byte[] buffer = new byte[1024];
int count = 0;
while ((count = in.read(buffer)) >= 0) {
out.write(buffer, 0, count);
}
in.close();
out.close();
System.out.println("fileKey: "+fileKey);
}
System.out.println("upload file sucessed!");
}catch(Exception e){
e.printStackTrace();
}
}
@Test
public void testGetFile(){
try{
MogileFS mfs = new PooledMogileFSImpl(domain,
new String[] { server }, 0, 1, 10000);
byte[] content = mfs.getFileBytes("ADempiere1264139404773.pdf");
FileOutputStream fos=null;
try{
fos=new FileOutputStream(fileName,true);
fos.write(content);
fos.flush();
}catch(Exception e){
e.printStackTrace();
}
finally{
try{
fos.close();
}catch(IOException iex){}
}
System.out.println("Get file sucessed! "+fileName);
}catch(Exception e){
e.printStackTrace();
}
}
}
- mogilefs文件系统TestCase
- 分布式文件系统之MogileFS
- 分布式文件系统MogileFS简介
- 分布式文件系统 MogileFS 安装手册
- 分布式文件系统 MogileFS 安装手册
- 分布式文件系统 MogileFS 安装手册
- 分布式文件系统 Mogilefs 安装步骤
- MogileFS一个开源的分布式文件系统
- 开源分布式文件系统 MogileFS 和 FastDFS
- mogilefs
- mogilefs
- TestCase
- TestCase
- 开源分布式文件系统FastDFS和MogileFS - [Linux]
- 开源分布式文件系统FastDFS 和 MogileFS
- CentOS 6.5 分布式文件系统之MogileFS工作原理及实现过程
- 一些流行的分布式文件系统(Hadoop、Lustre、MogileFS、FreeNAS、FastDFS、GoogleFS)
- centos 6.5环境下分布式文件系统MogileFS工作原理及分布式部署实现过程
- 稍后等于永久
- mysql缓存参数
- 关于MySQL的查询缓存
- 如何使用离线博客发布工具发布CSDN的博客文章
- WTL出现GUID错误 Did you forget to pass the LIBID to CComModule::Init?
- mogilefs文件系统TestCase
- vector
- Stardict
- 【转】 oracle临时表-优化查询速度
- 支持 FF 的实时时间显示
- linux PS1 提示符定义
- [ZT]高调忽悠低调富强
- 医生比病人更了解疾病的危险
- 从瀑布模型、极限编程到敏捷开发