Search in sources :

Example 1 with AllServiceOfflineException

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

the class FSCK method checkEachObject.

/*public void howtouse(String progName){
        System.out.format("%s FSCK --action=<check|fix> --type=<Server|Disk|Object> --serverid=<OsdServerId> --diskid=<OsdDiskId> --objid=<ObjectId>\n"
                + "  Where: "
                + " --type  : server if the whole server failed, Disk if a disk failed and otherwise Object if a single object failed ", progName);
    }
    private int parseArgs(String [] args){
        String argInLower;
        String tmp;
        for(String arg : args){
            argInLower = arg.toLowerCase();
            if (argInLower.startsWith("--action")){ 
                tmp =argInLower.split("=")[1];
                if (tmp.equalsIgnoreCase("fix"))
                    isFixOn = true;      
            }
            if (argInLower.startsWith("--type")) {
                type = argInLower.split("=")[1].toLowerCase();
            }
            if (argInLower.startsWith("--serverid")) serverId = argInLower.split("=")[1];
            if (argInLower.startsWith("--diskid")) diskid = argInLower.split("=")[1];
            if (argInLower.startsWith("--objid")) objid = argInLower.split("=")[1];
        }
        
        return 0;
    }
    
    private DISK getNewDisk(String bucketName, String pdpath, String pdiskid) throws ResourceNotFoundException, AllServiceOfflineException{
        return obmu.allocReplicaDisk(bucketName, pdpath, pdiskid);
    }
    
    private int getObjectAttr(){
        return 0;
    }
    
    private int replicate(String objid, DISK from, DISK to) throws Exception{
        String bindingKey="recoverObject";
        String msg2send = String.format("{ from: %s to : %s }", from.toString(), to.toString());
        
        mqSender.send(msg2send, bindingKey);
        return 0;
    }
    
    private int repairObject(Metadata mt, String path, String diskid){
        obmu.updateObject(mt.getBucket(), mt.getObjId(),  mt, 1);
        return 0;
    }*/
private long checkEachObject(String bucketName, String diskid) {
    List<Metadata> list;
    long offset = 0;
    long numObjects = 100;
    long job_done = 0;
    int ret;
    ret = objm.startJob();
    if (ret != 0)
        return 0;
    do {
        list = obmu.listObjects(bucketName, diskid, 1, offset, numObjects);
        if (list == null)
            return 0;
        if (list.isEmpty())
            return 0;
        Iterator<Metadata> it = list.iterator();
        while (it.hasNext()) {
            totalChecked++;
            if (!objm.ISJobRunning()) {
                totalFixed = totalFixed + job_done;
                objm.updateNumberObjectsProcessed(totalChecked, totalFixed);
                return job_done;
            }
            Metadata mt = it.next();
            try {
                if (!mt.isReplicaExist()) {
                    System.out.format(">> Bucket : %s path : %s pdisk : %s rdisk : %s \n", mt.getBucket(), mt.getPath(), mt.isPrimaryExist() ? mt.getPrimaryDisk().getPath() : " Empty", mt.isReplicaExist() ? mt.getReplicaDisk().getPath() : " Empty");
                    if (!checkOnly)
                        objm.moveObject(bucketName, mt.getObjId(), mt.getPrimaryDisk().getId());
                    job_done++;
                }
            } catch (ResourceNotFoundException | AllServiceOfflineException ex) {
                System.out.format(" Bucket : %s path : %s pdisk : %s \n", mt.getBucket(), mt.getPath(), mt.isPrimaryExist() ? mt.getPrimaryDisk().getPath() : "");
            }
        }
        offset = offset + numObjects;
        System.out.println("----------------------------------------------------------->" + job_done);
    } while (list.size() == numObjects);
    totalFixed = totalFixed + job_done;
    objm.updateNumberObjectsProcessed(totalChecked, totalFixed);
    objm.finishedJob();
    return job_done;
}
Also used : AllServiceOfflineException(com.pspace.ifs.ksan.objmanager.ObjManagerException.AllServiceOfflineException) Metadata(com.pspace.ifs.ksan.objmanager.Metadata) ResourceNotFoundException(com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException)

Example 2 with AllServiceOfflineException

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

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

AllServiceOfflineException (com.pspace.ifs.ksan.objmanager.ObjManagerException.AllServiceOfflineException)3 ResourceNotFoundException (com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceNotFoundException)3 Metadata (com.pspace.ifs.ksan.objmanager.Metadata)2 IOException (java.io.IOException)2 InvalidParameterException (java.security.InvalidParameterException)2 ObjectListParameter (com.pspace.ifs.ksan.gw.identity.ObjectListParameter)1 S3ObjectList (com.pspace.ifs.ksan.gw.identity.S3ObjectList)1 ResourceAlreadyExistException (com.pspace.ifs.ksan.objmanager.ObjManagerException.ResourceAlreadyExistException)1 SQLException (java.sql.SQLException)1