无为清净楼资源网 Design By www.qnjia.com
多个文件服务器读写,这里可采用SMB协议
页面静态化,可采用freemarker开源框架
如果考虑到大量的读写请求,则将请求分布式或采用调度的办法来解决
第一点我们首先应该考虑文件服务器与静态页面的映射关系,即什么文件应该读写到哪台服务器,这个关系最简单的办法是随机映射,然后将映射关系保存到数据库中即可,SMB常用的操作代码如下:
复制代码 代码如下:
public static boolean exists(String filepath,String username,String pwd) throws Exception
{
SmbFile file = new SmbFile("smb://"+username+":"+pwd+"@"+filepath);
try{
return file.exists();
}catch(Exception ex){
return false;
}
}
public static boolean fileRename(String filepath,String newFilename,String username,String pwd)
{
try{
SmbFile f=new SmbFile("smb://"+username+":"+pwd+"@"+filepath);
if(f.isFile()){
String str=filepath.substring(0,filepath.lastIndexOf("/"));
str="smb://"+username+":"+pwd+"@"+str+"/"+newFilename;
f.renameTo(new SmbFile(str));
}else if(f.isDirectory()){
String str=filepath.substring(0,filepath.length()-1);
str=filepath.substring(0,str.lastIndexOf("/"));
str="smb://"+username+":"+pwd+"@"+str+"/"+newFilename;
f.renameTo(new SmbFile(str));
}
return true;
}catch(Exception ex){
return false;
}
}
public static void mkdir(String dir,String username,String pwd)
{
try{
SmbFile f=new SmbFile("smb://"+username+":"+pwd+"@"+dir);
if(!f.exists())
f.mkdir();
}catch(Exception ex)
{
}
}
public static void mkfile(String filepath,String username,String pwd)
{
try
{
SmbFile f=new SmbFile("smb://"+username+":"+pwd+"@"+filepath);
if(!f.exists())
f.createNewFile();
}catch(Exception ex)
{
}
}
public static void mkfile(String filepath,String username,String pwd,String content)
{
try
{
SmbFile f=new SmbFile("smb://"+username+":"+pwd+"@"+filepath);
if(!f.exists())
f.createNewFile();
writeFile(filepath,content,username,pwd);
}catch(Exception ex)
{
}
}
public static boolean isdir(String filepath,String username,String pwd) throws Exception
{
String dir="smb://"+username+":"+pwd+"@"+filepath;
SmbFile f=new SmbFile(dir);
return f.isDirectory();
}
第二点,页面静态化可由freemarker生成,freemarker的使用比较简单,我这里不再啰嗦,重复说了
第三点,调度中心,或把静态化的请求先保存到Task中,然后通过调度中心异步执行,可用我在博客中说道的另外一篇文章解决即可
页面静态化,可采用freemarker开源框架
如果考虑到大量的读写请求,则将请求分布式或采用调度的办法来解决
第一点我们首先应该考虑文件服务器与静态页面的映射关系,即什么文件应该读写到哪台服务器,这个关系最简单的办法是随机映射,然后将映射关系保存到数据库中即可,SMB常用的操作代码如下:
复制代码 代码如下:
public static boolean exists(String filepath,String username,String pwd) throws Exception
{
SmbFile file = new SmbFile("smb://"+username+":"+pwd+"@"+filepath);
try{
return file.exists();
}catch(Exception ex){
return false;
}
}
public static boolean fileRename(String filepath,String newFilename,String username,String pwd)
{
try{
SmbFile f=new SmbFile("smb://"+username+":"+pwd+"@"+filepath);
if(f.isFile()){
String str=filepath.substring(0,filepath.lastIndexOf("/"));
str="smb://"+username+":"+pwd+"@"+str+"/"+newFilename;
f.renameTo(new SmbFile(str));
}else if(f.isDirectory()){
String str=filepath.substring(0,filepath.length()-1);
str=filepath.substring(0,str.lastIndexOf("/"));
str="smb://"+username+":"+pwd+"@"+str+"/"+newFilename;
f.renameTo(new SmbFile(str));
}
return true;
}catch(Exception ex){
return false;
}
}
public static void mkdir(String dir,String username,String pwd)
{
try{
SmbFile f=new SmbFile("smb://"+username+":"+pwd+"@"+dir);
if(!f.exists())
f.mkdir();
}catch(Exception ex)
{
}
}
public static void mkfile(String filepath,String username,String pwd)
{
try
{
SmbFile f=new SmbFile("smb://"+username+":"+pwd+"@"+filepath);
if(!f.exists())
f.createNewFile();
}catch(Exception ex)
{
}
}
public static void mkfile(String filepath,String username,String pwd,String content)
{
try
{
SmbFile f=new SmbFile("smb://"+username+":"+pwd+"@"+filepath);
if(!f.exists())
f.createNewFile();
writeFile(filepath,content,username,pwd);
}catch(Exception ex)
{
}
}
public static boolean isdir(String filepath,String username,String pwd) throws Exception
{
String dir="smb://"+username+":"+pwd+"@"+filepath;
SmbFile f=new SmbFile(dir);
return f.isDirectory();
}
第二点,页面静态化可由freemarker生成,freemarker的使用比较简单,我这里不再啰嗦,重复说了
第三点,调度中心,或把静态化的请求先保存到Task中,然后通过调度中心异步执行,可用我在博客中说道的另外一篇文章解决即可
标签:
大型网站,页面,静态化
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年09月20日
2024年09月20日
- 《神话时代:重述版》评测:粉丝们的朝花夕拾
- 战锤40K星际战士2先锋职业介绍|先锋职业技能效果一览
- 战锤40K星际战士2重装职业介绍|重装职业技能效果一览
- 交错战线能源发电站推荐角色一览
- 阿波罗乐神之音《第4集出埃及记》[WAV+CUE]
- JohnWrightTrio-SouthSideSoul-1960-2024(24-192)
- AnthonyBruno-Cefalu(2024)[24-96]
- 《地狱潜者2》玩家人数飙升:终于不再削弱玩家了
- 黑神话引力!外媒分享孙悟空英文书籍:美生中国人等
- 《荒野大镖客》PC版曝光!《GTA6》疑似也有PC版
- 林宥嘉.2008-神秘嘉宾(引进版)【华研国际】【WAV+CUE】
- 徐小凤.1997-金曲精选(康艺经典珍藏系列)【康艺成音】【WAV+CUE】
- 群星.1994-非常精丫宝丽金】【WAV+CUE】
- 《赛马娘 热血喧闹大感谢祭!》评测:现代复古派对
- 《星球大战:亡命之徒》评测:还是看看远方的光剑吧