Search in sources :

Example 6 with NormalFileState

use of org.smartdata.model.NormalFileState in project SSM by Intel-bigdata.

the class MetaStore method getFileState.

/**
 * Get FileState of the given path.
 *
 * @param path
 * @return
 * @throws MetaStoreException
 */
public FileState getFileState(String path) throws MetaStoreException {
    FileState fileState;
    try {
        fileState = fileStateDao.getByPath(path);
        // Fetch info from corresponding table to regenerate a specific file state
        switch(fileState.getFileType()) {
            case NORMAL:
                fileState = new NormalFileState(path);
                break;
            case COMPACT:
                fileState = smallFileDao.getFileStateByPath(path);
                break;
            case COMPRESSION:
                CompressionFileState compressionFileState = getCompressionInfo(path);
                if (compressionFileState != null) {
                    compressionFileState.setFileStage(fileState.getFileStage());
                    fileState = compressionFileState;
                }
                break;
            case S3:
                fileState = new S3FileState(path);
                break;
            default:
        }
    } catch (EmptyResultDataAccessException e1) {
        fileState = new NormalFileState(path);
    } catch (Exception e2) {
        throw new MetaStoreException(e2);
    }
    return fileState;
}
Also used : S3FileState(org.smartdata.model.S3FileState) NormalFileState(org.smartdata.model.NormalFileState) CompactFileState(org.smartdata.model.CompactFileState) FileState(org.smartdata.model.FileState) CompressionFileState(org.smartdata.model.CompressionFileState) NormalFileState(org.smartdata.model.NormalFileState) CompressionFileState(org.smartdata.model.CompressionFileState) EmptyResultDataAccessException(org.springframework.dao.EmptyResultDataAccessException) S3FileState(org.smartdata.model.S3FileState) EmptyResultDataAccessException(org.springframework.dao.EmptyResultDataAccessException) SQLException(java.sql.SQLException)

Aggregations

NormalFileState (org.smartdata.model.NormalFileState)6 FileState (org.smartdata.model.FileState)5 CompressionFileState (org.smartdata.model.CompressionFileState)4 Test (org.junit.Test)3 CompactFileState (org.smartdata.model.CompactFileState)2 ConnectException (java.net.ConnectException)1 SQLException (java.sql.SQLException)1 SmartClient (org.smartdata.client.SmartClient)1 MetaStore (org.smartdata.metastore.MetaStore)1 S3FileState (org.smartdata.model.S3FileState)1 CompactFileStateProto (org.smartdata.protocol.ClientServerProto.CompactFileStateProto)1 CompressionFileStateProto (org.smartdata.protocol.ClientServerProto.CompressionFileStateProto)1 S3FileStateProto (org.smartdata.protocol.ClientServerProto.S3FileStateProto)1 SmartClientProtocol (org.smartdata.protocol.SmartClientProtocol)1 EmptyResultDataAccessException (org.springframework.dao.EmptyResultDataAccessException)1