mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 9651: network tagging changes working now
This commit is contained in:
parent
0ab12edd6c
commit
7c74c3a51d
@ -90,6 +90,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
||||
protected static Callback[] s_callbacks = new Callback[] { NoOp.INSTANCE, new DatabaseCallback()};
|
||||
protected static CallbackFilter s_callbackFilter = new DatabaseCallbackFilter();
|
||||
protected static final List<AnnotationInterceptor<?>> s_interceptors = new ArrayList<AnnotationInterceptor<?>>();
|
||||
protected static CleanupThread s_janitor = null;
|
||||
|
||||
protected HashMap<String, Adapters<? extends Adapter>> _adapterMap;
|
||||
protected HashMap<String, ComponentInfo<Manager>> _managerMap;
|
||||
@ -99,12 +100,18 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
||||
protected HashMap<Class<?>, Class<?>> _factories;
|
||||
|
||||
static {
|
||||
Runtime.getRuntime().addShutdownHook(new CleanupThread());
|
||||
if (s_janitor == null) {
|
||||
s_janitor = new CleanupThread();
|
||||
Runtime.getRuntime().addShutdownHook(new CleanupThread());
|
||||
}
|
||||
}
|
||||
|
||||
public ComponentLocator(String server) {
|
||||
_serverName = server;
|
||||
Runtime.getRuntime().addShutdownHook(new CleanupThread());
|
||||
if (s_janitor == null) {
|
||||
s_janitor = new CleanupThread();
|
||||
Runtime.getRuntime().addShutdownHook(new CleanupThread());
|
||||
}
|
||||
}
|
||||
|
||||
public String getLocatorName() {
|
||||
@ -237,7 +244,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
||||
if (singleton.state == Singleton.State.Instantiated) {
|
||||
inject(info.clazz, info.instance);
|
||||
singleton.state = Singleton.State.Injected;
|
||||
}
|
||||
}
|
||||
if (singleton.state == Singleton.State.Injected) {
|
||||
if (!info.instance.configure(info.name, info.params)) {
|
||||
s_logger.error("Unable to configure DAO: " + info.name);
|
||||
@ -398,7 +405,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
||||
System.exit(1);
|
||||
}
|
||||
s.state = Singleton.State.Configured;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
s_logger.info("Configuring Manager: " + info.name);
|
||||
try {
|
||||
@ -526,7 +533,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
||||
s_logger.info("Injecting singleton Adapter: " + info.getName());
|
||||
inject(info.clazz, info.instance);
|
||||
singleton.state = Singleton.State.Injected;
|
||||
}
|
||||
}
|
||||
if (singleton.state == Singleton.State.Injected) {
|
||||
s_logger.info("Configuring singleton Adapter: " + info.getName());
|
||||
if (!info.instance.configure(info.name, info.params)) {
|
||||
@ -551,7 +558,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
||||
s_logger.error("Unable to configure adapter: " + info.name, e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1015,43 +1022,45 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
||||
|
||||
protected static class CleanupThread extends Thread {
|
||||
@Override
|
||||
public synchronized void run() {
|
||||
for (ComponentLocator locator : s_locators.values()) {
|
||||
Iterator<Adapters<? extends Adapter>> itAdapters = locator._adapterMap.values().iterator();
|
||||
while (itAdapters.hasNext()) {
|
||||
Adapters<? extends Adapter> adapters = itAdapters.next();
|
||||
itAdapters.remove();
|
||||
for (ComponentInfo<Adapter> adapter : adapters._infos) {
|
||||
if (adapter.singleton) {
|
||||
Singleton singleton = s_singletons.get(adapter.clazz);
|
||||
if (singleton.state == Singleton.State.Started) {
|
||||
public void run() {
|
||||
synchronized (CleanupThread.class) {
|
||||
for (ComponentLocator locator : s_locators.values()) {
|
||||
Iterator<Adapters<? extends Adapter>> itAdapters = locator._adapterMap.values().iterator();
|
||||
while (itAdapters.hasNext()) {
|
||||
Adapters<? extends Adapter> adapters = itAdapters.next();
|
||||
itAdapters.remove();
|
||||
for (ComponentInfo<Adapter> adapter : adapters._infos) {
|
||||
if (adapter.singleton) {
|
||||
Singleton singleton = s_singletons.get(adapter.clazz);
|
||||
if (singleton.state == Singleton.State.Started) {
|
||||
s_logger.info("Asking " + adapter.getName() + " to shutdown.");
|
||||
adapter.instance.stop();
|
||||
singleton.state = Singleton.State.Stopped;
|
||||
} else {
|
||||
s_logger.debug("Skippng " + adapter.getName() + " because it has already stopped");
|
||||
}
|
||||
} else {
|
||||
s_logger.info("Asking " + adapter.getName() + " to shutdown.");
|
||||
adapter.instance.stop();
|
||||
singleton.state = Singleton.State.Stopped;
|
||||
} else {
|
||||
s_logger.debug("Skippng " + adapter.getName() + " because it has already stopped");
|
||||
}
|
||||
} else {
|
||||
s_logger.info("Asking " + adapter.getName() + " to shutdown.");
|
||||
adapter.instance.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ComponentLocator locator : s_locators.values()) {
|
||||
Iterator<ComponentInfo<Manager>> itManagers = locator._managerMap.values().iterator();
|
||||
while (itManagers.hasNext()) {
|
||||
ComponentInfo<Manager> manager = itManagers.next();
|
||||
itManagers.remove();
|
||||
if (manager.singleton == true) {
|
||||
Singleton singleton = s_singletons.get(manager.clazz);
|
||||
if (singleton != null && singleton.state == Singleton.State.Started) {
|
||||
s_logger.info("Asking Manager " + manager.getName() + " to shutdown.");
|
||||
manager.instance.stop();
|
||||
singleton.state = Singleton.State.Stopped;
|
||||
} else {
|
||||
s_logger.info("Skipping Manager " + manager.getName() + " because it is not in a state to shutdown.");
|
||||
|
||||
for (ComponentLocator locator : s_locators.values()) {
|
||||
Iterator<ComponentInfo<Manager>> itManagers = locator._managerMap.values().iterator();
|
||||
while (itManagers.hasNext()) {
|
||||
ComponentInfo<Manager> manager = itManagers.next();
|
||||
itManagers.remove();
|
||||
if (manager.singleton == true) {
|
||||
Singleton singleton = s_singletons.get(manager.clazz);
|
||||
if (singleton != null && singleton.state == Singleton.State.Started) {
|
||||
s_logger.info("Asking Manager " + manager.getName() + " to shutdown.");
|
||||
manager.instance.stop();
|
||||
singleton.state = Singleton.State.Stopped;
|
||||
} else {
|
||||
s_logger.info("Skipping Manager " + manager.getName() + " because it is not in a state to shutdown.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1440,11 +1440,12 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
|
||||
EcInfo ec = (EcInfo)attr.attache;
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
ResultSet rs = null;
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(ec.selectSql);
|
||||
pstmt = txn.prepareStatement(ec.selectSql);
|
||||
pstmt.setObject(1, _idField.get(entity));
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
rs = pstmt.executeQuery();
|
||||
ArrayList lst = new ArrayList();
|
||||
if (ec.targetClass == Integer.class) {
|
||||
while (rs.next()) {
|
||||
@ -1501,6 +1502,17 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
|
||||
throw new CloudRuntimeException("Error executing " + pstmt, e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new CloudRuntimeException("Error executing " + pstmt, e);
|
||||
} finally {
|
||||
try {
|
||||
if (rs != null) {
|
||||
rs.close();
|
||||
}
|
||||
if (pstmt != null) {
|
||||
pstmt.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
s_logger.error("Why are we getting an exception at close? ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -109,7 +109,7 @@ public class Transaction {
|
||||
// Usage of this transaction setup should be limited, it will always open a new transaction context regardless of whether or not there is other
|
||||
// transaction context in the stack. It is used in special use cases that we want to control DB connection explicitly and in the mean time utilize
|
||||
// the existing DAO features
|
||||
//
|
||||
//
|
||||
public static Transaction openNew(final String name, Connection conn) {
|
||||
assert(conn != null);
|
||||
Transaction txn = new Transaction(name, false, CONNECTED_DB);
|
||||
@ -191,7 +191,7 @@ public class Transaction {
|
||||
s_logger.warn("Unexpected exception: ", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void attach(TransactionAttachment value) {
|
||||
_stack.push(new StackElement(ATTACHMENT, value));
|
||||
@ -452,7 +452,6 @@ public class Transaction {
|
||||
* @throws SQLException
|
||||
*/
|
||||
public Connection getConnection() throws SQLException {
|
||||
closePreviousStatement();
|
||||
if (_conn == null) {
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace("conn: Creating a DB connection with " + (_txn ? " txn: " : " no txn: ") + buildName());
|
||||
@ -653,8 +652,9 @@ public class Transaction {
|
||||
|
||||
try {
|
||||
s_logger.trace("conn: Closing DB connection");
|
||||
if(this._dbId != CONNECTED_DB)
|
||||
_conn.close();
|
||||
if(this._dbId != CONNECTED_DB) {
|
||||
_conn.close();
|
||||
}
|
||||
|
||||
_conn = null;
|
||||
} catch (final SQLException e) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user