bugFix on building accounting record
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/content-management/storage-manager-trigger@95337 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3febcf534f
commit
eca94fd6da
|
@ -40,16 +40,7 @@ import org.slf4j.LoggerFactory;
|
||||||
@Override
|
@Override
|
||||||
public void start(String consumerId, String resourceScope, String creationTime) {
|
public void start(String consumerId, String resourceScope, String creationTime) {
|
||||||
logger.info("set accounting properties: consumerId "+consumerId+" scope: "+resourceScope+ " creationTime "+creationTime);
|
logger.info("set accounting properties: consumerId "+consumerId+" scope: "+resourceScope+ " creationTime "+creationTime);
|
||||||
raFactory = null;
|
if(raFactory==null) init();
|
||||||
try {
|
|
||||||
raFactory = ResourceAccountingFactory.getResourceAccountingInstance();
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
this.ur = new RawUsageRecord();
|
this.ur = new RawUsageRecord();
|
||||||
// generic properties
|
// generic properties
|
||||||
ur.setResourceType("storage-usage");
|
ur.setResourceType("storage-usage");
|
||||||
|
@ -57,43 +48,46 @@ import org.slf4j.LoggerFactory;
|
||||||
// ur.setResourceOwner("paolo.fabriani");
|
// ur.setResourceOwner("paolo.fabriani");
|
||||||
if(resourceScope !=null) ur.setResourceScope(resourceScope);
|
if(resourceScope !=null) ur.setResourceScope(resourceScope);
|
||||||
//set creation time
|
//set creation time
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("dd MM yyyy 'at' hh:mm:ss z");
|
if(creationTime!=null){
|
||||||
Date date=null;
|
SimpleDateFormat formatter = new SimpleDateFormat("dd MM yyyy 'at' hh:mm:ss z");
|
||||||
try {
|
Date date=null;
|
||||||
date = formatter.parse(creationTime);
|
try {
|
||||||
} catch (ParseException e) {
|
date = formatter.parse(creationTime);
|
||||||
logger.error("Error in parsing date: "+e.getMessage());
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
logger.error("Error in parsing date: "+creationTime+" exc msg: "+e.getMessage());
|
||||||
|
}
|
||||||
ur.setCreateTime(date);
|
ur.setCreateTime(date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void timeUpdate() {
|
public void timeUpdate() {
|
||||||
// setIpAddress();
|
|
||||||
setStartTime();
|
setStartTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ultimate(String owner, String operation, String size, String filePath, String id, String callerIP, String lastAccess) {
|
public void ultimate(String owner, String operation, String size, String filePath, String id, String callerIP, String lastAccess) {
|
||||||
logger.info("set accounting properties: owner "+owner+" operation: "+operation+" size: "+size+ " remotePath: "+filePath+" id: "+id);
|
logger.info("set accounting properties: owner "+owner+" operation: "+operation+" size: "+size+ " remotePath: "+filePath+" id: "+id+"callerIP "+callerIP+" lastAccess"+lastAccess);
|
||||||
//specific properties TODO
|
if(ur==null) this.ur = new RawUsageRecord();
|
||||||
|
//specific properties
|
||||||
if(owner != null) ur.setResourceOwner(owner);
|
if(owner != null) ur.setResourceOwner(owner);
|
||||||
// if(uri != null) ur.setResourceSpecificProperty("objectURI", uri);
|
|
||||||
if (operation!=null) ur.setResourceSpecificProperty("operationType",operation);
|
if (operation!=null) ur.setResourceSpecificProperty("operationType",operation);
|
||||||
ur.setResourceSpecificProperty("dataType","STORAGE");
|
|
||||||
if(size!= null) ur.setResourceSpecificProperty("dataVolume", size);
|
if(size!= null) ur.setResourceSpecificProperty("dataVolume", size);
|
||||||
if(filePath != null) ur.setResourceSpecificProperty("remotePath", filePath);
|
if(filePath != null) ur.setResourceSpecificProperty("remotePath", filePath);
|
||||||
if(id!= null) ur.setResourceSpecificProperty("id", id);
|
if(id!= null) ur.setResourceSpecificProperty("id", id);
|
||||||
|
if(callerIP!=null) ur.setResourceSpecificProperty("callerIP", "etics.eng.it");
|
||||||
|
if(lastAccess!=null)ur.setResourceSpecificProperty("lastAccess", lastAccess);
|
||||||
|
// set static properties
|
||||||
|
ur.setResourceSpecificProperty("dataType","STORAGE");
|
||||||
ur.setResourceSpecificProperty("dataCount", "1");
|
ur.setResourceSpecificProperty("dataCount", "1");
|
||||||
ur.setResourceSpecificProperty("callerIP", "etics.eng.it");
|
|
||||||
// setEndTime();
|
|
||||||
ur.setResourceSpecificProperty("lastAccess", lastAccess);
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void send() {
|
public void send() {
|
||||||
logger.info("report sending...");
|
logger.info("report sending...");
|
||||||
raFactory.sendAccountingMessage(ur);
|
if(raFactory!=null)
|
||||||
|
raFactory.sendAccountingMessage(ur);
|
||||||
|
else
|
||||||
|
logger.error("Problem on building accounting record: Factory Object is null ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|
Loading…
Reference in New Issue