2013-07-19 2 views
1

오프라인 사용자가 콘텐츠를 사용할 수있게하려는 appengine의 응용 프로그램을 만들고 있습니다. 즉, 사용 된 모든 blobstore 파일을 가져 와서 오프라인 사용자를 위해 저장해야합니다. 나는 그것을하기 위해서만 서버 측을 사용하고 있으므로 모든 최종 사용자가 한 번만 수행됩니다. 나는 쉽게 시간을 초과 할 수 있기 때문에이 과정을 실행하기 위해 작업 큐를 사용하고있다. 이 코드가 모두 태스크로 실행되고 있다고 가정합니다.Google Appengine JAVA-blobstore 파일을 압축하면 BLOBSTORE에 다시 저장하면 오류 202가 발생합니다.

소규모 컬렉션은 정상적으로 작동하지만 큰 컬렉션은 appengine 오류 202를 발생시키고 작업을 반복해서 다시 시작합니다. 다음은 Writing Zip Files to GAE Blobstore의 조합과 큰 zip 파일에 대한 조언 (Google Appengine JAVA - Zip lots of images saving in Blobstore)의 필요에 따라 채널을 다시 열어 샘플 코드입니다. 또한 AppEngine Error Code 202 - Task Queue을 오류로 참조했습니다.

//Set up the zip file that will be saved to the blobstore 
AppEngineFile assetFile = fileService.createNewBlobFile("application/zip", assetsZipName); 
FileWriteChannel writeChannel = fileService.openWriteChannel(assetFile, true); 
ZipOutputStream assetsZip = new ZipOutputStream(new BufferedOutputStream(Channels.newOutputStream(writeChannel))); 

HashSet<String> blobsEntries = getAllBlobEntries(); //gets blobs that I need 
saveBlobAssetsToZip(blobsEntries); 

writeChannel.closeFinally(); 

.....
private void saveBlobAssetsToZip(blobsEntries) throws IOException {   
    for (String blobId : blobsEntries) { 

     /*gets the blobstote key that will result in the blobstore entry - ignore the bsmd as 
     that is internal to our wrapper for blobstore.*/ 

     BlobKey blobKey = new BlobKey(bsmd.getBlobId()); 

     //gets the blob file as a byte array  
     byte[] blobData = blobstoreService.fetchData(blobKey, 0, BlobstoreService.MAX_BLOB_FETCH_SIZE-1); 
     String extension = type of file saved from our metadata (ie .jpg, .png, .pfd) 

     assetsZip.putNextEntry(new ZipEntry(blobId + "." + extension)); 

     assetsZip.write(blobData); 
     assetsZip.closeEntry(); 
     assetsZip.flush(); 

     /*I have found that if I don't close the channel and reopen it, I can get a IO exception 
     because the files in the blobstore are too large, thus the write a file and then close and reopen*/ 

     assetsZip.close(); 
     writeChannel.close(); 
     String assetsPath = assetFile.getFullPath(); 
     assetFile = new AppEngineFile(assetsPath); 
     writeChannel = fileService.openWriteChannel(assetFile, true); 
     assetsZip = new ZipOutputStream(new BufferedOutputStream(Channels.newOutputStream(writeChannel))); 

    } 
} 

이 AppEngine에에서 실행 얻을 수있는 적절한 방법은 무엇입니까

? 다시 작은 프로젝트가 잘 작동하고 zip 저장되지만 더 많은 blob 파일을 가진 더 큰 프로젝트가이 오류를 발생시킵니다.

+0

파일의 크기는 어느 정도입니까? –

+0

크기가 105 메가 바이트에 이릅니다. 어쩌면 내 인스턴스가 128 메가 바이트 밖에되지 않을 수도 있습니다. 감사. – Rod

답변

0

나는 인스턴스가 메모리가 부족하다고 생각한다. appstats를 사용하고 있습니까? 많은 양의 메모리를 소비 할 수 있습니다. 그래도 작동하지 않으면 인스턴스 크기를 늘려야 할 것입니다.