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);
}
}
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;
}
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;
}
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;
}
Aggregations