Added logic to exclude harvesting in some cases

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-dashboard-harvester-se-plugin@169213 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2018-06-14 14:22:19 +00:00
parent 13c74dc4f9
commit 56d97e228b
1 changed files with 55 additions and 51 deletions

View File

@ -47,7 +47,10 @@ public class AccountingDataHarvesterPlugin extends Plugin<DataHarvestPluginDecla
public static final String DRY_RUN_INPUT_PARAMETER = "dryRun"; public static final String DRY_RUN_INPUT_PARAMETER = "dryRun";
public static final String SO_BIG_DATA_VO = "/d4science.research-infrastructures.eu/SoBigData"; public static final String SO_BIG_DATA_VO = "/d4science.research-infrastructures.eu/SoBigData";
public static final String SO_BIG_DATA_EU_VRE = "/d4science.research-infrastructures.eu/gCubeApps/SoBigData.eu";
public static final String SO_BIG_DATA_IT_VRE = "/d4science.research-infrastructures.eu/gCubeApps/SoBigData.it";
public static final String SO_BIG_DATA_CATALOGUE_CONTEXT = "/d4science.research-infrastructures.eu/SoBigData/ResourceCatalogue"; public static final String SO_BIG_DATA_CATALOGUE_CONTEXT = "/d4science.research-infrastructures.eu/SoBigData/ResourceCatalogue";
public static final String TAGME_CONTEXT = "/d4science.research-infrastructures.eu/SoBigData/TagMe"; public static final String TAGME_CONTEXT = "/d4science.research-infrastructures.eu/SoBigData/TagMe";
protected Date start; protected Date start;
@ -104,7 +107,7 @@ public class AccountingDataHarvesterPlugin extends Plugin<DataHarvestPluginDecla
if(inputs.containsKey(RERUN_INPUT_PARAMETER)) { if(inputs.containsKey(RERUN_INPUT_PARAMETER)) {
try { try {
reRun = (boolean) inputs.get(RERUN_INPUT_PARAMETER); reRun = (boolean) inputs.get(RERUN_INPUT_PARAMETER);
}catch (Exception e) { } catch(Exception e) {
throw new IllegalArgumentException("'" + RERUN_INPUT_PARAMETER + "' must be a boolean"); throw new IllegalArgumentException("'" + RERUN_INPUT_PARAMETER + "' must be a boolean");
} }
} }
@ -113,17 +116,16 @@ public class AccountingDataHarvesterPlugin extends Plugin<DataHarvestPluginDecla
if(inputs.containsKey(GET_VRE_USERS_INPUT_PARAMETER)) { if(inputs.containsKey(GET_VRE_USERS_INPUT_PARAMETER)) {
try { try {
reRun = (boolean) inputs.get(GET_VRE_USERS_INPUT_PARAMETER); reRun = (boolean) inputs.get(GET_VRE_USERS_INPUT_PARAMETER);
}catch (Exception e) { } catch(Exception e) {
throw new IllegalArgumentException("'" + GET_VRE_USERS_INPUT_PARAMETER + "' must be a boolean"); throw new IllegalArgumentException("'" + GET_VRE_USERS_INPUT_PARAMETER + "' must be a boolean");
} }
} }
boolean dryRun = true; boolean dryRun = true;
if(inputs.containsKey(DRY_RUN_INPUT_PARAMETER)) { if(inputs.containsKey(DRY_RUN_INPUT_PARAMETER)) {
try { try {
dryRun = (boolean) inputs.get(DRY_RUN_INPUT_PARAMETER); dryRun = (boolean) inputs.get(DRY_RUN_INPUT_PARAMETER);
}catch (Exception e) { } catch(Exception e) {
throw new IllegalArgumentException("'" + DRY_RUN_INPUT_PARAMETER + "' must be a boolean"); throw new IllegalArgumentException("'" + DRY_RUN_INPUT_PARAMETER + "' must be a boolean");
} }
} }
@ -137,8 +139,7 @@ public class AccountingDataHarvesterPlugin extends Plugin<DataHarvestPluginDecla
end = DateUtils.getEndDateFromStartDate(measureType, start, 1); end = DateUtils.getEndDateFromStartDate(measureType, start, 1);
logger.debug("Harvesting from {} to {}", DateUtils.format(start), logger.debug("Harvesting from {} to {}", DateUtils.format(start), DateUtils.format(end));
DateUtils.format(end));
Properties properties = getConfigParameters(); Properties properties = getConfigParameters();
getProperties().set(properties); getProperties().set(properties);
@ -165,7 +166,7 @@ public class AccountingDataHarvesterPlugin extends Plugin<DataHarvestPluginDecla
if(scopeBean.is(Type.INFRASTRUCTURE)) { if(scopeBean.is(Type.INFRASTRUCTURE)) {
vreAccessesHarvester = new VREAccessesHarvester(start, end); vreAccessesHarvester = new VREAccessesHarvester(start, end);
}else { } else {
// This code should be never used because the scopes are sorted by fullname // This code should be never used because the scopes are sorted by fullname
ScopeBean parent = scopeBean.enclosingScope(); ScopeBean parent = scopeBean.enclosingScope();
@ -184,10 +185,12 @@ public class AccountingDataHarvesterPlugin extends Plugin<DataHarvestPluginDecla
} }
try { try {
if(context.startsWith(SO_BIG_DATA_VO) && start.before(DateUtils.getStartCalendar(2018, Calendar.APRIL, 1).getTime())) { if((context.startsWith(SO_BIG_DATA_VO) || context.startsWith(SO_BIG_DATA_EU_VRE)
logger.info("Not Harvesting VREs Accesses for {} from {} to {}", context, DateUtils.format(start), DateUtils.format(end)); || context.startsWith(SO_BIG_DATA_IT_VRE))
&& start.before(DateUtils.getStartCalendar(2018, Calendar.APRIL, 1).getTime())) {
logger.info("Not Harvesting VREs Accesses for {} from {} to {}", context, DateUtils.format(start),
DateUtils.format(end));
} else { } else {
// Collecting Google Analytics Data for VREs Accesses // Collecting Google Analytics Data for VREs Accesses
List<HarvestedData> harvested = vreAccessesHarvester.getData(); List<HarvestedData> harvested = vreAccessesHarvester.getData();
@ -197,7 +200,6 @@ public class AccountingDataHarvesterPlugin extends Plugin<DataHarvestPluginDecla
logger.error("Error harvesting Social Interactions for {}", context, e); logger.error("Error harvesting Social Interactions for {}", context, e);
} }
try { try {
// Collecting info on social (posts, replies and likes) // Collecting info on social (posts, replies and likes)
SocialInteractionsHarvester socialHarvester = new SocialInteractionsHarvester(start, end); SocialInteractionsHarvester socialHarvester = new SocialInteractionsHarvester(start, end);
@ -222,12 +224,12 @@ public class AccountingDataHarvesterPlugin extends Plugin<DataHarvestPluginDecla
logger.error("Error harvesting Context Users for {}", context, e); logger.error("Error harvesting Context Users for {}", context, e);
} }
if(context.startsWith(SO_BIG_DATA_CATALOGUE_CONTEXT)) { if(context.startsWith(SO_BIG_DATA_CATALOGUE_CONTEXT)) {
try { try {
// Collecting info on Resource Catalogue (Dataset, Application, Deliverables, Methods) // Collecting info on Resource Catalogue (Dataset, Application, Deliverables, Methods)
ResourceCatalogueHarvester resourceCatalogueHarvester = new ResourceCatalogueHarvester(start, end, contexts); ResourceCatalogueHarvester resourceCatalogueHarvester = new ResourceCatalogueHarvester(start, end,
contexts);
List<HarvestedData> harvested = resourceCatalogueHarvester.getData(); List<HarvestedData> harvested = resourceCatalogueHarvester.getData();
data.addAll(harvested); data.addAll(harvested);
} catch(Exception e) { } catch(Exception e) {
@ -236,7 +238,8 @@ public class AccountingDataHarvesterPlugin extends Plugin<DataHarvestPluginDecla
try { try {
// Collecting info on Data/Method download // Collecting info on Data/Method download
DataMethodDownloadHarvester dataMethodDownloadHarvester = new DataMethodDownloadHarvester(start, end, contexts); DataMethodDownloadHarvester dataMethodDownloadHarvester = new DataMethodDownloadHarvester(start,
end, contexts);
List<HarvestedData> harvested = dataMethodDownloadHarvester.getData(); List<HarvestedData> harvested = dataMethodDownloadHarvester.getData();
data.addAll(harvested); data.addAll(harvested);
} catch(Exception e) { } catch(Exception e) {
@ -248,13 +251,14 @@ public class AccountingDataHarvesterPlugin extends Plugin<DataHarvestPluginDecla
if(context.startsWith(TAGME_CONTEXT)) { if(context.startsWith(TAGME_CONTEXT)) {
try { try {
// Collecting info on method invocation // Collecting info on method invocation
TagMeMethodInvocationHarvester tagMeMethodInvocationHarvester = new TagMeMethodInvocationHarvester(start, end); TagMeMethodInvocationHarvester tagMeMethodInvocationHarvester = new TagMeMethodInvocationHarvester(
start, end);
List<HarvestedData> harvested = tagMeMethodInvocationHarvester.getData(); List<HarvestedData> harvested = tagMeMethodInvocationHarvester.getData();
data.addAll(harvested); data.addAll(harvested);
} catch(Exception e) { } catch(Exception e) {
logger.error("Error harvesting Method Invocations for {}", context, e); logger.error("Error harvesting Method Invocations for {}", context, e);
} }
}else { } else {
try { try {
// Collecting info on method invocation // Collecting info on method invocation
MethodInvocationHarvester methodInvocationHarvester = new MethodInvocationHarvester(start, end); MethodInvocationHarvester methodInvocationHarvester = new MethodInvocationHarvester(start, end);