유 니 버 설 대형 사이트 페이지 정적 화 솔 루 션

여러 파일 서버 의 읽 기와 쓰 기 는 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 에 저장 합 니 다.그리고 스케줄 러 센터 를 통 해 비동기 적 으로 실행 하면 제 가 블 로그 에서 말 한 다른 글 로 해결 하면 됩 니 다.

좋은 웹페이지 즐겨찾기