Search in sources :

Example 6 with ObjectListParameter

use of com.pspace.ifs.ksan.gw.identity.ObjectListParameter 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 7 with ObjectListParameter

use of com.pspace.ifs.ksan.gw.identity.ObjectListParameter in project ksan by infinistor.

the class S3Request method listObjectVersions.

protected ObjectListParameter listObjectVersions(String bucket, S3ObjectList s3ObjectList) throws GWException {
    ObjectListParameter objectListParameter = null;
    try {
        setObjManager();
        objectListParameter = objManager.listObjectVersions(bucket, s3ObjectList);
    } 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 objectListParameter;
}
Also used : ObjectListParameter(com.pspace.ifs.ksan.gw.identity.ObjectListParameter) GWException(com.pspace.ifs.ksan.gw.exception.GWException) 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 8 with ObjectListParameter

use of com.pspace.ifs.ksan.gw.identity.ObjectListParameter in project ksan by infinistor.

the class S3Request method listObjectV2.

protected ObjectListParameter listObjectV2(String bucket, S3ObjectList s3ObjectList) throws GWException {
    ObjectListParameter objectListParameter = null;
    try {
        setObjManager();
        objectListParameter = objManager.listObjectV2(bucket, s3ObjectList);
    } 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 objectListParameter;
}
Also used : ObjectListParameter(com.pspace.ifs.ksan.gw.identity.ObjectListParameter) GWException(com.pspace.ifs.ksan.gw.exception.GWException) 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

ObjectListParameter (com.pspace.ifs.ksan.gw.identity.ObjectListParameter)8 GWException (com.pspace.ifs.ksan.gw.exception.GWException)6 XMLStreamException (javax.xml.stream.XMLStreamException)6 S3ObjectList (com.pspace.ifs.ksan.gw.identity.S3ObjectList)4 ResourceAlreadyExistException (com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceAlreadyExistException)4 ResourceNotFoundException (com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException)4 IOException (java.io.IOException)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)3 S3Bucket (com.pspace.ifs.ksan.gw.identity.S3Bucket)3 S3Metadata (com.pspace.ifs.ksan.gw.identity.S3Metadata)3 Writer (java.io.Writer)3 XMLOutputFactory (javax.xml.stream.XMLOutputFactory)3 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)3 DataListBuckets (com.pspace.ifs.ksan.gw.data.DataListBuckets)1 DataListObjectV2 (com.pspace.ifs.ksan.gw.data.DataListObjectV2)1 DataListObjectVersions (com.pspace.ifs.ksan.gw.data.DataListObjectVersions)1 AllServiceOfflineException (com.pspace.ifs.ksan.objmanager.ObjManagerException.AllServiceOfflineException)1 InvalidParameterException (java.security.InvalidParameterException)1 SQLException (java.sql.SQLException)1