Mercurial > hg > openmind
changeset 45:fd98c31371cb
better transaction logging.
author | casties |
---|---|
date | Thu, 20 Oct 2016 14:06:10 +0200 |
parents | 23c043a19134 |
children | fc120c3c6ce4 |
files | src/main/java/org/mpi/openmind/cache/WrapperService.java src/main/java/org/mpi/openmind/repository/bo/Entity.java |
diffstat | 2 files changed, 22 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/org/mpi/openmind/cache/WrapperService.java Thu Oct 20 14:04:36 2016 +0200 +++ b/src/main/java/org/mpi/openmind/cache/WrapperService.java Thu Oct 20 14:06:10 2016 +0200 @@ -35,7 +35,9 @@ private static Logger logger = Logger.getLogger(WrapperService.class); - private transient CacheService cache; + private static Logger txLog = Logger.getLogger(PersistenceService.TRANSACTION_LOGGER); + + private transient CacheService cache; public long getSourceRelationsCount(Entity entity, String relationName, String tarObjClass) { @@ -599,10 +601,15 @@ entity.resetId(); entity.setType(Node.TYPE_ABOX); entity.setUser(user); - + + txLog.debug("** START save entity as new: user="+user+" entity="+entity.toSmallString()); + // save in database this.getPS().saveEntity(entity); + // save in cache cache.saveEntity(entity); - logger.info("[U=" + user + "] SaveEntityAsNew - execution time[ms]: " + (System.currentTimeMillis() - start)); + txLog.debug("** END save entity as new: user="+user+" entity="+entity.toSmallString()); + + logger.debug("[U=" + user + "] SaveEntityAsNew - execution time[ms]: " + (System.currentTimeMillis() - start)); return (Entity) entity.clone(); } @@ -626,10 +633,15 @@ entity = removeWrongRelations(entity); entity = removeEmptyAttributes(entity); + txLog.debug("** START save entity: user="+user+" entity="+entity.toSmallString()); + // save in database this.getPS().saveEntity(entity); + // save in cache cache.saveEntity(entity); + txLog.debug("** END save entity: user="+user+" entity="+entity.toSmallString()); + System.gc(); - logger.info("[U=" + user + "] SaveEntity - execution time[ms]: " + (System.currentTimeMillis() - start)); + logger.debug("[U=" + user + "] SaveEntity - execution time[ms]: " + (System.currentTimeMillis() - start)); Entity clone = (Entity) entity.clone(); // logger.info(clone.toString()); return clone; @@ -646,11 +658,13 @@ entity = removeWrongRelations(entity); entity = removeEmptyAttributes(entity); } + txLog.debug("** START save entity list: user="+user+" list="+list); this.getPS().saveEntityList(list); for(Entity entity : list){ cache.saveEntity(entity); } - logger.info("[U=" + user + "] SaveEntityList - execution time[ms]: " + (System.currentTimeMillis() - start)); + txLog.debug("** END save entity list: user="+user+" list="+list); + logger.debug("[U=" + user + "] SaveEntityList - execution time[ms]: " + (System.currentTimeMillis() - start)); } private Entity removeEmptyAttributes(Entity ent){
--- a/src/main/java/org/mpi/openmind/repository/bo/Entity.java Thu Oct 20 14:04:36 2016 +0200 +++ b/src/main/java/org/mpi/openmind/repository/bo/Entity.java Thu Oct 20 14:06:10 2016 +0200 @@ -1014,7 +1014,7 @@ String rowIdString = (this.getRowId() == null) ? "" : "rowId=" + this.getRowId() + ", "; String idString = (this.getId() == null) ? "" : "id=" + getId() + ", "; - return "Entity[" + rowIdString + idString + "objClass=" + this.getObjectClass() + ", ownValue=" + this.getOwnValue() + "]"; + return "Entity[" + rowIdString + idString + "objClass=" + this.getObjectClass() + "]"; } @Override @@ -1046,7 +1046,8 @@ + "system-status=\"" + this.getSystemStatus() + "\", " + "status=\"" + this.getStatus() + "\", " + "type=\"" + this.getType() + "\", " - + "b64-value=\"" + ((this.getOwnValue() != null) ? Base64.encodeBase64String(this.getOwnValue().getBytes("UTF-8")) : "") + "\"]"; + + "b64-value=\"" + ((this.getOwnValue() != null) ? Base64.encodeBase64String(this.getOwnValue().getBytes("UTF-8")) : "") + + "\"]"; return es; } catch (UnsupportedEncodingException e) { // this shouldn't happen