mirror of https://github.com/apache/nifi.git
NIFI-271
This commit is contained in:
parent
5a559e4557
commit
90ae022e54
|
@ -68,12 +68,12 @@ import com.maxmind.geoip2.record.Subdivision;
|
|||
@WritesAttribute(attribute = "X.geo.city", description = "The city identified for the IP address"),
|
||||
@WritesAttribute(attribute = "X.geo.latitude", description = "The latitude identified for this IP address"),
|
||||
@WritesAttribute(attribute = "X.geo.longitude", description = "The longitude identified for this IP address"),
|
||||
@WritesAttribute(attribute="X.geo.subdivision.N", description="Each subdivision that is identified for this IP address is added with a one-up number appended to the attribute name, starting with 0"),
|
||||
@WritesAttribute(attribute = "X.geo.subdivision.N",
|
||||
description = "Each subdivision that is identified for this IP address is added with a one-up number appended to the attribute name, starting with 0"),
|
||||
@WritesAttribute(attribute = "X.geo.subdivision.isocode.N", description = "The ISO code for the subdivision that is identified by X.geo.subdivision.N"),
|
||||
@WritesAttribute(attribute = "X.geo.country", description = "The country identified for this IP address"),
|
||||
@WritesAttribute(attribute = "X.geo.country.isocode", description = "The ISO Code for the country identified"),
|
||||
@WritesAttribute(attribute="X.geo.postalcode", description="The postal code for the country identified"),
|
||||
})
|
||||
@WritesAttribute(attribute = "X.geo.postalcode", description = "The postal code for the country identified"),})
|
||||
public class GeoEnrichIP extends AbstractProcessor {
|
||||
|
||||
public static final PropertyDescriptor GEO_DATABASE_FILE = new PropertyDescriptor.Builder()
|
||||
|
|
|
@ -47,8 +47,8 @@ import com.maxmind.geoip2.model.IspResponse;
|
|||
* https://raw.githubusercontent.com/maxmind/GeoIP2-java/master/src/main/java/com/maxmind/geoip2/DatabaseReader.java
|
||||
* It is written by Maxmind and it is available under Apache Software License V2
|
||||
*
|
||||
* The modification we're making to the code below is to stop using exceptions for
|
||||
* mainline flow control. Specifically we don't want to throw an exception
|
||||
* The modification we're making to the code below is to stop using exceptions
|
||||
* for mainline flow control. Specifically we don't want to throw an exception
|
||||
* simply because an address was not found.
|
||||
* </p>
|
||||
*
|
||||
|
@ -96,6 +96,7 @@ public class DatabaseReader implements GeoIp2Provider, Closeable {
|
|||
* </p>
|
||||
*/
|
||||
public final static class Builder {
|
||||
|
||||
final File database;
|
||||
final InputStream stream;
|
||||
|
||||
|
@ -131,9 +132,9 @@ public class DatabaseReader implements GeoIp2Provider, Closeable {
|
|||
/**
|
||||
* @param val The file mode used to open the GeoIP2 database
|
||||
* @return Builder object
|
||||
* @throws java.lang.IllegalArgumentException if you initialized the Builder with a URL, which uses
|
||||
* {@link FileMode#MEMORY}, but you provided a different
|
||||
* FileMode to this method.
|
||||
* @throws java.lang.IllegalArgumentException if you initialized the
|
||||
* Builder with a URL, which uses {@link FileMode#MEMORY}, but you
|
||||
* provided a different FileMode to this method.
|
||||
*/
|
||||
public Builder fileMode(FileMode val) {
|
||||
if (this.stream != null && !FileMode.MEMORY.equals(val)) {
|
||||
|
@ -156,9 +157,10 @@ public class DatabaseReader implements GeoIp2Provider, Closeable {
|
|||
|
||||
/**
|
||||
* @param ipAddress IPv4 or IPv6 address to lookup.
|
||||
* @return A <T> object with the data for the IP address or null if no
|
||||
* @return An object of type T with the data for the IP address or null if no
|
||||
* information could be found for the given IP address
|
||||
* @throws IOException if there is an error opening or reading from the file.
|
||||
* @throws IOException if there is an error opening or reading from the
|
||||
* file.
|
||||
*/
|
||||
private <T> T get(InetAddress ipAddress, Class<T> cls, boolean hasTraits,
|
||||
String type) throws IOException, AddressNotFoundException {
|
||||
|
@ -199,9 +201,9 @@ public class DatabaseReader implements GeoIp2Provider, Closeable {
|
|||
* <p>
|
||||
* If you are using <code>FileMode.MEMORY_MAPPED</code>, this will
|
||||
* <em>not</em> unmap the underlying file due to a limitation in Java's
|
||||
* <code>MappedByteBuffer</code>. It will however set the reference to
|
||||
* the buffer to <code>null</code>, allowing the garbage collector to
|
||||
* collect it.
|
||||
* <code>MappedByteBuffer</code>. It will however set the reference to the
|
||||
* buffer to <code>null</code>, allowing the garbage collector to collect
|
||||
* it.
|
||||
* </p>
|
||||
*
|
||||
* @throws IOException if an I/O error occurs.
|
||||
|
|
Loading…
Reference in New Issue