add forceClose operation. Update to version 2.13.0-SNAPSHOT

This commit is contained in:
Roberto Cirillo 2021-08-04 09:43:10 +02:00
parent ee531ec7ef
commit 7965fa019f
10 changed files with 34 additions and 73 deletions

View File

@ -1,6 +1,9 @@
# Changelog for storage-manager-core
## [v2.12.1-SNAPSHOT
## [v2.13.0-SNAPSHOT]
* add close operation on IClient interface
## [v2.12.1-SNAPSHOT]
* add check on transport layer instance: if the memory type is not the same, a new transportLayer is instatiated
* move memoryType var from super class TransportManager
* convert BasicDBObject to DBObject the return type used for metadata collections

57
pom.xml
View File

@ -8,7 +8,7 @@
</parent>
<groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-manager-core</artifactId>
<version>2.12.1-SNAPSHOT</version>
<version>2.13.0-SNAPSHOT</version>
<!-- <properties> -->
<!-- <distroDirectory>${project.basedir}/distro</distroDirectory> -->
<!-- </properties> -->
@ -53,54 +53,11 @@
<artifactId>commons-codec</artifactId>
<version>1.8</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.slf4j</groupId> -->
<!-- <artifactId>slf4j-simple</artifactId> -->
<!-- <version>1.7.32</version> -->
<!-- <scope>test</scope> -->
<!-- </dependency> -->
</dependencies>
<!-- <build> -->
<!-- <plugins> -->
<!-- <plugin> -->
<!-- <groupId>org.apache.maven.plugins</groupId> -->
<!-- <artifactId>maven-resources-plugin</artifactId> -->
<!-- <version>2.5</version> -->
<!-- <executions> -->
<!-- <execution> -->
<!-- <id>copy-profile</id> -->
<!-- <phase>install</phase> -->
<!-- <goals> -->
<!-- <goal>copy-resources</goal> -->
<!-- </goals> -->
<!-- <configuration> -->
<!-- <outputDirectory>target</outputDirectory> -->
<!-- <resources> -->
<!-- <resource> -->
<!-- <directory>${distroDirectory}</directory> -->
<!-- <filtering>true</filtering> -->
<!-- <includes> -->
<!-- <include>profile.xml</include> -->
<!-- </includes> -->
<!-- </resource> -->
<!-- </resources> -->
<!-- </configuration> -->
<!-- </execution> -->
<!-- </executions> -->
<!-- </plugin> -->
<!-- <plugin> -->
<!-- <groupId>org.apache.maven.plugins</groupId> -->
<!-- <artifactId>maven-assembly-plugin</artifactId> -->
<!-- -->
<!-- <configuration> -->
<!-- <descriptors> -->
<!-- <descriptor>${distroDirectory}/descriptor.xml</descriptor> -->
<!-- </descriptors> -->
<!-- </configuration> -->
<!-- <executions> -->
<!-- <execution> -->
<!-- <id>servicearchive</id> -->
<!-- <phase>install</phase> -->
<!-- <goals> -->
<!-- <goal>single</goal> -->
<!-- </goals> -->
<!-- </execution> -->
<!-- </executions> -->
<!-- </plugin> -->
<!-- </plugins> -->
<!-- </build> -->
</project>

View File

@ -1,15 +0,0 @@
log4j.rootLogger=INFO, A1, stdout
log4j.appender.A1=org.apache.log4j.RollingFileAppender
log4j.appender.A1.File=log.txt
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
# ***** Max file size is set to 100KB
log4j.appender.A1.MaxFileSize=100MB
# ***** Keep one backup file
log4j.appender.A1.MaxBackupIndex=1
#CONSOLE
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Threshold=INFO
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%t] %-5p %c %d{dd MMM yyyy ;HH:mm:ss.SSS} - %m%n

View File

@ -206,7 +206,7 @@ public RemoteResourceComplexInfo getMetaFile();
/**
* close the connections to backend storage system
*/
public void close();
public void forceClose();
public RemoteResource getUrl(boolean forceCreation);

View File

@ -911,13 +911,13 @@ public class ServiceEngine implements IClient {
}
@Override
public void close(){
currentOperation="close";
public void forceClose(){
currentOperation="forceclose";
file.setOwner(owner);
getMyFile().setRemoteResource(REMOTE_RESOURCE.PATH);
setMyFile(file);
service.setResource(getMyFile());
service.setTypeOperation("close");
service.setTypeOperation("forceclose");
try {
if(((file.getInputStream() != null) || (file.getOutputStream()!=null)) || ((file.getLocalPath() != null) || (file.getRemotePath() != null)))
service.startOperation(file,file.getRemotePath(), owner, primaryBackend, Costants.DEFAULT_CHUNK_OPTION, getContext(), isReplaceOption());

View File

@ -7,7 +7,7 @@ import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendEx
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Close extends Operation{
public class ForceClose extends Operation{
/**
* Logger for this class
@ -15,7 +15,7 @@ public class Close extends Operation{
final Logger logger=LoggerFactory.getLogger(GetSize.class);
// public String file_separator = ServiceEngine.FILE_SEPARATOR;//System.getProperty("file.separator");
public Close(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
public ForceClose(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
}
@ -24,7 +24,7 @@ public class Close extends Operation{
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
TransportManager tm=getTransport(myFile);
try {
tm.close();
tm.forceClose();
} catch (Exception e) {
throw new RemoteBackendException(" Error in GetSize operation ", e.getCause()); }
if (logger.isDebugEnabled()) {

View File

@ -52,6 +52,8 @@ public class OperationFactory {
op=new Remove(server, user, password, bucket, monitor, isChunk, backendType, dbNames);
}else if(operation.equalsIgnoreCase("getSize")){
op=new GetSize(server, user, password, bucket, monitor, isChunk, backendType, dbNames);
}else if(operation.equalsIgnoreCase("forceclose")){
op=new ForceClose(server, user, password, bucket, monitor, isChunk, backendType, dbNames);
}else if(operation.equalsIgnoreCase("duplicate")){
op=new DuplicateOperator(server, user, password, bucket, monitor, isChunk, backendType, dbNames);
}else if(operation.equalsIgnoreCase("softcopy")){

View File

@ -326,6 +326,8 @@ public abstract class TransportManager {
public abstract String getField(String remoteIdentifier, String fieldName) throws UnknownHostException ;
public abstract void close();
public abstract void forceClose();
public abstract void setFileProperty(String remotePath, String propertyField, String propertyValue);

View File

@ -1074,6 +1074,13 @@ public class MongoIOManager {
// db=null;
}
public void forceClose() {
if(mongo!=null)
mongo.close();
logger.info("Mongo pool closed");
}
public void removeGFSFile(GridFSDBFile f, ObjectId idF){
// this field is an advice for oplog collection reader
f.put("onDeleting", "true");

View File

@ -133,6 +133,11 @@ public class MongoOperationManager extends TransportManager{
// mongoSecondaryInstance.close();
}
public void forceClose() {
mongoPrimaryInstance.forceClose();
mongoSecondaryInstance.forceClose();
}
/**
* Unlock the object specified, this method accept the key field for the unlock operation
* @throws FileNotFoundException