Skip to content

Commit

Permalink
Nested blocks of code should not be left empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Lázaro committed May 18, 2015
1 parent 8457f02 commit 53c4256
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
public abstract class KeedioSource<T> {

private static final Logger log = LoggerFactory.getLogger(KeedioSource.class);
private static final Logger logger = LoggerFactory.getLogger(KeedioSource.class);

private Map<String, Long> fileList = new HashMap<>();
private Set<String> existFileList = new HashSet<>();
Expand Down Expand Up @@ -85,9 +85,9 @@ public void saveMap() {
out.writeObject((HashMap) getFileList());
}
} catch (FileNotFoundException e) {
log.error("Error saving map File", e);
logger.error("Error saving map File", e);
} catch (IOException e) {
log.error("Error saving map IO:", e);
logger.error("Error saving map IO:", e);
}
}

Expand Down Expand Up @@ -126,14 +126,14 @@ public void checkPreviousMap() {
try {
if (Files.exists(file1)) {
setFileList(loadMap(file1.toString()));
log.info("Found previous map of files flumed");
logger.info("Found previous map of files flumed");
} else {
log.info("Not found preivous map of files flumed");
logger.info("Not found preivous map of files flumed");

}

} catch (IOException | ClassNotFoundException e) {
log.info("Exception thrown checking previous map ", e);
logger.info("Exception thrown checking previous map ", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public class SourceFactory {

private KeedioSource keedioSource;
private static final Logger log = LoggerFactory.getLogger(KeedioSource.class);
private static final Logger logger = LoggerFactory.getLogger(KeedioSource.class);
private final Integer discoverDelay = 10000;
private final boolean flushlinesDefault = true;
private final String folderDefault = System.getProperty("java.io.tmpdir");
Expand Down Expand Up @@ -65,7 +65,7 @@ public KeedioSource initSource(Context context) {
initCommonParam(context);
break;
default:
log.error("Source not found in context");
logger.error("Source not found in context");
}
return keedioSource;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
public class FTPSSource extends KeedioSource<FTPFile> {

private static final Logger log = LoggerFactory.getLogger(FTPSSource.class);
private static final Logger logger = LoggerFactory.getLogger(FTPSSource.class);

private boolean securityMode, securityCert;
private String protocolSec;
Expand Down Expand Up @@ -53,12 +53,12 @@ public boolean connect() {

if (!FTPReply.isPositiveCompletion(replyCode)) {
ftpsClient.disconnect();
log.error("Connect Failed due to FTPS, server refused connection.");
logger.error("Connect Failed due to FTPS, server refused connection.");
this.setConnected(false);
}

if (!(ftpsClient.login(user, password))) {
log.error("Could not login to the server");
logger.error("Could not login to the server");
this.setConnected(false);
}

Expand All @@ -74,7 +74,7 @@ public boolean connect() {

} catch (IOException e) {
this.setConnected(false);
log.error("", e);
logger.error("", e);
}
return isConnected();
}
Expand All @@ -90,7 +90,7 @@ public void disconnect() {
ftpsClient.disconnect();
setConnected(false);
} catch (IOException e) {
log.error("Source " + this.getClass().getName() + " failed disconnect", e);
logger.error("Source " + this.getClass().getName() + " failed disconnect", e);
}
}

Expand Down Expand Up @@ -175,7 +175,7 @@ public boolean particularCommand() {
try {
success = getFtpsClient().completePendingCommand();
} catch (IOException e) {
log.error("Error on command completePendingCommand of FTPClient", e);
logger.error("Error on command completePendingCommand of FTPClient", e);
}
return success;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
public class FTPSource extends KeedioSource<FTPFile> {

private static final Logger log = LoggerFactory.getLogger(FTPSource.class);
private static final Logger logger = LoggerFactory.getLogger(FTPSource.class);
private FTPClient ftpClient = new FTPClient();

/**
Expand All @@ -41,12 +41,12 @@ public boolean connect() {

if (!FTPReply.isPositiveCompletion(replyCode)) {
getFtpClient().disconnect();
log.error("Connect Failed due to FTP, server refused connection.");
logger.error("Connect Failed due to FTP, server refused connection.");
this.setConnected(false);
}

if (!(ftpClient.login(user, password))) {
log.error("Could not login to the server");
logger.error("Could not login to the server");
this.setConnected(false);
}

Expand All @@ -62,7 +62,7 @@ public boolean connect() {

} catch (IOException e) {
this.setConnected(false);
log.error("", e);
logger.error("", e);
}
return isConnected();
}
Expand All @@ -79,7 +79,7 @@ public void disconnect() {
setConnected(false);

} catch (IOException e) {
log.error("Source " + this.getClass().getName() + " failed disconnect", e);
logger.error("Source " + this.getClass().getName() + " failed disconnect", e);
}
}

Expand Down Expand Up @@ -162,7 +162,7 @@ public boolean particularCommand() {
try {
success = getFtpClient().completePendingCommand();
} catch (IOException e) {
log.error("Error on command completePendingCommand of FTPClient", e);
logger.error("Error on command completePendingCommand of FTPClient", e);
}
return success;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
public class SFTPSource extends KeedioSource<ChannelSftp.LsEntry> {

private static final Logger log = LoggerFactory.getLogger(SFTPSource.class);
private static final Logger logger = LoggerFactory.getLogger(SFTPSource.class);

private String knownHosts;
private JSch jsch;
Expand Down Expand Up @@ -60,7 +60,7 @@ public boolean connect() {
}
} catch (JSchException e) {
if (!(sessionSftp.isConnected())) {
log.info("JSchException ", e);
logger.info("JSchException ", e);
this.setConnected(false);
}
}
Expand Down Expand Up @@ -147,7 +147,7 @@ public void disconnect() {
sessionSftp.disconnect();
setConnected(false);
if (isConnected()) {
log.error("Source " + this.getClass().getName() + " failed disconnect");
logger.error("Source " + this.getClass().getName() + " failed disconnect");
}
}

Expand All @@ -160,7 +160,7 @@ public void changeToDirectory(String directory) throws IOException {
try {
sftpClient.cd(directory);
} catch (SftpException e) {
log.error("Could not change to directory " + directory, e);
logger.error("Could not change to directory " + directory, e);
throw new IOException(e.getMessage());
}
}
Expand All @@ -175,7 +175,7 @@ public List<ChannelSftp.LsEntry> listElements(String directory) throws IOExcepti
try {
list = sftpClient.ls(directory);
} catch (SftpException e) {
log.error("Could not list files from " + directory, e);
logger.error("Could not list files from " + directory, e);
throw new IOException(e.getMessage());
}
return list;
Expand All @@ -191,7 +191,7 @@ public InputStream getInputStream(ChannelSftp.LsEntry file) throws IOException {
try {
inputStream = sftpClient.get(file.getFilename());
} catch (SftpException e) {
log.error("Error trying to retrieve inputstream", e);
logger.error("Error trying to retrieve inputstream", e);
throw new IOException(e.getMessage());
}
return inputStream;
Expand Down Expand Up @@ -253,7 +253,7 @@ public long getObjectSize(ChannelSftp.LsEntry file) {
try {
filesize = sftpClient.lstat(file.getFilename()).getSize();
} catch (SftpException e) {
log.error("Could not lstat to get size of the file", e);
logger.error("Could not lstat to get size of the file", e);
}
return filesize;
}
Expand All @@ -277,7 +277,7 @@ public String getLink(ChannelSftp.LsEntry file) {
try {
link = sftpClient.readlink(file.getFilename());
} catch (SftpException e) {
log.error("Could not readLink to get name");
logger.error("Could not readLink to get name");
}
return link;
}
Expand All @@ -292,7 +292,7 @@ public String getDirectoryserver() throws IOException {
try {
printWorkingDirectory = sftpClient.pwd();
} catch (SftpException e) {
log.error("Error getting printworkingdirectory for server -sftpsource");
logger.error("Error getting printworkingdirectory for server -sftpsource");
throw new IOException(e.getMessage());
}
return printWorkingDirectory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,54 +42,57 @@ public SourceCounter(String name){
MbProcessed = 0;
}

/*
/**
@return long, number of files discovered
*/
@Override
public long getFilesCount(){
return files_count;
}

/*
/**
@void, increment count of files
*/
@Override
public void incrementFilesCount(){
files_count++;
}

/*
/**
@return long, files succesfully
*/
@Override
public long getFilesProcCount(){
return filesProcCount;
}

/*
/**
@void, increment count of proc files
*/
@Override
public void incrementFilesProcCount(){
filesProcCount++;
}

/*
/**
@return long, files proc with error
*/
@Override
public long getFilesProcCountError(){
return filesProcCountError;
}

/*
/**
@void, increment count of proc files with error
*/
@Override
public void incrementFilesProcCountError(){
filesProcCountError++;
}

/**
*@void
*/
@Override
public void incrementEventCount(){
last_sent = System.currentTimeMillis();
Expand All @@ -100,47 +103,83 @@ public void incrementEventCount(){
}
}

/**
*
* @return long
*/

@Override
public long getEventCount(){
return eventCount;
}

/**
*
* @return
*/
@Override
public long getSendThroughput() {
return sendThroughput;
}

/**
* @return
*/
@Override
public void incrementCountModProc(){
countModProc++;
}

/**
*
* @return
*/
@Override
public long getCountModProc(){
return countModProc;
}

/**
*
* @return
*/
@Override
public long getLastSent(){
return last_sent;
}

/**
*
* @param size
*/
@Override
public void incrementCountSizeProc(long size){
bytesProcessed+= size;
}

/**
*
* @return
*/
@Override
public long getCountSizeProc(){
return bytesProcessed;
}

/**
*
* @return
*/
@Override
public long getCountSizeProcKb(){
KbProcessed = getCountSizeProc() / 1024;
return KbProcessed;
}

/**
*
* @return
*/
@Override
public long getCountSizeProcMb(){
MbProcessed = getCountSizeProc() / (1024 * 1024);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/keedio/flume/source/ftp/source/Source.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ public <T> void discoverElements(KeedioSource keedioSource, String parentDir, St
String dirToList = parentDir;
if (!("").equals(currentDir)){
dirToList += "/" + currentDir;
} else {
}
}
List<T> list = keedioSource.listElements(dirToList);
if (!(list.isEmpty())) {

Expand Down

0 comments on commit 53c4256

Please sign in to comment.