Search in sources :

Example 6 with Part

use of com.pspace.ifs.ksan.gw.object.multipart.Part in project ksan by infinistor.

the class S3ObjectOperation method abortMultipart.

public void abortMultipart(SortedMap<Integer, Part> listPart) throws GWException {
    try {
        for (Iterator<Map.Entry<Integer, Part>> it = listPart.entrySet().iterator(); it.hasNext(); ) {
            Map.Entry<Integer, Part> entry = it.next();
            logger.info("key : {}, diskId : {}", entry.getKey(), objMeta.getPrimaryDisk().getId());
            if (GWDiskConfig.getInstance().getLocalDiskID().equals(entry.getValue().getDiskID())) {
                // part is in local disk
                File partFile = new File(makeTempPath(GWDiskConfig.getInstance().getLocalPath(), objMeta.getObjId(), String.valueOf(entry.getValue().getPartNumber())));
                partFile.delete();
            } else {
                String host = GWDiskConfig.getInstance().getOSDIP(entry.getValue().getDiskID());
                OSDClient client = OSDClientManager.getInstance().getOSDClient(host);
                client.deletePart(objMeta.getPrimaryDisk().getPath(), objMeta.getObjId(), s3Parameter.getPartNumber());
                OSDClientManager.getInstance().returnOSDClient(client);
            }
        }
    } catch (Exception e) {
        PrintStack.logging(logger, e);
        throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
    }
}
Also used : OSDClient(com.pspace.ifs.ksan.gw.object.osdclient.OSDClient) Part(com.pspace.ifs.ksan.gw.object.multipart.Part) GWException(com.pspace.ifs.ksan.gw.exception.GWException) Map(java.util.Map) SortedMap(java.util.SortedMap) File(java.io.File) GWException(com.pspace.ifs.ksan.gw.exception.GWException) ResourceNotFoundException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 7 with Part

use of com.pspace.ifs.ksan.gw.object.multipart.Part in project ksan by infinistor.

the class MongoDataRepository method getParts.

// SELECT changeTime, etag, size, partNo FROM MULTIPARTS WHERE uploadid=? AND partNo > ? ORDER BY partNo LIMIT ?")
@Override
public ResultParts getParts(String uploadId, int partNumberMarker, int maxParts) throws SQLException {
    MongoCollection<Document> multip;
    ResultParts resultParts = new ResultParts(uploadId, maxParts);
    resultParts.setListPart(new TreeMap<>());
    multip = getMultiPartUploadCollection();
    if (multip == null)
        return resultParts;
    BasicDBObject sortList = new BasicDBObject(PARTNO, 1);
    FindIterable fit = multip.find(Filters.and(Filters.eq(UPLOADID, uploadId), Filters.gt(PARTNO, partNumberMarker))).limit(maxParts + 1).sort(sortList);
    Iterator it = fit.iterator();
    int count = 0;
    resultParts.setTruncated(false);
    while ((it.hasNext())) {
        Document doc = (Document) it.next();
        count++;
        if (count > maxParts) {
            resultParts.setPartNumberMarker(doc.getString(PARTNO));
            resultParts.setTruncated(true);
            break;
        }
        Part part = new Part();
        part.setLastModified((Date) doc.getDate(LASTMODIFIED));
        part.setPartETag(doc.getString(ETAG));
        part.setPartSize(doc.getLong(SIZE));
        part.setPartNumber(doc.getInteger(PARTNO));
        part.setDiskID(PDISKID);
        resultParts.getListPart().put(part.getPartNumber(), part);
    }
    return resultParts;
}
Also used : BasicDBObject(com.mongodb.BasicDBObject) Part(com.pspace.ifs.ksan.gw.object.multipart.Part) Iterator(java.util.Iterator) ResultParts(com.pspace.ifs.ksan.gw.object.multipart.ResultParts) FindIterable(com.mongodb.client.FindIterable) Document(org.bson.Document)

Example 8 with Part

use of com.pspace.ifs.ksan.gw.object.multipart.Part in project ksan by infinistor.

the class MysqlDataRepository method getParts.

// TO BE
@Override
public SortedMap<Integer, Part> getParts(String uploadId) throws SQLException {
    SortedMap<Integer, Part> listPart = new TreeMap<>();
    this.pstGetParts.clearParameters();
    this.pstGetParts.setString(1, uploadId);
    ResultSet rs = this.pstGetParts.executeQuery();
    while (rs.next()) {
        Part part = new Part();
        part.setLastModified((Date) rs.getObject(1));
        part.setPartETag(rs.getString(2));
        part.setPartSize(rs.getLong(3));
        part.setPartNumber(rs.getInt(4));
        part.setDiskID(rs.getString(5));
        listPart.put(part.getPartNumber(), part);
    }
    return listPart;
}
Also used : Part(com.pspace.ifs.ksan.gw.object.multipart.Part) TreeMap(java.util.TreeMap)

Example 9 with Part

use of com.pspace.ifs.ksan.gw.object.multipart.Part in project ksan by infinistor.

the class MysqlDataRepository method getParts.

// TO BE
@Override
public ResultParts getParts(String uploadId, int partNumberMarker, int maxParts) throws SQLException {
    ResultParts resultParts = new ResultParts(uploadId, maxParts);
    resultParts.setListPart(new TreeMap<Integer, Part>());
    pstGetPartsMax.clearParameters();
    pstGetPartsMax.setString(1, uploadId);
    /*if (Strings.isNullOrEmpty(partNumberMarker)) {
            pstGetPartsMax.setInt(2, 0);
        } else*/
    {
        pstGetPartsMax.setInt(2, Integer.valueOf(partNumberMarker));
    }
    pstGetPartsMax.setInt(3, maxParts + 1);
    ResultSet rs = pstGetPartsMax.executeQuery();
    resultParts.setTruncated(false);
    int count = 0;
    while (rs.next()) {
        count++;
        if (count > maxParts) {
            resultParts.setPartNumberMarker(String.valueOf(rs.getInt(4)));
            resultParts.setTruncated(true);
            break;
        }
        Part part = new Part();
        part.setLastModified((Date) rs.getObject(1));
        part.setPartETag(rs.getString(2));
        part.setPartSize(rs.getLong(3));
        part.setPartNumber(rs.getInt(4));
        part.setDiskID(rs.getString(5));
        resultParts.getListPart().put(part.getPartNumber(), part);
    }
    return resultParts;
}
Also used : Part(com.pspace.ifs.ksan.gw.object.multipart.Part) ResultParts(com.pspace.ifs.ksan.gw.object.multipart.ResultParts)

Aggregations

Part (com.pspace.ifs.ksan.gw.object.multipart.Part)9 GWException (com.pspace.ifs.ksan.gw.exception.GWException)4 Map (java.util.Map)4 S3Bucket (com.pspace.ifs.ksan.gw.identity.S3Bucket)3 Multipart (com.pspace.ifs.ksan.gw.object.multipart.Multipart)3 ResultParts (com.pspace.ifs.ksan.gw.object.multipart.ResultParts)3 ObjMultipart (com.pspace.ifs.ksan.objmanager.ObjMultipart)3 IOException (java.io.IOException)3 SortedMap (java.util.SortedMap)3 TreeMap (java.util.TreeMap)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 FindIterable (com.mongodb.client.FindIterable)2 S3Metadata (com.pspace.ifs.ksan.gw.identity.S3Metadata)2 S3ObjectOperation (com.pspace.ifs.ksan.gw.object.S3ObjectOperation)2 OSDClient (com.pspace.ifs.ksan.gw.object.osdclient.OSDClient)2 Metadata (com.pspace.ifs.ksan.objmanager.Metadata)2 ResourceNotFoundException (com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException)2 File (java.io.File)2