mirror of
https://github.com/apache/sqoop.git
synced 2025-05-16 17:00:53 +08:00
SQOOP-2485: Sqoop2: Findbugs: Fix smaller-ish warnings in core module
(Colin Ma via Jarek Jarcec Cecho)
This commit is contained in:
parent
5b5042c1f2
commit
b62c3dec82
@ -63,15 +63,6 @@ public static AuditLoggerManager getInstance() {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows to set instance in case that it's need.
|
|
||||||
*
|
|
||||||
* @param newInstance New instance
|
|
||||||
*/
|
|
||||||
public void setInstance(AuditLoggerManager newInstance) {
|
|
||||||
instance = newInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AuditLoggerManager() {
|
public AuditLoggerManager() {
|
||||||
loggers = new ArrayList<AuditLogger>();
|
loggers = new ArrayList<AuditLogger>();
|
||||||
}
|
}
|
||||||
@ -95,10 +86,11 @@ private void initializeLoggers() {
|
|||||||
AuditLoggerConstants.PREFIX_AUDITLOGGER_CONFIG);
|
AuditLoggerConstants.PREFIX_AUDITLOGGER_CONFIG);
|
||||||
|
|
||||||
// Initialize audit loggers
|
// Initialize audit loggers
|
||||||
for (String key : auditLoggerProps.keySet()) {
|
for (Map.Entry<String, String> entry : auditLoggerProps.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
if (key.endsWith(AuditLoggerConstants.SUFFIX_AUDITLOGGER_CLASS)) {
|
if (key.endsWith(AuditLoggerConstants.SUFFIX_AUDITLOGGER_CLASS)) {
|
||||||
String loggerName = key.substring(0, key.indexOf("."));
|
String loggerName = key.substring(0, key.indexOf("."));
|
||||||
String loggerClassName = auditLoggerProps.get(key);
|
String loggerClassName = entry.getValue();
|
||||||
|
|
||||||
if (loggerClassName == null || loggerClassName.trim().length() == 0) {
|
if (loggerClassName == null || loggerClassName.trim().length() == 0) {
|
||||||
throw new SqoopException(AuditLoggerError.AUDIT_0001,
|
throw new SqoopException(AuditLoggerError.AUDIT_0001,
|
||||||
|
@ -196,8 +196,8 @@ private synchronized void registerConnectors(boolean autoUpgrade) {
|
|||||||
try {
|
try {
|
||||||
rtx = repository.getTransaction();
|
rtx = repository.getTransaction();
|
||||||
rtx.begin();
|
rtx.begin();
|
||||||
for (String name : handlerMap.keySet()) {
|
for (Map.Entry<String, ConnectorHandler> entry : handlerMap.entrySet()) {
|
||||||
ConnectorHandler handler = handlerMap.get(name);
|
ConnectorHandler handler = entry.getValue();
|
||||||
MConnector newConnector = handler.getConnectorConfigurable();
|
MConnector newConnector = handler.getConnectorConfigurable();
|
||||||
MConnector registeredConnector = repository.registerConnector(newConnector, autoUpgrade);
|
MConnector registeredConnector = repository.registerConnector(newConnector, autoUpgrade);
|
||||||
// Set the registered connector in the database to the connector configurable instance
|
// Set the registered connector in the database to the connector configurable instance
|
||||||
|
@ -159,7 +159,7 @@ private synchronized boolean isShutdown() {
|
|||||||
private synchronized void loadSleepTime() {
|
private synchronized void loadSleepTime() {
|
||||||
try {
|
try {
|
||||||
String value = configuration.get(PROPERTIES_PROVIDER_SLEEP);
|
String value = configuration.get(PROPERTIES_PROVIDER_SLEEP);
|
||||||
sleepTime = Long.valueOf(value);
|
sleepTime = Long.parseLong(value);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
LOG.debug("Can't load sleeping period from configuration file,"
|
LOG.debug("Can't load sleeping period from configuration file,"
|
||||||
+ " using default value " + DEFAULT_SLEEP_TIME, e);
|
+ " using default value " + DEFAULT_SLEEP_TIME, e);
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.apache.sqoop.audit.AuditLoggerManager;
|
import org.apache.sqoop.audit.AuditLoggerManager;
|
||||||
|
import org.apache.sqoop.common.SqoopException;
|
||||||
import org.apache.sqoop.connector.ConnectorManager;
|
import org.apache.sqoop.connector.ConnectorManager;
|
||||||
import org.apache.sqoop.driver.Driver;
|
import org.apache.sqoop.driver.Driver;
|
||||||
import org.apache.sqoop.driver.JobManager;
|
import org.apache.sqoop.driver.JobManager;
|
||||||
@ -58,9 +59,9 @@ public static void initialize() {
|
|||||||
Driver.getInstance().initialize();
|
Driver.getInstance().initialize();
|
||||||
JobManager.getInstance().initialize();
|
JobManager.getInstance().initialize();
|
||||||
LOG.info("Sqoop server has successfully boot up");
|
LOG.info("Sqoop server has successfully boot up");
|
||||||
} catch (Exception ex) {
|
} catch (RuntimeException | ClassNotFoundException | IllegalAccessException | InstantiationException e) {
|
||||||
LOG.error("Server startup failure", ex);
|
LOG.error("Server startup failure", e);
|
||||||
throw new RuntimeException("Failure in server initialization", ex);
|
throw new RuntimeException("Failure in server initialization", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ public MSubmission start(long jobId, HttpEventContext ctx) {
|
|||||||
prepareJob(jobRequest);
|
prepareJob(jobRequest);
|
||||||
// Make sure that this job id is not currently running and submit the job
|
// Make sure that this job id is not currently running and submit the job
|
||||||
// only if it's not.
|
// only if it's not.
|
||||||
synchronized (getClass()) {
|
synchronized (JobManager.class) {
|
||||||
MSubmission lastSubmission = RepositoryManager.getInstance().getRepository()
|
MSubmission lastSubmission = RepositoryManager.getInstance().getRepository()
|
||||||
.findLastSubmissionForJob(jobId);
|
.findLastSubmissionForJob(jobId);
|
||||||
if (lastSubmission != null && lastSubmission.getStatus().isRunning()) {
|
if (lastSubmission != null && lastSubmission.getStatus().isRunning()) {
|
||||||
@ -561,8 +561,8 @@ void invokeDestroyerOnJobSuccess(MSubmission submission) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RepositoryManager.getInstance().getRepository().updateJob(job);
|
RepositoryManager.getInstance().getRepository().updateJob(job);
|
||||||
} catch(Exception ex) {
|
} catch (RuntimeException e) {
|
||||||
LOG.error("Exception when invoking destroyer on job success", ex);
|
LOG.error("RuntimeException when invoking destroyer on job success", e);
|
||||||
submission.setStatus(SubmissionStatus.FAILED);
|
submission.setStatus(SubmissionStatus.FAILED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -729,7 +729,7 @@ public Object doIt(Connection conn) {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void updateJobConfig(final long jobId, final MConfig config, final MConfigUpdateEntityType type) {
|
public void updateJobConfig(final long jobId, final MConfig config, final MConfigUpdateEntityType type) {
|
||||||
updateJobConfig(jobId, config, null);
|
updateJobConfig(jobId, config, type, null);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package org.apache.sqoop.repository;
|
package org.apache.sqoop.repository;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public enum JdbcTransactionIsolation {
|
public enum JdbcTransactionIsolation {
|
||||||
|
|
||||||
@ -50,6 +51,6 @@ public static JdbcTransactionIsolation getByName(String name) {
|
|||||||
if (name == null || name.trim().length() == 0) {
|
if (name == null || name.trim().length() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return valueOf(name.trim().toUpperCase());
|
return valueOf(name.trim().toUpperCase(Locale.getDefault()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -459,11 +459,15 @@ public abstract class Repository {
|
|||||||
protected abstract void deleteLinkInputs(long linkId, RepositoryTransaction tx);
|
protected abstract void deleteLinkInputs(long linkId, RepositoryTransaction tx);
|
||||||
|
|
||||||
private void deletelinksAndJobInputs(List<MLink> links, List<MJob> jobs, RepositoryTransaction tx) {
|
private void deletelinksAndJobInputs(List<MLink> links, List<MJob> jobs, RepositoryTransaction tx) {
|
||||||
for (MJob job : jobs) {
|
if (jobs != null) {
|
||||||
deleteJobInputs(job.getPersistenceId(), tx);
|
for (MJob job : jobs) {
|
||||||
|
deleteJobInputs(job.getPersistenceId(), tx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (MLink link : links) {
|
if (links != null) {
|
||||||
deleteLinkInputs(link.getPersistenceId(), tx);
|
for (MLink link : links) {
|
||||||
|
deleteLinkInputs(link.getPersistenceId(), tx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user