Downgrade to legacy storage implementation

This commit is contained in:
Fabio Sinibaldi 2021-10-07 14:44:15 +02:00
parent 9eab028bab
commit 19951b804e
2 changed files with 42 additions and 23 deletions

View File

@ -107,13 +107,12 @@
<dependency> <dependency>
<groupId>org.gcube.contentmanagement</groupId> <groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-manager-core</artifactId> <artifactId>storage-manager-core</artifactId>
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
<version>[2.0.0, 2.9.0-SNAPSHOT)</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.contentmanagement</groupId> <groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-manager-wrapper</artifactId> <artifactId>storage-manager-wrapper</artifactId>
<version>[2.0.0, 2.9.0-SNAPSHOT)</version> <version>[2.0.0, 3.0.0-SNAPSHOT)</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -1,5 +1,6 @@
package org.gcube.application.cms.usecases; package org.gcube.application.cms.usecases;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.cms.tests.TokenSetter; import org.gcube.application.cms.tests.TokenSetter;
import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI; import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
@ -7,10 +8,14 @@ import org.gcube.application.geoportal.common.model.legacy.Concessione;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni; import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni;
@Slf4j
public class ClearConcessioni { public class ClearConcessioni {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
@ -26,34 +31,49 @@ public class ClearConcessioni {
AtomicLong count=new AtomicLong(0); AtomicLong count=new AtomicLong(0);
AtomicLong nullCount=new AtomicLong(0); AtomicLong nullCount=new AtomicLong(0);
AtomicLong errCount=new AtomicLong(0); AtomicLong errCount=new AtomicLong(0);
AtomicLong found=new AtomicLong(0);
Iterator<Concessione> it=null; Iterator<Concessione> it=null;
// it=manager.getList(); // it=manager.getList();
it=manager.search("{\"nome\" : {\"$regex\" : \"Mock.*\"}}"); it=manager.search("{\"creationUser\" : {\"$ne\" : \"francesco.mangiacrapa\"}}");
ExecutorService service = Executors.newFixedThreadPool(10);
it.forEachRemaining((Concessione c)->{ it.forEachRemaining((Concessione c)->{
try{ found.incrementAndGet();
String currentId=c.getMongo_id(); service.submit(new Runnable() {
if(currentId==null) { @Override
System.out.println("ID IS NULL " + c); public void run() {
nullCount.incrementAndGet(); try{
} TokenSetter.set("/gcube/devsec/devVRE");
else String currentId=c.getMongo_id();
if(toSkipIds.contains(currentId)) if(currentId==null) {
System.out.println("Skipping "+currentId); System.out.println("ID IS NULL " + c);
else { nullCount.incrementAndGet();
System.out.println("Deleting " + c.getMongo_id()); }
manager.deleteById(c.getMongo_id(),true); else
if(toSkipIds.contains(currentId))
System.out.println("Skipping "+currentId);
else {
System.out.println("Deleting " + c.getMongo_id());
manager.deleteById(c.getMongo_id(),true);
}
}catch(Throwable throwable){
System.err.println(throwable);
errCount.incrementAndGet();
}finally {
count.incrementAndGet();
} }
}catch(Throwable throwable){ }
System.err.println(throwable); });
errCount.incrementAndGet();
}finally {
count.incrementAndGet();
}
}); });
while (!service.awaitTermination(2, TimeUnit.MINUTES)) {
log.info("Waiting .. completed {}, out of {} ",count.get(),found.get());
if(found.get()==count.get()) service.shutdown();
}
System.out.println("Done "+count.get()+" [null : "+nullCount.get()+", err : "+errCount.get()+"]"); System.out.println("Done "+count.get()+" [null : "+nullCount.get()+", err : "+errCount.get()+"]");
} }