Author: shawkins
Date: 2009-04-04 13:12:45 -0400 (Sat, 04 Apr 2009)
New Revision: 716
Added:
trunk/client/src/test/java/com/metamatrix/common/comm/platform/client/
trunk/client/src/test/java/com/metamatrix/common/comm/platform/client/TestSeverAdminFactory.java
Removed:
trunk/common-core/src/main/java/com/metamatrix/api/exception/ComponentCommunicationException.java
Modified:
trunk/client/src/main/java/com/metamatrix/common/comm/platform/client/ServerAdminFactory.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/AbstractVDBDeleteUtility.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ConfigurationAdminAPIImpl.java
Log:
TEIID-463 fixing the bounce wait logic.
Modified:
trunk/client/src/main/java/com/metamatrix/common/comm/platform/client/ServerAdminFactory.java
===================================================================
---
trunk/client/src/main/java/com/metamatrix/common/comm/platform/client/ServerAdminFactory.java 2009-04-04
16:42:31 UTC (rev 715)
+++
trunk/client/src/main/java/com/metamatrix/common/comm/platform/client/ServerAdminFactory.java 2009-04-04
17:12:45 UTC (rev 716)
@@ -33,11 +33,13 @@
import com.metamatrix.admin.api.exception.AdminException;
import com.metamatrix.admin.api.server.ServerAdmin;
import com.metamatrix.api.exception.security.LogonException;
+import com.metamatrix.client.ExceptionUtil;
import com.metamatrix.common.api.MMURL;
+import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.common.comm.api.ServerConnectionFactory;
import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.comm.exception.ConnectionException;
import com.metamatrix.common.comm.platform.CommPlatformPlugin;
-import com.metamatrix.common.comm.platform.socket.client.SocketServerConnection;
import com.metamatrix.common.comm.platform.socket.client.SocketServerConnectionFactory;
import com.metamatrix.common.util.MetaMatrixProductNames;
import com.metamatrix.common.util.PropertiesUtils;
@@ -49,12 +51,12 @@
*/
public class ServerAdminFactory {
- private static final int BOUNCE_WAIT = 2000;
+ private static final int DEFAULT_BOUNCE_WAIT = 2000;
- private final static class ReconnectingProxy implements InvocationHandler {
+ private final class ReconnectingProxy implements InvocationHandler {
private ServerAdmin target;
- private SocketServerConnection registry;
+ private ServerConnection registry;
private Properties p;
private boolean closed;
@@ -70,7 +72,7 @@
return target;
}
try {
- registry = SocketServerConnectionFactory.getInstance().createConnection(p);
+ registry = serverConnectionFactory.createConnection(p);
} catch (ConnectionException e) {
throw new AdminComponentException(e.getMessage());
}
@@ -90,15 +92,15 @@
try {
return method.invoke(getTarget(), args);
} catch (InvocationTargetException e) {
+ if (method.getName().endsWith("bounceSystem") &&
ExceptionUtil.getExceptionOfType(e, CommunicationException.class) != null) {
//$NON-NLS-1$
+ bounceSystem(((Boolean)args[0]).booleanValue());
+ return null;
+ }
throw e.getTargetException();
} catch (CommunicationException e) {
t = e;
}
}
- if (method.getName().endsWith("bounceSystem")) { //$NON-NLS-1$
- bounceSystem(((Boolean)args[1]).booleanValue());
- return null;
- }
throw t;
}
@@ -113,38 +115,43 @@
}
public void bounceSystem(boolean waitUntilDone) {
- if (waitUntilDone) {
- //we'll wait 2 seconds for the server to go down
- try {
- Thread.sleep(BOUNCE_WAIT);
- } catch (InterruptedException e) {
- throw new MetaMatrixRuntimeException(e);
- }
- //we'll wait 30 seconds for the server to come back up
- for (int i = 0; i < 15; i++) {
- try {
- getTarget().getSystem();
- } catch (Exception e) {
-
- } finally {
- //reestablish a connection and retry
- try {
- Thread.sleep(BOUNCE_WAIT);
- } catch (InterruptedException e) {
- throw new MetaMatrixRuntimeException(e);
- }
- }
- }
+ if (!waitUntilDone) {
+ return;
}
+ //we'll wait 2 seconds for the server to come up
+ try {
+ Thread.sleep(bounceWait);
+ } catch (InterruptedException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ //we'll wait 30 seconds for the server to come back up
+ for (int i = 0; i < 15; i++) {
+ try {
+ getTarget().getSystem();
+ return;
+ } catch (Exception e) {
+ //reestablish a connection and retry
+ try {
+ Thread.sleep(bounceWait);
+ } catch (InterruptedException ex) {
+ throw new MetaMatrixRuntimeException(ex);
+ }
+ }
+ }
}
}
public static final String DEFAULT_APPLICATION_NAME = "Admin"; //$NON-NLS-1$
/**Singleton instance*/
- private static ServerAdminFactory instance = new ServerAdminFactory();
+ private static ServerAdminFactory instance = new
ServerAdminFactory(SocketServerConnectionFactory.getInstance(), DEFAULT_BOUNCE_WAIT);
- private ServerAdminFactory() {
+ private ServerConnectionFactory serverConnectionFactory;
+ private int bounceWait;
+
+ ServerAdminFactory(ServerConnectionFactory connFactory, int bounceWait) {
+ this.serverConnectionFactory = connFactory;
+ this.bounceWait = bounceWait;
}
/**Get the singleton instance*/
Added:
trunk/client/src/test/java/com/metamatrix/common/comm/platform/client/TestSeverAdminFactory.java
===================================================================
---
trunk/client/src/test/java/com/metamatrix/common/comm/platform/client/TestSeverAdminFactory.java
(rev 0)
+++
trunk/client/src/test/java/com/metamatrix/common/comm/platform/client/TestSeverAdminFactory.java 2009-04-04
17:12:45 UTC (rev 716)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.comm.platform.client;
+
+import java.util.Properties;
+
+import org.junit.Test;
+import static org.mockito.Mockito.*;
+
+import com.metamatrix.admin.api.exception.AdminComponentException;
+import com.metamatrix.admin.api.server.ServerAdmin;
+import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.common.comm.api.ServerConnectionFactory;
+import com.metamatrix.common.comm.exception.SingleInstanceCommunicationException;
+
+public class TestSeverAdminFactory {
+
+ @Test public void testBounce() throws Exception {
+ ServerConnectionFactory scf = mock(ServerConnectionFactory.class);
+ ServerConnection sc = mock(ServerConnection.class);
+ ServerAdmin sa = mock(ServerAdmin.class);
+ stubVoid(sa).toThrow(new AdminComponentException(new
SingleInstanceCommunicationException())).on().bounceSystem(true);
+ stub(sc.getService(ServerAdmin.class)).toReturn(sa);
+ stub(scf.createConnection((Properties)anyObject())).toReturn(sc);
+
+ ServerAdminFactory saf = new ServerAdminFactory(scf, 1);
+ ServerAdmin admin = saf.createAdmin("foo", "bar".toCharArray(),
"mm://test:1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ admin.bounceSystem(true);
+
+ //verify that the actual bounce was called
+ verify(sa, times(1)).bounceSystem(true);
+
+ //here's the test we issue to see that the system is up after the bounce
+ verify(sa, times(1)).getSystem();
+ }
+
+}
Property changes on:
trunk/client/src/test/java/com/metamatrix/common/comm/platform/client/TestSeverAdminFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/common-core/src/main/java/com/metamatrix/api/exception/ComponentCommunicationException.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/api/exception/ComponentCommunicationException.java 2009-04-04
16:42:31 UTC (rev 715)
+++
trunk/common-core/src/main/java/com/metamatrix/api/exception/ComponentCommunicationException.java 2009-04-04
17:12:45 UTC (rev 716)
@@ -1,80 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.api.exception;
-
-/**
- * Exception which occurs if there is a communication failure between
- * components - like socket failure, or JMS message failure.
- */
-public class ComponentCommunicationException extends MetaMatrixComponentException {
-
- /**
- * No-Arg Constructor
- */
- public ComponentCommunicationException( ) {
- super( );
- }
-
- /**
- * Construct an instance with the message specified.
- *
- * @param message A message describing the exception
- */
- public ComponentCommunicationException( String message ) {
- super( message );
- }
-
- /**
- * Construct an instance with the message and error code specified.
- *
- * @param message A message describing the exception
- * @param code The error code
- */
- public ComponentCommunicationException( String code, String message ) {
- super( code, message );
- }
-
- /**
- * Construct an instance from a message and an exception to chain to this one.
- *
- * @param e An exception to nest within this one
- * @param message A message describing the exception
- */
- public ComponentCommunicationException( Throwable e, String message ) {
- super( e, message );
- }
-
- /**
- * Construct an instance from a message and a code and an exception to
- * chain to this one.
- *
- * @param e An exception to nest within this one
- * @param message A message describing the exception
- * @param code A code denoting the exception
- */
- public ComponentCommunicationException( Throwable e, String code, String message ) {
- super( e, code, message );
- }
-
-} // END CLASS
-
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/AbstractVDBDeleteUtility.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/AbstractVDBDeleteUtility.java 2009-04-04
16:42:31 UTC (rev 715)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/AbstractVDBDeleteUtility.java 2009-04-04
17:12:45 UTC (rev 716)
@@ -26,7 +26,7 @@
import java.util.Collections;
import java.util.Iterator;
-import com.metamatrix.api.exception.ComponentCommunicationException;
+import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.api.exception.security.SessionServiceException;
@@ -131,9 +131,9 @@
try {
sessionIDs = getSessionServiceProxy().getSessionsLoggedInToVDB(VDBName,
VDBVersion);
} catch (SessionServiceException e) {
- throw new ComponentCommunicationException(e, ErrorMessageKeys.VDBDU_0003,
RuntimeMetadataPlugin.Util.getString(ErrorMessageKeys.VDBDU_0003));
+ throw new MetaMatrixComponentException(e, ErrorMessageKeys.VDBDU_0003,
RuntimeMetadataPlugin.Util.getString(ErrorMessageKeys.VDBDU_0003));
} catch (ServiceException e) {
- throw new ComponentCommunicationException(e, ErrorMessageKeys.VDBDU_0003,
RuntimeMetadataPlugin.Util.getString(ErrorMessageKeys.VDBDU_0003));
+ throw new ComponentNotFoundException(e, ErrorMessageKeys.VDBDU_0003,
RuntimeMetadataPlugin.Util.getString(ErrorMessageKeys.VDBDU_0003));
}
return sessionIDs;
}
Modified:
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ConfigurationAdminAPIImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ConfigurationAdminAPIImpl.java 2009-04-04
16:42:31 UTC (rev 715)
+++
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ConfigurationAdminAPIImpl.java 2009-04-04
17:12:45 UTC (rev 716)
@@ -29,7 +29,6 @@
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.admin.api.server.AdminRoles;
-import com.metamatrix.api.exception.ComponentCommunicationException;
import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.security.AuthorizationException;
@@ -499,7 +498,7 @@
} catch (ServiceException e) {
throw new ComponentNotFoundException(e,
PlatformPlugin.Util.getString("ConfigurationAdminAPIImpl.Problem_getting_Product_Release_Infos",
e.getMessage())); //$NON-NLS-1$
} catch (ConfigurationException e) {
- throw new ComponentCommunicationException(e,
PlatformPlugin.Util.getString("ConfigurationAdminAPIImpl.Problem_getting_Product_Release_Infos",
e.getMessage())); //$NON-NLS-1$
+ throw new MetaMatrixComponentException(e,
PlatformPlugin.Util.getString("ConfigurationAdminAPIImpl.Problem_getting_Product_Release_Infos",
e.getMessage())); //$NON-NLS-1$
}
return result;
}