delegate the transportManager check to TransportManagerFactory class
This commit is contained in:
parent
77ec6925c7
commit
ab9dfcab66
|
@ -29,6 +29,7 @@ public class DirectoryBucket {
|
|||
String path;
|
||||
String[] server;
|
||||
String user, password;
|
||||
TransportManager tm;
|
||||
public DirectoryBucket(String[] server, String user, String password, String path, String author){
|
||||
if(logger.isDebugEnabled())
|
||||
logger.debug("DirectoryBucket PATH: "+path);
|
||||
|
@ -91,7 +92,7 @@ public class DirectoryBucket {
|
|||
String[] bucketList=null;
|
||||
bucketList=retrieveBucketsName(path, rootArea);
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, resource.getGcubeMemoryType(), dbNames, resource.getWriteConcern(), resource.getReadPreference());
|
||||
tm=tmf.getTransport(tm, backendType, resource.getGcubeMemoryType(), dbNames, resource.getWriteConcern(), resource.getReadPreference());
|
||||
// TerrastoreClient client=new TerrastoreClient( new OrderedHostManager(Arrays.asList(server)), new HTTPConnectionFactory());
|
||||
for(int i=0;i<bucketList.length;i++){
|
||||
if(logger.isDebugEnabled())
|
||||
|
@ -124,7 +125,7 @@ public class DirectoryBucket {
|
|||
logger.debug("bucketDir Coded: "+bucketDirCoded);
|
||||
bucketList=retrieveBucketsName(bucket, rootArea);
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(server, user, password);
|
||||
TransportManager tm=tmf.getTransport(backendType, resource.getGcubeMemoryType(), dbNames, resource.getWriteConcern(),resource.getReadPreference());
|
||||
tm=tmf.getTransport(tm, backendType, resource.getGcubeMemoryType(), dbNames, resource.getWriteConcern(),resource.getReadPreference());
|
||||
for(int i=0;i<bucketList.length;i++){
|
||||
if(logger.isDebugEnabled())
|
||||
logger.debug("REMOVE: check "+bucketList[i]+" bucketDirCoded: "+bucketDirCoded );
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
|
|||
*/
|
||||
public class RemoteResource extends Resource{
|
||||
|
||||
|
||||
TransportManager tm;
|
||||
|
||||
public RemoteResource(MyFile file, ServiceEngine engine) {
|
||||
super(file, engine);
|
||||
|
@ -112,7 +112,7 @@ public class RemoteResource extends Resource{
|
|||
if(engine.getCurrentOperation().equalsIgnoreCase("showdir")){
|
||||
dir = new BucketCoding().bucketDirCoding(dir, engine.getContext());
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(engine.primaryBackend, engine.getBackendUser(), engine.getBackendPassword());
|
||||
TransportManager tm=tmf.getTransport(engine.getBackendType(), engine.getGcubeMemoryType(), engine.getDbNames(), engine.getWriteConcern(), engine.getReadConcern());
|
||||
tm=tmf.getTransport(tm, engine.getBackendType(), engine.getGcubeMemoryType(), engine.getDbNames(), engine.getWriteConcern(), engine.getReadConcern());
|
||||
Map<String, StorageObject> mapDirs=null;
|
||||
try {
|
||||
mapDirs = tm.getValues(getMyFile(), dir, DirectoryEntity.class);
|
||||
|
@ -133,7 +133,7 @@ public class RemoteResource extends Resource{
|
|||
dirBuc.removeDirBucket(getMyFile(), dir, engine.getContext(), engine.getBackendType(), engine.getDbNames());
|
||||
else{
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(engine.primaryBackend, engine.getBackendUser(), engine.getBackendPassword());
|
||||
TransportManager tm=tmf.getTransport(Costants.CLIENT_TYPE, engine.getGcubeMemoryType(), engine.getDbNames(), engine.getWriteConcern(), engine.getReadConcern());
|
||||
tm=tmf.getTransport(tm, Costants.CLIENT_TYPE, engine.getGcubeMemoryType(), engine.getDbNames(), engine.getWriteConcern(), engine.getReadConcern());
|
||||
dir=new BucketCoding().bucketFileCoding(dir, engine.getContext());
|
||||
try {
|
||||
tm.removeDir(dir, getMyFile());
|
||||
|
|
|
@ -117,7 +117,7 @@ public class ChunkConsumer implements Runnable {
|
|||
synchronized(ChunkConsumer.class){
|
||||
String [] randomServer=randomizeServer(server);
|
||||
TransportManagerFactory tmf=new TransportManagerFactory(randomServer, null, null);
|
||||
client.set(tmf.getTransport(Costants.CLIENT_TYPE, null, null, myFile.getWriteConcern(), myFile.getReadPreference()));
|
||||
client.set(tmf.getTransport(null, Costants.CLIENT_TYPE, null, null, myFile.getWriteConcern(), myFile.getReadPreference()));
|
||||
}
|
||||
if(logger.isDebugEnabled()){
|
||||
logger.debug("waiting time for upload: "
|
||||
|
|
|
@ -74,10 +74,8 @@ public class GetHttpUrl extends Operation {
|
|||
|
||||
private String getId(String path, boolean forceCreation, MemoryType memoryType, String writeConcern, String readPreference){
|
||||
String id=null;
|
||||
if(tm ==null){
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
tm=tmf.getTransport(backendType, memoryType, dbNames, writeConcern, readPreference);
|
||||
}
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
tm=tmf.getTransport(tm, backendType, memoryType, dbNames, writeConcern, readPreference);
|
||||
try {
|
||||
id = tm.getId(bucket, forceCreation);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -75,10 +75,8 @@ public class GetHttpsUrl extends Operation {
|
|||
|
||||
private String getId(String path, boolean forceCreation, MemoryType memoryType, String writeConcern, String readPreference){
|
||||
String id=null;
|
||||
if(tm ==null){
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
tm=tmf.getTransport(backendType, memoryType, dbNames, writeConcern, readPreference);
|
||||
}
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
tm=tmf.getTransport(tm, backendType, memoryType, dbNames, writeConcern, readPreference);
|
||||
try {
|
||||
id = tm.getId(bucket, forceCreation);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -58,10 +58,8 @@ public class GetUrl extends Operation{
|
|||
|
||||
private String getId(String path, boolean forceCreation, MemoryType memoryType, String writeConcern, String readPreference){
|
||||
String id=null;
|
||||
if(tm ==null){
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
tm=tmf.getTransport(backendType, memoryType, dbNames, writeConcern, readPreference);
|
||||
}
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
tm=tmf.getTransport(tm, backendType, memoryType, dbNames, writeConcern, readPreference);
|
||||
try {
|
||||
id = tm.getId(bucket, forceCreation);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -384,7 +384,7 @@ public abstract class Operation {
|
|||
protected TransportManager getTransport(MyFile myFile) {
|
||||
// if(Objects.isNull(transport)) {
|
||||
TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
||||
transport=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
transport=tmf.getTransport(transport, backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
// }
|
||||
return transport;
|
||||
}
|
||||
|
|
|
@ -33,9 +33,10 @@ public class UploadAndUnlock extends Operation {
|
|||
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());
|
||||
TransportManager tm=tmf.getTransport(transport, backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
||||
tm.close();
|
||||
throw new RemoteBackendException(" Error in uploadAndUnlock operation ", e.getCause()); }
|
||||
throw new RemoteBackendException(" Error in uploadAndUnlock operation ", e);
|
||||
}
|
||||
return objectId;
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class TransportManagerFactory {
|
|||
this.password=password;
|
||||
}
|
||||
|
||||
public TransportManager getTransport(String backendType, MemoryType memoryType, String[] dbNames, String writeConcern, String readConcern){
|
||||
public TransportManager getTransport(TransportManager tm, String backendType, MemoryType memoryType, String[] dbNames, String writeConcern, String readConcern){
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("getOperation(String) - start");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue