Author: shawkins
Date: 2009-04-03 15:47:52 -0400 (Fri, 03 Apr 2009)
New Revision: 704
Modified:
trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java
trunk/server/src/main/java/com/metamatrix/platform/registry/ClusteredRegistryState.java
trunk/server/src/main/java/com/metamatrix/platform/registry/RegistryListener.java
trunk/server/src/main/java/com/metamatrix/platform/service/proxy/ProxyManager.java
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java
trunk/server/src/main/java/com/metamatrix/server/HostController.java
Log:
TEIID-459 fixing misc shutdown issues.
Modified:
trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java 2009-04-03
19:43:55 UTC (rev 703)
+++
trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java 2009-04-03
19:47:52 UTC (rev 704)
@@ -117,8 +117,6 @@
protected void closeService() throws Exception {
String instanceName = this.getInstanceName().toString();
LogManager.logDetail(CONTEXT, instanceName + ": closing");
//$NON-NLS-1$
-// this.serviceIsClosed = true;
- I18nLogManager.logInfo(CONTEXT, LogMessageKeys.CONFIG_0003, new Object[]{
instanceName});
}
/**
Modified:
trunk/server/src/main/java/com/metamatrix/platform/registry/ClusteredRegistryState.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/registry/ClusteredRegistryState.java 2009-04-03
19:43:55 UTC (rev 703)
+++
trunk/server/src/main/java/com/metamatrix/platform/registry/ClusteredRegistryState.java 2009-04-03
19:47:52 UTC (rev 704)
@@ -24,8 +24,9 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -46,7 +47,7 @@
private static final String NAME = "Name"; //$NON-NLS-1$
Cache cache;
- private List<RegistryListener> listeners = Collections.synchronizedList(new
ArrayList<RegistryListener>());
+ private Queue<RegistryListener> listeners = new
ConcurrentLinkedQueue<RegistryListener>();
@Inject
public ClusteredRegistryState(CacheFactory cacheFactory) {
@@ -320,6 +321,9 @@
public void shutdown() {
this.cache.removeListener();
+ for(RegistryListener l:this.listeners) {
+ l.registryShutdown();
+ }
this.listeners.clear();
}
}
Modified:
trunk/server/src/main/java/com/metamatrix/platform/registry/RegistryListener.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/registry/RegistryListener.java 2009-04-03
19:43:55 UTC (rev 703)
+++
trunk/server/src/main/java/com/metamatrix/platform/registry/RegistryListener.java 2009-04-03
19:47:52 UTC (rev 704)
@@ -24,4 +24,5 @@
public interface RegistryListener {
void registryChanged();
+ void registryShutdown();
}
Modified:
trunk/server/src/main/java/com/metamatrix/platform/service/proxy/ProxyManager.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/service/proxy/ProxyManager.java 2009-04-03
19:43:55 UTC (rev 703)
+++
trunk/server/src/main/java/com/metamatrix/platform/service/proxy/ProxyManager.java 2009-04-03
19:47:52 UTC (rev 704)
@@ -36,6 +36,7 @@
import com.metamatrix.common.queue.WorkerPoolFactory;
import com.metamatrix.platform.registry.ClusteredRegistryState;
import com.metamatrix.platform.registry.RegistryListener;
+import com.metamatrix.platform.registry.ServiceRegistryBinding;
import com.metamatrix.platform.service.ServiceMessages;
import com.metamatrix.platform.service.ServicePlugin;
import com.metamatrix.platform.service.api.ServiceInterface;
@@ -49,7 +50,7 @@
public class ProxyManager implements RegistryListener{
// Map of all SelectionPolicies.
- private Map<ServiceSelectionPolicyKey, ServiceSelectionPolicy> policyRegistry =
new HashMap();
+ private Map<ServiceSelectionPolicyKey, ServiceSelectionPolicy> policyRegistry =
new HashMap<ServiceSelectionPolicyKey, ServiceSelectionPolicy>();
/**
* Thread that updates the service instances of the service selection policies
@@ -71,7 +72,12 @@
this.registry.addListener(this);
}
+ @Override
+ public void registryShutdown() {
+ this.updatePool.shutdownNow();
+ }
+ @Override
public void registryChanged() {
updatePool.execute(new Runnable() {public void run() { doUpdate(); } });
}
@@ -214,8 +220,8 @@
* @param serviceType The type of the service of interest.
*/
private void setServiceInstances(ServiceSelectionPolicy policy, String serviceType)
{
- List localServiceBindings = this.registry.getActiveServiceBindings(this.hostName,
this.processName, serviceType);
- List serviceBindings = this.registry.getActiveServiceBindings(null, null,
serviceType);
+ List<ServiceRegistryBinding> localServiceBindings =
this.registry.getActiveServiceBindings(this.hostName, this.processName, serviceType);
+ List<ServiceRegistryBinding> serviceBindings =
this.registry.getActiveServiceBindings(null, null, serviceType);
serviceBindings.removeAll(localServiceBindings);
policy.updateServices(localServiceBindings, serviceBindings);
}
Modified:
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java 2009-04-03
19:43:55 UTC (rev 703)
+++
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java 2009-04-03
19:47:52 UTC (rev 704)
@@ -31,6 +31,7 @@
import java.util.EventObject;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -201,8 +202,6 @@
this.registerSubSystemAdminAPIs(hostManagement);
manageCommonExtensionClassloader();
-
- addShutdownHook();
}
@@ -245,18 +244,6 @@
private void registerILogonAPI() throws ConfigurationException, ServiceException {
this.clientServices.registerClientService(ILogon.class, new
LogonImpl(PlatformProxyHelper.getSessionServiceProxy(PlatformProxyHelper.ROUND_ROBIN_LOCAL),
CurrentConfiguration.getInstance().getClusterName()), LogCommonConstants.CTX_LOGON);
}
-
- private void addShutdownHook() {
- Runtime.getRuntime().addShutdownHook(new Thread() {
- public void run() {
- try {
- shutdown(false);
- } catch (Exception e) {
- // ignore
- }
- }
- });
- }
/**
* Lazily get Current Configuration
@@ -796,25 +783,25 @@
*/
private void stopServices(boolean now, boolean shutdown) throws MultipleException {
- MultipleException multipleException = new MultipleException();
-
List<ServiceRegistryBinding> bindings =
this.registry.getServiceBindings(host.getFullName(), this.processName);
+ List<ServiceException> exceptions = new
LinkedList<ServiceException>();
+
for (ServiceRegistryBinding binding:bindings) {
try {
stopService(binding, now, shutdown);
} catch (ServiceException se) {
- multipleException.getExceptions().add(se);
+ exceptions.add(se);
}
}
- int numExceptions = multipleException.getExceptions().size();
+ int numExceptions = exceptions.size();
if (numExceptions == 1) {
//if there is one ServiceException, throw it
- throw (ServiceException) multipleException.getExceptions().get(0);
+ throw exceptions.get(0);
} else if (numExceptions > 1) {
//if there are many, throw the MultipleException containing all of them
- throw multipleException;
+ throw new MultipleException(exceptions, "Multiple errors stopping
services"); //$NON-NLS-1$
}
}
Modified: trunk/server/src/main/java/com/metamatrix/server/HostController.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/HostController.java 2009-04-03
19:43:55 UTC (rev 703)
+++ trunk/server/src/main/java/com/metamatrix/server/HostController.java 2009-04-03
19:47:52 UTC (rev 704)
@@ -118,6 +118,7 @@
}
}
};
+ monitorThread.setDaemon(true);
monitorThread.start();
}