Search in sources :

Example 26 with ResourceNotFoundException

use of com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException in project ksan by infinistor.

the class CBalance method getListOfObjects.

private List<Metadata> getListOfObjects(String bucketName, String SrcDiskId, long size, long offset, String DstDiskId) {
    List<Metadata> res;
    List<Metadata> list;
    // long offset = 0;
    long numObjects = 100;
    // long job_done = 0;
    long size_counter = 0;
    int ret;
    res = new ArrayList();
    ret = objm.startJob();
    if (ret != 0)
        return res;
    do {
        list = obmu.listObjects(bucketName, SrcDiskId, 1, offset, numObjects);
        if (list == null)
            return res;
        if (list.isEmpty())
            return res;
        Iterator<Metadata> it = list.iterator();
        while (it.hasNext()) {
            totalChecked++;
            Metadata mt = it.next();
            if (mt.getSize() > size || mt.getSize() <= 0)
                continue;
            try {
                if (!obmu.allowedToReplicate(bucketName, mt.getPrimaryDisk(), mt.getReplicaDisk(), DstDiskId))
                    continue;
            } catch (ResourceNotFoundException ex) {
                if (!obmu.allowedToReplicate(bucketName, mt.getPrimaryDisk(), null, DstDiskId))
                    continue;
            }
            size_counter = size_counter + mt.getSize();
            res.add(mt);
            if (size_counter > size)
                return res;
        }
        offset = offset + numObjects;
    } while (list.size() == numObjects);
    return res;
}
Also used : Metadata(com.pspace.ifs.ksan.objmanager.Metadata) ArrayList(java.util.ArrayList) ResourceNotFoundException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException)

Example 27 with ResourceNotFoundException

use of com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException in project ksan by infinistor.

the class GetAttr method getObjects.

void getObjects() {
    Metadata mt;
    try {
        ObjManagerUtil obmu = new ObjManagerUtil();
        if (!ObjectPath.isEmpty())
            mt = obmu.getObjectWithPath(bucketName, ObjectPath);
        else
            mt = obmu.getObject(bucketName, objId);
        displayMeta(mt);
    } catch (ResourceNotFoundException ex) {
        displayNothing();
    } catch (Exception ex) {
        Logger.getLogger(GetAttr.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : ObjManagerUtil(com.pspace.ifs.ksan.objmanager.ObjManagerUtil) Metadata(com.pspace.ifs.ksan.objmanager.Metadata) ResourceNotFoundException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException) CmdLineException(org.kohsuke.args4j.CmdLineException) ResourceNotFoundException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException)

Example 28 with ResourceNotFoundException

use of com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException in project ksan by infinistor.

the class GetObjectMetadata method getObjects.

private int getObjects() {
    Metadata mt1;
    try {
        ObjManagerUtil obmu = new ObjManagerUtil();
        mt1 = obmu.getObjectWithPath(mt.getBucket(), mt.getPath());
        message = mt1.toString();
        return 1;
    } catch (ResourceNotFoundException ex) {
        message = displayNoInformation();
        return 0;
    } catch (Exception ex) {
        message = dispalyError();
    }
    return -1;
}
Also used : ObjManagerUtil(com.pspace.ifs.ksan.objmanager.ObjManagerUtil) Metadata(com.pspace.ifs.ksan.objmanager.Metadata) ResourceNotFoundException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException) ResourceNotFoundException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException)

Example 29 with ResourceNotFoundException

use of com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException in project ksan by infinistor.

the class S3Request method open.

protected Metadata open(String bucket, String object) throws GWException {
    Metadata meta = null;
    try {
        setObjManager();
        meta = objManager.open(bucket, object);
    } catch (ResourceNotFoundException e) {
        throw new GWException(GWErrorCode.NO_SUCH_KEY, s3Parameter);
    } catch (Exception e) {
        PrintStack.logging(logger, e);
        throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
    } finally {
        try {
            releaseObjManager();
        } catch (Exception e) {
            PrintStack.logging(logger, e);
            throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
        }
    }
    return meta;
}
Also used : Metadata(com.pspace.ifs.ksan.objmanager.Metadata) GWException(com.pspace.ifs.ksan.gw.exception.GWException) ResourceNotFoundException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException) GWException(com.pspace.ifs.ksan.gw.exception.GWException) ResourceAlreadyExistException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceAlreadyExistException) XMLStreamException(javax.xml.stream.XMLStreamException) ResourceNotFoundException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException)

Example 30 with ResourceNotFoundException

use of com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException in project ksan by infinistor.

the class S3Request method getSomeBucket.

protected Bucket getSomeBucket(String bucket) throws GWException {
    checkBucket(bucket);
    Bucket bucketInfo = null;
    try {
        setObjManager();
        bucketInfo = objManager.getBucket(bucket);
        if (bucketInfo != null) {
            if (!bucketInfo.getAcl().startsWith(GWConstants.XML_VERSION)) {
                bucketInfo.setAcl(GWUtils.makeOriginalXml(bucketInfo.getAcl(), s3Parameter));
            }
        }
    } catch (ResourceNotFoundException e) {
        throw new GWException(GWErrorCode.NO_SUCH_BUCKET, s3Parameter);
    } catch (Exception e) {
        PrintStack.logging(logger, e);
        throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
    } finally {
        try {
            releaseObjManager();
        } catch (Exception e) {
            PrintStack.logging(logger, e);
            throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
        }
    }
    if (bucketInfo == null) {
        logger.info(GWConstants.LOG_BUCKET_IS_NOT_EXIST, bucket);
        throw new GWException(GWErrorCode.NO_SUCH_BUCKET, s3Parameter);
    }
    return bucketInfo;
}
Also used : Bucket(com.pspace.ifs.ksan.objmanager.Bucket) GWException(com.pspace.ifs.ksan.gw.exception.GWException) ResourceNotFoundException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException) GWException(com.pspace.ifs.ksan.gw.exception.GWException) ResourceAlreadyExistException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceAlreadyExistException) XMLStreamException(javax.xml.stream.XMLStreamException) ResourceNotFoundException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException)

Aggregations

ResourceNotFoundException (com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException)36 ResourceAlreadyExistException (com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceAlreadyExistException)11 SQLException (java.sql.SQLException)11 GWException (com.pspace.ifs.ksan.gw.exception.GWException)10 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)8 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)8 Metadata (com.pspace.ifs.ksan.objmanager.Metadata)8 XMLStreamException (javax.xml.stream.XMLStreamException)8 IOException (java.io.IOException)6 InvalidParameterException (java.security.InvalidParameterException)5 Document (org.bson.Document)5 AllServiceOfflineException (com.pspace.ifs.ksan.objmanager.ObjManagerException.AllServiceOfflineException)4 Iterator (java.util.Iterator)4 Bucket (com.pspace.ifs.ksan.objmanager.Bucket)3 ArrayList (java.util.ArrayList)3 FindIterable (com.mongodb.client.FindIterable)2 MQResponse (com.pspace.ifs.ksan.mq.MQResponse)2 ObjManager (com.pspace.ifs.ksan.objmanager.ObjManager)2 ObjManagerUtil (com.pspace.ifs.ksan.objmanager.ObjManagerUtil)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2