added storage status report filter
update to version 1.1.1-SNAPSHOT git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/content-management/storage-manager-trigger@100491 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1b7c905ecb
commit
23561c3a80
|
@ -1,3 +1,5 @@
|
||||||
|
v 1.1.1 (06/10/2014)
|
||||||
|
* added storage status report filter
|
||||||
v 1.1.0 (08/09/2014)
|
v 1.1.0 (08/09/2014)
|
||||||
* added storage status report
|
* added storage status report
|
||||||
v. 1.0.2 (30-06-2014)
|
v. 1.0.2 (30-06-2014)
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
<ReleaseNotes>
|
<ReleaseNotes>
|
||||||
<ReleaseNotes>
|
<ReleaseNotes>
|
||||||
<Changeset component="org.gcube.content-management.storage-manager-trigger.1-1-0" date="2014-06-30">
|
<Changeset component="org.gcube.content-management.storage-manager-trigger.1-1-1" date="2014-10-06">
|
||||||
|
<Change>added storage status report filter</Change>
|
||||||
|
</Changeset>
|
||||||
|
<Changeset component="org.gcube.content-management.storage-manager-trigger.1-1-0" date="2014-09-08">
|
||||||
<Change>added storage status report</Change>
|
<Change>added storage status report</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.content-management.storage-manager-trigger.1-0-2" date="2014-06-30">
|
<Changeset component="org.gcube.content-management.storage-manager-trigger.1-0-2" date="2014-06-30">
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -8,7 +8,7 @@
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.gcube.contentmanagement</groupId>
|
<groupId>org.gcube.contentmanagement</groupId>
|
||||||
<artifactId>storage-manager-trigger</artifactId>
|
<artifactId>storage-manager-trigger</artifactId>
|
||||||
<version>1.1.0-SNAPSHOT</version>
|
<version>1.1.1-SNAPSHOT</version>
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/content-management/${project.artifactId}</connection>
|
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/content-management/${project.artifactId}</connection>
|
||||||
<developerConnection>scm:svn:https://svn.d4science.research-infrastructures.eu/gcube/trunk/content-management/${project.artifactId}</developerConnection>
|
<developerConnection>scm:svn:https://svn.d4science.research-infrastructures.eu/gcube/trunk/content-management/${project.artifactId}</developerConnection>
|
||||||
|
|
|
@ -26,5 +26,10 @@ public interface Report {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public void send(RawUsageRecord sur);
|
public void send(RawUsageRecord sur);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public abstract void printRecord(RawUsageRecord record);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RawUsageRecord setGenericProperties(String resourceType, String consumerId, String resourceScope, String creationTime, String lastAccess, String owner) {
|
public RawUsageRecord setGenericProperties(String resourceType, String consumerId, String resourceScope, String creationTime, String lastAccess, String owner) {
|
||||||
logger.info("set accounting generic properties: resourceType: "+resourceType+" consumerId "+consumerId+" scope: "+resourceScope+ " creationTime "+creationTime+" lastAccess "+lastAccess+" owner "+ owner);
|
logger.trace("set accounting generic properties: resourceType: "+resourceType+" consumerId "+consumerId+" scope: "+resourceScope+ " creationTime "+creationTime+" lastAccess "+lastAccess+" owner "+ owner);
|
||||||
if(raFactory==null) init();
|
if(raFactory==null) init();
|
||||||
RawUsageRecord sr = new RawUsageRecord();
|
RawUsageRecord sr = new RawUsageRecord();
|
||||||
sr.setResourceType(resourceType);
|
sr.setResourceType(resourceType);
|
||||||
|
@ -67,7 +67,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RawUsageRecord setSpecificProperties( RawUsageRecord sur, String operation, String size, String filePath, String callerIP, String dataType, String dataCount) {
|
public RawUsageRecord setSpecificProperties( RawUsageRecord sur, String operation, String size, String filePath, String callerIP, String dataType, String dataCount) {
|
||||||
logger.info("set accounting properties: operation: "+operation+" size: "+size+ " remotePath: "+filePath+" callerIP "+callerIP+" dataType "+dataType+" dataCount "+dataCount);
|
logger.trace("set accounting properties: operation: "+operation+" size: "+size+ " remotePath: "+filePath+" callerIP "+callerIP+" dataType "+dataType+" dataCount "+dataCount);
|
||||||
if(sur==null) sur = new RawUsageRecord();
|
if(sur==null) sur = new RawUsageRecord();
|
||||||
if (operation!=null) sur.setResourceSpecificProperty("operationType",operation);
|
if (operation!=null) sur.setResourceSpecificProperty("operationType",operation);
|
||||||
if(size!= null) sur.setResourceSpecificProperty("dataVolume", size);
|
if(size!= null) sur.setResourceSpecificProperty("dataVolume", size);
|
||||||
|
@ -77,6 +77,22 @@ import org.slf4j.LoggerFactory;
|
||||||
sur.setResourceSpecificProperty("dataCount", dataCount);
|
sur.setResourceSpecificProperty("dataCount", dataCount);
|
||||||
return sur;
|
return sur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void printRecord(RawUsageRecord record){
|
||||||
|
logger.info(" accounting properties: " +
|
||||||
|
"\n\t owner: "+record.getResourceOwner()+
|
||||||
|
"\n\t scope "+record.getResourceScope()+
|
||||||
|
"\n\t type "+record.getResourceType()+
|
||||||
|
"\n\t consumer "+record.getConsumerId()+
|
||||||
|
"\n\t startTime "+record.getStartTime()+
|
||||||
|
"\n\t endTime "+record.getEndTime()+
|
||||||
|
"\n\t file "+record.getResourceSpecificProperty("remotePath")+
|
||||||
|
"\n\t size "+record.getResourceSpecificProperty("dataVolume")+
|
||||||
|
"\n\t caller "+record.getResourceSpecificProperty("callerIP")+
|
||||||
|
"\n\t dataType "+record.getResourceSpecificProperty("dataType")+
|
||||||
|
"\n\t dataCount "+record.getResourceSpecificProperty("dataCount")+
|
||||||
|
"\n\t operation "+record.getResourceSpecificProperty("operationType"));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void send(RawUsageRecord sur) {
|
public void send(RawUsageRecord sur) {
|
||||||
|
@ -86,9 +102,9 @@ import org.slf4j.LoggerFactory;
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if(raFactory!=null){
|
if(raFactory!=null){
|
||||||
logger.info("report sending...");
|
logger.debug("report sending...");
|
||||||
raFactory.sendAccountingMessage(sur);
|
raFactory.sendAccountingMessage(sur);
|
||||||
logger.info(" report send ");
|
logger.info(" report send: \n\t"+sur);
|
||||||
}else
|
}else
|
||||||
logger.error("Problem on building accounting record: Factory Object is null ");
|
logger.error("Problem on building accounting record: Factory Object is null ");
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,21 +109,28 @@ public class JsonParser extends Thread{
|
||||||
logger.warn("lastOperation: "+lastOperation+" lastUser: "+lastUser+". These values cannot be null. Skip next ");
|
logger.warn("lastOperation: "+lastOperation+" lastUser: "+lastUser+". These values cannot be null. Skip next ");
|
||||||
}
|
}
|
||||||
StorageStatusRecord ssr=null;
|
StorageStatusRecord ssr=null;
|
||||||
try{
|
if(isNeedSSReport(lastOperation)){
|
||||||
mongo=new MongoDB(server, user, password);
|
try{
|
||||||
ssr=mongo.update(lastUser, length, 1, lastOperation);
|
mongo=new MongoDB(server, user, password);
|
||||||
mongo.close();
|
if(lastOperation.equalsIgnoreCase("COPY"))
|
||||||
}catch(Exception e){
|
owner=lastUser;
|
||||||
logger.error("Problem in updating storage status record: "+e.getMessage());
|
ssr=mongo.update(owner, length, 1, lastOperation);
|
||||||
|
mongo.close();
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("Problem in updating storage status record: "+e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
logger.info(" operation accounted "+lastOperation);
|
logger.info(" operation accounted "+lastOperation);
|
||||||
//call to the accounting library
|
//call to the accounting library
|
||||||
report( filename, owner, creationTime, length, scope, lastOperation, callerIp, lastAccess, lastUser, ssr.getVolume()+"", ssr.getCount()+"");
|
if (ssr !=null)
|
||||||
|
report( filename, owner, creationTime, length, scope, lastOperation, callerIp, lastAccess, lastUser, ssr.getVolume()+"", ssr.getCount()+"");
|
||||||
|
else
|
||||||
|
report( filename, owner, creationTime, length, scope, lastOperation, callerIp, lastAccess, lastUser, null, null);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Problem sending accounting report. Exception message: "+e.getMessage());
|
logger.error("Problem sending accounting report. Exception message: "+e.getMessage());
|
||||||
}
|
}
|
||||||
logger.info("\n[accountingCall] operation: "+lastOperation+"\n\t name: "+name+"\n\t type: "+type+"\n\t path: "+filename+"\n\t length: "+length+"\n\t owner: "+owner+"\n\t cretionTime: "+creationTime+"\n\t scope: "+scope+"\n\t lastOperation "+lastOperation+"\n\t lastUser: "+lastUser+"\n\t lastAccess: "+lastAccess+"\n\t callerIp: "+callerIp);
|
// logger.info("\n[accountingCall] operation: "+lastOperation+"\n\t name: "+name+"\n\t type: "+type+"\n\t path: "+filename+"\n\t length: "+length+"\n\t owner: "+owner+"\n\t cretionTime: "+creationTime+"\n\t scope: "+scope+"\n\t lastOperation "+lastOperation+"\n\t lastUser: "+lastUser+"\n\t lastAccess: "+lastAccess+"\n\t callerIp: "+callerIp);
|
||||||
}else{
|
}else{
|
||||||
logger.info("operation is not accounted: invalid scope: "+scope);
|
logger.info("operation is not accounted: invalid scope: "+scope);
|
||||||
}
|
}
|
||||||
|
@ -142,6 +149,12 @@ public class JsonParser extends Thread{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean isNeedSSReport(String lastOperation) {
|
||||||
|
if(lastOperation.equalsIgnoreCase("UPLOAD") || lastOperation.equalsIgnoreCase("COPY") || lastOperation.equalsIgnoreCase("DELETE"))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void runWithoutThread(DBObject x){
|
public void runWithoutThread(DBObject x){
|
||||||
try {
|
try {
|
||||||
report=new ReportFactory().getReport(ReportConfig.ACCOUNTING_TYPE);
|
report=new ReportFactory().getReport(ReportConfig.ACCOUNTING_TYPE);
|
||||||
|
@ -184,14 +197,22 @@ public class JsonParser extends Thread{
|
||||||
}else if((lastOperation==null) || (lastUser==null)){
|
}else if((lastOperation==null) || (lastUser==null)){
|
||||||
logger.warn("lastOperation: "+lastOperation+" lastUser: "+lastUser+". These values cannot be null. Skip next ");
|
logger.warn("lastOperation: "+lastOperation+" lastUser: "+lastUser+". These values cannot be null. Skip next ");
|
||||||
}
|
}
|
||||||
// operation=mappingOperationField(op, id, delete, lastAccess);
|
logger.debug(" current operation "+lastOperation);
|
||||||
StorageStatusRecord ssr=null;
|
StorageStatusRecord ssr=null;
|
||||||
try{
|
if(isNeedSSReport(lastOperation)){
|
||||||
mongo=new MongoDB(server, user, password);
|
try{
|
||||||
ssr=mongo.update(lastUser, length, 1, lastOperation);
|
mongo=new MongoDB(server, user, password);
|
||||||
mongo.close();
|
if(lastOperation.equalsIgnoreCase("COPY")){
|
||||||
logger.info(" operation accounted "+lastOperation);
|
ssr=mongo.update(lastUser, length, 1, lastOperation);
|
||||||
logger.info("\n[accountingCall] operation: "+lastOperation+"\n\t name: "+name+"\n\t type: "+type+"\n\t path: "+filename+"\n\t length: "+length+"\n\t owner: "+owner+"\n\t cretionTime: "+creationTime+"\n\t scope: "+scope+"\n\t lastOperation "+lastOperation+"\n\t lastUser: "+lastUser+"\n\t lastAccess: "+lastAccess+"\n\t callerIp: "+callerIp);
|
}else{
|
||||||
|
ssr=mongo.update(owner, length, 1, lastOperation);
|
||||||
|
}
|
||||||
|
mongo.close();
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("Problem in updating storage status record: "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try{
|
||||||
//call to the accounting library
|
//call to the accounting library
|
||||||
report( filename, owner, creationTime, length, scope, lastOperation, callerIp, lastAccess, lastUser, ssr.getVolume()+"", ssr.getCount()+"");
|
report( filename, owner, creationTime, length, scope, lastOperation, callerIp, lastAccess, lastUser, ssr.getVolume()+"", ssr.getCount()+"");
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
@ -242,15 +263,22 @@ public class JsonParser extends Thread{
|
||||||
RawUsageRecord sur=report.setGenericProperties("storage-usage",lastUser, scope, creationTime, lastAccess, owner);
|
RawUsageRecord sur=report.setGenericProperties("storage-usage",lastUser, scope, creationTime, lastAccess, owner);
|
||||||
sur=report.setSpecificProperties(sur, operation, length+"", filename, callerIP, "STORAGE", "1");
|
sur=report.setSpecificProperties(sur, operation, length+"", filename, callerIP, "STORAGE", "1");
|
||||||
logger.info("[accounting call] type: storage usage ");
|
logger.info("[accounting call] type: storage usage ");
|
||||||
|
report.printRecord(sur);
|
||||||
report.send(sur);
|
report.send(sur);
|
||||||
// ACCOUNTING CALL TYPE: STORAGE STATUS
|
// ACCOUNTING CALL TYPE: STORAGE STATUS
|
||||||
logger.debug("set properties: totVolume: "+totVolume+" totCount "+totCount);
|
logger.debug("set properties: totVolume: "+totVolume+" totCount "+totCount);
|
||||||
RawUsageRecord ssr=report.setGenericProperties("storage-status",lastUser, scope, creationTime, lastAccess, owner);
|
if((totVolume!=null) && (totCount!=null)){
|
||||||
ssr=report.setSpecificProperties(ssr, operation, totVolume, filename, callerIP, "STORAGE", totCount);
|
RawUsageRecord ssr=report.setGenericProperties("storage-status",lastUser, scope, creationTime, lastAccess, owner);
|
||||||
logger.info("[accounting call] type: storage status ");
|
ssr=report.setSpecificProperties(ssr, operation, totVolume, filename, callerIP, "STORAGE", totCount);
|
||||||
report.send(ssr);
|
logger.info("[accounting call] type: storage status ");
|
||||||
|
report.printRecord(ssr);
|
||||||
|
report.send(ssr);
|
||||||
|
}else{
|
||||||
|
logger.info("StorageStatus record not send for operation "+lastOperation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String retrieveScopeFromRemoteFilePath(String filename) {
|
private String retrieveScopeFromRemoteFilePath(String filename) {
|
||||||
|
@ -273,6 +301,17 @@ public class JsonParser extends Thread{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private StorageStatusRecord getStorageStatusRecord(String[] server, String user, String password, String owner, String lastUser, long length, String lastOperation, MongoDB mongo){
|
||||||
|
// StorageStatusRecord ssr=null;
|
||||||
|
// try{
|
||||||
|
// mongo=new MongoDB(server, user, password);
|
||||||
|
// ssr=mongo.update(lastUser, length, 1, lastOperation);
|
||||||
|
// mongo.close();
|
||||||
|
// }catch(Exception e){
|
||||||
|
// logger.error("Problem in updating storage status record: "+e.getMessage());
|
||||||
|
// }
|
||||||
|
// return ssr;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,10 @@ public class Startup {
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
for (int i=0; i<args.length;i++)
|
||||||
|
System.out.println("param N." +i + ": " + args[i]);
|
||||||
|
|
||||||
if(args.length != 2 && args.length != 4){
|
if(args.length != 2 && args.length != 4){
|
||||||
System.out.println("Usage:");
|
System.out.println("Usage:");
|
||||||
System.out.println("\tjava Startup scope ip user password\n\n");
|
System.out.println("\tjava Startup scope ip user password\n\n");
|
||||||
|
@ -32,6 +36,7 @@ public class Startup {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
scope=args[0];
|
scope=args[0];
|
||||||
String oplogServer= args[1];
|
String oplogServer= args[1];
|
||||||
if(args.length == 4){
|
if(args.length == 4){
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class MongoDB {
|
||||||
|
|
||||||
private int setCount(int count, int currentCount, String operation) {
|
private int setCount(int count, int currentCount, String operation) {
|
||||||
logger.info("accounting: operation "+operation+" total count "+currentCount+" current count"+count);
|
logger.info("accounting: operation "+operation+" total count "+currentCount+" current count"+count);
|
||||||
if(operation.equalsIgnoreCase("UPLOAD"))
|
if(operation.equalsIgnoreCase("UPLOAD")|| operation.equalsIgnoreCase("COPY"))
|
||||||
currentCount=currentCount+count;
|
currentCount=currentCount+count;
|
||||||
else if(operation.equalsIgnoreCase("DELETE"))
|
else if(operation.equalsIgnoreCase("DELETE"))
|
||||||
currentCount=currentCount-count;
|
currentCount=currentCount-count;
|
||||||
|
|
Loading…
Reference in New Issue