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>
<groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-manager-core</artifactId>
<version>[2.0.0, 2.9.0-SNAPSHOT)</version>
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.contentmanagement</groupId>
<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>

View File

@ -1,5 +1,6 @@
package org.gcube.application.cms.usecases;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.cms.tests.TokenSetter;
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.Iterator;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni;
@Slf4j
public class ClearConcessioni {
public static void main(String[] args) throws Exception {
@ -26,14 +31,22 @@ public class ClearConcessioni {
AtomicLong count=new AtomicLong(0);
AtomicLong nullCount=new AtomicLong(0);
AtomicLong errCount=new AtomicLong(0);
AtomicLong found=new AtomicLong(0);
Iterator<Concessione> it=null;
// 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)->{
found.incrementAndGet();
service.submit(new Runnable() {
@Override
public void run() {
try{
TokenSetter.set("/gcube/devsec/devVRE");
String currentId=c.getMongo_id();
if(currentId==null) {
System.out.println("ID IS NULL " + c);
@ -52,7 +65,14 @@ public class ClearConcessioni {
}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()+"]");