class ResourceConsumptionManager implements IOFogModule {

	private void removeArchives(float amount) {
		logDebug("Start remove archives : " + amount);
		String archivesDirectory = Configuration.getDiskDirectory() + "messages/archive/";
		
		final File workingDirectory = new File(archivesDirectory);
		File[] filesList = workingDirectory.listFiles((dir, fileName) ->
				fileName.substring(fileName.indexOf(".")).equals(".idx"));

		if (filesList != null) {
			Arrays.sort(filesList, (o1, o2) -> {
				String t1 = o1.getName().substring(o1.getName().indexOf('_') + 1, o1.getName().indexOf("."));
				String t2 = o2.getName().substring(o2.getName().indexOf('_') + 1, o2.getName().indexOf("."));
				return t1.compareTo(t2);
			});

			for (File indexFile : filesList) {
				File dataFile = new File(archivesDirectory + indexFile.getName().substring(0, indexFile.getName().indexOf('.')) + ".iomsg");
				amount -= indexFile.length();
				indexFile.delete();
				amount -= dataFile.length();
				dataFile.delete();
				if (amount < 0)
					break;
			}
		}
		logDebug("Finished remove archives : ");
	}

	private  ResourceConsumptionManager();

}