Commit 40e639ed by apoorvnaik Committed by Madhan Neethiraj

ATLAS-1407: improve LOG statement performance

parent 3725dcf1
......@@ -112,7 +112,7 @@ public class AtlasService implements FalconService, ConfigurationChangeListener
@Override
public void onAdd(Entity entity) throws FalconException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasService.onAdd(" + entity + ")");
LOG.debug("==> AtlasService.onAdd({})", entity);
}
try {
......@@ -123,14 +123,14 @@ public class AtlasService implements FalconService, ConfigurationChangeListener
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasService.onAdd(" + entity + ")");
LOG.debug("<== AtlasService.onAdd({})", entity);
}
}
@Override
public void onRemove(Entity entity) throws FalconException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasService.onRemove(" + entity + ")");
LOG.debug("==> AtlasService.onRemove({})", entity);
}
try {
......@@ -141,14 +141,14 @@ public class AtlasService implements FalconService, ConfigurationChangeListener
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasService.onRemove(" + entity + ")");
LOG.debug("<== AtlasService.onRemove({})", entity);
}
}
@Override
public void onChange(Entity entity, Entity entity1) throws FalconException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasService.onChange(" + entity + ", " + entity1 + ")");
LOG.debug("==> AtlasService.onChange({}, {})", entity, entity1);
}
try {
......@@ -159,14 +159,14 @@ public class AtlasService implements FalconService, ConfigurationChangeListener
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasService.onChange(" + entity + ", " + entity1 + ")");
LOG.debug("<== AtlasService.onChange({}, {})", entity, entity1);
}
}
@Override
public void onReload(Entity entity) throws FalconException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasService.onReload(" + entity + ")");
LOG.debug("==> AtlasService.onReload({})", entity);
}
try {
......@@ -177,7 +177,7 @@ public class AtlasService implements FalconService, ConfigurationChangeListener
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasService.onReload(" + entity + ")");
LOG.debug("<== AtlasService.onReload({})", entity);
}
}
......
......@@ -142,7 +142,7 @@ public class FalconHook extends AtlasHook implements FalconEventPublisher {
});
}
} catch (Throwable t) {
LOG.warn("Error in processing data " + data, t);
LOG.warn("Error in processing data {}", data, t);
}
}
......
......@@ -343,7 +343,7 @@ public class FalconHookIT {
if (System.currentTimeMillis() >= mustEnd) {
fail("Assertions failed. Failing after waiting for timeout " + timeout + " msecs", e);
}
LOG.debug("Waiting up to " + (mustEnd - System.currentTimeMillis()) + " msec as assertion failed", e);
LOG.debug("Waiting up to {} msec as assertion failed", mustEnd - System.currentTimeMillis(), e);
Thread.sleep(400);
}
}
......
......@@ -44,7 +44,7 @@ public class HiveHook implements ExecuteWithHookContext {
@Override
public void run(final HookContext hookContext) throws Exception {
if (LOG.isDebugEnabled()) {
LOG.debug("==> HiveHook.run(" + hookContext + ")");
LOG.debug("==> HiveHook.run({})", hookContext);
}
try {
......@@ -55,7 +55,7 @@ public class HiveHook implements ExecuteWithHookContext {
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== HiveHook.run(" + hookContext + ")");
LOG.debug("<== HiveHook.run({})", hookContext);
}
}
......
......@@ -179,7 +179,7 @@ public class HiveMetaStoreBridge {
}
private Referenceable createOrUpdateDBInstance(Database hiveDB, Referenceable dbRef) {
LOG.info("Importing objects from databaseName : " + hiveDB.getName());
LOG.info("Importing objects from databaseName : {}", hiveDB.getName());
if (dbRef == null) {
dbRef = new Referenceable(HiveDataTypes.HIVE_DB.getName());
......@@ -206,12 +206,12 @@ public class HiveMetaStoreBridge {
*/
private Referenceable registerInstance(Referenceable referenceable) throws Exception {
String typeName = referenceable.getTypeName();
LOG.debug("creating instance of type " + typeName);
LOG.debug("creating instance of type {}", typeName);
String entityJSON = InstanceSerialization.toJson(referenceable, true);
LOG.debug("Submitting new entity {} = {}", referenceable.getTypeName(), entityJSON);
List<String> guids = getAtlasClient().createEntity(entityJSON);
LOG.debug("created instance for type " + typeName + ", guid: " + guids);
LOG.debug("created instance for type {}, guid: {}", typeName, guids);
return new Referenceable(guids.get(guids.size() - 1), referenceable.getTypeName(), null);
}
......@@ -497,9 +497,9 @@ public class HiveMetaStoreBridge {
private Referenceable registerTable(Referenceable dbReference, Table table) throws Exception {
String dbName = table.getDbName();
String tableName = table.getTableName();
LOG.info("Attempting to register table [" + tableName + "]");
LOG.info("Attempting to register table [{}]", tableName);
Referenceable tableReference = getTableReference(table);
LOG.info("Found result " + tableReference);
LOG.info("Found result {}", tableReference);
if (tableReference == null) {
tableReference = createTableInstance(dbReference, table);
tableReference = registerInstance(tableReference);
......@@ -514,7 +514,7 @@ public class HiveMetaStoreBridge {
private void updateInstance(Referenceable referenceable) throws AtlasServiceException {
String typeName = referenceable.getTypeName();
LOG.debug("updating instance of type " + typeName);
LOG.debug("updating instance of type {}", typeName);
String entityJSON = InstanceSerialization.toJson(referenceable, true);
LOG.debug("Updating entity {} = {}", referenceable.getTypeName(), entityJSON);
......@@ -524,13 +524,13 @@ public class HiveMetaStoreBridge {
public Referenceable fillStorageDesc(StorageDescriptor storageDesc, String tableQualifiedName,
String sdQualifiedName, Id tableId) throws Exception {
LOG.debug("Filling storage descriptor information for " + storageDesc);
LOG.debug("Filling storage descriptor information for {}", storageDesc);
Referenceable sdReferenceable = new Referenceable(HiveDataTypes.HIVE_STORAGEDESC.getName());
sdReferenceable.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, sdQualifiedName);
SerDeInfo serdeInfo = storageDesc.getSerdeInfo();
LOG.debug("serdeInfo = " + serdeInfo);
LOG.debug("serdeInfo = {}", serdeInfo);
// SkewedInfo skewedInfo = storageDesc.getSkewedInfo();
String serdeInfoName = HiveDataTypes.HIVE_SERDE.getName();
......@@ -594,7 +594,7 @@ public class HiveMetaStoreBridge {
List<Referenceable> colList = new ArrayList<>();
int columnPosition = 0;
for (FieldSchema fs : schemaList) {
LOG.debug("Processing field " + fs);
LOG.debug("Processing field {}", fs);
Referenceable colReferenceable = new Referenceable(HiveDataTypes.HIVE_COLUMN.getName());
colReferenceable.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
getColumnQualifiedName((String) tableReference.get(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME), fs.getName()));
......
......@@ -201,7 +201,7 @@ public class HiveITBase {
if (System.currentTimeMillis() >= mustEnd) {
fail("Assertions failed. Failing after waiting for timeout " + timeout + " msecs", e);
}
LOG.debug("Waiting up to " + (mustEnd - System.currentTimeMillis()) + " msec as assertion failed", e);
LOG.debug("Waiting up to {} msec as assertion failed", mustEnd - System.currentTimeMillis(), e);
Thread.sleep(5000);
}
}
......
......@@ -43,7 +43,7 @@ public class SqoopHook extends SqoopJobDataPublisher {
@Override
public void publish(SqoopJobDataPublisher.Data data) throws Exception {
if (LOG.isDebugEnabled()) {
LOG.debug("==> SqoopHook.run(" + data + ")");
LOG.debug("==> SqoopHook.run({})", data);
}
try {
......@@ -54,7 +54,7 @@ public class SqoopHook extends SqoopJobDataPublisher {
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== SqoopHook.run(" + data + ")");
LOG.debug("<== SqoopHook.run({})", data);
}
}
......
......@@ -49,7 +49,7 @@ public class StormAtlasHook implements ISubmitterHook {
public void notify(TopologyInfo topologyInfo, Map stormConf, StormTopology stormTopology)
throws IllegalAccessException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> StormAtlasHook.notify(" + topologyInfo + ", " + stormConf + ", " + stormTopology + ")");
LOG.debug("==> StormAtlasHook.notify({}, {}, {})", topologyInfo, stormConf, stormTopology);
}
try {
......@@ -60,7 +60,7 @@ public class StormAtlasHook implements ISubmitterHook {
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== StormAtlasHook.notify(" + topologyInfo + ", " + stormConf + ", " + stormTopology + ")");
LOG.debug("<== StormAtlasHook.notify({}, {}, {})", topologyInfo, stormConf, stormTopology);
}
}
......
......@@ -62,7 +62,7 @@ public class AtlasAuthorizerFactory {
}
if (isDebugEnabled) {
LOG.debug("Initializing Authorizer :: " + authorizerClass);
LOG.debug("Initializing Authorizer :: {}", authorizerClass);
}
try {
Class authorizerMetaObject = Class.forName(authorizerClass);
......@@ -70,7 +70,7 @@ public class AtlasAuthorizerFactory {
INSTANCE = (AtlasAuthorizer) authorizerMetaObject.newInstance();
}
} catch (Exception e) {
LOG.error("Error while creating authorizer of type '" + authorizerClass + "'", e);
LOG.error("Error while creating authorizer of type '{}", authorizerClass, e);
throw new AtlasAuthorizationException("Error while creating authorizer of type '"
+ authorizerClass + "'", e);
}
......
......@@ -36,7 +36,7 @@ public class AtlasAuthorizationUtils {
public static String getApi(String contextPath) {
if (isDebugEnabled) {
LOG.debug("==> getApi from " + contextPath);
LOG.debug("==> getApi from {}", contextPath);
}
if (contextPath.startsWith(BASE_URL)) {
contextPath = contextPath.substring(BASE_URL.length());
......@@ -74,14 +74,14 @@ public class AtlasAuthorizationUtils {
break;
default:
if (isDebugEnabled) {
LOG.debug("getAtlasAction(): Invalid HTTP method '" + method + "'");
LOG.debug("getAtlasAction(): Invalid HTTP method '{}", method);
}
break;
}
if (isDebugEnabled) {
LOG.debug("<== AtlasAuthorizationFilter getAtlasAction HTTP Method " + method + " mapped to AtlasAction : "
+ action);
LOG.debug("<== AtlasAuthorizationFilter getAtlasAction HTTP Method {} mapped to AtlasAction : {}",
method, action);
}
return action;
}
......@@ -96,15 +96,15 @@ public class AtlasAuthorizationUtils {
* entities,lineage and discovery apis are mapped with AtlasResourceTypes.ENTITY eg :- /api/atlas/lineage/hive/table/*
* /api/atlas/entities/{guid}* /api/atlas/discovery/*
*
* taxonomy API are also mapped to AtlasResourceTypes.TAXONOMY & AtlasResourceTypes.ENTITY and its terms APIs have
* taxonomy API are also mapped to AtlasResourceTypes.TAXONOMY & AtlasResourceTypes.ENTITY and its terms APIs have
* added AtlasResourceTypes.TERM associations.
*
*
* unprotected types are mapped with AtlasResourceTypes.UNKNOWN, access to these are allowed.
*/
public static Set<AtlasResourceTypes> getAtlasResourceType(String contextPath) {
Set<AtlasResourceTypes> resourceTypes = new HashSet<>();
if (isDebugEnabled) {
LOG.debug("==> getAtlasResourceType for " + contextPath);
LOG.debug("==> getAtlasResourceType for {}", contextPath);
}
String api = getApi(contextPath);
if (api.startsWith("types")) {
......@@ -125,13 +125,13 @@ public class AtlasAuthorizationUtils {
resourceTypes.add(AtlasResourceTypes.TERM);
}
} else {
LOG.error("Unable to find Atlas Resource corresponding to : " + api + "\nSetting "
+ AtlasResourceTypes.UNKNOWN.name());
LOG.error("Unable to find Atlas Resource corresponding to : {}\nSetting {}"
, api, AtlasResourceTypes.UNKNOWN.name());
resourceTypes.add(AtlasResourceTypes.UNKNOWN);
}
if (isDebugEnabled) {
LOG.debug("<== Returning AtlasResource/s " + resourceTypes + " for api " + api);
LOG.debug("<== Returning AtlasResources {} for api {}", resourceTypes, api);
}
return resourceTypes;
}
......
......@@ -71,7 +71,7 @@ public class PolicyParser {
default:
if (LOG.isErrorEnabled()) {
LOG.error("Invalid action: '" + access + "'");
LOG.error("Invalid action: '{}'", access);
}
break;
}
......@@ -108,7 +108,7 @@ public class PolicyParser {
String[] props = data.split(";;");
if (props.length < RESOURCE_INDEX) {
LOG.warn("skipping invalid policy line: " + data);
LOG.warn("skipping invalid policy line: {}", data);
} else {
def = new PolicyDef();
def.setPolicyName(props[POLICYNAME]);
......
......@@ -36,15 +36,14 @@ public class PolicyUtil {
public Map<String, Map<AtlasResourceTypes, List<String>>> createPermissionMap(List<PolicyDef> policyDefList,
AtlasActionTypes permissionType, SimpleAtlasAuthorizer.AtlasAccessorTypes principalType) {
if (isDebugEnabled) {
LOG.debug("==> PolicyUtil createPermissionMap" + "\nCreating Permission Map for :: " + permissionType
+ " & " + principalType);
LOG.debug("==> PolicyUtil createPermissionMap\nCreating Permission Map for :: {} & {}", permissionType, principalType);
}
Map<String, Map<AtlasResourceTypes, List<String>>> userReadMap =
new HashMap<>();
// Iterate over the list of policies to create map
for (PolicyDef policyDef : policyDefList) {
LOG.info("Processing policy def : " + policyDef);
LOG.info("Processing policy def : {}", policyDef);
Map<String, List<AtlasActionTypes>> principalMap =
principalType.equals(SimpleAtlasAuthorizer.AtlasAccessorTypes.USER) ? policyDef.getUsers() : policyDef
.getGroups();
......@@ -61,7 +60,7 @@ public class PolicyUtil {
// If its not added then create a new resource list
if (userResourceList == null) {
if (isDebugEnabled) {
LOG.debug("Resource list not found for " + username + ", creating it");
LOG.debug("Resource list not found for {}, creating it", username);
}
userResourceList = new HashMap<>();
}
......@@ -89,11 +88,11 @@ public class PolicyUtil {
userResourceList.put(type, resourceList);
}
userReadMap.put(username, userResourceList);
LOG.info("userReadMap " + userReadMap);
LOG.info("userReadMap {}", userReadMap);
}
}
if (isDebugEnabled) {
LOG.debug("Returning Map for " + principalType + " :: " + userReadMap);
LOG.debug("Returning Map for {} :: {}", principalType, userReadMap);
LOG.debug("<== PolicyUtil createPermissionMap");
}
return userReadMap;
......
......@@ -79,14 +79,14 @@ public final class SimpleAtlasAuthorizer implements AtlasAuthorizer {
optIgnoreCase = Boolean.valueOf(PropertiesUtil.getProperty("optIgnoreCase", "false"));
if (isDebugEnabled) {
LOG.debug("Read from PropertiesUtil --> optIgnoreCase :: " + optIgnoreCase);
LOG.debug("Read from PropertiesUtil --> optIgnoreCase :: {}", optIgnoreCase);
}
Configuration configuration = ApplicationProperties.get();
String policyStorePath = configuration.getString("atlas.auth.policy.file", System.getProperty("atlas.conf")+"/policy-store.txt");
if (isDebugEnabled) {
LOG.debug("Loading Apache Atlas policies from : " + policyStorePath);
LOG.debug("Loading Apache Atlas policies from : {}", policyStorePath);
}
List<String> policies = FileReaderUtil.readFile(policyStorePath);
......@@ -103,10 +103,10 @@ public final class SimpleAtlasAuthorizer implements AtlasAuthorizer {
groupDeleteMap = util.createPermissionMap(policyDef, AtlasActionTypes.DELETE, AtlasAccessorTypes.GROUP);
if (isDebugEnabled) {
LOG.debug("\n\nUserReadMap :: " + userReadMap + "\nGroupReadMap :: " + groupReadMap);
LOG.debug("\n\nUserWriteMap :: " + userWriteMap + "\nGroupWriteMap :: " + groupWriteMap);
LOG.debug("\n\nUserUpdateMap :: " + userUpdateMap + "\nGroupUpdateMap :: " + groupUpdateMap);
LOG.debug("\n\nUserDeleteMap :: " + userDeleteMap + "\nGroupDeleteMap :: " + groupDeleteMap);
LOG.debug("\n\nUserReadMap :: {}\nGroupReadMap :: {}", userReadMap, groupReadMap);
LOG.debug("\n\nUserWriteMap :: {}\nGroupWriteMap :: {}", userWriteMap, groupWriteMap);
LOG.debug("\n\nUserUpdateMap :: {}\nGroupUpdateMap :: {}", userUpdateMap, groupUpdateMap);
LOG.debug("\n\nUserDeleteMap :: {}\nGroupDeleteMap :: {}", userDeleteMap, groupDeleteMap);
}
} catch (IOException | AtlasException e) {
......@@ -121,7 +121,7 @@ public final class SimpleAtlasAuthorizer implements AtlasAuthorizer {
public boolean isAccessAllowed(AtlasAccessRequest request) throws AtlasAuthorizationException {
if (isDebugEnabled) {
LOG.debug("==> SimpleAtlasAuthorizer isAccessAllowed");
LOG.debug("isAccessAllowd(" + request + ")");
LOG.debug("isAccessAllowd({})", request);
}
String user = request.getUser();
Set<String> groups = request.getUserGroups();
......@@ -129,8 +129,7 @@ public final class SimpleAtlasAuthorizer implements AtlasAuthorizer {
String resource = request.getResource();
Set<AtlasResourceTypes> resourceTypes = request.getResourceTypes();
if (isDebugEnabled)
LOG.debug("Checking for :: \nUser :: " + user + "\nGroups :: " + groups + "\nAction :: " + action
+ "\nResource :: " + resource);
LOG.debug("Checking for :: \nUser :: {}\nGroups :: {}\nAction :: {}\nResource :: {}", user, groups, action, resource);
boolean isAccessAllowed = false;
boolean isUser = user != null;
......@@ -143,7 +142,7 @@ public final class SimpleAtlasAuthorizer implements AtlasAuthorizer {
return isAccessAllowed;
} else {
if (isDebugEnabled) {
LOG.debug("checkAccess for Operation :: " + action + " on Resource " + resourceTypes + ":" + resource);
LOG.debug("checkAccess for Operation :: {} on Resource {}:{}", action, resourceTypes, resource);
}
switch (action) {
case READ:
......@@ -168,14 +167,14 @@ public final class SimpleAtlasAuthorizer implements AtlasAuthorizer {
break;
default:
if (isDebugEnabled) {
LOG.debug("Invalid Action " + action+"\nRaising AtlasAuthorizationException!!!");
LOG.debug("Invalid Action {}\nRaising AtlasAuthorizationException!!!", action);
}
throw new AtlasAuthorizationException("Invalid Action :: " + action);
}
}
if (isDebugEnabled) {
LOG.debug("<== SimpleAtlasAuthorizer isAccessAllowed = " + isAccessAllowed);
LOG.debug("<== SimpleAtlasAuthorizer isAccessAllowed = {}", isAccessAllowed);
}
return isAccessAllowed;
......@@ -185,8 +184,7 @@ public final class SimpleAtlasAuthorizer implements AtlasAuthorizer {
Map<String, Map<AtlasResourceTypes, List<String>>> map) {
if (isDebugEnabled) {
LOG.debug("==> SimpleAtlasAuthorizer checkAccess");
LOG.debug("Now checking access for accessor : " + accessor + "\nResource Types : " + resourceTypes
+ "\nResource : " + resource + "\nMap : " + map);
LOG.debug("Now checking access for accessor : {}\nResource Types : {}\nResource : {}\nMap : {}", accessor, resourceTypes, resource, map);
}
boolean result = true;
Map<AtlasResourceTypes, List<String>> rescMap = map.get(accessor);
......@@ -194,7 +192,7 @@ public final class SimpleAtlasAuthorizer implements AtlasAuthorizer {
for (AtlasResourceTypes resourceType : resourceTypes) {
List<String> accessList = rescMap.get(resourceType);
if (isDebugEnabled) {
LOG.debug("\nChecking for resource : " + resource + " in list : " + accessList + "\n");
LOG.debug("\nChecking for resource : {} in list : {}\n", resource, accessList);
}
if (accessList != null) {
result = result && isMatch(resource, accessList);
......@@ -205,11 +203,11 @@ public final class SimpleAtlasAuthorizer implements AtlasAuthorizer {
} else {
result = false;
if (isDebugEnabled)
LOG.debug("Key " + accessor + " missing. Returning with result : " + result);
LOG.debug("Key {} missing. Returning with result : {}", accessor, result);
}
if (isDebugEnabled) {
LOG.debug("Check for " + accessor + " :: " + result);
LOG.debug("Check for {} :: {}", accessor, result);
LOG.debug("<== SimpleAtlasAuthorizer checkAccess");
}
return result;
......@@ -308,14 +306,13 @@ public final class SimpleAtlasAuthorizer implements AtlasAuthorizer {
}
sb.append("]");
LOG.debug("AtlasDefaultResourceMatcher.isMatch returns FALSE, (resource=" + resource
+ ", policyValues=" + sb.toString() + ")");
LOG.debug("AtlasDefaultResourceMatcher.isMatch returns FALSE, (resource={}, policyValues={})", resource, sb.toString());
}
}
if (isDebugEnabled) {
LOG.debug("<== SimpleAtlasAuthorizer isMatch(" + resource + "): " + isMatch);
LOG.debug("<== SimpleAtlasAuthorizer isMatch({}): {}", resource, isMatch);
}
return isMatch;
......
......@@ -95,7 +95,7 @@ public class QueryFactory {
} catch (ParseException e) {
throw new InvalidQueryException(e.getMessage());
}
LOG.info("LuceneQuery: " + query);
LOG.info("LuceneQuery: {}", query);
queryExpression = create(query, resourceDefinition);
} else {
queryExpression = new AlwaysQueryExpression();
......
......@@ -261,9 +261,7 @@ public final class InMemoryJAASConfiguration extends Configuration {
String loginModuleName = properties.getProperty(keyParam);
if (loginModuleName == null) {
LOG.error("Unable to add JAAS configuration for "
+ "client [" + jaasClient + "] as it is missing param [" + keyParam + "]."
+ " Skipping JAAS config for [" + jaasClient + "]");
LOG.error("Unable to add JAAS configuration for client [{}] as it is missing param [{}]. Skipping JAAS config for [{}]", jaasClient, keyParam, jaasClient);
continue;
} else {
loginModuleName = loginModuleName.trim();
......@@ -290,15 +288,12 @@ public final class InMemoryJAASConfiguration extends Configuration {
break;
default:
String validValues = "optional|requisite|sufficient|required";
LOG.warn("Unknown JAAS configuration value for (" + keyParam
+ ") = [" + controlFlag + "], valid value are [" + validValues
+ "] using the default value, REQUIRED");
LOG.warn("Unknown JAAS configuration value for ({}) = [{}], valid value are [{}] using the default value, REQUIRED", keyParam, controlFlag, validValues);
loginControlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED;
break;
}
} else {
LOG.warn("Unable to find JAAS configuration ("
+ keyParam + "); using the default value, REQUIRED");
LOG.warn("Unable to find JAAS configuration ({}); using the default value, REQUIRED", keyParam);
loginControlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED;
}
......@@ -318,8 +313,7 @@ public final class InMemoryJAASConfiguration extends Configuration {
optionVal = SecurityUtil.getServerPrincipal(optionVal, (String) null);
}
} catch (IOException e) {
LOG.warn("Failed to build serverPrincipal. Using provided value:["
+ optionVal + "]");
LOG.warn("Failed to build serverPrincipal. Using provided value:[{}]", optionVal);
}
}
options.put(optionKey, optionVal);
......
......@@ -74,7 +74,7 @@ public final class AtlasPerfTracer {
public void log() {
long elapsedTime = getElapsedTime();
if (elapsedTime > reportingThresholdMs) {
logger.debug("PERF|" + tag + "|" + elapsedTime);
logger.debug("PERF|{}|{}", tag, elapsedTime);
}
}
}
......@@ -17,34 +17,34 @@
*/
package org.apache.atlas.model;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasStruct;
import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_BUILTIN_TYPES;
import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_PRIMITIVE_TYPES;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.model.typedef.AtlasClassificationDef;
import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.atlas.model.typedef.AtlasEnumDef;
import org.apache.atlas.model.typedef.AtlasStructDef;
import org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef;
import org.apache.atlas.model.typedef.AtlasStructDef;
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
import org.apache.atlas.model.typedef.AtlasClassificationDef;
import org.apache.atlas.type.AtlasType;
import org.apache.atlas.type.AtlasClassificationType;
import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasStructType;
import org.apache.atlas.type.AtlasType;
import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_BUILTIN_TYPES;
import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_PRIMITIVE_TYPES;
public final class ModelTestUtil {
private static final Logger LOG = LoggerFactory.getLogger(ModelTestUtil.class);
......@@ -309,7 +309,7 @@ public final class ModelTestUtil {
ret = ((AtlasEntityType) dataType).createDefaultValue();
}
} catch (AtlasBaseException excp) {
LOG.error("failed to get entity-type " + entityDef.getName(), excp);
LOG.error("failed to get entity-type {}", entityDef.getName(), excp);
}
return ret;
......@@ -329,7 +329,7 @@ public final class ModelTestUtil {
ret = ((AtlasStructType)dataType).createDefaultValue();
}
} catch (AtlasBaseException excp) {
LOG.error("failed to get struct-type " + structDef.getName(), excp);
LOG.error("failed to get struct-type {}", structDef.getName(), excp);
}
return ret;
......@@ -350,7 +350,7 @@ public final class ModelTestUtil {
ret = ((AtlasClassificationType)dataType).createDefaultValue();
}
} catch (AtlasBaseException excp) {
LOG.error("failed to get classification-type " + classificationDef.getName(), excp);
LOG.error("failed to get classification-type {}", classificationDef.getName(), excp);
}
return ret;
......
......@@ -131,7 +131,7 @@ public abstract class AtlasHook {
} catch (Exception e) {
numRetries++;
if (numRetries < maxRetries) {
LOG.error("Failed to send notification - attempt #" + numRetries + "; error=" + e.getMessage());
LOG.error("Failed to send notification - attempt #{}; error={}", numRetries, e.getMessage());
try {
LOG.debug("Sleeping for {} ms before retry", notificationRetryInterval);
Thread.sleep(notificationRetryInterval);
......@@ -190,14 +190,14 @@ public abstract class AtlasHook {
public static String getUser(String userName, UserGroupInformation ugi) {
if (StringUtils.isNotEmpty(userName)) {
if (LOG.isDebugEnabled()) {
LOG.debug("Returning userName {} " + userName);
LOG.debug("Returning userName {}", userName);
}
return userName;
}
if (ugi != null && StringUtils.isNotEmpty(ugi.getShortUserName())) {
if (LOG.isDebugEnabled()) {
LOG.debug("Returning ugi.getShortUserName {} " + userName);
LOG.debug("Returning ugi.getShortUserName {}", userName);
}
return ugi.getShortUserName();
}
......
......@@ -294,7 +294,7 @@ public class KafkaNotification extends AbstractNotification implements Service {
consumerProperties.putAll(properties);
consumerProperties.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);
LOG.info("Consumer property: auto.commit.enable: " + consumerProperties.getProperty("auto.commit.enable"));
LOG.info("Consumer property: auto.commit.enable: {}", consumerProperties.getProperty("auto.commit.enable"));
return consumerProperties;
}
......
......@@ -76,7 +76,7 @@ public final class AtlasPluginClassLoader extends URLClassLoader {
@Override
public Class<?> findClass(String name) throws ClassNotFoundException {
if (LOG.isTraceEnabled()) {
LOG.trace("==> AtlasPluginClassLoader.findClass(" + name + ")");
LOG.trace("==> AtlasPluginClassLoader.findClass({})", name);
}
Class<?> ret = null;
......@@ -84,7 +84,7 @@ public final class AtlasPluginClassLoader extends URLClassLoader {
try {
// first try to find the class in pluginClassloader
if (LOG.isTraceEnabled()) {
LOG.trace("AtlasPluginClassLoader.findClass(" + name + "): calling pluginClassLoader.findClass()");
LOG.trace("AtlasPluginClassLoader.findClass({}): calling pluginClassLoader.findClass()", name);
}
ret = super.findClass(name);
......@@ -94,8 +94,7 @@ public final class AtlasPluginClassLoader extends URLClassLoader {
if (savedClassLoader != null) {
if (LOG.isTraceEnabled()) {
LOG.trace(
"AtlasPluginClassLoader.findClass(" + name + "): calling componentClassLoader.findClass()");
LOG.trace("AtlasPluginClassLoader.findClass({}): calling componentClassLoader.findClass()", name);
}
ret = savedClassLoader.findClass(name);
......@@ -103,7 +102,7 @@ public final class AtlasPluginClassLoader extends URLClassLoader {
}
if (LOG.isTraceEnabled()) {
LOG.trace("<== AtlasPluginClassLoader.findClass(" + name + "): " + ret);
LOG.trace("<== AtlasPluginClassLoader.findClass({}): {}", name, ret);
}
return ret;
......@@ -112,7 +111,7 @@ public final class AtlasPluginClassLoader extends URLClassLoader {
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
if (LOG.isTraceEnabled()) {
LOG.trace("==> AtlasPluginClassLoader.loadClass(" + name + ")");
LOG.trace("==> AtlasPluginClassLoader.loadClass({})", name);
}
Class<?> ret = null;
......@@ -120,7 +119,7 @@ public final class AtlasPluginClassLoader extends URLClassLoader {
try {
// first try to load the class from pluginClassloader
if (LOG.isTraceEnabled()) {
LOG.trace("AtlasPluginClassLoader.loadClass(" + name + "): calling pluginClassLoader.loadClass()");
LOG.trace("AtlasPluginClassLoader.loadClass({}): calling pluginClassLoader.loadClass()", name);
}
ret = super.loadClass(name);
......@@ -130,8 +129,7 @@ public final class AtlasPluginClassLoader extends URLClassLoader {
if (savedClassLoader != null) {
if (LOG.isTraceEnabled()) {
LOG.trace(
"AtlasPluginClassLoader.loadClass(" + name + "): calling componentClassLoader.loadClass()");
LOG.trace("AtlasPluginClassLoader.loadClass({}): calling componentClassLoader.loadClass()", name);
}
ret = savedClassLoader.loadClass(name);
......@@ -139,7 +137,7 @@ public final class AtlasPluginClassLoader extends URLClassLoader {
}
if (LOG.isTraceEnabled()) {
LOG.trace("<== AtlasPluginClassLoader.loadClass(" + name + "): " + ret);
LOG.trace("<== AtlasPluginClassLoader.loadClass({}): {}", name, ret);
}
return ret;
......@@ -148,12 +146,12 @@ public final class AtlasPluginClassLoader extends URLClassLoader {
@Override
public URL findResource(String name) {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasPluginClassLoader.findResource(" + name + ") ");
LOG.debug("==> AtlasPluginClassLoader.findResource({}) ", name);
}
// first try to find the resource from pluginClassloader
if (LOG.isDebugEnabled()) {
LOG.debug("AtlasPluginClassLoader.findResource(" + name + "): calling pluginClassLoader.findResource()");
LOG.debug("AtlasPluginClassLoader.findResource({}): calling pluginClassLoader.findResource()", name);
}
URL ret = super.findResource(name);
......@@ -163,8 +161,7 @@ public final class AtlasPluginClassLoader extends URLClassLoader {
if (savedClassLoader != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("AtlasPluginClassLoader.findResource(" + name
+ "): calling componentClassLoader.getResource()");
LOG.debug("AtlasPluginClassLoader.findResource({}): calling componentClassLoader.getResource()", name);
}
ret = savedClassLoader.getResource(name);
......@@ -172,7 +169,7 @@ public final class AtlasPluginClassLoader extends URLClassLoader {
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasPluginClassLoader.findResource(" + name + "): " + ret);
LOG.debug("<== AtlasPluginClassLoader.findResource({}): {}", name, ret);
}
return ret;
......@@ -181,7 +178,7 @@ public final class AtlasPluginClassLoader extends URLClassLoader {
@Override
public Enumeration<URL> findResources(String name) throws IOException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasPluginClassLoader.findResources(" + name + ")");
LOG.debug("==> AtlasPluginClassLoader.findResources({})", name);
}
Enumeration<URL> ret = null;
......@@ -198,7 +195,7 @@ public final class AtlasPluginClassLoader extends URLClassLoader {
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasPluginClassLoader.findResources(" + name + "): " + ret);
LOG.debug("<== AtlasPluginClassLoader.findResources({}): {}", name, ret);
}
return ret;
......@@ -241,7 +238,7 @@ public final class AtlasPluginClassLoader extends URLClassLoader {
private Enumeration<URL> findResourcesUsingPluginClassLoader(String name) {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasPluginClassLoader.findResourcesUsingPluginClassLoader(" + name + ")");
LOG.debug("==> AtlasPluginClassLoader.findResourcesUsingPluginClassLoader({})", name);
}
Enumeration<URL> ret = null;
......@@ -251,13 +248,12 @@ public final class AtlasPluginClassLoader extends URLClassLoader {
} catch (Throwable excp) {
// Ignore exceptions
if (LOG.isDebugEnabled()) {
LOG.debug("AtlasPluginClassLoader.findResourcesUsingPluginClassLoader(" + name
+ "): resource not found in plugin", excp);
LOG.debug("AtlasPluginClassLoader.findResourcesUsingPluginClassLoader({}): resource not found in plugin", name, excp);
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasPluginClassLoader.findResourcesUsingPluginClassLoader(" + name + "): " + ret);
LOG.debug("<== AtlasPluginClassLoader.findResourcesUsingPluginClassLoader({}): {}", name, ret);
}
return ret;
......@@ -265,7 +261,7 @@ public final class AtlasPluginClassLoader extends URLClassLoader {
private Enumeration<URL> findResourcesUsingComponentClassLoader(String name) {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasPluginClassLoader.findResourcesUsingComponentClassLoader(" + name + ")");
LOG.debug("==> AtlasPluginClassLoader.findResourcesUsingComponentClassLoader({})", name);
}
Enumeration<URL> ret = null;
......@@ -275,20 +271,18 @@ public final class AtlasPluginClassLoader extends URLClassLoader {
if (savedClassLoader != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("AtlasPluginClassLoader.findResourcesUsingComponentClassLoader(" + name
+ "): calling componentClassLoader.getResources()");
LOG.debug("AtlasPluginClassLoader.findResourcesUsingComponentClassLoader({}): calling componentClassLoader.getResources()", name);
}
ret = savedClassLoader.getResources(name);
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasPluginClassLoader.findResourcesUsingComponentClassLoader(" + name + "): " + ret);
LOG.debug("<== AtlasPluginClassLoader.findResourcesUsingComponentClassLoader({}): {}", name, ret);
}
} catch (Throwable t) {
if (LOG.isDebugEnabled()) {
LOG.debug("AtlasPluginClassLoader.findResourcesUsingComponentClassLoader(" + name
+ "): class not found in componentClassLoader.", t);
LOG.debug("AtlasPluginClassLoader.findResourcesUsingComponentClassLoader({}): class not found in componentClassLoader.", name, t);
}
}
......
......@@ -52,7 +52,7 @@ final class AtlasPluginClassLoaderUtil {
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasPluginClassLoaderUtil.getFilesInDirectories(): " + ret.size() + " files");
LOG.debug("<== AtlasPluginClassLoaderUtil.getFilesInDirectories(): {} files", ret.size());
}
return ret.toArray(new URL[]{});
......@@ -73,32 +73,31 @@ final class AtlasPluginClassLoaderUtil {
URL jarPath = dirFile.toURI().toURL();
if (LOG.isDebugEnabled()) {
LOG.debug(
"getFilesInDirectory('" + dirPath + "'): adding " + dirFile.getAbsolutePath());
LOG.debug("getFilesInDirectory('{}'): adding {}", dirPath, dirFile.getAbsolutePath());
}
files.add(jarPath);
} catch (Exception excp) {
LOG.warn("getFilesInDirectory('" + dirPath + "'): failed to get URI for file " + dirFile
LOG.warn("getFilesInDirectory('{}'): failed to get URI for file {}", dirPath, dirFile
.getAbsolutePath(), excp);
}
}
}
} catch (Exception excp) {
LOG.warn("getFilesInDirectory('" + dirPath + "'): error", excp);
LOG.warn("getFilesInDirectory('{}'): error", dirPath, excp);
}
} else {
LOG.warn("getFilesInDirectory('" + dirPath + "'): could not find directory in path " + dirPath);
LOG.warn("getFilesInDirectory('{}'): could not find directory in path {}", dirPath, dirPath);
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasPluginClassLoaderUtil.getFilesInDirectory(" + dirPath + ")");
LOG.debug("<== AtlasPluginClassLoaderUtil.getFilesInDirectory({})", dirPath);
}
}
public static String getPluginImplLibPath(String pluginType, Class<?> pluginClass) throws Exception {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasPluginClassLoaderUtil.getPluginImplLibPath for Class (" + pluginClass.getName() + ")");
LOG.debug("==> AtlasPluginClassLoaderUtil.getPluginImplLibPath for Class ({})", pluginClass.getName());
}
URI uri = pluginClass.getProtectionDomain().getCodeSource().getLocation().toURI();
......@@ -106,8 +105,7 @@ final class AtlasPluginClassLoaderUtil {
String ret = path.getParent().toString() + File.separatorChar + ATLAS_PLUGIN_LIBDIR.replaceAll("%", pluginType);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasPluginClassLoaderUtil.getPluginImplLibPath for Class " + pluginClass.getName() + "): "
+ ret + ")");
LOG.debug("<== AtlasPluginClassLoaderUtil.getPluginImplLibPath for Class {}): {})", pluginClass.getName(), ret);
}
return ret;
......
......@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES:
ATLAS-1407 improve LOG statement performance (apoorvnaik via mneethiraj)
ATLAS-1350 update authorization to handle v2 REST endpoints (saqeeb.s via mneethiraj)
ATLAS-1311 Integration tests for V2 Entity APIs (apoorvnaik via mneethiraj)
ATLAS-1377 fix for Escaping comma in for LDAP properties (nixonrodrigues via mneethiraj)
......
......@@ -57,7 +57,7 @@ public class GraphTransactionInterceptor implements MethodInterceptor {
if (logException(t)) {
LOG.error("graph rollback due to exception ", t);
} else {
LOG.error("graph rollback due to exception " + t.getClass().getSimpleName() + ":" + t.getMessage());
LOG.error("graph rollback due to exception {}:{}", t.getClass().getSimpleName(), t.getMessage());
}
graph.rollback();
throw t;
......
......@@ -347,7 +347,7 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
} catch (EntityNotFoundException e) {
// Entity does not exist - treat as non-error, since the caller
// wanted to delete the entity and it's already gone.
LOG.info("Deletion request ignored for non-existent entity with guid " + guid);
LOG.info("Deletion request ignored for non-existent entity with guid {}", guid);
}
}
......
......@@ -564,7 +564,7 @@ public final class GraphHelper {
result = findVertex(propertyKey, instance.get(attributeInfo.name),
Constants.ENTITY_TYPE_PROPERTY_KEY, classType.getName(),
Constants.STATE_PROPERTY_KEY, Id.EntityState.ACTIVE.name());
LOG.debug("Found vertex by unique attribute : " + propertyKey + "=" + instance.get(attributeInfo.name));
LOG.debug("Found vertex by unique attribute : {}={}", propertyKey, instance.get(attributeInfo.name));
} catch (EntityNotFoundException e) {
//Its ok if there is no entity with the same unique value
}
......
......@@ -588,7 +588,7 @@ public final class TypedInstanceToGraphMapper {
String edgeLabel) throws AtlasException {
AtlasVertex newReferenceVertex = getClassVertex(newAttributeValue);
if( ! GraphHelper.elementExists(newReferenceVertex) && newAttributeValue != null) {
LOG.error("Could not find vertex for Class Reference " + newAttributeValue);
LOG.error("Could not find vertex for Class Reference {}", newAttributeValue);
throw new EntityNotFoundException("Could not find vertex for Class Reference " + newAttributeValue);
}
......
......@@ -130,7 +130,7 @@ public class AtlasTypeDefStoreInitializer {
typeDefStore.createTypesDef(typesToCreate);
} catch (Throwable t) {
LOG.error("error while registering types in file " + typeDefFile.getAbsolutePath(), t);
LOG.error("error while registering types in file {}", typeDefFile.getAbsolutePath(), t);
}
}
......@@ -194,12 +194,11 @@ public class AtlasTypeDefStoreInitializer {
try {
patchHandler.applyPatch(patch);
} catch (AtlasBaseException excp) {
LOG.error("Failed to apply " + patch.getAction() + " patch in file " +
typePatchFile.getAbsolutePath() + ". Ignored", excp);
LOG.error("Failed to apply {} patch in file {}. Ignored", patch.getAction(), typePatchFile.getAbsolutePath(), excp);
}
}
} catch (Throwable t) {
LOG.error("Failed to apply patches in file " + typePatchFile.getAbsolutePath() + ". Ignored", t);
LOG.error("Failed to apply patches in file {}. Ignored", typePatchFile.getAbsolutePath(), t);
}
}
}
......
......@@ -159,7 +159,7 @@ public class DefaultMetadataService implements MetadataService, ActiveStateChang
if (typesDef != null && !typesDef.isEmpty()) {
TypeSystem.TransientTypeSystem transientTypeSystem = typeSystem.createTransientTypeSystem(typesDef, true);
Map<String, IDataType> typesAdded = transientTypeSystem.getTypesAdded();
LOG.info("Number of types got from transient type system: " + typesAdded.size());
LOG.info("Number of types got from transient type system: {}", typesAdded.size());
typeSystem.commitTypes(typesAdded);
}
}
......@@ -748,7 +748,7 @@ public class DefaultMetadataService implements MetadataService, ActiveStateChang
TypeSystem.TransientTypeSystem transientTypeSystem
= typeSystem.createTransientTypeSystem(typesDef, false);
Map<String, IDataType> typesAdded = transientTypeSystem.getTypesAdded();
LOG.info("Number of types got from transient type system: " + typesAdded.size());
LOG.info("Number of types got from transient type system: {}", typesAdded.size());
typeSystem.commitTypes(typesAdded);
} catch (AtlasException e) {
LOG.error("Failed to restore type-system after TypeRegistry changes", e);
......
......@@ -27,6 +27,7 @@ import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.List;
@Aspect
......@@ -55,11 +56,11 @@ public class AtlasAspect {
String methodName = methodSign.getDeclaringType().getSimpleName() + "." + methodSign.getName();
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("==> %s(%s)", methodName, joinPoint.getArgs()));
LOG.debug(String.format("==> %s(%s)", methodName, Arrays.toString(joinPoint.getArgs())));
}
Object response = joinPoint.proceed();
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("<== %s(%s): %s", methodName, joinPoint.getArgs(),
LOG.debug(String.format("<== %s(%s): %s", methodName, Arrays.toString(joinPoint.getArgs()),
response instanceof List ? ((List)response).size() : response));
}
return response;
......
......@@ -56,18 +56,18 @@ public class AtlasServerIdSelector {
try {
socketAddress = NetUtils.createSocketAddr(hostPort);
} catch (Exception e) {
LOG.warn("Exception while trying to get socket address for " + hostPort, e);
LOG.warn("Exception while trying to get socket address for {}", hostPort, e);
continue;
}
if (!socketAddress.isUnresolved()
&& NetUtils.isLocalAddress(socketAddress.getAddress())
&& appPort == socketAddress.getPort()) {
LOG.info("Found matched server id " + id + " with host port: " + hostPort);
LOG.info("Found matched server id {} with host port: {}", id, hostPort);
matchingServerId = id;
break;
}
} else {
LOG.info("Could not find matching address entry for id: " + id);
LOG.info("Could not find matching address entry for id: {}", id);
}
}
if (matchingServerId == null) {
......
......@@ -249,7 +249,7 @@ public class NotificationHookConsumer implements Service, ActiveStateChangeHandl
break;
} catch (Throwable e) {
LOG.warn("Error handling message" + e.getMessage());
LOG.warn("Error handling message{}", e.getMessage());
try{
LOG.info("Sleeping for {} ms before retry", consumerRetryInterval);
Thread.sleep(consumerRetryInterval);
......@@ -273,7 +273,7 @@ public class NotificationHookConsumer implements Service, ActiveStateChangeHandl
private void recordFailedMessages() {
//logging failed messages
for (HookNotification.HookNotificationMessage message : failedMessages) {
FAILED_LOG.error("[DROPPED_NOTIFICATION] " + AbstractNotification.getMessageJson(message));
FAILED_LOG.error("[DROPPED_NOTIFICATION] {}", AbstractNotification.getMessageJson(message));
}
failedMessages.clear();
}
......
......@@ -67,12 +67,11 @@ public class UserDao {
inStr = new FileInputStream(PROPERTY_FILE_PATH);
userLogins.load(inStr);
}else {
LOG.error("Error while reading user.properties file, filepath="
+ PROPERTY_FILE_PATH);
LOG.error("Error while reading user.properties file, filepath={}", PROPERTY_FILE_PATH);
}
} catch (IOException | AtlasException e) {
LOG.error("Error while reading user.properties file, filepath=" + PROPERTY_FILE_PATH, e);
LOG.error("Error while reading user.properties file, filepath={}", PROPERTY_FILE_PATH, e);
throw new RuntimeException(e);
} finally {
if(inStr != null) {
......@@ -99,7 +98,7 @@ public class UserDao {
role = dataArr[0];
password = dataArr[1];
} else {
LOG.error("User role credentials is not set properly for " + username);
LOG.error("User role credentials is not set properly for {}", username);
throw new AtlasAuthenticationException("User role credentials is not set properly for " + username );
}
......@@ -107,7 +106,7 @@ public class UserDao {
if (StringUtils.hasText(role)) {
grantedAuths.add(new SimpleGrantedAuthority(role));
} else {
LOG.error("User role credentials is not set properly for " + username);
LOG.error("User role credentials is not set properly for {}", username);
throw new AtlasAuthenticationException("User role credentials is not set properly for " + username );
}
......
......@@ -32,9 +32,9 @@ import org.apache.hadoop.security.authentication.client.AuthenticatedURL;
import org.apache.hadoop.security.authentication.client.AuthenticationException;
import org.apache.hadoop.security.authentication.client.KerberosAuthenticator;
import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
import org.apache.hadoop.security.authentication.server.AuthenticationHandler;
import org.apache.hadoop.security.authentication.server.AuthenticationToken;
import org.apache.hadoop.security.authentication.server.KerberosAuthenticationHandler;
import org.apache.hadoop.security.authentication.server.AuthenticationHandler;
import org.apache.hadoop.security.authentication.util.Signer;
import org.apache.hadoop.security.authentication.util.SignerException;
import org.apache.hadoop.security.authentication.util.SignerSecretProvider;
......@@ -50,16 +50,18 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.web.authentication.WebAuthenticationDetails;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.net.InetAddress;
......@@ -69,7 +71,6 @@ import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.http.Cookie;
/**
* This enforces authentication as part of the filter before processing the request.
......@@ -91,7 +92,7 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
LOG.info("AtlasAuthenticationFilter initialization started");
init(null);
} catch (ServletException e) {
LOG.error("Error while initializing AtlasAuthenticationFilter : " + e.getMessage());
LOG.error("Error while initializing AtlasAuthenticationFilter : {}", e.getMessage());
}
}
......@@ -149,7 +150,7 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
@Override
public void initializeSecretProvider(FilterConfig filterConfig)
throws ServletException {
LOG.debug("AtlasAuthenticationFilter :: initializeSecretProvider " + filterConfig);
LOG.debug("AtlasAuthenticationFilter :: initializeSecretProvider {}", filterConfig);
secretProvider = (SignerSecretProvider) filterConfig.getServletContext().
getAttribute(AuthenticationFilter.SIGNER_SECRET_PROVIDER_ATTRIBUTE);
if (secretProvider == null) {
......@@ -278,7 +279,7 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
SecurityContextHolder.getContext().setAuthentication(finalAuthentication);
request.setAttribute("atlas.http.authentication.type", true);
LOG.info("Logged into Atlas as = " + userName);
LOG.info("Logged into Atlas as = {}", userName);
}
}
// OPTIONS method is sent from quick start jersey atlas client
......@@ -357,7 +358,7 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
token = getToken(httpRequest);
}
catch (AuthenticationException ex) {
LOG.warn("AuthenticationToken ignored: " + ex.getMessage());
LOG.warn("AuthenticationToken ignored: {}", ex.getMessage());
// will be sent back in a 401 unless filter authenticates
authenticationEx = ex;
token = null;
......@@ -412,7 +413,7 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
// exception from the filter itself is fatal
errCode = HttpServletResponse.SC_FORBIDDEN;
authenticationEx = ex;
LOG.warn("Authentication exception: " + ex.getMessage(), ex);
LOG.warn("Authentication exception: {}", ex.getMessage(), ex);
}
if (unauthorizedResponse) {
if (!httpResponse.isCommitted()) {
......
......@@ -18,18 +18,7 @@
package org.apache.atlas.web.filters;
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.google.common.base.Strings;
import org.apache.atlas.AtlasClient;
import org.apache.atlas.authorize.AtlasAccessRequest;
import org.apache.atlas.authorize.AtlasAuthorizationException;
......@@ -44,7 +33,16 @@ import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.filter.GenericFilterBean;
import com.google.common.base.Strings;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
public class AtlasAuthorizationFilter extends GenericFilterBean {
......@@ -95,7 +93,7 @@ public class AtlasAuthorizationFilter extends GenericFilterBean {
String pathInfo = request.getServletPath();
if (!Strings.isNullOrEmpty(pathInfo) && pathInfo.startsWith(BASE_URL)) {
if (isDebugEnabled) {
LOG.debug(pathInfo + " is a valid REST API request!!!");
LOG.debug("{} is a valid REST API request!!!", pathInfo);
}
String userName = null;
......@@ -111,16 +109,13 @@ public class AtlasAuthorizationFilter extends GenericFilterBean {
}
} else {
if (LOG.isErrorEnabled()) {
LOG.error("Cannot obtain Security Context : " + auth);
LOG.error("Cannot obtain Security Context : {}", auth);
}
throw new ServletException("Cannot obtain Security Context : " + auth);
}
AtlasAccessRequest atlasRequest = new AtlasAccessRequest(request, userName, groups);
if (isDebugEnabled) {
LOG.debug("============================\n" + "UserName :: " + atlasRequest.getUser() + "\nGroups :: "
+ atlasRequest.getUserGroups() + "\nURL :: " + request.getRequestURL() + "\nAction :: "
+ atlasRequest.getAction() + "\nrequest.getServletPath() :: " + pathInfo
+ "\n============================\n");
LOG.debug("============================\nUserName :: {}\nGroups :: {}\nURL :: {}\nAction :: {}\nrequest.getServletPath() :: {}\n============================\n", atlasRequest.getUser(), atlasRequest.getUserGroups(), request.getRequestURL(), atlasRequest.getAction(), pathInfo);
}
boolean accessAllowed = false;
......@@ -129,7 +124,7 @@ public class AtlasAuthorizationFilter extends GenericFilterBean {
if (atlasResourceTypes.size() == 1 && atlasResourceTypes.contains(AtlasResourceTypes.UNKNOWN)) {
// Allowing access to unprotected resource types
if (LOG.isDebugEnabled()) {
LOG.debug("Allowing access to unprotected resource types " + atlasResourceTypes);
LOG.debug("Allowing access to unprotected resource types {}", atlasResourceTypes);
}
accessAllowed = true;
} else {
......@@ -140,11 +135,11 @@ public class AtlasAuthorizationFilter extends GenericFilterBean {
}
} catch (AtlasAuthorizationException e) {
if (LOG.isErrorEnabled()) {
LOG.error("Access Restricted. Could not process the request :: " + e);
LOG.error("Access Restricted. Could not process the request :: {}", e);
}
}
if (isDebugEnabled) {
LOG.debug("Authorizer result :: " + accessAllowed);
LOG.debug("Authorizer result :: {}", accessAllowed);
}
}
if (accessAllowed) {
......@@ -162,15 +157,13 @@ public class AtlasAuthorizationFilter extends GenericFilterBean {
response.sendError(HttpServletResponse.SC_FORBIDDEN, json.toString());
if (isDebugEnabled) {
LOG.debug("You are not authorized for " + atlasRequest.getAction().name() + " on "
+ atlasResourceTypes + " : " + atlasRequest.getResource()
+ "\nReturning 403 since the access is blocked update!!!!");
LOG.debug("You are not authorized for {} on {} : {}\nReturning 403 since the access is blocked update!!!!", atlasRequest.getAction().name(), atlasResourceTypes, atlasRequest.getResource());
}
}
} else {
if (isDebugEnabled) {
LOG.debug("Ignoring request " + pathInfo);
LOG.debug("Ignoring request {}", pathInfo);
}
chain.doFilter(req, res);
}
......
......@@ -237,7 +237,7 @@ public class AtlasKnoxSSOAuthenticationFilter implements Filter {
for (Cookie cookie : cookies) {
if (cookieName.equals(cookie.getName())) {
if (LOG.isDebugEnabled()) {
LOG.debug(cookieName + " cookie has been found and is being processed");
LOG.debug("{} cookie has been found and is being processed", cookieName);
}
serializedJWT = cookie.getValue();
break;
......
......@@ -102,7 +102,7 @@ public class GuiceServletConfig extends GuiceServletContextListener {
String initParamValue = getServletContext().getInitParameter(initParamName);
if (GUICE_CTX_PARAM.equals(initParamName)) {
LOG.info("Jersey loading from packages: " + initParamValue);
LOG.info("Jersey loading from packages: {}", initParamValue);
initParams.put(PackagesResourceConfig.PROPERTY_PACKAGES, initParamValue);
} else {
......
......@@ -268,10 +268,10 @@ public class EntityResource {
LOG.error("An entity with type={} and qualifiedName={} does not exist {} ", entityType, value, entityJson, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.NOT_FOUND));
} catch (AtlasException | IllegalArgumentException e) {
LOG.error("Unable to partially update entity {} {} " + entityType + ":" + attribute + "." + value, entityJson, e);
LOG.error("Unable to partially update entity {} {}:{}.{}", entityJson, entityType, attribute, value, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
} catch (Throwable e) {
LOG.error("Unable to partially update entity {} {} " + entityType + ":" + attribute + "." + value, entityJson, e);
LOG.error("Unable to partially update entity {} {}:{}.{}", entityJson, entityType, attribute, value, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
}
}
......
......@@ -40,7 +40,7 @@ public class AtlasSetup {
public AtlasSetup() {
injector = Guice.createInjector(new AtlasSetupModule());
LOG.info("Got injector: " + injector);
LOG.info("Got injector: {}", injector);
}
public static void main(String[] args) {
......
......@@ -71,7 +71,7 @@ public class SetupSteps {
LOG.info("Acquired lock for running setup.");
handleSetupInProgress(configuration, zookeeperProperties);
for (SetupStep step : setupSteps) {
LOG.info("Running setup step: " + step);
LOG.info("Running setup step: {}", step);
step.run();
}
clearSetupInProgress(zookeeperProperties);
......
......@@ -134,7 +134,7 @@ public class EntityNotificationIT extends BaseResourceIT {
Struct traitInstance = new Struct(traitName);
String traitInstanceJSON = InstanceSerialization.toJson(traitInstance, true);
LOG.debug("Trait instance = " + traitInstanceJSON);
LOG.debug("Trait instance = {}", traitInstanceJSON);
final String guid = tableId._getId();
......@@ -161,7 +161,7 @@ public class EntityNotificationIT extends BaseResourceIT {
traitInstance = new Struct(anotherTraitName);
traitInstanceJSON = InstanceSerialization.toJson(traitInstance, true);
LOG.debug("Trait instance = " + traitInstanceJSON);
LOG.debug("Trait instance = {}", traitInstanceJSON);
atlasClientV1.addTrait(guid, traitInstance);
......@@ -200,7 +200,7 @@ public class EntityNotificationIT extends BaseResourceIT {
TypesUtil.createTraitTypeDef(traitName, ImmutableSet.copyOf(superTraitNames));
String traitDefinitionJSON = TypesSerialization$.MODULE$.toJson(trait, true);
LOG.debug("Trait definition = " + traitDefinitionJSON);
LOG.debug("Trait definition = {}", traitDefinitionJSON);
createType(traitDefinitionJSON);
}
......
......@@ -398,7 +398,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
final String definition = response.getString(AtlasClient.DEFINITION);
Assert.assertNotNull(definition);
LOG.debug("tableInstanceAfterGet = " + definition);
LOG.debug("tableInstanceAfterGet = {}", definition);
InstanceSerialization.fromJsonReferenceable(definition, true);
}
......@@ -483,12 +483,12 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
HierarchicalTypeDefinition<TraitType> piiTrait =
TypesUtil.createTraitTypeDef(traitName, ImmutableSet.<String>of());
String traitDefinitionAsJSON = TypesSerialization$.MODULE$.toJson(piiTrait, true);
LOG.debug("traitDefinitionAsJSON = " + traitDefinitionAsJSON);
LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON);
createType(traitDefinitionAsJSON);
Struct traitInstance = new Struct(traitName);
String traitInstanceAsJSON = InstanceSerialization.toJson(traitInstance, true);
LOG.debug("traitInstanceAsJSON = " + traitInstanceAsJSON);
LOG.debug("traitInstanceAsJSON = {}", traitInstanceAsJSON);
final String guid = tableId._getId();
JSONObject response = atlasClientV1.callAPIWithBodyAndParams(AtlasClient.API.ADD_TRAITS, traitInstanceAsJSON, guid, TRAITS);
......@@ -504,12 +504,12 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
HierarchicalTypeDefinition<TraitType> piiTrait =
TypesUtil.createTraitTypeDef(traitName, ImmutableSet.<String>of());
String traitDefinitionAsJSON = TypesSerialization$.MODULE$.toJson(piiTrait, true);
LOG.debug("traitDefinitionAsJSON = " + traitDefinitionAsJSON);
LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON);
createType(traitDefinitionAsJSON);
Struct traitInstance = new Struct(traitName);
String traitInstanceAsJSON = InstanceSerialization.toJson(traitInstance, true);
LOG.debug("traitInstanceAsJSON = " + traitInstanceAsJSON);
LOG.debug("traitInstanceAsJSON = {}", traitInstanceAsJSON);
final String guid = tableId._getId();
JSONObject response = atlasClientV1.callAPIWithBodyAndParams(AtlasClient.API.ADD_TRAITS, traitInstanceAsJSON, guid, TRAITS);
......@@ -531,7 +531,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
Struct traitInstance = new Struct(traitName);
String traitInstanceAsJSON = InstanceSerialization.toJson(traitInstance, true);
LOG.debug("traitInstanceAsJSON = " + traitInstanceAsJSON);
LOG.debug("traitInstanceAsJSON = {}", traitInstanceAsJSON);
final String guid = tableId._getId();
JSONObject response = atlasClientV1.callAPIWithBodyAndParams(AtlasClient.API.ADD_TRAITS, traitInstanceAsJSON, guid, TRAITS);
......@@ -545,13 +545,13 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
.createTraitTypeDef(traitName, ImmutableSet.<String>of(),
TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE));
String traitDefinitionAsJSON = TypesSerialization$.MODULE$.toJson(piiTrait, true);
LOG.debug("traitDefinitionAsJSON = " + traitDefinitionAsJSON);
LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON);
createType(traitDefinitionAsJSON);
Struct traitInstance = new Struct(traitName);
traitInstance.set("type", "SSN");
String traitInstanceAsJSON = InstanceSerialization.toJson(traitInstance, true);
LOG.debug("traitInstanceAsJSON = " + traitInstanceAsJSON);
LOG.debug("traitInstanceAsJSON = {}", traitInstanceAsJSON);
final String guid = tableId._getId();
JSONObject response = atlasClientV1.callAPIWithBodyAndParams(AtlasClient.API.ADD_TRAITS, traitInstanceAsJSON, guid, TRAITS);
......@@ -576,11 +576,11 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
HierarchicalTypeDefinition<TraitType> piiTrait =
TypesUtil.createTraitTypeDef(traitName, ImmutableSet.<String>of());
String traitDefinitionAsJSON = TypesSerialization$.MODULE$.toJson(piiTrait, true);
LOG.debug("traitDefinitionAsJSON = " + traitDefinitionAsJSON);
LOG.debug("traitDefinitionAsJSON = {}", traitDefinitionAsJSON);
Struct traitInstance = new Struct(traitName);
String traitInstanceAsJSON = InstanceSerialization$.MODULE$.toJson(traitInstance, true);
LOG.debug("traitInstanceAsJSON = " + traitInstanceAsJSON);
LOG.debug("traitInstanceAsJSON = {}", traitInstanceAsJSON);
JSONObject response = atlasClientV1.callAPIWithBodyAndParams(AtlasClient.API.CREATE_ENTITY, traitInstanceAsJSON, "random", TRAITS);
}
......@@ -675,7 +675,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
put("columns", columns);
}});
LOG.debug("Updating entity= " + tableUpdated);
LOG.debug("Updating entity= {}", tableUpdated);
AtlasClient.EntityResult entityResult = atlasClientV1.updateEntity(tableId._getId(), tableUpdated);
assertEquals(entityResult.getUpdateEntities().size(), 1);
assertEquals(entityResult.getUpdateEntities().get(0), tableId._getId());
......@@ -694,7 +694,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
put("columns", columns);
}});
LOG.debug("Updating entity= " + tableUpdated);
LOG.debug("Updating entity= {}", tableUpdated);
entityResult = atlasClientV1.updateEntity(BaseResourceIT.HIVE_TABLE_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
(String) tableInstance.get(QUALIFIED_NAME), tableUpdated);
assertEquals(entityResult.getUpdateEntities().size(), 2);
......@@ -740,7 +740,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
String entityJson = InstanceSerialization.toJson(tableInstance, true);
JSONArray entityArray = new JSONArray(1);
entityArray.put(entityJson);
LOG.debug("Replacing entity= " + tableInstance);
LOG.debug("Replacing entity= {}", tableInstance);
JSONObject response = atlasClientV1.callAPIWithBody(AtlasClient.API.UPDATE_ENTITY, entityArray);
......
......@@ -114,7 +114,7 @@ public class FileAuthenticationTest {
when(authentication.getCredentials()).thenReturn("admin");
Authentication auth = authProvider.authenticate(authentication);
LOG.debug(" " + auth);
LOG.debug(" {}", auth);
Assert.assertTrue(auth.isAuthenticated());
}
......@@ -127,7 +127,7 @@ public class FileAuthenticationTest {
try {
Authentication auth = authProvider.authenticate(authentication);
LOG.debug(" " + auth);
LOG.debug(" {}", auth);
} catch (BadCredentialsException bcExp) {
Assert.assertEquals("Wrong password", bcExp.getMessage());
}
......@@ -140,7 +140,7 @@ public class FileAuthenticationTest {
when(authentication.getCredentials()).thenReturn("wrongpassword");
try {
Authentication auth = authProvider.authenticate(authentication);
LOG.debug(" " + auth);
LOG.debug(" {}", auth);
} catch (UsernameNotFoundException uExp) {
Assert.assertTrue(uExp.getMessage().contains("Username not found."));
}
......@@ -153,7 +153,7 @@ public class FileAuthenticationTest {
when(authentication.getCredentials()).thenReturn("user12");
try {
Authentication auth = authProvider.authenticate(authentication);
LOG.debug(" " + auth);
LOG.debug(" {}", auth);
} catch (AtlasAuthenticationException uExp) {
Assert.assertTrue(uExp.getMessage().startsWith("User role credentials is not set properly for"));
}
......@@ -167,7 +167,7 @@ public class FileAuthenticationTest {
when(authentication.getCredentials()).thenReturn("P@ssword");
try {
Authentication auth = authProvider.authenticate(authentication);
LOG.debug(" " + auth);
LOG.debug(" {}", auth);
} catch (UsernameNotFoundException uExp) {
Assert.assertTrue(uExp.getMessage().startsWith("Username not found"));
}
......@@ -180,7 +180,7 @@ public class FileAuthenticationTest {
when(authentication.getCredentials()).thenReturn("admin");
Authentication auth = authProvider.authenticate(authentication);
LOG.debug(" " + auth);
LOG.debug(" {}", auth);
Assert.assertTrue(auth.isAuthenticated());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment