0

使用可能なすべてのファイルストアが宣言されているマップを更新しているスレッドがあります。利用できるようにするには、ファイルストアが"online"で、サイズが である必要があります< 500MB。ファイルストアが 500MB の制限に達すると、彼の番に"Read Only"なり、新しいファイルストアが作成されます。その部分はOKです。

メイン スレッドは、マップ上で使用可能なファイルストアに基づいて、すべての新しいドキュメントにファイルストアを関連付けています。しかし、ドキュメントがファイルストアにリンクされている場合を処理したいと思います。たとえば、filestore_01属性とsave()メソッドの間で、filestore_01は 2 番目のスレッドによって更新され"Read Only"

そのため、catch を配置し、エラー コードに対してテストを実行して、エラーが発生した場合にドキュメントに対して新しいコンピューティング ストレージを起動します。問題は、「新しい」ファイルストアがドキュメントにリンクされているように見える場合でも、save()Documentum がドキュメントを元のファイルストアに保存しようとする方法を思い出すと、filestore_01.

すべてを DFC 経由で行いますMIGRATE_JOB。ドキュメントが新しく、今のところ保存されていないため、 を使用できません。

誰にもアイデアがありますか?

コードは次のとおりです。

    //Save the document
try {
    doc.save();
    DfLogger.info(ListenerCreateDocumentOperation.class, "Created document with id '" + doc.getObjectId().getId() + "' and serie '" + serialId + "'", null, null);


     } catch (DfException e) {
                     //if filestore is readonly
        if(e.getErrorCode()==256) {
            StorageService.getInstance().updateFileStoresArray(); //force to update the filestores map

            try {                   
                doc.computeStorageType(); //recompute the filestore where the doc will be save
                doc.save(); //save the document

                DfLogger.info(ListenerCreateDocumentOperation.class, "Created document with id '" + doc.getObjectId().getId() + "'", null, null);
            } catch (Exception e2) {
                e.printStackTrace();
                throw new DfException("Error - Transaction aborted for XML : " + process.getXmlPath());
            }
        }
        e.printStackTrace();

最初のcomputeStorage()呼び出しはsetFile()DFC メソッド内で、PDF をドキュメントにリンクします。

そして、ファイルストア マップが更新される 2 番目のスレッド (約 5 秒ごとに実行) は、次の関数を起動します。

    public void updateFileStoresArray() {       
        LOGGER.info(StorageService.class+" updating filestore array");
        IDfSession s0 = null;
        try {
            FILESTORE_ARRAY.clear();
            s0 = getDctmSessionManager().getSession(getRepository());               
            s0.addDynamicGroup("dm_superusers_dynamic");
            getAllFileStores(s0);
            for(int i=0; i<FILESTORE_ARRAY.size(); i++) {
                try {
                    IDfFileStore currentFileStore = FILESTORE_ARRAY.get(i);
                    if(currentFileStore.getCurrentUse()/1000000 >= max_size) {
                        LOGGER.info("Filestore "+currentFileStore.getName()+" is full, he'll be set in readonly mode and a new dm_filestore will be create");
                        FILESTORE_ARRAY.remove(i);
                        IDfQuery batchList = new DfQuery();
                        batchList.setDQL("execute set_storage_state with store = '"+currentFileStore.getName()+"', readonly=true");
                        batchList.execute(s0, IDfQuery.DF_QUERY);
                        IDfFileStore filestore = createNewFilestore(s0);
                        FILESTORE_ARRAY.add(filestore);                 
                    }
                } catch (Exception e) {
                    DfLogger.error(StorageService.class, "Error in execute()", null, e);
                    e.printStackTrace();
                }
            }
            if(FILESTORE_ARRAY.size()==0) {
                LOGGER.info("Recomputing");
                createNewFilestore(s0);
            }
        }
        catch (DfException e1) {

            e1.printStackTrace();
        } 
        finally {
            if (s0 != null) {
                getDctmSessionManager().release(s0);
            }
        }
    }

そして、ここにcomputeStorage()方法があります:

public void computeStorageType() throws DfException {
    if(getStorageType()==null || getStorageType().equals("filestore_01") || Utils.isNullString(getStorageType())) {
        getSession().addDynamicGroup("dm_superusers_dynamic");
        String storageType=null;
        StorageService.getInstance();
        storageType = StorageService.computeStorage(getSession(), this);        
        if(getStorageType()==null || !getStorageType().equals(storageType)) {
            setStorageType(storageType);    
        }
        getSession().removeDynamicGroup("dm_superusers_dynamic");
    }   
}

public static String computeStorage(IDfSession s0, IGenericAspect vfkGenericDocumentAspect) throws DfException {

    String result = null;

    try {
        if(FILESTORE_ARRAY.size()==0) {
            getAllFileStores(s0);
        }           
        if(FILESTORE_ARRAY.size()==0) {
            createNewFilestore(s0);
            getAllFileStores(s0);
        }

        IDfFileStore filestore = FILESTORE_ARRAY.get(currentFileStoreIndex);

        if(filestore.getStatus()==2 || filestore.getStatus()==1) {
            if(currentFileStoreIndex+1<FILESTORE_ARRAY.size() && FILESTORE_ARRAY.get(currentFileStoreIndex+1)!=null) {
                currentFileStoreIndex=currentFileStoreIndex+1;
                filestore = FILESTORE_ARRAY.get(currentFileStoreIndex);
            }

        }
        result= filestore.getName();

        LOGGER.info("Document "+vfkGenericDocumentAspect.getObjectId()+" will be store in filestore "+result);

        if(currentFileStoreIndex+1<FILESTORE_ARRAY.size())
            currentFileStoreIndex=currentFileStoreIndex+1;
        else
            currentFileStoreIndex=0;



    } catch(Exception e) {
        DfLogger.error(StorageService.class, "Error in execute()", null, e);
        e.printStackTrace();
    }

    return result;
}
4

0 に答える 0