use of org.apache.carbondata.core.datastore.filesystem.CarbonFileFilter in project carbondata by apache.
the class DeleteLoadFolders method physicalFactAndMeasureMetadataDeletion.
private static boolean physicalFactAndMeasureMetadataDeletion(String path) {
boolean status = false;
try {
if (FileFactory.isFileExist(path, FileFactory.getFileType(path))) {
CarbonFile file = FileFactory.getCarbonFile(path, FileFactory.getFileType(path));
CarbonFile[] filesToBeDeleted = file.listFiles(new CarbonFileFilter() {
@Override
public boolean accept(CarbonFile file) {
return (CarbonTablePath.isCarbonDataFile(file.getName()) || CarbonTablePath.isCarbonIndexFile(file.getName()));
}
});
//entry in metadata.
if (filesToBeDeleted.length == 0) {
status = true;
} else {
for (CarbonFile eachFile : filesToBeDeleted) {
if (!eachFile.delete()) {
LOGGER.warn("Unable to delete the file as per delete command " + eachFile.getAbsolutePath());
status = false;
} else {
status = true;
}
}
}
// need to delete the complete folder.
if (status) {
if (!file.delete()) {
LOGGER.warn("Unable to delete the folder as per delete command " + file.getAbsolutePath());
status = false;
}
}
} else {
status = false;
}
} catch (IOException e) {
LOGGER.warn("Unable to delete the file as per delete command " + path);
}
return status;
}
use of org.apache.carbondata.core.datastore.filesystem.CarbonFileFilter in project carbondata by apache.
the class CarbonDataProcessorUtil method renameBadRecordsFromInProgressToNormal.
/**
* @param storeLocation
*/
public static void renameBadRecordsFromInProgressToNormal(String storeLocation) {
// get the base store location
String badLogStoreLocation = CarbonProperties.getInstance().getProperty(CarbonCommonConstants.CARBON_BADRECORDS_LOC);
badLogStoreLocation = badLogStoreLocation + File.separator + storeLocation;
FileType fileType = FileFactory.getFileType(badLogStoreLocation);
try {
if (!FileFactory.isFileExist(badLogStoreLocation, fileType)) {
return;
}
} catch (IOException e1) {
LOGGER.info("bad record folder does not exist");
}
CarbonFile carbonFile = FileFactory.getCarbonFile(badLogStoreLocation, fileType);
CarbonFile[] listFiles = carbonFile.listFiles(new CarbonFileFilter() {
@Override
public boolean accept(CarbonFile pathname) {
if (pathname.getName().indexOf(CarbonCommonConstants.FILE_INPROGRESS_STATUS) > -1) {
return true;
}
return false;
}
});
String badRecordsInProgressFileName = null;
String changedFileName = null;
for (CarbonFile badFiles : listFiles) {
badRecordsInProgressFileName = badFiles.getName();
changedFileName = badLogStoreLocation + File.separator + badRecordsInProgressFileName.substring(0, badRecordsInProgressFileName.lastIndexOf('.'));
badFiles.renameTo(changedFileName);
if (badFiles.exists()) {
if (!badFiles.delete()) {
LOGGER.error("Unable to delete File : " + badFiles.getName());
}
}
}
}
Aggregations