Search in sources :

Example 1 with ObjManager

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

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

the class DBPerformanceTest method run.

@Override
public void run() {
    long diff;
    try {
        ObjManager om = new ObjManager();
        System.out.print("\033[H\033[2J");
        System.out.flush();
        // System.out.println("Thread: " + getId() + " running");
        initWriteStartTime();
        createFileOnDBPerformanceTest(om, "Thread_" + getId());
        // System.out.format("maxNumJob : %d  num_entry : %d  isFinished : %s \n", maxNumJob,num_entry ,  isFinished);
        if ((maxNumJob == num_entry) && (isFinished == false)) {
            diff = System.nanoTime() - startTime;
            System.out.println("Total " + num_entry + " create excution time  : " + getInSecond(diff));
            isFinished = true;
        // System.exit(0);
        }
        readFileFromDBPerformanceTest(om, "Thread_" + getId());
        if ((maxNumJob == num_ReadEntry) && (isReadFinished == false)) {
            diff = System.nanoTime() - startReadTime;
            System.out.println("Total " + num_ReadEntry + " read excution time  : " + getInSecond(diff));
            isReadFinished = true;
        // System.exit(0);
        }
    } catch (Exception ex) {
        latch.countDown();
        ex.printStackTrace();
        System.out.println(" [Thread : " + getId() + "] OBJMANAGER INIT Error : " + ex);
    }
}
Also used : ObjManager(com.pspace.ifs.ksan.objmanager.ObjManager) 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 3 with ObjManager

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

the class TestTrashSender method main.

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    int i = 0;
    // String queueName = "osdThrashQueue";
    String exchange = "OSDExchange";
    String option = "";
    String msg;
    String fileName;
    Metadata mt;
    int idx = 0;
    try {
        MQSender mq1ton = new MQSender("192.168.11.76", exchange, option, "");
        ObjManager om = new ObjManager();
        while (true) {
            Date dt = new Date();
            fileName = "testfile" + idx + ".txt";
            mt = om.create("testv1", fileName);
            msg = "{id : " + dt.getTime() + " path: " + fileName + " diskpath1 : " + mt.getPrimaryDisk().getPath() + " diskpath2 : " + mt.getReplicaDisk().getPath() + "}";
            mq1ton.send(msg, "");
            System.out.format("Sent Message (to %s) :-> %s\n", mq1ton.getExchangeName(), msg);
            Thread.sleep(10000);
            idx++;
        }
    } catch (Exception ex) {
        System.out.println("--->Error : " + ex.getMessage() + " L. msg :" + ex.getLocalizedMessage());
    }
}
Also used : Metadata(com.pspace.ifs.ksan.objmanager.Metadata) ObjManager(com.pspace.ifs.ksan.objmanager.ObjManager) Date(java.util.Date)

Example 4 with ObjManager

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

the class S3Signing method publicvalidation.

public S3Parameter publicvalidation() throws GWException {
    String uri = s3Parameter.getRequest().getRequestURI();
    String hostHeader = s3Parameter.getRequest().getHeader(HttpHeaders.HOST);
    String preuri = uriReconstructer(uri, hostHeader, Optional.fromNullable(s3Parameter.getVirtualHost()));
    String bucket;
    String[] path = null;
    if (preuri.startsWith(GWConstants.SLASH_WEBSITE)) {
        path = preuri.split(GWConstants.SLASH, 4);
        bucket = path[2];
        s3Parameter.setWebsite(true);
    } else {
        path = preuri.split(GWConstants.SLASH, 3);
        bucket = path[1];
        s3Parameter.setWebsite(false);
    }
    for (int i = 0; i < path.length; i++) {
        try {
            path[i] = URLDecoder.decode(path[i], GWConstants.CHARSET_UTF_8);
        } catch (UnsupportedEncodingException e) {
            PrintStack.logging(logger, e);
            throw new GWException(GWErrorCode.SERVER_ERROR, GWConstants.LOG_S3SIGNING_UNSUPPORT_ENCODING_LANGUAGE, s3Parameter);
        }
    }
    if (preuri.startsWith(GWConstants.SLASH_WEBSITE)) {
        path = preuri.split(GWConstants.SLASH, 4);
    } else {
        path = preuri.split(GWConstants.SLASH, 3);
    }
    Bucket bucketInfo = null;
    ObjManager objManager = null;
    try {
        objManager = ObjManagerHelper.getInstance().getObjManager();
        bucketInfo = objManager.getBucket(bucket);
    } catch (ResourceNotFoundException e) {
        logger.info("bucket({}) is not fount in the db", bucket);
        throw new GWException(GWErrorCode.NO_SUCH_BUCKET, s3Parameter);
    } catch (SQLException e) {
        PrintStack.logging(logger, e);
    } catch (Exception e) {
        PrintStack.logging(logger, e);
    } finally {
        try {
            ObjManagerHelper.getInstance().returnObjManager(objManager);
        } catch (Exception e) {
            PrintStack.logging(logger, e);
        }
    }
    if (bucketInfo == null) {
        throw new GWException(GWErrorCode.INVALID_ACCESS_KEY_ID, s3Parameter);
    }
    S3User user = GWUtils.getDBInstance().getIdentityByID(bucketInfo.getUserId(), s3Parameter);
    if (user == null) {
        throw new GWException(GWErrorCode.INVALID_ACCESS_KEY_ID, s3Parameter);
    }
    s3Parameter.setUser(user);
    if (s3Parameter.isWebsite()) {
        String[] enhancepath = new String[path.length - 1];
        for (int i = 0; i < path.length; i++) {
            if (i == 0) {
                enhancepath[i] = path[i];
                continue;
            }
            if (i == 1) {
                continue;
            }
            enhancepath[i - 1] = path[i];
            logger.debug(GWConstants.LOG_S3SIGNING_ENHANCE_PATH, i, enhancepath[i]);
        }
    // s3Parameter.path = enhancepath;
    } else {
    // s3Parameter.path = path;
    }
    return s3Parameter;
}
Also used : S3User(com.pspace.ifs.ksan.gw.identity.S3User) Bucket(com.pspace.ifs.ksan.objmanager.Bucket) SQLException(java.sql.SQLException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) GWException(com.pspace.ifs.ksan.gw.exception.GWException) ObjManager(com.pspace.ifs.ksan.objmanager.ObjManager) ResourceNotFoundException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException) GWException(com.pspace.ifs.ksan.gw.exception.GWException) SQLException(java.sql.SQLException) ResourceNotFoundException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeyException(java.security.InvalidKeyException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

ObjManager (com.pspace.ifs.ksan.objmanager.ObjManager)4 ResourceNotFoundException (com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException)3 IOException (java.io.IOException)3 AllServiceOfflineException (com.pspace.ifs.ksan.objmanager.ObjManagerException.AllServiceOfflineException)2 ResourceAlreadyExistException (com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceAlreadyExistException)2 InvalidParameterException (java.security.InvalidParameterException)2 GWException (com.pspace.ifs.ksan.gw.exception.GWException)1 S3User (com.pspace.ifs.ksan.gw.identity.S3User)1 Bucket (com.pspace.ifs.ksan.objmanager.Bucket)1 Metadata (com.pspace.ifs.ksan.objmanager.Metadata)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 InvalidKeyException (java.security.InvalidKeyException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 SQLException (java.sql.SQLException)1 Date (java.util.Date)1