use of com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException in project ksan by infinistor.
the class ObjManager method close.
public int close(String bucketName, String path, Metadata mt) throws ResourceNotFoundException {
Bucket bt;
try {
bt = getBucket(bucketName);
} catch (SQLException ex) {
throw new ResourceNotFoundException("Bucket(" + bucketName + ") not exist ! >" + ex);
}
if (bt == null)
throw new ResourceNotFoundException("Bucket(" + bucketName + ") not exist!");
try {
Metadata mtd = dbm.selectSingleObject(bt.getDiskPoolId(), bucketName, path);
if (!bt.getVersioning().equalsIgnoreCase("Enabled"))
dbm.deleteObject(bucketName, path, "null");
} catch (ResourceNotFoundException ex) {
}
if (!obmCache.isDiskSeparatedAndValid(bt.getDiskPoolId(), mt)) {
String err = String.format("Bucket : %s key : %s disk information pdiskid : %s rdiskid : %s is not separated or not exist in the syystem", bucketName, path, mt.getPrimaryDisk().getId(), mt.isReplicaExist() ? mt.getReplicaDisk().getId() : "");
logger.debug(err);
throw new InvalidParameterException(err);
}
// System.out.format("[close ] bucket : %s path : %s objid : %s\n", mt.getBucket(), mt.getPath(), mt.getObjId());
// to update last modified time to now
mt.updateLastmodified();
return dbm.insertObject(mt);
}
use of com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException in project ksan by infinistor.
the class ObjManager method replaceDisk.
/**
* Replace replica disk with new one after recovery
* @param bucketName bucket name
* @param objid object id
* @param pdiskid primary disk id
* @param rdiskid new replica disk id
* @return -1 if it is failed, 0 if nothing is updated or 1 if it is successful
* @throws ResourceNotFoundException if the disk provided is not valid or exist in the system
*/
public int replaceDisk(String bucketName, String objid, String pdiskid, String rdiskid) throws ResourceNotFoundException {
String diskpoolid;
DISK primary;
DISK replica;
Bucket bt;
try {
bt = getBucket(bucketName);
} catch (SQLException ex) {
throw new ResourceNotFoundException("unable to get buckt " + bucketName + " in the system!");
}
diskpoolid = bt.getDiskPoolId();
primary = obmCache.getDiskWithId(diskpoolid, pdiskid);
replica = obmCache.getDiskWithId(diskpoolid, rdiskid);
logger.debug(" PRIMARY > " + pdiskid + ", " + primary + " REPLICA >" + rdiskid + " ," + replica);
Metadata md = new Metadata();
md.setObjid(objid);
md.setPrimaryDisk(primary);
md.setReplicaDISK(replica);
return dbm.updateDisks(md);
}
use of com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException in project ksan by infinistor.
the class ObjManager method createCopy.
/**
* Return the same primary and replica disk to copy the the object and reside in the same osd.
* @param bucket bucket name
* @param toBucket bucket name of destination
* @param from key of the source metadata
* @param to key of the destination metadata
* @param versionId version id of the source object
* @return a basics of metadata object with allocated disk information
* @throws IOException
* @throws AllServiceOfflineException
* @throws ResourceNotFoundException
*/
public Metadata createCopy(String bucket, String from, String versionId, String toBucket, String to) throws IOException, AllServiceOfflineException, ResourceNotFoundException, SQLException {
Metadata mt;
Metadata cpy_mt;
Bucket bt = getBucket(bucket);
mt = dbm.selectSingleObject(bt.getDiskPoolId(), bucket, from, versionId);
if (mt == null)
throw new ResourceNotFoundException("Bucket(" + bucket + ") and key(" + from + ") not exist!");
cpy_mt = new Metadata(toBucket, to);
cpy_mt.setPrimaryDisk(mt.getPrimaryDisk());
cpy_mt.setReplicaCount(bt.getReplicaCount());
if (mt.isReplicaExist())
cpy_mt.setReplicaDISK(mt.getReplicaDisk());
return cpy_mt;
}
use of com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException in project ksan by infinistor.
the class ObjManager method close.
/**
* Store the metadata for the file associated with path
* @param bucketName
* @param path path or key of the metadata is going to be stored
* @param etag
* @param meta
* @param tag
* @param pdskPath primary disk path
* @param rdskPath replica disk path
* @return
* @throws InvalidParameterException
* @throws ResourceNotFoundException
*/
public int close(String bucketName, String path, String etag, String meta, String tag, long size, String acl, String pdskPath, String rdskPath, String versionId, String deleteMarker) throws InvalidParameterException, ResourceNotFoundException {
Metadata mt;
Bucket bt;
DISK pdsk;
DISK rdsk;
boolean isreplicaExist;
mt = new Metadata(bucketName, path);
mt.set(etag, tag, meta, acl, size);
mt.setVersionId(versionId, deleteMarker, true);
try {
bt = this.getBucket(bucketName);
} catch (SQLException ex) {
throw new ResourceNotFoundException("Bucket(" + bucketName + ") not exist ! >" + ex);
}
if (bt == null)
throw new ResourceNotFoundException("Bucket(" + bucketName + ") not exist!");
pdsk = obmCache.getDiskWithPath(bt.getDiskPoolId(), pdskPath);
isreplicaExist = false;
mt.setPrimaryDisk(pdsk);
if (rdskPath != null) {
if (!rdskPath.isEmpty()) {
rdsk = obmCache.getDiskWithPath(bt.getDiskPoolId(), rdskPath);
isreplicaExist = true;
mt.setReplicaDISK(rdsk);
}
}
mt.setReplicaCount(bt.getReplicaCount());
return this.close(bucketName, path, mt);
/*try {
if (path.isEmpty())
throw new InvalidParameterException("empty path not allowed!");
if (!obmCache.validateDisk(bt.getDiskPoolId(), "", pdskPath))
throw new InvalidParameterException("primary disk("+pdskPath+") not exist in the system!");
if (isreplicaExist){
if (!obmCache.validateDisk(bt.getDiskPoolId(), "", rdskPath)){
logger.debug("bucket : {} path : {} there replica disk provided", bucketName, path);
//throw new InvalidParameterException("Replica disk not exist in the system!");
}
}
mt = dbm.selectSingleObject(bt.getDiskPoolId(), bucketName, path);
if (!bt.getVersioning().equalsIgnoreCase("Enabled"))
dbm.deleteObject(bucketName, path, "null");
mt.setPrimaryDisk(pdsk);
if (isreplicaExist)
mt.setReplicaDISK(rdsk);
mt.setEtag(etag);
mt.setTag(tag);
mt.setMeta(meta);
mt.setSize(size);
mt.setAcl(acl);
mt.setVersionId(versionId, deleteMarker, true);
} catch(ResourceNotFoundException ex){
// create meta
mt = new Metadata(bucketName, path, etag, meta, tag, size, acl, pdsk.getId(),
pdsk.getPath(), isreplicaExist? rdsk.getId() : "",
isreplicaExist ? rdsk.getPath() : "", versionId, deleteMarker);
mt.setVersionId(versionId, deleteMarker, true);
}
// inseret to db
return dbm.insertObject(mt);*/
}
use of com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException in project ksan by infinistor.
the class ObjManager method _open.
private Metadata _open(String bucket, String path, String versionId) throws ResourceNotFoundException {
Metadata mt;
Bucket bt;
try {
bt = getBucket(bucket);
} catch (SQLException ex) {
throw new ResourceNotFoundException("Bucket(" + bucket + ") failed to reterive in the system due to :" + ex);
}
if (bt == null) {
throw new ResourceNotFoundException("Bucket(" + bucket + ") not exist in the system!");
}
if (versionId == null)
mt = dbm.selectSingleObject(bt.getDiskPoolId(), bucket, path);
else
mt = dbm.selectSingleObject(bt.getDiskPoolId(), bucket, path, versionId);
mt.setReplicaCount(bt.getReplicaCount());
return mt;
}
Aggregations