Search in sources :

Example 21 with ResourceNotFoundException

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

the class S3Request method createBucket.

protected int createBucket(String bucket, String userName, String userId, String acl, String encryption, String objectlock) throws GWException {
    int result = 0;
    try {
        setObjManager();
        result = objManager.createBucket(bucket, userName, userId, acl, encryption, objectlock);
    } catch (ResourceAlreadyExistException e) {
        PrintStack.logging(logger, e);
        throw new GWException(GWErrorCode.BUCKET_ALREADY_EXISTS, s3Parameter);
    } catch (ResourceNotFoundException e) {
        PrintStack.logging(logger, e);
        throw new GWException(GWErrorCode.INTERNAL_SERVER_ERROR, s3Parameter);
    } catch (Exception e) {
        PrintStack.logging(logger, e);
        throw new GWException(GWErrorCode.INTERNAL_SERVER_ERROR, s3Parameter);
    } finally {
        try {
            releaseObjManager();
        } catch (Exception e) {
            PrintStack.logging(logger, e);
            throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
        }
    }
    if (result != 0) {
        throw new GWException(GWErrorCode.INTERNAL_SERVER_DB_ERROR, s3Parameter);
    }
    return result;
}
Also used : ResourceAlreadyExistException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceAlreadyExistException) 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 22 with ResourceNotFoundException

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

the class S3Request method initBucketInfo.

protected void initBucketInfo(String bucket) throws GWException {
    checkBucket(bucket);
    try {
        setObjManager();
        dstBucket = objManager.getBucket(bucket);
        if (dstBucket != null) {
            if (!dstBucket.getAcl().startsWith(GWConstants.XML_VERSION)) {
                dstBucket.setAcl(GWUtils.makeOriginalXml(dstBucket.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 (dstBucket == null) {
        logger.info(GWConstants.LOG_BUCKET_IS_NOT_EXIST, bucket);
        throw new GWException(GWErrorCode.NO_SUCH_BUCKET, s3Parameter);
    }
}
Also used : 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 23 with ResourceNotFoundException

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

the class Objmanagertest method testVersiong.

static void testVersiong() throws Exception {
    String path;
    String bucket = "testvol3vers";
    String tmp = "parentD1/subDir/test";
    String etag = "etag_sample";
    String tag = "tag_sample";
    String meta = "meta_sample";
    String acl = "acl_sample";
    String vers;
    int ret;
    ObjManager om;
    om = new ObjManager();
    S3ObjectList s3ObjectList = new S3ObjectList();
    try {
        sleep(3);
    } catch (InterruptedException ex) {
        Logger.getLogger(Objmanagertest.class.getName()).log(Level.SEVERE, null, ex);
    }
    try {
        try {
            om.createBucket(bucket, "legesse1", "legesse1", "acl", "", "");
        } catch (ResourceAlreadyExistException ex) {
            System.out.println("Bucket already exist!");
        }
        try {
            vers = om.getBucketVersioning(bucket);
            if (vers.isEmpty())
                om.putBucketVersioning(bucket, "Enabled");
            System.out.println("111Versioin ret :> " + vers);
        } catch (ResourceNotFoundException | SQLException ex) {
            try {
                ret = om.putBucketVersioning(bucket, "Enabled");
                System.out.println("222Versioin ret :> " + ret);
            } catch (SQLException ex1) {
                Logger.getLogger(Objmanagertest.class.getName()).log(Level.SEVERE, null, ex1);
            }
        }
        long startTime = System.nanoTime();
        long startTime1m = System.nanoTime();
        long diff = 0;
        int mcount = 1;
        int idx;
        Metadata mt;
        for (idx = 0; idx < 200; idx++) {
            path = tmp + idx;
            // to create on round robin osd disk
            mt = om.create(bucket, path);
            om.close(bucket, path, etag, meta, tag, 0L, acl, mt.getPrimaryDisk().getPath(), mt.isReplicaExist() ? mt.getReplicaDisk().getPath() : "", Long.toString(startTime), "file");
            if ((idx + 1) % 1000000 == 0) {
                diff = System.nanoTime() - startTime1m;
                System.out.println(mcount + ": Millon create excution time  : " + diff + "nanosecond");
                startTime1m = System.nanoTime();
                mcount++;
            }
        }
        diff = System.nanoTime() - startTime;
        System.out.println("Total " + idx + " create excution time  : " + diff + "nanosecond");
        String delimiter = "/";
        String startAfter = "";
        int maxKeys = 10;
        String prefix = "parentD1/subDir";
        s3ObjectList.setMaxKeys(String.valueOf(maxKeys));
        s3ObjectList.setDelimiter(delimiter);
        s3ObjectList.setPrefix(prefix);
        s3ObjectList.setStartAfter(startAfter);
        s3ObjectList.setVersionIdMarker("");
        s3ObjectList.setMarker(prefix);
        try {
            // om.listObjectsVersion(bucket, delimiter, startAfter, "", maxKeys, prefix);
            ObjectListParameter res = om.listObjectVersions(bucket, s3ObjectList);
            System.out.println("res >>" + res);
        } catch (SQLException ex) {
            Logger.getLogger(Objmanagertest.class.getName()).log(Level.SEVERE, null, ex);
        }
    } catch (IOException | InvalidParameterException | AllServiceOfflineException | ResourceNotFoundException ex) {
        System.out.println("Error : " + ex.getMessage());
    // Logger.getLogger(Objmanagertest.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : SQLException(java.sql.SQLException) AllServiceOfflineException(com.pspace.ifs.ksan.objmanager.ObjManagerException.AllServiceOfflineException) IOException(java.io.IOException) S3ObjectList(com.pspace.ifs.ksan.gw.identity.S3ObjectList) InvalidParameterException(java.security.InvalidParameterException) ObjectListParameter(com.pspace.ifs.ksan.gw.identity.ObjectListParameter) ResourceAlreadyExistException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceAlreadyExistException) ResourceNotFoundException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException)

Example 24 with ResourceNotFoundException

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

the class DBPerformanceTest method readFileFromDBPerformanceTest.

static void readFileFromDBPerformanceTest(ObjManager om, String name) {
    int idx = 0;
    String path;
    String tmp = bucket + "testDir_" + name + "/test";
    try {
        // ObjManager om = new ObjManager();
        latch.await();
        initReadStartTime();
        // for (idx = 0; idx < (int) numJobPerT; idx++) { //500000
        while ((idx = getIndex(name + "_read")) != -1) {
            path = getPath(tmp, idx);
            try {
                Metadata mt = om.open(bucket, path, "nil");
            } catch (ResourceNotFoundException ex) {
                countGetEntry();
                continue;
            }
            countGetEntry();
        }
    // System.out.format("End num_entry : %d  idx : %d  thread  : %s \n",  num_entry, idx, name);
    } catch (InvalidParameterException ex) {
        System.out.println("Error : " + ex.getMessage());
    } catch (InterruptedException ex) {
        System.out.println("Thread interrupted : " + ex);
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) Metadata(com.pspace.ifs.ksan.objmanager.Metadata) ResourceNotFoundException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException)

Example 25 with ResourceNotFoundException

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

the class DBPerformanceTest method createFileOnDBPerformanceTest.

static void createFileOnDBPerformanceTest(ObjManager om, String name) {
    int idx = 0;
    String path;
    String tmp = bucket + "testDir_" + name + "/test";
    String etag = "etag_sample";
    String tag = "tag_sample";
    String meta = "meta_sample";
    String acl = "acl_sample";
    String deleteMarker = "dmarker";
    try {
        // for (idx = 0; idx < (int) numJobPerT; idx++) { //500000
        while ((idx = getIndex(name + "_create")) != -1) {
            path = getPath(tmp, idx);
            // to create on round robin osd disk
            Metadata mt = om.create(bucket, path);
            mt.setMeta(meta);
            mt.setEtag(etag);
            mt.setTag(tag);
            mt.setAcl(acl);
            mt.setVersionId("nil", deleteMarker, true);
            om.close(bucket, path, mt);
            // count++;
            countEntry();
        }
    // System.out.format("End num_entry : %d  idx : %d  thread  : %s \n",  num_entry, idx, name);
    } catch (IOException | InvalidParameterException | AllServiceOfflineException | ResourceNotFoundException ex) {
        System.out.println("Error : " + ex.getMessage());
        System.out.println("<><><> idx :" + idx + " thread > " + name);
    }
    /*catch (Exception ex) {
            System.out.println(" OBJMANAGER INIT Error : " + ex.getMessage());
            Logger.getLogger(DBPerformanceTest.class.getName()).log(Level.SEVERE, null, ex);
        }*/
    // diff = System.nanoTime() - tm;
    // System.out.format(" > name : %s time : %s jobDone : %d\n", name, getInSecond(diff), count);
    latch.countDown();
}
Also used : InvalidParameterException(java.security.InvalidParameterException) AllServiceOfflineException(com.pspace.ifs.ksan.objmanager.ObjManagerException.AllServiceOfflineException) Metadata(com.pspace.ifs.ksan.objmanager.Metadata) IOException(java.io.IOException) ResourceNotFoundException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException)

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