Search in sources :

Example 1 with ResourceAlreadyExistException

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

the class DBPerformanceTest method createBucket.

static void createBucket() {
    try {
        ObjManager om = new ObjManager();
        try {
            System.out.println("bucketName :>" + bucket);
            om.createBucket(bucket, userName, userName, "acl", "", "");
        } catch (ResourceNotFoundException ex) {
            Logger.getLogger(DBPerformanceTest.class.getName()).log(Level.SEVERE, null, ex);
        }
    } catch (ResourceAlreadyExistException ex) {
        System.out.println("Bucket already exist!");
    } catch (Exception ex) {
        System.out.println("OBJMANAGER INIT ERROR : " + ex);
    }
}
Also used : ResourceAlreadyExistException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceAlreadyExistException) ObjManager(com.pspace.ifs.ksan.objmanager.ObjManager) ResourceNotFoundException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException) IOException(java.io.IOException) ResourceAlreadyExistException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceAlreadyExistException) InvalidParameterException(java.security.InvalidParameterException) AllServiceOfflineException(com.pspace.ifs.ksan.objmanager.ObjManagerException.AllServiceOfflineException) ResourceNotFoundException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException)

Example 2 with ResourceAlreadyExistException

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

the class MongoDataRepository method insertBucket.

@Override
public Bucket insertBucket(Bucket bt) throws ResourceAlreadyExistException {
    Document doc;
    Document index;
    try {
        doc = new Document(BUCKETNAME, bt.getName());
        // doc.append(BUCKETNAME, bucketName);
        doc.append(DISKPOOLID, bt.getDiskPoolId());
        doc.append(BUCKETID, new Metadata(bt.getName(), "/").getBucketId());
        doc.append(USERID, bt.getUserId());
        doc.append(ACL, bt.getAcl());
        doc.append(REPLICACOUNT, bt.getReplicaCount());
        doc.append(WEB, "");
        doc.append(CORS, "");
        doc.append(LIFECYCLE, "");
        doc.append(ACCESS, "");
        doc.append(TAGGING, "");
        doc.append(REPLICATION, "");
        doc.append(VERSIONING, "");
        doc.append(MFADELETE, "");
        doc.append(ENCRYPTION, "");
        doc.append(OBJECTLOCK, "");
        doc.append(POLICY, "");
        doc.append(FILECOUNT, 0);
        doc.append(USEDSPACE, 0);
        doc.append(CREATETIME, getCurrentDateTime());
        buckets.insertOne(doc);
        database.createCollection(bt.getName());
        // for index for object collection
        index = new Document(OBJID, 1);
        index.append(VERSIONID, 1);
        index.append(LASTVERSION, 1);
        index.append(DELETEMARKER, 1);
        database.getCollection(bt.getName()).createIndex(index);
        // bt = new Bucket(bucketName, bucketName, diskPoolId);
        getUserDiskPool(bt);
    } catch (SQLException ex) {
        throw new ResourceAlreadyExistException(String.format("Bucket(%s) is laready exist in the db!", bt.getName()), ex);
    }
    return bt;
}
Also used : ResourceAlreadyExistException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceAlreadyExistException) SQLException(java.sql.SQLException) Document(org.bson.Document)

Example 3 with ResourceAlreadyExistException

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

the class MysqlDataRepository method insertBucket.

@Override
public synchronized Bucket insertBucket(Bucket bt) throws ResourceAlreadyExistException {
    try {
        this.pstInsertBucket.clearParameters();
        this.pstInsertBucket.setString(1, bt.getName());
        this.pstInsertBucket.setString(2, bt.getId());
        this.pstInsertBucket.setString(3, bt.getDiskPoolId());
        this.pstInsertBucket.setString(4, bt.getUserName());
        this.pstInsertBucket.setString(5, bt.getUserId());
        this.pstInsertBucket.setString(6, bt.getAcl());
        this.pstInsertBucket.setString(7, bt.getEncryption());
        this.pstInsertBucket.setString(8, bt.getObjectLock());
        this.pstInsertBucket.setInt(9, bt.getReplicaCount());
        this.pstInsertBucket.executeUpdate();
        // get diskpoolId and replicaCount
        getUserDiskPool(bt);
    } catch (SQLException ex) {
        throw new ResourceAlreadyExistException(String.format("Bucket(%s) is laready exist in the db!\n", bt.getName()), ex);
    }
    return bt;
}
Also used : ResourceAlreadyExistException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceAlreadyExistException)

Example 4 with ResourceAlreadyExistException

use of com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceAlreadyExistException 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 5 with ResourceAlreadyExistException

use of com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceAlreadyExistException 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)

Aggregations

ResourceAlreadyExistException (com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceAlreadyExistException)6 ResourceNotFoundException (com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException)4 SQLException (java.sql.SQLException)3 AllServiceOfflineException (com.pspace.ifs.ksan.objmanager.ObjManagerException.AllServiceOfflineException)2 IOException (java.io.IOException)2 InvalidParameterException (java.security.InvalidParameterException)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 GWException (com.pspace.ifs.ksan.gw.exception.GWException)1 ObjectListParameter (com.pspace.ifs.ksan.gw.identity.ObjectListParameter)1 S3ObjectList (com.pspace.ifs.ksan.gw.identity.S3ObjectList)1 ObjManager (com.pspace.ifs.ksan.objmanager.ObjManager)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 Document (org.bson.Document)1