多個文件服務(wù)器讀寫,這里可采用SMB協(xié)議
頁面靜態(tài)化,可采用freemarker開源框架
如果考慮到大量的讀寫請求,則將請求分布式或采用調(diào)度的辦法來解決
第一點我們首先應(yīng)該考慮文件服務(wù)器與靜態(tài)頁面的映射關(guān)系,即什么文件應(yīng)該讀寫到哪臺服務(wù)器,這個關(guān)系最簡單的辦法是隨機映射,然后將映射關(guān)系保存到數(shù)據(jù)庫中即可,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();
}
第二點,頁面靜態(tài)化可由freemarker生成,freemarker的使用比較簡單,我這里不再啰嗦,重復說了
第三點,調(diào)度中心,或把靜態(tài)化的請求先保存到Task中,然后通過調(diào)度中心異步執(zhí)行,可用我在博客中說道的另外一篇文章解決即可
您可能感興趣的文章:- 比較詳細的Asp偽靜態(tài)化方法及Asp靜態(tài)化探討
- 不用mod_rewrite直接用php實現(xiàn)偽靜態(tài)化頁面代碼
- 網(wǎng)頁的HTML靜態(tài)化_網(wǎng)站優(yōu)化之談
- php 靜態(tài)化實現(xiàn)代碼
- asp 網(wǎng)站靜態(tài)化函數(shù)代碼html
- nginx 偽靜態(tài)化rewrite規(guī)則
- ASP頁面靜態(tài)化批量生成代碼分享(多種方法)
- php靜態(tài)化頁面 htaccess寫法詳解(htaccess怎么寫?)
- smarty 緩存控制前的頁面靜態(tài)化原理
- aspx文件格式使用URLRewriter實現(xiàn)靜態(tài)化變成html
- php頁碼形式分頁函數(shù)支持靜態(tài)化地址及ajax分頁
- 使用ob系列函數(shù)實現(xiàn)PHP網(wǎng)站頁面靜態(tài)化
- 分享常見的幾種頁面靜態(tài)化的方法
- 如何對ASP.NET網(wǎng)站實現(xiàn)靜態(tài)化