Project

General

Profile

« Previous | Next » 

Revision 28297

Updated version, Implemented method for dropping a transaction,
added log, created quartz bean that delete the old collection not still used

View differences:

MDStoreTransactionManagerImpl.java
413 413
	@Override
414 414
	public void garbage() throws MDStoreServiceException {
415 415
		verifyConsistency();
416
		log.info("Start garbage collection");
416
		log.info("Start garbage collection of MdStore");
417 417
		DBCursor cursor = this.managerTable.find();
418 418
		while (cursor.hasNext()) {
419 419
			DBObject currentObject = cursor.next();
......
437 437
				}
438 438
			}
439 439
		}
440
		log.info("Complete garbage collection  of MdStore");
440 441
	}
441 442

  
442 443
	/**
......
469 470
	public void setMdstoreDao(final MDStoreDao mdstoreDao) {
470 471
		this.mdstoreDao = mdstoreDao;
471 472
	}
473

  
474
	@Override
475
	public Boolean dropTransaction(final String mdId, final String idToDrop) throws MDStoreServiceException {
476
		verifyConsistency();
477
		BasicDBObject query = new BasicDBObject();
478
		query.put("mdId", mdId);
479
		DBCursor cursor = this.getManagerTable().find(query);
480
		if (cursor.hasNext() == false) throw new DocumentNotFoundException("Error, unable to find Mdstore with Id " + mdId);
481
		DBObject object = cursor.next();
482
		BasicDBList values = (BasicDBList) object.get("transactions");
483
		for (int i = 0; i < values.size(); i++) {
484
			DBObject value = (DBObject) values.get(i);
485
			String currentUsedId = (String) value.get("id");
486
			if (currentUsedId.equals(idToDrop)) {
487
				db.getCollection(idToDrop).drop();
488
				values.remove(value);
489
				this.managerTable.save(object);
490
				return true;
491
			}
492
		}
493
		throw new DocumentNotFoundException("Error, unable to drop old collection " + idToDrop);
494
	}
472 495
}

Also available in: Unified diff