5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-06 19:49:08 +08:00

SQOOP-2556: Sqoop2: Declare default constructor private for singleton classes

(Dian Fu via Jarek Jarcec Cecho)
This commit is contained in:
Jarek Jarcec Cecho 2015-09-08 12:54:46 +02:00
parent 933839f0f7
commit a0cf47053b
9 changed files with 30 additions and 20 deletions

View File

@ -63,7 +63,7 @@ public static AuditLoggerManager getInstance() {
return instance;
}
public AuditLoggerManager() {
private AuditLoggerManager() {
loggers = new ArrayList<AuditLogger>();
}
@ -122,10 +122,11 @@ private void initializeLoggers() {
}
public synchronized void destroy() {
loggers = null;
LOG.trace("Begin audit logger manager destroy");
}
public void logAuditEvent(String username,
public synchronized void logAuditEvent(String username,
String ip, String operation, String objectType, String objectId) {
for (AuditLogger logger : loggers) {
logger.logAuditEvent(username, ip, operation, objectType, objectId);
@ -133,7 +134,7 @@ public void logAuditEvent(String username,
}
@Override
public void configurationChanged() {
public synchronized void configurationChanged() {
LOG.info("Begin audit logger manager reconfiguring");
initializeLoggers();
LOG.info("Audit logger manager reconfigured");

View File

@ -41,22 +41,10 @@ public class FileAuditLogger extends AuditLogger {
*/
private Logger logger;
/**
* Configurations for this audit logger
*/
private Map<String, String> config;
/**
* Properties to setup logger
*/
private Properties props;
public FileAuditLogger() {
this.props = new Properties();
}
public FileAuditLogger() {}
public void initialize() {
config = getLoggerConfig();
Map<String, String> config = getLoggerConfig();
String outputFile = config.get(FILE);
if (outputFile == null) {
@ -66,6 +54,7 @@ public void initialize() {
// setup logger
String appender = "log4j.appender." + getLoggerName() + APPENDER_SURFIX;
LOG.warn("appender: " + appender);
Properties props = new Properties();
props.put(appender, "org.apache.log4j.RollingFileAppender");
props.put(appender + ".File", outputFile);
props.put(appender + ".layout", "org.apache.log4j.PatternLayout");

View File

@ -67,6 +67,11 @@ public class ConnectorManager implements Reconfigurable {
instance = new ConnectorManager();
}
/**
* The private constructor for the singleton class.
*/
private ConnectorManager() {}
/**
* Return current instance.
*

View File

@ -68,6 +68,11 @@ public class SqoopConfiguration implements Reconfigurable {
instance = new SqoopConfiguration();
}
/**
* The private constructor for the singleton class.
*/
private SqoopConfiguration() {}
/**
* Return current instance.
*

View File

@ -110,7 +110,7 @@ public Class getDriverJobConfigurationClass() {
return JobConfiguration.class;
}
public Driver() {
private Driver() {
List<MConfig> driverConfig = ConfigUtils.toConfigs(getDriverJobConfigurationClass());
mDriver = new MDriver(new MDriverConfig(driverConfig), DriverBean.CURRENT_DRIVER_VERSION);

View File

@ -72,6 +72,11 @@ public class JobManager implements Reconfigurable {
instance = new JobManager();
}
/**
* The private constructor for the singleton class.
*/
private JobManager() {}
/**
* Return current instance.
*

View File

@ -48,6 +48,11 @@ public class RepositoryManager implements Reconfigurable {
instance = new RepositoryManager();
}
/**
* The private constructor for the singleton class.
*/
private RepositoryManager() {}
/**
* Return current instance.
*

View File

@ -46,7 +46,7 @@ public class AuthenticationManager implements Reconfigurable {
}
/**
* The private constructor for the singleton class,
* The private constructor for the singleton class.
*/
private AuthenticationManager(){}

View File

@ -51,7 +51,7 @@ public class TestJobManager {
@BeforeMethod(alwaysRun = true)
public void setUp() {
jobManager = new JobManager();
jobManager = JobManager.getInstance();
connectorMgrMock = mock(ConnectorManager.class);
sqoopConnectorMock = mock(SqoopConnector.class);
ConnectorManager.setInstance(connectorMgrMock);