mirror of
https://github.com/apache/sqoop.git
synced 2025-05-07 05:30:22 +08:00
SQOOP-2556: Sqoop2: Declare default constructor private for singleton classes
(Dian Fu via Jarek Jarcec Cecho)
This commit is contained in:
parent
933839f0f7
commit
a0cf47053b
@ -63,7 +63,7 @@ public static AuditLoggerManager getInstance() {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuditLoggerManager() {
|
private AuditLoggerManager() {
|
||||||
loggers = new ArrayList<AuditLogger>();
|
loggers = new ArrayList<AuditLogger>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,10 +122,11 @@ private void initializeLoggers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void destroy() {
|
public synchronized void destroy() {
|
||||||
|
loggers = null;
|
||||||
LOG.trace("Begin audit logger manager destroy");
|
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) {
|
String ip, String operation, String objectType, String objectId) {
|
||||||
for (AuditLogger logger : loggers) {
|
for (AuditLogger logger : loggers) {
|
||||||
logger.logAuditEvent(username, ip, operation, objectType, objectId);
|
logger.logAuditEvent(username, ip, operation, objectType, objectId);
|
||||||
@ -133,7 +134,7 @@ public void logAuditEvent(String username,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configurationChanged() {
|
public synchronized void configurationChanged() {
|
||||||
LOG.info("Begin audit logger manager reconfiguring");
|
LOG.info("Begin audit logger manager reconfiguring");
|
||||||
initializeLoggers();
|
initializeLoggers();
|
||||||
LOG.info("Audit logger manager reconfigured");
|
LOG.info("Audit logger manager reconfigured");
|
||||||
|
@ -41,22 +41,10 @@ public class FileAuditLogger extends AuditLogger {
|
|||||||
*/
|
*/
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
|
|
||||||
/**
|
public FileAuditLogger() {}
|
||||||
* Configurations for this audit logger
|
|
||||||
*/
|
|
||||||
private Map<String, String> config;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Properties to setup logger
|
|
||||||
*/
|
|
||||||
private Properties props;
|
|
||||||
|
|
||||||
public FileAuditLogger() {
|
|
||||||
this.props = new Properties();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
config = getLoggerConfig();
|
Map<String, String> config = getLoggerConfig();
|
||||||
|
|
||||||
String outputFile = config.get(FILE);
|
String outputFile = config.get(FILE);
|
||||||
if (outputFile == null) {
|
if (outputFile == null) {
|
||||||
@ -66,6 +54,7 @@ public void initialize() {
|
|||||||
// setup logger
|
// setup logger
|
||||||
String appender = "log4j.appender." + getLoggerName() + APPENDER_SURFIX;
|
String appender = "log4j.appender." + getLoggerName() + APPENDER_SURFIX;
|
||||||
LOG.warn("appender: " + appender);
|
LOG.warn("appender: " + appender);
|
||||||
|
Properties props = new Properties();
|
||||||
props.put(appender, "org.apache.log4j.RollingFileAppender");
|
props.put(appender, "org.apache.log4j.RollingFileAppender");
|
||||||
props.put(appender + ".File", outputFile);
|
props.put(appender + ".File", outputFile);
|
||||||
props.put(appender + ".layout", "org.apache.log4j.PatternLayout");
|
props.put(appender + ".layout", "org.apache.log4j.PatternLayout");
|
||||||
|
@ -67,6 +67,11 @@ public class ConnectorManager implements Reconfigurable {
|
|||||||
instance = new ConnectorManager();
|
instance = new ConnectorManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The private constructor for the singleton class.
|
||||||
|
*/
|
||||||
|
private ConnectorManager() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return current instance.
|
* Return current instance.
|
||||||
*
|
*
|
||||||
|
@ -68,6 +68,11 @@ public class SqoopConfiguration implements Reconfigurable {
|
|||||||
instance = new SqoopConfiguration();
|
instance = new SqoopConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The private constructor for the singleton class.
|
||||||
|
*/
|
||||||
|
private SqoopConfiguration() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return current instance.
|
* Return current instance.
|
||||||
*
|
*
|
||||||
|
@ -110,7 +110,7 @@ public Class getDriverJobConfigurationClass() {
|
|||||||
return JobConfiguration.class;
|
return JobConfiguration.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Driver() {
|
private Driver() {
|
||||||
List<MConfig> driverConfig = ConfigUtils.toConfigs(getDriverJobConfigurationClass());
|
List<MConfig> driverConfig = ConfigUtils.toConfigs(getDriverJobConfigurationClass());
|
||||||
mDriver = new MDriver(new MDriverConfig(driverConfig), DriverBean.CURRENT_DRIVER_VERSION);
|
mDriver = new MDriver(new MDriverConfig(driverConfig), DriverBean.CURRENT_DRIVER_VERSION);
|
||||||
|
|
||||||
|
@ -72,6 +72,11 @@ public class JobManager implements Reconfigurable {
|
|||||||
instance = new JobManager();
|
instance = new JobManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The private constructor for the singleton class.
|
||||||
|
*/
|
||||||
|
private JobManager() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return current instance.
|
* Return current instance.
|
||||||
*
|
*
|
||||||
|
@ -48,6 +48,11 @@ public class RepositoryManager implements Reconfigurable {
|
|||||||
instance = new RepositoryManager();
|
instance = new RepositoryManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The private constructor for the singleton class.
|
||||||
|
*/
|
||||||
|
private RepositoryManager() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return current instance.
|
* Return current instance.
|
||||||
*
|
*
|
||||||
|
@ -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(){}
|
private AuthenticationManager(){}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public class TestJobManager {
|
|||||||
|
|
||||||
@BeforeMethod(alwaysRun = true)
|
@BeforeMethod(alwaysRun = true)
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
jobManager = new JobManager();
|
jobManager = JobManager.getInstance();
|
||||||
connectorMgrMock = mock(ConnectorManager.class);
|
connectorMgrMock = mock(ConnectorManager.class);
|
||||||
sqoopConnectorMock = mock(SqoopConnector.class);
|
sqoopConnectorMock = mock(SqoopConnector.class);
|
||||||
ConnectorManager.setInstance(connectorMgrMock);
|
ConnectorManager.setInstance(connectorMgrMock);
|
||||||
|
Loading…
Reference in New Issue
Block a user