Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxt2015 committed Apr 23, 2022
1 parent d4039a3 commit 308f82e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE;


public class DataSourceClientProvider {
private static final Logger logger = LoggerFactory.getLogger(DataSourceClientProvider.class);
Expand All @@ -44,7 +46,10 @@ public class DataSourceClientProvider {
.expireAfterWrite(duration, TimeUnit.HOURS)
.maximumSize(100)
.build();

/**
* retry get hive connection when connect failed
*/
private boolean isRetry = true;
private DataSourcePluginManager dataSourcePluginManager;

private DataSourceClientProvider() {
Expand Down Expand Up @@ -72,7 +77,13 @@ public Connection getConnection(DbType dbType, ConnectionParam connectionParam)
}
return dataSourceChannel.createDataSourceClient(baseConnectionParam, dbType);
});
return dataSourceClient.getConnection();
Connection connection = dataSourceClient.getConnection();
if (null == connection && dbType.isHive() && isRetry && PropertyUtils.getBoolean(HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, false)) {
isRetry = false;
uniqueId2dataSourceClientCache.invalidate(datasourceUniqueId);
return getConnection(dbType, connectionParam);
}
return connection;
}

private void initDataSourcePlugin() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ public String[] tryExecuteSqlResolveColumnNames(DbType sourceType, BaseConnectio
columnNames[i - 1] = md.getColumnName(i);
}
} catch (SQLException | ExecutionException e) {
logger.warn(e.getMessage(), e);
logger.error(e.getMessage(), e);
return null;
}

Expand Down

0 comments on commit 308f82e

Please sign in to comment.