Code redesign

Refs #11756: Refactor DataHArvesterPlugin to support scheduled execution from smart-executor 

Task-Url: https://support.d4science.org/issues/11756

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-dashboard-harvester-se-plugin@167597 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2018-05-18 12:23:57 +00:00
parent 9db4794c16
commit 2cb0d8b15f
3 changed files with 38 additions and 37 deletions

View File

@ -136,49 +136,52 @@ public class AccountingDataHarvesterPlugin extends Plugin<DataHarvestPluginDecla
Utils.setContext(contextAuthorization.getTokenForContext(context));
try {
// collecting info on VRE users
VreUsersHarvester vreUsersHarvester = new VreUsersHarvester(start, end);
List<HarvestedData> harvested = vreUsersHarvester.getData();
data.addAll(harvested);
} catch(Exception x) {
logger.error(x.getLocalizedMessage());
}
try {
// collecting info on Res. Catalogue (Dataset, Application, Deliverables, Methods)
ResourceCatalogueHarvester resourceCatalogueHarvester = new ResourceCatalogueHarvester(start, end);
List<HarvestedData> harvested = resourceCatalogueHarvester.getData();
data.addAll(harvested);
} catch(Exception x) {
logger.error(x.getLocalizedMessage());
}
try {
// collecting info on Data/Method download
DataMethodDownloadHarvester dataMethodDownloadHarvester = new DataMethodDownloadHarvester(start, end);
List<HarvestedData> harvested = dataMethodDownloadHarvester.getData();
data.addAll(harvested);
} catch(Exception x) {
logger.error(x.getLocalizedMessage());
}
try {
// collecting info on social (posts, replies and likes)
// Collecting info on social (posts, replies and likes)
SocialHarvester socialHarvester = new SocialHarvester(start, end);
List<HarvestedData> harvested = socialHarvester.getData();
data.addAll(harvested);
} catch(Exception x) {
logger.error(x.getLocalizedMessage());
} catch(Exception e) {
logger.error("Error harvesting Scoial Interactions for {}", context, e);
}
try {
// Collecting info on VRE users
VreUsersHarvester vreUsersHarvester = new VreUsersHarvester(start, end);
List<HarvestedData> harvested = vreUsersHarvester.getData();
data.addAll(harvested);
} catch(Exception e) {
logger.error("Error harvesting Context Users for {}", context, e);
}
try {
// Collecting info on Res. Catalogue (Dataset, Application, Deliverables, Methods)
ResourceCatalogueHarvester resourceCatalogueHarvester = new ResourceCatalogueHarvester(start, end);
List<HarvestedData> harvested = resourceCatalogueHarvester.getData();
data.addAll(harvested);
} catch(Exception e) {
logger.error("Error harvesting Resource Catalogue Information for {}", context, e);
}
try {
// collecting info on method invocation
// Collecting info on Data/Method download
DataMethodDownloadHarvester dataMethodDownloadHarvester = new DataMethodDownloadHarvester(start, end);
List<HarvestedData> harvested = dataMethodDownloadHarvester.getData();
data.addAll(harvested);
} catch(Exception e) {
logger.error("Error harvesting Data Method Download for {}", context, e);
}
try {
// Collecting info on method invocation
MethodInvocationHarvester methodInvocationHarvester = new MethodInvocationHarvester(start, end);
List<HarvestedData> harvested = methodInvocationHarvester.getData();
data.addAll(harvested);
} catch(Exception x) {
logger.error(x.getLocalizedMessage());
} catch(Exception e) {
logger.error("Error harvesting Method Invocations for {}", context, e);
}
}

View File

@ -28,8 +28,8 @@ public class VreUsersHarvester extends BasicHarvester {
@Override
public List<HarvestedData> getData() throws Exception {
String context = Utils.getCurrentContext();
try {
String context = Utils.getCurrentContext();
int measure = get();
HarvestedData harvest = new HarvestedData(HarvestedData.USERS, context, measure);
logger.debug(harvest.toString());
@ -37,7 +37,6 @@ public class VreUsersHarvester extends BasicHarvester {
data.add(harvest);
return data;
} catch(Exception e) {
logger.error("Error Haversting Context Users for context {}", context, e);
throw e;
}
}

View File

@ -68,7 +68,6 @@ public class DataMethodDownloadHarvester extends BasicHarvester {
return data;
} catch(Exception e) {
logger.error("Error Harvesting Data Methods Download for context {}", context, e);
throw e;
}