public abstract FileSystem getFileSystem();
protected void initializeCounterIfNecessary() throws IOException {
if (!initialized) {
FsShell fsShell = new FsShell(getFileSystem().getConf(), getFileSystem());
if (getFileSystem().exists(new Path(getBasePath()))) {
int maxCounter = 0;
boolean foundFile = false;
Collection<FileStatus> fileStats = fsShell.ls(this.getBasePath());
for (FileStatus fileStatus : fileStats) {
String shortName = fileStatus.getPath().getName();
int counterFromName = getCounterFromName(shortName);
if (counterFromName != -1) {
foundFile = true;
}
if (counterFromName > maxCounter) {
maxCounter = counterFromName;
}
}
if (foundFile) {
logger.debug("Found " + maxCounter + " existing files");
this.setCounter(maxCounter + 1);
}
}
else {
logger.info("Creating base path " + getBasePath());
fsShell.mkdir(getBasePath());
}
initialized = true;
}
}