refactoring Operation class. Created new method getTransport
This commit is contained in:
parent
a3619dc643
commit
1a7d79127b
|
@ -20,8 +20,9 @@ public class Close extends Operation{
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
try {
|
||||
tm.close();
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -38,8 +38,9 @@ public abstract class Copy extends Operation{
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
String id=null;
|
||||
try {
|
||||
// id=tm.copy(myFile, sourcePath, destinationPath);
|
||||
|
|
|
@ -41,8 +41,7 @@ public abstract class CopyDir extends Operation{
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm = getTransport(myFile);
|
||||
List<String> ids=null;
|
||||
try {
|
||||
// ids=tm.copyDir(myFile, sourcePath, destinationPath);
|
||||
|
@ -56,6 +55,8 @@ public abstract class CopyDir extends Operation{
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String initOperation(MyFile resource, String remotePath,
|
||||
String author, String[] server, String rootArea) {
|
||||
|
|
|
@ -51,8 +51,9 @@ public abstract class Download extends Operation{
|
|||
id=get(this, myFile, false);
|
||||
|
||||
} catch (Throwable e) {
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(getServer(), getUser(), getPassword());
|
||||
TransportManager tm=tmf.getTransport(getBackendType(), myFile.getGcubeMemoryType(), getDbNames(), myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf=new TransportManagerFactory(getServer(), getUser(), getPassword());
|
||||
// TransportManager tm=tmf.getTransport(getBackendType(), myFile.getGcubeMemoryType(), getDbNames(), myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
tm.close();
|
||||
logger.error("Problem in download from: "+myFile.getRemotePath()+": "+e.getMessage());
|
||||
// e.printStackTrace();
|
||||
|
|
|
@ -40,8 +40,9 @@ public class DownloadAndLock extends Operation {
|
|||
//TODO add field for file lock
|
||||
get(download,myFile, true);
|
||||
} catch (Exception e) {
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(getServer(), getUser(), getPassword());
|
||||
TransportManager tm=tmf.getTransport(getBackendType(), myFile.getGcubeMemoryType(), getDbNames(), myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf=new TransportManagerFactory(getServer(), getUser(), getPassword());
|
||||
// TransportManager tm=tmf.getTransport(getBackendType(), myFile.getGcubeMemoryType(), getDbNames(), myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in downloadAndLock operation ", e.getCause());
|
||||
}
|
||||
|
|
|
@ -31,8 +31,9 @@ public abstract class DuplicateFile extends Operation {
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
String id=null;
|
||||
try {
|
||||
// id = tm.duplicateFile(myFile, bucket);
|
||||
|
|
|
@ -31,8 +31,9 @@ public class Exist extends Operation{
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
boolean isPresent=false;
|
||||
try {
|
||||
isPresent = tm.exist(bucket);
|
||||
|
|
|
@ -23,8 +23,9 @@ public class GetFolderCount extends Operation {
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
long dim=0;
|
||||
try {
|
||||
dim = tm.getFolderTotalItems(bucket);
|
||||
|
|
|
@ -22,8 +22,9 @@ public class GetFolderSize extends Operation {
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
long dim=0;
|
||||
try {
|
||||
dim = tm.getFolderTotalVolume(bucket);
|
||||
|
|
|
@ -31,8 +31,9 @@ public class GetMetaFile extends Operation{
|
|||
*
|
||||
*/
|
||||
public MyFile doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
long dim=0;
|
||||
String id=null;
|
||||
String mime=null;
|
||||
|
|
|
@ -21,8 +21,9 @@ public class GetMetaInfo extends Operation {
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
String value=null;
|
||||
try {
|
||||
value=tm.getFileProperty(bucket, myFile.getGenericPropertyField());
|
||||
|
|
|
@ -21,8 +21,9 @@ public class GetRemotePath extends Operation{
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
String path=null;
|
||||
try {
|
||||
path = tm.getRemotePath(bucket);
|
||||
|
|
|
@ -28,8 +28,9 @@ public class GetSize extends Operation{
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
long dim=0;
|
||||
try {
|
||||
dim = tm.getSize(bucket, myFile);
|
||||
|
|
|
@ -36,8 +36,9 @@ public class GetTTL extends Operation {
|
|||
TransportManager tm=null;
|
||||
try {
|
||||
//aggiungere field per il lock del file
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
||||
tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
||||
// tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
tm=getTransport(myFile);
|
||||
currentTTL=tm.getTTL(bucket);
|
||||
} catch (Exception e) {
|
||||
tm.close();
|
||||
|
|
|
@ -20,8 +20,9 @@ public class GetUserTotalItems extends Operation {
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
String dim=null;
|
||||
logger.info("check user total items for user: "+getOwner()+ " user is "+user);
|
||||
try {
|
||||
|
|
|
@ -20,8 +20,9 @@ public class GetUserTotalVolume extends Operation {
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
String dim=null;
|
||||
logger.info("check user total volume for user: "+getOwner()+ " user is "+user);
|
||||
try {
|
||||
|
|
|
@ -37,8 +37,9 @@ public abstract class Link extends Operation{
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
String id=null;
|
||||
try {
|
||||
id=tm.link(this);
|
||||
|
|
|
@ -44,8 +44,9 @@ public abstract class Lock extends Operation {
|
|||
Download download = new DownloadOperator(getServer(), getUser(), getPassword(), getBucket(), getMonitor(), isChunk(), getBackendType(), getDbNames());
|
||||
unlockKey=get(download, myFile, true);
|
||||
} catch (Exception e) {
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(getServer(), getUser(), getPassword());
|
||||
TransportManager tm=tmf.getTransport(getBackendType(), myFile.getGcubeMemoryType(), getDbNames(), myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf=new TransportManagerFactory(getServer(), getUser(), getPassword());
|
||||
// TransportManager tm=tmf.getTransport(getBackendType(), myFile.getGcubeMemoryType(), getDbNames(), myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in lock operation ", e.getCause());
|
||||
}
|
||||
|
|
|
@ -40,8 +40,9 @@ public abstract class Move extends Operation{
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
String id=null;
|
||||
try {
|
||||
// id=tm.move(myFile, sourcePath, destinationPath);
|
||||
|
|
|
@ -39,8 +39,9 @@ public abstract class MoveDir extends Operation{
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
List<String>ids=null;
|
||||
try {
|
||||
ids=tm.moveDir(this);
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.io.FileNotFoundException;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -40,6 +41,7 @@ public abstract class Operation {
|
|||
private Monitor monitor;
|
||||
private boolean isChunk;
|
||||
String backendType;
|
||||
TransportManager transport;
|
||||
|
||||
public Operation(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs){
|
||||
this.server=server;
|
||||
|
@ -159,8 +161,9 @@ public abstract class Operation {
|
|||
}else{
|
||||
if(logger.isDebugEnabled())
|
||||
logger.debug("NO THREAD POOL USED");
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, resource.getGcubeMemoryType(), dbNames, resource.getWriteConcern(), resource.getReadPreference());
|
||||
// TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, resource.getGcubeMemoryType(), dbNames, resource.getWriteConcern(), resource.getReadPreference());
|
||||
TransportManager tm=getTransport(resource);
|
||||
String objectId=tm.uploadManager(upload, resource, bucket, bucket+"_1", replaceOption);
|
||||
return objectId;
|
||||
}
|
||||
|
@ -177,12 +180,10 @@ public abstract class Operation {
|
|||
logger.debug("get(String) - start");
|
||||
}
|
||||
String unlocKey=null;
|
||||
TransportManagerFactory tmf=null;
|
||||
// if(server.length >1)
|
||||
tmf=new TransportManagerFactory(server, user, password);
|
||||
// else
|
||||
// tmf=new TransportManagerFactory(server, null, null);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf=null;
|
||||
// tmf=new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
long start=System.currentTimeMillis();
|
||||
String path=myFile.getLocalPath();
|
||||
if(!Costants.CLIENT_TYPE.equalsIgnoreCase("mongo")){
|
||||
|
@ -380,6 +381,13 @@ public abstract class Operation {
|
|||
this.user = user;
|
||||
}
|
||||
|
||||
|
||||
protected TransportManager getTransport(MyFile myFile) {
|
||||
if(Objects.isNull(transport)) {
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
return tm;
|
||||
}
|
||||
return transport;
|
||||
}
|
||||
|
||||
}
|
|
@ -25,8 +25,9 @@ public class Remove extends Operation{
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
removeBucket(tm, bucket, myFile);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(" REMOVE " + bucket);
|
||||
|
|
|
@ -30,8 +30,9 @@ public class RenewTTL extends Operation {
|
|||
|
||||
@Override
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException {
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
long ttl=-1;
|
||||
try {
|
||||
myFile.setRemotePath(bucket);
|
||||
|
|
|
@ -21,8 +21,9 @@ public class SetMetaInfo extends Operation {
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
try {
|
||||
tm.setFileProperty(bucket, myFile.getGenericPropertyField(), myFile.getGenericPropertyValue());
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -60,8 +60,9 @@ public abstract class SoftCopy extends Operation {
|
|||
}
|
||||
|
||||
public String doIt(MyFile myFile) throws RemoteBackendException{
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
String id=null;
|
||||
try {
|
||||
id=tm.softCopy(this);
|
||||
|
|
|
@ -43,8 +43,9 @@ public abstract class Unlock extends Operation {
|
|||
//inserire parametro per il lock
|
||||
objectId=put(upload, myFile, isChunk(), false, false, true);
|
||||
} catch (Exception e) {
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in unlock operation ", e.getCause());
|
||||
}
|
||||
|
|
|
@ -49,8 +49,9 @@ public abstract class Upload extends Operation {
|
|||
try {
|
||||
objectId=put(this, myFile, isChunk(), false, replaceOption, false);
|
||||
} catch (Throwable e) {
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
||||
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
TransportManager tm=getTransport(myFile);
|
||||
tm.close();
|
||||
logger.error("Problem in upload from: "+myFile.getLocalPath()+": "+e.getMessage());
|
||||
throw new RemoteBackendException(" Error in upload operation ", e.getCause());
|
||||
|
|
|
@ -4,10 +4,12 @@ package org.gcube.contentmanagement.blobstorage.transport;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.MongoOperationManager;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -28,6 +30,7 @@ public class TransportManagerFactory {
|
|||
String[] server;
|
||||
String user;
|
||||
String password;
|
||||
TransportManager transport;
|
||||
|
||||
public TransportManagerFactory(String server[], String user, String password){
|
||||
this.server=server;
|
||||
|
@ -39,21 +42,25 @@ public class TransportManagerFactory {
|
|||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("getOperation(String) - start");
|
||||
}
|
||||
if(Objects.isNull(transport))
|
||||
return load(backendType, memoryType, dbNames, writeConcern, readConcern);
|
||||
return transport;
|
||||
}
|
||||
|
||||
private TransportManager load(String backendType, MemoryType memoryType, String[] dbNames, String writeConcern, String readConcern){
|
||||
ServiceLoader<TransportManager> loader = ServiceLoader.load(TransportManager.class);
|
||||
Iterator<TransportManager> iterator = loader.iterator();
|
||||
List<TransportManager> impls = new ArrayList<TransportManager>();
|
||||
logger.info("Try to load the backend...");
|
||||
logger.info("the specified backend passed as input param is "+backendType);
|
||||
while(iterator.hasNext())
|
||||
impls.add(iterator.next());
|
||||
int implementationCounted=impls.size();
|
||||
// System.out.println("size: "+implementationCounted);
|
||||
if(implementationCounted==0){
|
||||
if((implementationCounted==0) || backendType.equals(Costants.DEFAULT_TRANSPORT_MANAGER)){
|
||||
logger.info(" 0 implementation found. Load default implementation of TransportManager");
|
||||
return new MongoOperationManager(server, user, password, memoryType, dbNames, writeConcern, readConcern);
|
||||
}else if(implementationCounted==1){
|
||||
}else if((implementationCounted==1) && Objects.isNull(backendType)){
|
||||
TransportManager tm = impls.get(0);
|
||||
logger.info("1 implementation of TransportManager found. Load it. "+tm.getName());
|
||||
tm.initBackend(server, user, password, memoryType, dbNames, writeConcern, readConcern);
|
||||
|
@ -64,6 +71,7 @@ public class TransportManagerFactory {
|
|||
for(TransportManager tm : impls){
|
||||
if(tm.getName().equalsIgnoreCase(backendType)){
|
||||
logger.info("Found implementation "+backendType);
|
||||
tm.initBackend(server, user, password, memoryType, dbNames, writeConcern, readConcern);
|
||||
return tm;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue