-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Partial support for ELF. #50 * Full support for ELF. Added InputFileDeque the number of calls to list the directory contents. This will query only when needed to reduce the number of stat calls.
- Loading branch information
1 parent
cac32a7
commit b85ffb6
Showing
31 changed files
with
1,125 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
target | ||
*.iml | ||
.okhttpcache | ||
ELFTesting.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Copyright © 2016 Jeremy Custenborder ([email protected]) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
name=elftesting | ||
tasks.max=1 | ||
connector.class=com.github.jcustenborder.kafka.connect.spooldir.elf.SpoolDirELFSourceConnector | ||
input.file.pattern=^.*\.gz$ | ||
finished.path=/Users/jeremy/data/confluent/logs/packages/finished | ||
input.path=/Users/jeremy/data/confluent/logs/packages | ||
error.path=/Users/jeremy/data/confluent/logs/packages/error | ||
halt.on.error=true | ||
topic=cloudfront | ||
schema.generation.enabled=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,21 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
Copyright © 2016 Jeremy Custenborder ([email protected]) | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
|
@@ -57,6 +74,11 @@ | |
<artifactId>commons-compress</artifactId> | ||
<version>1.16.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.github.jcustenborder.parsers</groupId> | ||
<artifactId>extended-log-format</artifactId> | ||
<version>[0.0.1.2, 0.0.1.1000)</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
|
90 changes: 90 additions & 0 deletions
90
src/main/java/com/github/jcustenborder/kafka/connect/spooldir/InputFileDequeue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/** | ||
* Copyright © 2016 Jeremy Custenborder ([email protected]) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.github.jcustenborder.kafka.connect.spooldir; | ||
|
||
import com.google.common.collect.ForwardingDeque; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.File; | ||
import java.util.ArrayDeque; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Comparator; | ||
import java.util.Deque; | ||
import java.util.List; | ||
|
||
public class InputFileDequeue extends ForwardingDeque<File> { | ||
private static final Logger log = LoggerFactory.getLogger(InputFileDequeue.class); | ||
private final SpoolDirSourceConnectorConfig config; | ||
|
||
public InputFileDequeue(SpoolDirSourceConnectorConfig config) { | ||
this.config = config; | ||
} | ||
|
||
public static File processingFile(String processingFileExtension, File input) { | ||
String fileName = input.getName() + processingFileExtension; | ||
return new File(input.getParentFile(), fileName); | ||
} | ||
|
||
|
||
Deque<File> files; | ||
|
||
@Override | ||
protected Deque<File> delegate() { | ||
if (null != files && !files.isEmpty()) { | ||
return files; | ||
} | ||
|
||
log.info("Searching for file in {}", this.config.inputPath); | ||
File[] input = this.config.inputPath.listFiles(this.config.inputFilenameFilter); | ||
if (null == input || input.length == 0) { | ||
log.info("No files matching {} were found in {}", SpoolDirSourceConnectorConfig.INPUT_FILE_PATTERN_CONF, this.config.inputPath); | ||
return new ArrayDeque<>(); | ||
} | ||
Arrays.sort(input, Comparator.comparing(File::getName)); | ||
List<File> files = new ArrayList<>(input.length); | ||
for (File f : input) { | ||
File processingFile = processingFile(this.config.processingFileExtension, f); | ||
log.trace("Checking for processing file: {}", processingFile); | ||
|
||
if (processingFile.exists()) { | ||
log.debug("Skipping {} because processing file exists.", f); | ||
continue; | ||
} | ||
files.add(f); | ||
} | ||
|
||
Deque<File> result = new ArrayDeque<>(files.size()); | ||
|
||
for (File file : files) { | ||
long fileAgeMS = System.currentTimeMillis() - file.lastModified(); | ||
|
||
if (fileAgeMS < 0L) { | ||
log.warn("File {} has a date in the future.", file); | ||
} | ||
|
||
if (this.config.minimumFileAgeMS > 0L && fileAgeMS < this.config.minimumFileAgeMS) { | ||
log.debug("Skipping {} because it does not meet the minimum age.", file); | ||
continue; | ||
} | ||
result.add(file); | ||
} | ||
|
||
log.info("Found {} file(s) to process", result.size()); | ||
return (this.files = result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/main/java/com/github/jcustenborder/kafka/connect/spooldir/SpoolDirCsvSourceTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
/** | ||
* Copyright © 2016 Jeremy Custenborder ([email protected]) | ||
* <p> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/main/java/com/github/jcustenborder/kafka/connect/spooldir/SpoolDirJsonSourceTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
/** | ||
* Copyright © 2016 Jeremy Custenborder ([email protected]) | ||
* <p> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.