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);
}
}
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);
}
}
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());
}
}
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;
}
Aggregations