You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by sh...@apache.org on 2016/01/19 07:37:07 UTC
incubator-atlas git commit: ATLAS-433 Fix checkstyle issues for
common and notification module (shwethags)
Repository: incubator-atlas
Updated Branches:
refs/heads/master fd070cb80 -> d519ae8cf
ATLAS-433 Fix checkstyle issues for common and notification module (shwethags)
Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/d519ae8c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/d519ae8c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/d519ae8c
Branch: refs/heads/master
Commit: d519ae8cfe458c637c837d1f029bcb5c5522e0a6
Parents: fd070cb
Author: Shwetha GS <ss...@hortonworks.com>
Authored: Tue Jan 19 12:07:00 2016 +0530
Committer: Shwetha GS <ss...@hortonworks.com>
Committed: Tue Jan 19 12:07:00 2016 +0530
----------------------------------------------------------------------
common/pom.xml | 4 ++
.../org/apache/atlas/ApplicationProperties.java | 33 +++++----
.../java/org/apache/atlas/AtlasConstants.java | 19 +++--
.../java/org/apache/atlas/AtlasException.java | 1 -
.../java/org/apache/atlas/service/Service.java | 9 ++-
.../java/org/apache/atlas/service/Services.java | 9 ++-
.../java/org/apache/atlas/utils/MD5Utils.java | 47 ++++++------
.../org/apache/atlas/utils/ParamChecker.java | 24 ++++---
notification/pom.xml | 4 ++
.../java/org/apache/atlas/hook/AtlasHook.java | 8 +--
.../org/apache/atlas/kafka/KafkaConsumer.java | 16 ++---
.../apache/atlas/kafka/KafkaNotification.java | 57 +++++++--------
.../atlas/kafka/KafkaNotificationProvider.java | 11 +--
.../notification/AbstractNotification.java | 10 +--
.../AbstractNotificationConsumer.java | 67 +++++++++--------
.../notification/NotificationConsumer.java | 23 +++---
.../notification/NotificationException.java | 19 ++---
.../notification/NotificationHookConsumer.java | 76 ++++++++++----------
.../notification/NotificationInterface.java | 25 ++++---
.../atlas/notification/NotificationModule.java | 19 ++---
.../notification/entity/EntityNotification.java | 16 ++---
.../entity/EntityNotificationImpl.java | 33 +++++----
.../NotificationEntityChangeListener.java | 16 ++---
.../notification/hook/HookNotification.java | 64 ++++++++++++-----
.../atlas/kafka/KafkaNotificationTest.java | 24 +++----
.../NotificationHookConsumerTest.java | 19 ++---
.../entity/EntityNotificationImplTest.java | 4 +-
.../notification/hook/HookNotificationTest.java | 7 +-
pom.xml | 5 +-
release-log.txt | 1 +
src/build/checkstyle-suppressions.xml | 26 +++++++
src/build/checkstyle.xml | 3 +
32 files changed, 408 insertions(+), 291 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/common/pom.xml
----------------------------------------------------------------------
diff --git a/common/pom.xml b/common/pom.xml
index 28c64a7..1f3d96e 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -31,6 +31,10 @@
<name>Apache Atlas Common</name>
<packaging>jar</packaging>
+ <properties>
+ <checkstyle.failOnViolation>true</checkstyle.failOnViolation>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.testng</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/common/src/main/java/org/apache/atlas/ApplicationProperties.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/atlas/ApplicationProperties.java b/common/src/main/java/org/apache/atlas/ApplicationProperties.java
index 9fbbc35..6b4d31a 100644
--- a/common/src/main/java/org/apache/atlas/ApplicationProperties.java
+++ b/common/src/main/java/org/apache/atlas/ApplicationProperties.java
@@ -1,10 +1,11 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
@@ -14,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.atlas;
import org.apache.commons.configuration.CompositeConfiguration;
@@ -29,29 +29,32 @@ import java.net.URL;
import java.util.Arrays;
import java.util.Iterator;
-public class ApplicationProperties extends PropertiesConfiguration {
+/**
+ * Application properties used by Atlas.
+ */
+public final class ApplicationProperties extends PropertiesConfiguration {
private static final Logger LOG = LoggerFactory.getLogger(ApplicationProperties.class);
public static final String APPLICATION_PROPERTIES = "atlas-application.properties";
public static final String CLIENT_PROPERTIES = "client.properties";
- private static Configuration INSTANCE = null;
+ private static Configuration instance = null;
private ApplicationProperties(URL url) throws ConfigurationException {
super(url);
}
public static Configuration get() throws AtlasException {
- if (INSTANCE == null) {
+ if (instance == null) {
synchronized (ApplicationProperties.class) {
- if (INSTANCE == null) {
+ if (instance == null) {
Configuration applicationProperties = get(APPLICATION_PROPERTIES);
Configuration clientProperties = get(CLIENT_PROPERTIES);
- INSTANCE = new CompositeConfiguration(Arrays.asList(applicationProperties, clientProperties));
+ instance = new CompositeConfiguration(Arrays.asList(applicationProperties, clientProperties));
}
}
}
- return INSTANCE;
+ return instance;
}
public static Configuration get(String fileName) throws AtlasException {
@@ -80,7 +83,7 @@ public class ApplicationProperties extends PropertiesConfiguration {
}
}
- public static final Configuration getSubsetConfiguration(Configuration inConf, String prefix) {
+ public static Configuration getSubsetConfiguration(Configuration inConf, String prefix) {
return inConf.subset(prefix);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/common/src/main/java/org/apache/atlas/AtlasConstants.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/atlas/AtlasConstants.java b/common/src/main/java/org/apache/atlas/AtlasConstants.java
index d590d6d..85719c9 100644
--- a/common/src/main/java/org/apache/atlas/AtlasConstants.java
+++ b/common/src/main/java/org/apache/atlas/AtlasConstants.java
@@ -6,9 +6,9 @@
* to you 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/>
+ *
+ * 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.
@@ -18,9 +18,14 @@
package org.apache.atlas;
-public interface AtlasConstants {
- String CLUSTER_NAME_KEY = "atlas.cluster.name";
- String DEFAULT_CLUSTER_NAME = "primary";
- String CLUSTER_NAME_ATTRIBUTE = "clusterName";
+/**
+ * Constants used in Atlas configuration.
+ */
+public final class AtlasConstants {
+ private AtlasConstants() {
+ }
+ public static final String CLUSTER_NAME_KEY = "atlas.cluster.name";
+ public static final String DEFAULT_CLUSTER_NAME = "primary";
+ public static final String CLUSTER_NAME_ATTRIBUTE = "clusterName";
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/common/src/main/java/org/apache/atlas/AtlasException.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/atlas/AtlasException.java b/common/src/main/java/org/apache/atlas/AtlasException.java
index 9340af0..45d91d4 100644
--- a/common/src/main/java/org/apache/atlas/AtlasException.java
+++ b/common/src/main/java/org/apache/atlas/AtlasException.java
@@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.atlas;
/**
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/common/src/main/java/org/apache/atlas/service/Service.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/atlas/service/Service.java b/common/src/main/java/org/apache/atlas/service/Service.java
index 6454f90..64ce1d6 100644
--- a/common/src/main/java/org/apache/atlas/service/Service.java
+++ b/common/src/main/java/org/apache/atlas/service/Service.java
@@ -6,22 +6,21 @@
* to you 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/>
+ *
+ * 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 org.apache.atlas.service;
import org.apache.atlas.AtlasException;
/**
- * Service interface to start any background jobs
+ * Service interface to start any background jobs.
*/
public interface Service {
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/common/src/main/java/org/apache/atlas/service/Services.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/atlas/service/Services.java b/common/src/main/java/org/apache/atlas/service/Services.java
index 49b3fa7..10c7e5e 100644
--- a/common/src/main/java/org/apache/atlas/service/Services.java
+++ b/common/src/main/java/org/apache/atlas/service/Services.java
@@ -6,16 +6,15 @@
* to you 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/>
+ *
+ * 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 org.apache.atlas.service;
import com.google.inject.Inject;
@@ -26,7 +25,7 @@ import org.slf4j.LoggerFactory;
import java.util.Set;
/**
- * Utility for starting and stopping all services
+ * Utility for starting and stopping all services.
*/
@Singleton
public class Services {
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/common/src/main/java/org/apache/atlas/utils/MD5Utils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/atlas/utils/MD5Utils.java b/common/src/main/java/org/apache/atlas/utils/MD5Utils.java
index 35e4744..8529b3c 100644
--- a/common/src/main/java/org/apache/atlas/utils/MD5Utils.java
+++ b/common/src/main/java/org/apache/atlas/utils/MD5Utils.java
@@ -1,10 +1,11 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
@@ -19,22 +20,28 @@ package org.apache.atlas.utils;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-public class MD5Utils {
+/**
+ * Utilities for MD5 hash.
+ */
+public final class MD5Utils {
+
+ private MD5Utils() {
+ }
private static final ThreadLocal<MessageDigest> DIGESTER_FACTORY =
- new ThreadLocal<MessageDigest>() {
- @Override
- protected MessageDigest initialValue() {
- try {
- return MessageDigest.getInstance("MD5");
- } catch (NoSuchAlgorithmException e) {
- throw new RuntimeException(e);
+ new ThreadLocal<MessageDigest>() {
+ @Override
+ protected MessageDigest initialValue() {
+ try {
+ return MessageDigest.getInstance("MD5");
+ } catch (NoSuchAlgorithmException e) {
+ throw new RuntimeException(e);
+ }
}
- }
- };
+ };
/**
- * Create a thread local MD5 digester
+ * Create a thread local MD5 digester.
*/
public static MessageDigest getDigester() {
MessageDigest digester = DIGESTER_FACTORY.get();
@@ -43,10 +50,10 @@ public class MD5Utils {
}
private static final char[] HEX_DIGITS =
- {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
+ {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
public static String toString(byte[] digest) {
- StringBuilder buf = new StringBuilder(MD5_LEN*2);
+ StringBuilder buf = new StringBuilder(MD5_LEN * 2);
for (int i = 0; i < MD5_LEN; i++) {
int b = digest[i];
buf.append(HEX_DIGITS[(b >> 4) & 0xf]);
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/common/src/main/java/org/apache/atlas/utils/ParamChecker.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/atlas/utils/ParamChecker.java b/common/src/main/java/org/apache/atlas/utils/ParamChecker.java
index ab543e6..91adfaf 100644
--- a/common/src/main/java/org/apache/atlas/utils/ParamChecker.java
+++ b/common/src/main/java/org/apache/atlas/utils/ParamChecker.java
@@ -1,10 +1,11 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
@@ -14,13 +15,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.atlas.utils;
import java.util.Arrays;
import java.util.Collection;
-public class ParamChecker {
+/**
+ * Utilities for checking parameters.
+ */
+public final class ParamChecker {
+
+ private ParamChecker() {
+ }
/**
* Check that a value is not null. If null throws an IllegalArgumentException.
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/pom.xml
----------------------------------------------------------------------
diff --git a/notification/pom.xml b/notification/pom.xml
index 7f9fe34..b3738db 100644
--- a/notification/pom.xml
+++ b/notification/pom.xml
@@ -31,6 +31,10 @@
<name>Apache Atlas Notification</name>
<packaging>jar</packaging>
+ <properties>
+ <checkstyle.failOnViolation>true</checkstyle.failOnViolation>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.apache.atlas</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java b/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java
index 4b1c78c..ba50625 100644
--- a/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java
+++ b/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java
@@ -6,9 +6,9 @@
* to you 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/>
+ *
+ * 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.
@@ -116,7 +116,7 @@ public abstract class AtlasHook {
return;
} catch(Exception e) {
numRetries++;
- if(numRetries < maxRetries) {
+ if (numRetries < maxRetries) {
LOG.debug("Failed to notify atlas for entity {}. Retrying", message, e);
} else {
LOG.error("Failed to notify atlas for entity {} after {} retries. Quitting",
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/main/java/org/apache/atlas/kafka/KafkaConsumer.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/kafka/KafkaConsumer.java b/notification/src/main/java/org/apache/atlas/kafka/KafkaConsumer.java
index 1f05df4..f336481 100644
--- a/notification/src/main/java/org/apache/atlas/kafka/KafkaConsumer.java
+++ b/notification/src/main/java/org/apache/atlas/kafka/KafkaConsumer.java
@@ -1,10 +1,11 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
@@ -14,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.atlas.kafka;
import kafka.consumer.ConsumerIterator;
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/main/java/org/apache/atlas/kafka/KafkaNotification.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/kafka/KafkaNotification.java b/notification/src/main/java/org/apache/atlas/kafka/KafkaNotification.java
index 37467b3..7c91923 100644
--- a/notification/src/main/java/org/apache/atlas/kafka/KafkaNotification.java
+++ b/notification/src/main/java/org/apache/atlas/kafka/KafkaNotification.java
@@ -1,10 +1,11 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
@@ -14,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.atlas.kafka;
import com.google.inject.Singleton;
@@ -57,10 +57,10 @@ import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Future;
-@Singleton
/**
* Kafka specific access point to the Atlas notification framework.
*/
+@Singleton
public class KafkaNotification extends AbstractNotification implements Service {
public static final Logger LOG = LoggerFactory.getLogger(KafkaNotification.class);
@@ -68,9 +68,8 @@ public class KafkaNotification extends AbstractNotification implements Service {
private static final String ATLAS_KAFKA_DATA = "data";
- public static final String ATLAS_HOOK_TOPIC = "ATLAS_HOOK";
+ public static final String ATLAS_HOOK_TOPIC = "ATLAS_HOOK";
public static final String ATLAS_ENTITIES_TOPIC = "ATLAS_ENTITIES";
- public static final String ATLAS_TYPES_TOPIC = "ATLAS_TYPES";
protected static final String CONSUMER_GROUP_ID_PROPERTY = "group.id";
@@ -81,10 +80,12 @@ public class KafkaNotification extends AbstractNotification implements Service {
private KafkaProducer producer = null;
private List<ConsumerConnector> consumerConnectors = new ArrayList<>();
- private static final Map<NotificationType, String> topicMap = new HashMap<NotificationType, String>() {{
- put(NotificationType.HOOK, ATLAS_HOOK_TOPIC);
- put(NotificationType.ENTITIES, ATLAS_ENTITIES_TOPIC);
- }};
+ private static final Map<NotificationType, String> TOPIC_MAP = new HashMap<NotificationType, String>() {
+ {
+ put(NotificationType.HOOK, ATLAS_HOOK_TOPIC);
+ put(NotificationType.ENTITIES, ATLAS_ENTITIES_TOPIC);
+ }
+ };
// ----- Constructors ----------------------------------------------------
@@ -106,14 +107,14 @@ public class KafkaNotification extends AbstractNotification implements Service {
//Override default configs
properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG,
- "org.apache.kafka.common.serialization.StringSerializer");
+ "org.apache.kafka.common.serialization.StringSerializer");
properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
- "org.apache.kafka.common.serialization.StringSerializer");
+ "org.apache.kafka.common.serialization.StringSerializer");
properties.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "true");
properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG,
- "org.apache.kafka.common.serialization.StringDeserializer");
+ "org.apache.kafka.common.serialization.StringDeserializer");
properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,
"org.apache.kafka.common.serialization.StringDeserializer");
properties.put(ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY, "roundrobin");
@@ -129,7 +130,7 @@ public class KafkaNotification extends AbstractNotification implements Service {
try {
startZk();
startKafka();
- } catch(Exception e) {
+ } catch (Exception e) {
throw new AtlasException("Failed to start embedded kafka", e);
}
}
@@ -152,7 +153,7 @@ public class KafkaNotification extends AbstractNotification implements Service {
@Override
public <T> List<NotificationConsumer<T>> createConsumers(NotificationType notificationType,
int numConsumers) {
- String topic = topicMap.get(notificationType);
+ String topic = TOPIC_MAP.get(notificationType);
Properties consumerProperties = getConsumerProperties(notificationType);
@@ -174,12 +175,12 @@ public class KafkaNotification extends AbstractNotification implements Service {
}
@Override
- public void _send(NotificationType type, String... messages) throws NotificationException {
+ public void sendInternal(NotificationType type, String... messages) throws NotificationException {
if (producer == null) {
createProducer();
}
- String topic = topicMap.get(type);
+ String topic = TOPIC_MAP.get(type);
List<Future<RecordMetadata>> futures = new ArrayList<>();
for (String message : messages) {
ProducerRecord record = new ProducerRecord(topic, message);
@@ -217,12 +218,12 @@ public class KafkaNotification extends AbstractNotification implements Service {
/**
* Create a Kafka consumer connector from the given properties.
*
- * @param properties the properties for creating the consumer connector
+ * @param consumerProperties the properties for creating the consumer connector
*
* @return a new Kafka consumer connector
*/
- protected ConsumerConnector createConsumerConnector(Properties properties) {
- return Consumer.createJavaConsumerConnector(new kafka.consumer.ConsumerConfig(properties));
+ protected ConsumerConnector createConsumerConnector(Properties consumerProperties) {
+ return Consumer.createJavaConsumerConnector(new kafka.consumer.ConsumerConfig(consumerProperties));
}
/**
@@ -239,7 +240,7 @@ public class KafkaNotification extends AbstractNotification implements Service {
}
// Get properties for consumer request
- private Properties getConsumerProperties(NotificationType type) {
+ private Properties getConsumerProperties(NotificationType type) {
// find the configured group id for the given notification type
String groupId = properties.getProperty(type.toString().toLowerCase() + "." + CONSUMER_GROUP_ID_PROPERTY);
@@ -271,7 +272,7 @@ public class KafkaNotification extends AbstractNotification implements Service {
private URL getURL(String url) throws MalformedURLException {
try {
return new URL(url);
- } catch(MalformedURLException e) {
+ } catch (MalformedURLException e) {
return new URL("http://" + url);
}
}
@@ -282,7 +283,7 @@ public class KafkaNotification extends AbstractNotification implements Service {
URL zkAddress = getURL(zkValue);
this.factory = NIOServerCnxnFactory.createFactory(
- new InetSocketAddress(zkAddress.getHost(), zkAddress.getPort()), 1024);
+ new InetSocketAddress(zkAddress.getHost(), zkAddress.getPort()), 1024);
File snapshotDir = constructDir("zk/txn");
File logDir = constructDir("zk/snap");
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/main/java/org/apache/atlas/kafka/KafkaNotificationProvider.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/kafka/KafkaNotificationProvider.java b/notification/src/main/java/org/apache/atlas/kafka/KafkaNotificationProvider.java
index 1d73af5..fd0e518 100644
--- a/notification/src/main/java/org/apache/atlas/kafka/KafkaNotificationProvider.java
+++ b/notification/src/main/java/org/apache/atlas/kafka/KafkaNotificationProvider.java
@@ -6,16 +6,15 @@
* to you 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/>
+ *
+ * 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 org.apache.atlas.kafka;
import com.google.inject.Provider;
@@ -25,7 +24,11 @@ import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasException;
import org.apache.commons.configuration.Configuration;
+/**
+ * Provider class that provides KafkaNotification for Guice.
+ */
public class KafkaNotificationProvider implements Provider<KafkaNotification> {
+
@Override
@Provides
@Singleton
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/main/java/org/apache/atlas/notification/AbstractNotification.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/notification/AbstractNotification.java b/notification/src/main/java/org/apache/atlas/notification/AbstractNotification.java
index 72b5a0a..885242d 100644
--- a/notification/src/main/java/org/apache/atlas/notification/AbstractNotification.java
+++ b/notification/src/main/java/org/apache/atlas/notification/AbstractNotification.java
@@ -6,9 +6,9 @@
* to you 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/>
+ *
+ * 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.
@@ -56,7 +56,7 @@ public abstract class AbstractNotification implements NotificationInterface {
for (int index = 0; index < messages.size(); index++) {
strMessages[index] = AbstractNotificationConsumer.GSON.toJson(messages.get(index));
}
- _send(type, strMessages);
+ sendInternal(type, strMessages);
}
@Override
@@ -64,5 +64,5 @@ public abstract class AbstractNotification implements NotificationInterface {
send(type, Arrays.asList(messages));
}
- protected abstract void _send(NotificationType type, String[] messages) throws NotificationException;
+ protected abstract void sendInternal(NotificationType type, String[] messages) throws NotificationException;
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/main/java/org/apache/atlas/notification/AbstractNotificationConsumer.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/notification/AbstractNotificationConsumer.java b/notification/src/main/java/org/apache/atlas/notification/AbstractNotificationConsumer.java
index b6a9d7b..4bdaed3 100644
--- a/notification/src/main/java/org/apache/atlas/notification/AbstractNotificationConsumer.java
+++ b/notification/src/main/java/org/apache/atlas/notification/AbstractNotificationConsumer.java
@@ -6,16 +6,15 @@
* to you 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/>
+ *
+ * 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 org.apache.atlas.notification;
import com.google.common.collect.ImmutableList;
@@ -100,54 +99,59 @@ public abstract class AbstractNotificationConsumer<T> implements NotificationCon
protected abstract String peekMessage();
- // ----- inner class : ImmutableListDeserializer ---------------------------
-
- private static class ImmutableListDeserializer implements JsonDeserializer<ImmutableList<?>> {
+ /**
+ * Deserializer for ImmutableList used by AbstractNotificationConsumer.GSON.
+ */
+ public static class ImmutableListDeserializer implements JsonDeserializer<ImmutableList<?>> {
- public static final Type LIST_TYPE = new TypeToken<List<?>>() {}.getType();
+ public static final Type LIST_TYPE = new TypeToken<List<?>>() {
+ }.getType();
@Override
public ImmutableList<?> deserialize(JsonElement json, Type type,
- JsonDeserializationContext context) throws JsonParseException {
-
+ JsonDeserializationContext context) {
final List<?> list = context.deserialize(json, LIST_TYPE);
return ImmutableList.copyOf(list);
}
}
- // ----- inner class : ImmutableMapDeserializer ----------------------------
-
+ /**
+ * Deserializer for ImmutableMap used by AbstractNotificationConsumer.GSON.
+ */
public static class ImmutableMapDeserializer implements JsonDeserializer<ImmutableMap<?, ?>> {
- public static final Type MAP_TYPE = new TypeToken<Map<?, ?>>() {}.getType();
+ public static final Type MAP_TYPE = new TypeToken<Map<?, ?>>() {
+ }.getType();
@Override
public ImmutableMap<?, ?> deserialize(JsonElement json, Type type,
- JsonDeserializationContext context) throws JsonParseException {
+ JsonDeserializationContext context) {
final Map<?, ?> map = context.deserialize(json, MAP_TYPE);
return ImmutableMap.copyOf(map);
}
}
- // ----- inner class : EntityNotificationDeserializer ----------------------
-
- public final static class EntityNotificationDeserializer implements JsonDeserializer<EntityNotification> {
+ /**
+ * Deserializer for EntityNotification used by AbstractNotificationConsumer.GSON.
+ */
+ public static final class EntityNotificationDeserializer implements JsonDeserializer<EntityNotification> {
@Override
public EntityNotification deserialize(final JsonElement json, final Type type,
- final JsonDeserializationContext context) throws JsonParseException {
+ final JsonDeserializationContext context) {
return context.deserialize(json, EntityNotificationImpl.class);
}
}
- // ----- inner class : StructDeserializer -------------------------------
-
- public final static class StructDeserializer implements JsonDeserializer<IStruct>, JsonSerializer<IStruct> {
+ /**
+ * Serde for Struct used by AbstractNotificationConsumer.GSON.
+ */
+ public static final class StructDeserializer implements JsonDeserializer<IStruct>, JsonSerializer<IStruct> {
@Override
public IStruct deserialize(final JsonElement json, final Type type,
- final JsonDeserializationContext context) throws JsonParseException {
+ final JsonDeserializationContext context) {
return context.deserialize(json, Struct.class);
}
@@ -159,13 +163,14 @@ public abstract class AbstractNotificationConsumer<T> implements NotificationCon
}
- // ----- inner class : ReferenceableSerializerDeserializer ------------------------
-
- public final static class ReferenceableSerializerDeserializer implements JsonDeserializer<IStruct>,
+ /**
+ * Serde for Referenceable used by AbstractNotificationConsumer.GSON.
+ */
+ public static final class ReferenceableSerializerDeserializer implements JsonDeserializer<IStruct>,
JsonSerializer<IReferenceableInstance> {
@Override
public IReferenceableInstance deserialize(final JsonElement json, final Type type,
- final JsonDeserializationContext context) throws JsonParseException {
+ final JsonDeserializationContext context) {
return InstanceSerialization.fromJsonReferenceable(json.toString(), true);
}
@@ -178,14 +183,14 @@ public abstract class AbstractNotificationConsumer<T> implements NotificationCon
}
- // ----- inner class : JSONArraySerializerDeserializer ----------------------------
-
- public final static class JSONArraySerializerDeserializer implements JsonDeserializer<JSONArray>,
+ /**
+ * Serde for JSONArray used by AbstractNotificationConsumer.GSON.
+ */
+ public static final class JSONArraySerializerDeserializer implements JsonDeserializer<JSONArray>,
JsonSerializer<JSONArray> {
@Override
public JSONArray deserialize(final JsonElement json, final Type type,
- final JsonDeserializationContext context) throws JsonParseException {
-
+ final JsonDeserializationContext context) {
try {
return new JSONArray(json.toString());
} catch (JSONException e) {
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/main/java/org/apache/atlas/notification/NotificationConsumer.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/notification/NotificationConsumer.java b/notification/src/main/java/org/apache/atlas/notification/NotificationConsumer.java
index d2da975..53b3c6a 100644
--- a/notification/src/main/java/org/apache/atlas/notification/NotificationConsumer.java
+++ b/notification/src/main/java/org/apache/atlas/notification/NotificationConsumer.java
@@ -1,10 +1,11 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
@@ -14,11 +15,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.atlas.notification;
-// TODO : docs!
-public interface NotificationConsumer<T>{
+/**
+ * Interface for notification consumer.
+ * @param <T> message type
+ */
+public interface NotificationConsumer<T> {
boolean hasNext();
T next();
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/main/java/org/apache/atlas/notification/NotificationException.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/notification/NotificationException.java b/notification/src/main/java/org/apache/atlas/notification/NotificationException.java
index e6b02fb..d9d89df 100644
--- a/notification/src/main/java/org/apache/atlas/notification/NotificationException.java
+++ b/notification/src/main/java/org/apache/atlas/notification/NotificationException.java
@@ -1,10 +1,11 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
@@ -14,11 +15,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.atlas.notification;
import org.apache.atlas.AtlasException;
+/**
+ * Exception from notification.
+ */
public class NotificationException extends AtlasException {
public NotificationException(Exception e) {
super(e);
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java b/notification/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java
index 3352cd0..015af44 100644
--- a/notification/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java
+++ b/notification/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java
@@ -1,10 +1,11 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
@@ -14,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.atlas.notification;
import com.google.inject.Inject;
@@ -35,7 +35,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
/**
- * Consumer of notifications from hooks e.g., hive hook etc
+ * Consumer of notifications from hooks e.g., hive hook etc.
*/
@Singleton
public class NotificationHookConsumer implements Service {
@@ -93,7 +93,8 @@ public class NotificationHookConsumer implements Service {
this(atlasClient, consumer);
}
- public HookConsumer(AtlasClient client, NotificationConsumer<HookNotification.HookNotificationMessage> consumer) {
+ public HookConsumer(AtlasClient client,
+ NotificationConsumer<HookNotification.HookNotificationMessage> consumer) {
this.client = client;
this.consumer = consumer;
}
@@ -101,7 +102,7 @@ public class NotificationHookConsumer implements Service {
private boolean hasNext() {
try {
return consumer.hasNext();
- } catch(ConsumerTimeoutException e) {
+ } catch (ConsumerTimeoutException e) {
return false;
}
}
@@ -113,38 +114,41 @@ public class NotificationHookConsumer implements Service {
return;
}
- while(true) {
+ while (true) {
try {
if (hasNext()) {
HookNotification.HookNotificationMessage message = consumer.next();
try {
switch (message.getType()) {
- case ENTITY_CREATE:
- HookNotification.EntityCreateRequest createRequest =
- (HookNotification.EntityCreateRequest) message;
- atlasClient.createEntity(createRequest.getEntities());
- break;
-
- case ENTITY_PARTIAL_UPDATE:
- HookNotification.EntityPartialUpdateRequest partialUpdateRequest =
- (HookNotification.EntityPartialUpdateRequest) message;
- atlasClient.updateEntity(partialUpdateRequest.getTypeName(),
- partialUpdateRequest.getAttribute(), partialUpdateRequest.getAttributeValue(),
- partialUpdateRequest.getEntity());
- break;
-
- case ENTITY_FULL_UPDATE:
- HookNotification.EntityUpdateRequest updateRequest =
- (HookNotification.EntityUpdateRequest) message;
- atlasClient.updateEntities(updateRequest.getEntities());
- break;
+ case ENTITY_CREATE:
+ HookNotification.EntityCreateRequest createRequest =
+ (HookNotification.EntityCreateRequest) message;
+ atlasClient.createEntity(createRequest.getEntities());
+ break;
+
+ case ENTITY_PARTIAL_UPDATE:
+ HookNotification.EntityPartialUpdateRequest partialUpdateRequest =
+ (HookNotification.EntityPartialUpdateRequest) message;
+ atlasClient.updateEntity(partialUpdateRequest.getTypeName(),
+ partialUpdateRequest.getAttribute(),
+ partialUpdateRequest.getAttributeValue(), partialUpdateRequest.getEntity());
+ break;
+
+ case ENTITY_FULL_UPDATE:
+ HookNotification.EntityUpdateRequest updateRequest =
+ (HookNotification.EntityUpdateRequest) message;
+ atlasClient.updateEntities(updateRequest.getEntities());
+ break;
+
+ default:
+ throw new IllegalStateException("Unhandled exception!");
}
} catch (Exception e) {
//todo handle failures
LOG.warn("Error handling message {}", message, e);
}
}
- } catch(Throwable t) {
+ } catch (Throwable t) {
LOG.warn("Failure in NotificationHookConsumer", t);
}
}
@@ -158,15 +162,15 @@ public class NotificationHookConsumer implements Service {
SERVER_READY_WAIT_TIME_MS);
timer.sleep(SERVER_READY_WAIT_TIME_MS);
} catch (InterruptedException e) {
- LOG.info("Interrupted while waiting for Atlas Server to become ready, " +
- "exiting consumer thread.", e);
+ LOG.info("Interrupted while waiting for Atlas Server to become ready, "
+ + "exiting consumer thread.", e);
return false;
}
}
} catch (Throwable e) {
LOG.info(
- "Handled AtlasServiceException while waiting for Atlas Server to become ready, " +
- "exiting consumer thread.", e);
+ "Handled AtlasServiceException while waiting for Atlas Server to become ready, "
+ + "exiting consumer thread.", e);
return false;
}
LOG.info("Atlas Server is ready, can start reading Kafka events.");
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/main/java/org/apache/atlas/notification/NotificationInterface.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/notification/NotificationInterface.java b/notification/src/main/java/org/apache/atlas/notification/NotificationInterface.java
index e4c4fd6..dd52bff 100644
--- a/notification/src/main/java/org/apache/atlas/notification/NotificationInterface.java
+++ b/notification/src/main/java/org/apache/atlas/notification/NotificationInterface.java
@@ -1,10 +1,11 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
@@ -14,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.atlas.notification;
import org.apache.atlas.notification.entity.EntityNotification;
@@ -22,11 +22,18 @@ import org.apache.atlas.notification.hook.HookNotification;
import java.util.List;
-// TODO : docs!
+/**
+ * Notification interface for sending/receiving messages.
+ * 1. Atlas sends entity notifications
+ * 2. Hooks send notifications to create/update types/entities. Atlas reads these messages
+ */
public interface NotificationInterface {
String PROPERTY_PREFIX = "atlas.notification";
+ /**
+ * Notification type - hooks and entities.
+ */
enum NotificationType {
HOOK(HookNotification.HookNotificationMessage.class), ENTITIES(EntityNotification.class);
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/main/java/org/apache/atlas/notification/NotificationModule.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/notification/NotificationModule.java b/notification/src/main/java/org/apache/atlas/notification/NotificationModule.java
index c73f9cb..c20fdf1 100644
--- a/notification/src/main/java/org/apache/atlas/notification/NotificationModule.java
+++ b/notification/src/main/java/org/apache/atlas/notification/NotificationModule.java
@@ -1,10 +1,11 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
@@ -14,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.atlas.notification;
import com.google.inject.AbstractModule;
@@ -24,6 +24,9 @@ import org.apache.atlas.kafka.KafkaNotification;
import org.apache.atlas.kafka.KafkaNotificationProvider;
import org.apache.atlas.service.Service;
+/**
+ * Notification module for Guice.
+ */
public class NotificationModule extends AbstractModule {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotification.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotification.java b/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotification.java
index 32f325a..5579df2 100644
--- a/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotification.java
+++ b/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotification.java
@@ -1,10 +1,11 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
@@ -14,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.atlas.notification.entity;
import org.apache.atlas.typesystem.IReferenceableInstance;
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotificationImpl.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotificationImpl.java b/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotificationImpl.java
index 9f8ce45..fda588e 100644
--- a/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotificationImpl.java
+++ b/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotificationImpl.java
@@ -1,10 +1,11 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
@@ -14,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.atlas.notification.entity;
import org.apache.atlas.AtlasException;
@@ -106,14 +106,17 @@ public class EntityNotificationImpl implements EntityNotification {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
EntityNotificationImpl that = (EntityNotificationImpl) o;
- return !(entity != null ? !entity.equals(that.entity) : that.entity != null) &&
- operationType == that.operationType &&
- traits.equals(that.traits);
+ return !(entity != null ? !entity.equals(that.entity) : that.entity != null)
+ && operationType == that.operationType && traits.equals(that.traits);
}
@Override
@@ -141,7 +144,7 @@ public class EntityNotificationImpl implements EntityNotification {
}
private static List<IStruct> getSuperTraits(
- String typeName, Map<String, Object> values, TypeSystem typeSystem) throws AtlasException {
+ String typeName, Map<String, Object> values, TypeSystem typeSystem) throws AtlasException {
List<IStruct> superTypes = new LinkedList<>();
@@ -171,4 +174,4 @@ public class EntityNotificationImpl implements EntityNotification {
return superTypes;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/main/java/org/apache/atlas/notification/entity/NotificationEntityChangeListener.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/notification/entity/NotificationEntityChangeListener.java b/notification/src/main/java/org/apache/atlas/notification/entity/NotificationEntityChangeListener.java
index 243f93e..bdf9b2a 100644
--- a/notification/src/main/java/org/apache/atlas/notification/entity/NotificationEntityChangeListener.java
+++ b/notification/src/main/java/org/apache/atlas/notification/entity/NotificationEntityChangeListener.java
@@ -1,10 +1,11 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
@@ -14,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.atlas.notification.entity;
import org.apache.atlas.AtlasException;
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/main/java/org/apache/atlas/notification/hook/HookNotification.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/notification/hook/HookNotification.java b/notification/src/main/java/org/apache/atlas/notification/hook/HookNotification.java
index 33e0fe5..a000161 100644
--- a/notification/src/main/java/org/apache/atlas/notification/hook/HookNotification.java
+++ b/notification/src/main/java/org/apache/atlas/notification/hook/HookNotification.java
@@ -6,16 +6,15 @@
* to you 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/>
+ *
+ * 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 org.apache.atlas.notification.hook;
import com.google.gson.JsonDeserializationContext;
@@ -34,11 +33,14 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+/**
+ * Contains the structure of messages transferred from hooks to atlas.
+ */
public class HookNotification implements JsonDeserializer<HookNotification.HookNotificationMessage> {
@Override
public HookNotificationMessage deserialize(JsonElement json, Type typeOfT,
- JsonDeserializationContext context) throws JsonParseException {
+ JsonDeserializationContext context) {
if (json.isJsonArray()) {
JSONArray jsonArray = context.deserialize(json, JSONArray.class);
return new EntityCreateRequest(jsonArray);
@@ -46,31 +48,40 @@ public class HookNotification implements JsonDeserializer<HookNotification.HookN
HookNotificationType type =
context.deserialize(((JsonObject) json).get("type"), HookNotificationType.class);
switch (type) {
- case ENTITY_CREATE:
- return context.deserialize(json, EntityCreateRequest.class);
+ case ENTITY_CREATE:
+ return context.deserialize(json, EntityCreateRequest.class);
+
+ case ENTITY_FULL_UPDATE:
+ return context.deserialize(json, EntityUpdateRequest.class);
- case ENTITY_FULL_UPDATE:
- return context.deserialize(json, EntityUpdateRequest.class);
+ case ENTITY_PARTIAL_UPDATE:
+ return context.deserialize(json, EntityPartialUpdateRequest.class);
- case ENTITY_PARTIAL_UPDATE:
- return context.deserialize(json, EntityPartialUpdateRequest.class);
+ case TYPE_CREATE:
+ case TYPE_UPDATE:
+ return context.deserialize(json, TypeRequest.class);
- case TYPE_CREATE:
- case TYPE_UPDATE:
- return context.deserialize(json, TypeRequest.class);
+ default:
+ throw new IllegalStateException("Unhandled type " + type);
}
- throw new IllegalStateException("Unhandled type " + type);
}
}
+ /**
+ * Type of the hook message.
+ */
public enum HookNotificationType {
TYPE_CREATE, TYPE_UPDATE, ENTITY_CREATE, ENTITY_PARTIAL_UPDATE, ENTITY_FULL_UPDATE
}
+ /**
+ * Base type of hook message.
+ */
public static class HookNotificationMessage {
protected HookNotificationType type;
- private HookNotificationMessage() { }
+ private HookNotificationMessage() {
+ }
public HookNotificationMessage(HookNotificationType type) {
this.type = type;
@@ -81,10 +92,14 @@ public class HookNotification implements JsonDeserializer<HookNotification.HookN
}
}
+ /**
+ * Hook message for create type definitions.
+ */
public static class TypeRequest extends HookNotificationMessage {
private TypesDef typesDef;
- private TypeRequest() { }
+ private TypeRequest() {
+ }
public TypeRequest(HookNotificationType type, TypesDef typesDef) {
super(type);
@@ -96,10 +111,14 @@ public class HookNotification implements JsonDeserializer<HookNotification.HookN
}
}
+ /**
+ * Hook message for creating new entities.
+ */
public static class EntityCreateRequest extends HookNotificationMessage {
private List<Referenceable> entities;
- private EntityCreateRequest() { }
+ private EntityCreateRequest() {
+ }
public EntityCreateRequest(Referenceable... entities) {
this(HookNotificationType.ENTITY_CREATE, Arrays.asList(entities));
@@ -131,6 +150,9 @@ public class HookNotification implements JsonDeserializer<HookNotification.HookN
}
}
+ /**
+ * Hook message for updating entities(full update).
+ */
public static class EntityUpdateRequest extends EntityCreateRequest {
public EntityUpdateRequest(Referenceable... entities) {
this(Arrays.asList(entities));
@@ -141,13 +163,17 @@ public class HookNotification implements JsonDeserializer<HookNotification.HookN
}
}
+ /**
+ * Hook message for updating entities(partial update).
+ */
public static class EntityPartialUpdateRequest extends HookNotificationMessage {
private String typeName;
private String attribute;
private Referenceable entity;
private String attributeValue;
- private EntityPartialUpdateRequest() { }
+ private EntityPartialUpdateRequest() {
+ }
public EntityPartialUpdateRequest(String typeName, String attribute, String attributeValue,
Referenceable entity) {
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/test/java/org/apache/atlas/kafka/KafkaNotificationTest.java
----------------------------------------------------------------------
diff --git a/notification/src/test/java/org/apache/atlas/kafka/KafkaNotificationTest.java b/notification/src/test/java/org/apache/atlas/kafka/KafkaNotificationTest.java
index eb90f52..db34815 100644
--- a/notification/src/test/java/org/apache/atlas/kafka/KafkaNotificationTest.java
+++ b/notification/src/test/java/org/apache/atlas/kafka/KafkaNotificationTest.java
@@ -1,10 +1,11 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
@@ -14,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.atlas.kafka;
import com.google.inject.Inject;
@@ -99,7 +99,7 @@ public class KafkaNotificationTest {
assertTrue(streams.contains(kafkaStream2));
// assert that the given consumer group id was added to the properties used to create the consumer connector
- Properties properties = kafkaNotification.consumerProperties;
+ Properties properties = kafkaNotification.myProperties;
assertEquals(groupId, properties.getProperty(ConsumerConfig.GROUP_ID_CONFIG));
}
@@ -113,7 +113,7 @@ public class KafkaNotificationTest {
private final ConsumerConnector consumerConnector;
- private Properties consumerProperties;
+ private Properties myProperties;
private List<KafkaStream> kafkaStreams = new LinkedList<>();
public TestKafkaNotification(Configuration applicationProperties,
@@ -123,8 +123,8 @@ public class KafkaNotificationTest {
}
@Override
- protected ConsumerConnector createConsumerConnector(Properties properties) {
- this.consumerProperties = properties;
+ protected ConsumerConnector createConsumerConnector(Properties consumerProperties) {
+ this.myProperties = consumerProperties;
kafkaStreams.clear();
return consumerConnector;
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/test/java/org/apache/atlas/notification/NotificationHookConsumerTest.java
----------------------------------------------------------------------
diff --git a/notification/src/test/java/org/apache/atlas/notification/NotificationHookConsumerTest.java b/notification/src/test/java/org/apache/atlas/notification/NotificationHookConsumerTest.java
index e4d7f8c..b3d4721 100644
--- a/notification/src/test/java/org/apache/atlas/notification/NotificationHookConsumerTest.java
+++ b/notification/src/test/java/org/apache/atlas/notification/NotificationHookConsumerTest.java
@@ -1,10 +1,11 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
*
@@ -14,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.atlas.notification;
import org.apache.atlas.AtlasClient;
@@ -75,7 +75,8 @@ public class NotificationHookConsumerTest {
NotificationHookConsumer.HookConsumer hookConsumer =
notificationHookConsumer.new HookConsumer(atlasClient, mock(NotificationConsumer.class));
NotificationHookConsumer.Timer timer = mock(NotificationHookConsumer.Timer.class);
- when(atlasClient.isServerReady()).thenThrow(new AtlasServiceException(AtlasClient.API.VERSION, new Exception()));
+ when(atlasClient.isServerReady()).thenThrow(new AtlasServiceException(AtlasClient.API.VERSION,
+ new Exception()));
assertFalse(hookConsumer.serverAvailable(timer));
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/test/java/org/apache/atlas/notification/entity/EntityNotificationImplTest.java
----------------------------------------------------------------------
diff --git a/notification/src/test/java/org/apache/atlas/notification/entity/EntityNotificationImplTest.java b/notification/src/test/java/org/apache/atlas/notification/entity/EntityNotificationImplTest.java
index 6a0a920..385c41f 100644
--- a/notification/src/test/java/org/apache/atlas/notification/entity/EntityNotificationImplTest.java
+++ b/notification/src/test/java/org/apache/atlas/notification/entity/EntityNotificationImplTest.java
@@ -79,7 +79,7 @@ public class EntityNotificationImplTest {
}
@Test
- public void testGetAllTraits_superTraits() throws Exception {
+ public void testGetAllTraitsSuperTraits() throws Exception {
TypeSystem typeSystem = mock(TypeSystem.class);
@@ -146,4 +146,4 @@ public class EntityNotificationImplTest {
}
return new Referenceable(id, typeName, values, traitNames, traitMap);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/notification/src/test/java/org/apache/atlas/notification/hook/HookNotificationTest.java
----------------------------------------------------------------------
diff --git a/notification/src/test/java/org/apache/atlas/notification/hook/HookNotificationTest.java b/notification/src/test/java/org/apache/atlas/notification/hook/HookNotificationTest.java
index 4b9f81f..1dedb5b 100644
--- a/notification/src/test/java/org/apache/atlas/notification/hook/HookNotificationTest.java
+++ b/notification/src/test/java/org/apache/atlas/notification/hook/HookNotificationTest.java
@@ -6,16 +6,15 @@
* to you 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/>
+ *
+ * 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 org.apache.atlas.notification.hook;
import org.apache.atlas.notification.AbstractNotificationConsumer;
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 2131723..7470e65 100755
--- a/pom.xml
+++ b/pom.xml
@@ -368,6 +368,7 @@
<!-- skips checkstyle and find bugs -->
<skipCheck>false</skipCheck>
+ <checkstyle.failOnViolation>false</checkstyle.failOnViolation>
<skipUTs>false</skipUTs>
<skipITs>false</skipITs>
<skipDocs>true</skipDocs>
@@ -1611,7 +1612,9 @@
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<configLocation>src/build/checkstyle.xml</configLocation>
<headerLocation>src/build/checkstyle-java-header.txt</headerLocation>
- <failOnViolation>false</failOnViolation>
+ <suppressionsLocation>src/build/checkstyle-suppressions.xml</suppressionsLocation>
+ <suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression>
+ <failOnViolation>${checkstyle.failOnViolation}</failOnViolation>
</configuration>
</execution>
</executions>
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index a6c6bfc..e4346d0 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -7,6 +7,7 @@ ATLAS-409 Atlas will not import avro tables with schema read from a file (dosset
ATLAS-379 Create sqoop and falcon metadata addons (venkatnrangan,bvellanki,sowmyaramesh via shwethags)
ALL CHANGES:
+ATLAS-433 Fix checkstyle issues for common and notification module (shwethags)
ATLAS-183 Add a Hook in Storm to post the topology metadata (svenkat,yhemanth via shwethags)
ATLAS-370 Implement deleteEntities at repository level (dkantor via shwethags)
ATLAS-406 Resizing lineage window – should be an anchor on a corner – like ppt for graphic (sanjayp via shwethags)
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/src/build/checkstyle-suppressions.xml
----------------------------------------------------------------------
diff --git a/src/build/checkstyle-suppressions.xml b/src/build/checkstyle-suppressions.xml
new file mode 100644
index 0000000..0025360
--- /dev/null
+++ b/src/build/checkstyle-suppressions.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+ -->
+
+<!DOCTYPE suppressions PUBLIC
+ "-//Puppy Crawl//DTD Suppressions 1.1//EN"
+ "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
+
+<suppressions>
+ <suppress checks="JavadocType" files="[/\\]src[/\\]test[/\\]java[/\\]"/>
+</suppressions>
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d519ae8c/src/build/checkstyle.xml
----------------------------------------------------------------------
diff --git a/src/build/checkstyle.xml b/src/build/checkstyle.xml
index ab823fa..b7b7711 100755
--- a/src/build/checkstyle.xml
+++ b/src/build/checkstyle.xml
@@ -232,4 +232,7 @@
<property name="checkFormat" value="ParameterNumberCheck|VisibilityModifierCheck|HiddenFieldCheck|MethodName"/>
</module>
+ <module name="SuppressionFilter">
+ <property name="file" value="${checkstyle.suppressions.file}"/>
+ </module>
</module>