method /mdstores/info

This commit is contained in:
Michele Artini 2021-01-28 11:18:50 +01:00
parent 40c3ee37ef
commit 9b853732ce
5 changed files with 34 additions and 36 deletions

View File

@ -1,12 +1,4 @@
1) Usare un client hdfs per cancellare le stores
2) sostiuire il metodo expiredVersion s deleteVersions con un metodo solo che cancelli anche su hdfs
3) Non consentire operazioni lettura e scrittura sulle store in prepareDelete
4) Aggiungere il path hdfs delle store nelle versions e nella store (parent come property)
5) metodo info con alcune props
alter table mdstores add column creation_date timestamp;
alter table mdstores add column hdfs_path text;
alter table mdstore_versions add column hdfs_path text;
drop view mdstores_with_info;

View File

@ -1,6 +1,8 @@
package eu.dnetlib.data.mdstore.manager.controller;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
@ -55,12 +57,6 @@ public class MDStoreController extends AbstractDnetController {
return databaseUtils.startReading(mdId);
}
@ApiOperation("Return the number of mdstores")
@GetMapping("/count")
public SizeResponse count() {
return new SizeResponse(databaseUtils.countMdStores());
}
@ApiOperation("Create a new mdstore")
@GetMapping("/new/{format}/{layout}/{interpretation}")
public MDStoreWithInfo createMDStore(
@ -137,4 +133,15 @@ public class MDStoreController extends AbstractDnetController {
databaseUtils.deleteMdStoreVersions(force, versions);
return StatusResponse.DELETED;
}
@ApiOperation("Show informations")
@GetMapping("/info")
public Map<String, Object> info() {
final Map<String, Object> info = new LinkedHashMap<>();
info.put("number_of_mdstores", databaseUtils.countMdStores());
info.put("hadoop_cluster", databaseUtils.getHadoopCluster());
info.put("hdfs_base_path", databaseUtils.getHdfsBasePath());
return info;
}
}

View File

@ -1,21 +0,0 @@
package eu.dnetlib.data.mdstore.manager.controller;
public class SizeResponse {
private long size = 0;
public SizeResponse() {}
public SizeResponse(final long size) {
this.size = size;
}
public long getSize() {
return size;
}
public void setSize(final long size) {
this.size = size;
}
}

View File

@ -40,6 +40,9 @@ public class DatabaseUtils {
@Value("${dhp.mdstore-manager.hdfs.base-path}")
private String hdfsBasePath;
@Value("${dhp.mdstore-manager.hadoop.cluster}")
private String hadoopCluster;
private static final Logger log = LoggerFactory.getLogger(DatabaseUtils.class);
public Iterable<MDStoreWithInfo> listMdStores() {
@ -171,4 +174,20 @@ public class DatabaseUtils {
}
}
public String getHdfsBasePath() {
return hdfsBasePath;
}
public void setHdfsBasePath(final String hdfsBasePath) {
this.hdfsBasePath = hdfsBasePath;
}
public String getHadoopCluster() {
return hadoopCluster;
}
public void setHadoopCluster(final String hadoopCluster) {
this.hadoopCluster = hadoopCluster;
}
}

View File

@ -21,5 +21,6 @@ spring.jpa.open-in-view=true
# logs
logging.level.io.swagger.models.parameters.AbstractSerializableParameter = error
# Hadoop
dhp.mdstore-manager.hadoop.cluster = GARR
dhp.mdstore-manager.hdfs.base-path = /tmp/mdstoremanager_dev