Commit 7f2a4086 by Madhan Neethiraj Committed by Suma Shivaprasad

ATLAS-1108: updated references to atlas.rest.address to handle multiple URLs

parent 531a9684
...@@ -76,9 +76,9 @@ public class FalconHookIT { ...@@ -76,9 +76,9 @@ public class FalconHookIT {
public void setUp() throws Exception { public void setUp() throws Exception {
Configuration atlasProperties = ApplicationProperties.get(); Configuration atlasProperties = ApplicationProperties.get();
if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) { if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
atlasClient = new AtlasClient(new String[]{atlasProperties.getString(HiveMetaStoreBridge.ATLAS_ENDPOINT)}, new String[]{"admin", "admin"}); atlasClient = new AtlasClient(atlasProperties.getStringArray(HiveMetaStoreBridge.ATLAS_ENDPOINT), new String[]{"admin", "admin"});
} else { } else {
atlasClient = new AtlasClient(atlasProperties.getString(HiveMetaStoreBridge.ATLAS_ENDPOINT)); atlasClient = new AtlasClient(atlasProperties.getStringArray(HiveMetaStoreBridge.ATLAS_ENDPOINT));
} }
AtlasService service = new AtlasService(); AtlasService service = new AtlasService();
......
...@@ -635,8 +635,8 @@ public class HiveMetaStoreBridge { ...@@ -635,8 +635,8 @@ public class HiveMetaStoreBridge {
Configuration atlasConf = ApplicationProperties.get(); Configuration atlasConf = ApplicationProperties.get();
String[] atlasEndpoint = atlasConf.getStringArray(ATLAS_ENDPOINT); String[] atlasEndpoint = atlasConf.getStringArray(ATLAS_ENDPOINT);
if (atlasEndpoint == null){ if (atlasEndpoint == null || atlasEndpoint.length == 0){
atlasEndpoint = new String[]{DEFAULT_DGI_URL}; atlasEndpoint = new String[] { DEFAULT_DGI_URL };
} }
AtlasClient atlasClient; AtlasClient atlasClient;
......
...@@ -80,10 +80,16 @@ public class HiveITBase { ...@@ -80,10 +80,16 @@ public class HiveITBase {
SessionState.setCurrentSessionState(ss); SessionState.setCurrentSessionState(ss);
Configuration configuration = ApplicationProperties.get(); Configuration configuration = ApplicationProperties.get();
String[] atlasEndPoint = configuration.getStringArray(HiveMetaStoreBridge.ATLAS_ENDPOINT);
if (atlasEndPoint == null || atlasEndPoint.length == 0) {
atlasEndPoint = new String[] { DGI_URL };
}
if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) { if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
atlasClient = new AtlasClient(new String[]{configuration.getString(HiveMetaStoreBridge.ATLAS_ENDPOINT, DGI_URL)}, new String[]{"admin", "admin"}); atlasClient = new AtlasClient(atlasEndPoint, new String[]{"admin", "admin"});
} else { } else {
atlasClient = new AtlasClient(configuration.getString(HiveMetaStoreBridge.ATLAS_ENDPOINT, DGI_URL)); atlasClient = new AtlasClient(atlasEndPoint);
} }
hiveMetaStoreBridge = new HiveMetaStoreBridge(configuration, conf, atlasClient); hiveMetaStoreBridge = new HiveMetaStoreBridge(configuration, conf, atlasClient);
......
...@@ -50,9 +50,9 @@ public class SqoopHookIT { ...@@ -50,9 +50,9 @@ public class SqoopHookIT {
//Set-up sqoop session //Set-up sqoop session
Configuration configuration = ApplicationProperties.get(); Configuration configuration = ApplicationProperties.get();
if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) { if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
atlasClient = new AtlasClient(new String[]{configuration.getString(HiveMetaStoreBridge.ATLAS_ENDPOINT)}, new String[]{"admin", "admin"}); atlasClient = new AtlasClient(configuration.getStringArray(HiveMetaStoreBridge.ATLAS_ENDPOINT), new String[]{"admin", "admin"});
} else { } else {
atlasClient = new AtlasClient(configuration.getString(HiveMetaStoreBridge.ATLAS_ENDPOINT)); atlasClient = new AtlasClient(configuration.getStringArray(HiveMetaStoreBridge.ATLAS_ENDPOINT));
} }
registerDataModels(atlasClient); registerDataModels(atlasClient);
} }
......
...@@ -63,9 +63,9 @@ public class StormAtlasHookIT { ...@@ -63,9 +63,9 @@ public class StormAtlasHookIT {
Configuration configuration = ApplicationProperties.get(); Configuration configuration = ApplicationProperties.get();
if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) { if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
atlasClient = new AtlasClient(new String[]{configuration.getString(HiveMetaStoreBridge.ATLAS_ENDPOINT)}, new String[]{"admin", "admin"}); atlasClient = new AtlasClient(configuration.getStringArray(HiveMetaStoreBridge.ATLAS_ENDPOINT), new String[]{"admin", "admin"});
} else { } else {
atlasClient = new AtlasClient(configuration.getString(HiveMetaStoreBridge.ATLAS_ENDPOINT)); atlasClient = new AtlasClient(configuration.getStringArray(HiveMetaStoreBridge.ATLAS_ENDPOINT));
} }
registerDataModel(new HiveDataModelGenerator()); registerDataModel(new HiveDataModelGenerator());
} }
......
...@@ -60,20 +60,23 @@ public class AtlasAdminClient { ...@@ -60,20 +60,23 @@ public class AtlasAdminClient {
private int run(String[] args) throws AtlasException { private int run(String[] args) throws AtlasException {
CommandLine commandLine = parseCommandLineOptions(args); CommandLine commandLine = parseCommandLineOptions(args);
Configuration configuration = ApplicationProperties.get(); Configuration configuration = ApplicationProperties.get();
String atlasServerUri = configuration.getString( String[] atlasServerUri = configuration.getStringArray(AtlasConstants.ATLAS_REST_ADDRESS_KEY);
AtlasConstants.ATLAS_REST_ADDRESS_KEY, AtlasConstants.DEFAULT_ATLAS_REST_ADDRESS);
if (atlasServerUri == null || atlasServerUri.length == 0) {
atlasServerUri = new String[] { AtlasConstants.DEFAULT_ATLAS_REST_ADDRESS };
}
AtlasClient atlasClient = null; AtlasClient atlasClient = null;
if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) { if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
String[] basicAuthUsernamePassword = AuthenticationUtil.getBasicAuthenticationInput(); String[] basicAuthUsernamePassword = AuthenticationUtil.getBasicAuthenticationInput();
atlasClient = new AtlasClient(new String[]{atlasServerUri}, basicAuthUsernamePassword); atlasClient = new AtlasClient(atlasServerUri, basicAuthUsernamePassword);
} else { } else {
atlasClient = new AtlasClient(atlasServerUri, null, null); atlasClient = new AtlasClient(atlasServerUri, null);
} }
return handleCommand(commandLine, atlasServerUri, atlasClient); return handleCommand(commandLine, atlasServerUri, atlasClient);
} }
private int handleCommand(CommandLine commandLine, String atlasServerUri, AtlasClient atlasClient) { private int handleCommand(CommandLine commandLine, String[] atlasServerUri, AtlasClient atlasClient) {
int cmdStatus = PROGRAM_ERROR_STATUS; int cmdStatus = PROGRAM_ERROR_STATUS;
if (commandLine.hasOption(STATUS.getOpt())) { if (commandLine.hasOption(STATUS.getOpt())) {
try { try {
......
...@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES: ...@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES:
ATLAS-1060 Add composite indexes for exact match performance improvements for all attributes (sumasai via shwethags) ATLAS-1060 Add composite indexes for exact match performance improvements for all attributes (sumasai via shwethags)
ALL CHANGES: ALL CHANGES:
ATLAS-1115 Show Tag / Taxonomy Listing in sorted order (Kalyanikashikar via sumasai)
ATLAS-1117 Atlas start fails on trunk (jnhagelb via dkantor) ATLAS-1117 Atlas start fails on trunk (jnhagelb via dkantor)
ATLAS-1112 Hive table GET response from atlas server had duplicate column entries ( ayubkhan, mneethiraj via sumasai) ATLAS-1112 Hive table GET response from atlas server had duplicate column entries ( ayubkhan, mneethiraj via sumasai)
ATLAS-1108 In Atlas HA mode , import-hive.sh in Passive instance fails. (ayubkhan via sumasai) ATLAS-1108 In Atlas HA mode , import-hive.sh in Passive instance fails. (ayubkhan via sumasai)
......
...@@ -81,13 +81,13 @@ public class QuickStart { ...@@ -81,13 +81,13 @@ public class QuickStart {
@VisibleForTesting @VisibleForTesting
static void runQuickstart(String[] args, String[] basicAuthUsernamePassword) throws Exception { static void runQuickstart(String[] args, String[] basicAuthUsernamePassword) throws Exception {
String baseUrl = getServerUrl(args); String[] urls = getServerUrl(args);
QuickStart quickStart; QuickStart quickStart;
if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) { if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
quickStart = new QuickStart(baseUrl, basicAuthUsernamePassword); quickStart = new QuickStart(urls, basicAuthUsernamePassword);
} else { } else {
quickStart = new QuickStart(baseUrl); quickStart = new QuickStart(urls);
} }
// Shows how to create types in Atlas for your meta model // Shows how to create types in Atlas for your meta model
...@@ -100,19 +100,19 @@ public class QuickStart { ...@@ -100,19 +100,19 @@ public class QuickStart {
quickStart.search(); quickStart.search();
} }
static String getServerUrl(String[] args) throws AtlasException { static String[] getServerUrl(String[] args) throws AtlasException {
if (args.length > 0) { if (args.length > 0) {
return args[0]; return args[0].split(",");
} }
Configuration configuration = ApplicationProperties.get(); Configuration configuration = ApplicationProperties.get();
String baseUrl = configuration.getString(ATLAS_REST_ADDRESS); String[] urls = configuration.getStringArray(ATLAS_REST_ADDRESS);
if (baseUrl == null) { if (urls == null || urls.length == 0) {
System.out.println("Usage: quick_start.py <atlas endpoint of format <http/https>://<atlas-fqdn>:<atlas port> like http://localhost:21000>"); System.out.println("Usage: quick_start.py <atlas endpoint of format <http/https>://<atlas-fqdn>:<atlas port> like http://localhost:21000>");
System.exit(-1); System.exit(-1);
} }
return baseUrl; return urls;
} }
static final String DATABASE_TYPE = "DB"; static final String DATABASE_TYPE = "DB";
...@@ -128,13 +128,11 @@ public class QuickStart { ...@@ -128,13 +128,11 @@ public class QuickStart {
private final AtlasClient metadataServiceClient; private final AtlasClient metadataServiceClient;
QuickStart(String baseUrl,String[] basicAuthUsernamePassword) { QuickStart(String[] urls,String[] basicAuthUsernamePassword) {
String[] urls = baseUrl.split(",");
metadataServiceClient = new AtlasClient(urls,basicAuthUsernamePassword); metadataServiceClient = new AtlasClient(urls,basicAuthUsernamePassword);
} }
QuickStart(String baseUrl) throws AtlasException { QuickStart(String[] urls) throws AtlasException {
String[] urls = baseUrl.split(",");
metadataServiceClient = new AtlasClient(urls); metadataServiceClient = new AtlasClient(urls);
} }
......
...@@ -21,9 +21,7 @@ package org.apache.atlas.web.resources; ...@@ -21,9 +21,7 @@ package org.apache.atlas.web.resources;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import kafka.consumer.ConsumerTimeoutException; import kafka.consumer.ConsumerTimeoutException;
import org.apache.atlas.ApplicationProperties; import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
...@@ -58,7 +56,6 @@ import org.slf4j.LoggerFactory; ...@@ -58,7 +56,6 @@ import org.slf4j.LoggerFactory;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import javax.ws.rs.core.UriBuilder;
import java.util.List; import java.util.List;
/** /**
...@@ -72,18 +69,22 @@ public abstract class BaseResourceIT { ...@@ -72,18 +69,22 @@ public abstract class BaseResourceIT {
protected AtlasClient serviceClient; protected AtlasClient serviceClient;
public static final Logger LOG = LoggerFactory.getLogger(BaseResourceIT.class); public static final Logger LOG = LoggerFactory.getLogger(BaseResourceIT.class);
protected static final int MAX_WAIT_TIME = 60000; protected static final int MAX_WAIT_TIME = 60000;
protected String baseUrl; protected String[] atlasUrls;
@BeforeClass @BeforeClass
public void setUp() throws Exception { public void setUp() throws Exception {
Configuration configuration = ApplicationProperties.get(); Configuration configuration = ApplicationProperties.get();
baseUrl = configuration.getString(ATLAS_REST_ADDRESS, "http://localhost:21000/"); atlasUrls = configuration.getStringArray(ATLAS_REST_ADDRESS);
if (atlasUrls == null || atlasUrls.length == 0) {
atlasUrls = new String[] { "http://localhost:21000/" };
}
if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) { if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
serviceClient = new AtlasClient(new String[]{baseUrl}, new String[]{"admin", "admin"}); serviceClient = new AtlasClient(atlasUrls, new String[]{"admin", "admin"});
} else { } else {
serviceClient = new AtlasClient(baseUrl); serviceClient = new AtlasClient(atlasUrls);
} }
service = serviceClient.getResource(); service = serviceClient.getResource();
} }
......
...@@ -50,7 +50,6 @@ import org.apache.atlas.typesystem.types.TraitType; ...@@ -50,7 +50,6 @@ import org.apache.atlas.typesystem.types.TraitType;
import org.apache.atlas.typesystem.types.utils.TypesUtil; import org.apache.atlas.typesystem.types.utils.TypesUtil;
import org.apache.atlas.web.util.Servlets; import org.apache.atlas.web.util.Servlets;
import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.lang.RandomStringUtils;
import org.apache.hadoop.security.UserGroupInformation;
import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject; import org.codehaus.jettison.json.JSONObject;
...@@ -131,9 +130,9 @@ public class EntityJerseyResourceIT extends BaseResourceIT { ...@@ -131,9 +130,9 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
String user = "admin"; String user = "admin";
AtlasClient localClient = null; AtlasClient localClient = null;
if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) { if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
localClient = new AtlasClient(new String[]{baseUrl}, new String[]{"admin", "admin"}); localClient = new AtlasClient(atlasUrls, new String[]{"admin", "admin"});
} else { } else {
localClient = new AtlasClient(baseUrl); localClient = new AtlasClient(atlasUrls);
} }
String entityId = localClient.createEntity(entity).get(0); String entityId = localClient.createEntity(entity).get(0);
......
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