Mercurial > hg > release > thermostat-0.5
changeset 819:c563aedf9710
Remove PONG and EXCEPTION from ResponseType
Reviewed-by: vanaltj
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-December/004379.html
line wrap: on
line diff
--- a/agent/command/src/main/java/com/redhat/thermostat/agent/command/internal/PingReceiver.java Tue Dec 04 20:14:25 2012 -0500 +++ b/agent/command/src/main/java/com/redhat/thermostat/agent/command/internal/PingReceiver.java Wed Dec 05 18:16:16 2012 -0500 @@ -45,7 +45,7 @@ @Override public Response receive(Request request) { - return new Response(ResponseType.PONG); + return new Response(ResponseType.OK); } }
--- a/agent/command/src/main/java/com/redhat/thermostat/agent/command/internal/ServerHandler.java Tue Dec 04 20:14:25 2012 -0500 +++ b/agent/command/src/main/java/com/redhat/thermostat/agent/command/internal/ServerHandler.java Wed Dec 05 18:16:16 2012 -0500 @@ -92,14 +92,4 @@ e.getChannel().close(); } - private Response doRequest(Request request) { - Response response = new Response(ResponseType.ERROR); - switch ((RequestType) request.getType()) { - case RESPONSE_EXPECTED: - response = new Response(ResponseType.PONG); - break; - default: - } - return response; - } }
--- a/agent/command/src/test/java/com/redhat/thermostat/agent/command/internal/ResponseEncoderTest.java Tue Dec 04 20:14:25 2012 -0500 +++ b/agent/command/src/test/java/com/redhat/thermostat/agent/command/internal/ResponseEncoderTest.java Wed Dec 05 18:16:16 2012 -0500 @@ -68,7 +68,7 @@ @Before public void setUp() { - Response r = new Response(ResponseType.PONG); + Response r = new Response(ResponseType.OK); e = mock(MessageEvent.class); when(e.getMessage()).thenReturn(r); when(e.getFuture()).thenReturn(null); @@ -89,10 +89,10 @@ ChannelBuffer buf = (ChannelBuffer) argument.getValue(); int messageLength = buf.readInt(); - assertEquals(4, messageLength); + assertEquals(2, messageLength); ByteBuffer bbuf = ByteBuffer.allocate(buf.readableBytes()); buf.readBytes(bbuf); String message = new String(bbuf.array()); - assertEquals("PONG", message); + assertEquals("OK", message); } }
--- a/agent/heapdumper/src/main/java/com/redhat/thermostat/agent/heapdumper/internal/HeapDumpReceiver.java Tue Dec 04 20:14:25 2012 -0500 +++ b/agent/heapdumper/src/main/java/com/redhat/thermostat/agent/heapdumper/internal/HeapDumpReceiver.java Wed Dec 05 18:16:16 2012 -0500 @@ -84,10 +84,10 @@ } catch (IOException e) { log.log(Level.SEVERE, "Unexpected IO problem while writing heap dump", e); - return new Response(ResponseType.EXCEPTION); + return new Response(ResponseType.ERROR); } catch (HeapDumpException e) { log.log(Level.SEVERE, "Unexpected problem while writing heap dump", e); - return new Response(ResponseType.EXCEPTION); + return new Response(ResponseType.ERROR); } return new Response(ResponseType.OK); }
--- a/agent/heapdumper/src/test/java/com/redhat/thermostat/agent/heapdumper/internal/HeapDumpReceiverTest.java Tue Dec 04 20:14:25 2012 -0500 +++ b/agent/heapdumper/src/test/java/com/redhat/thermostat/agent/heapdumper/internal/HeapDumpReceiverTest.java Wed Dec 05 18:16:16 2012 -0500 @@ -127,7 +127,7 @@ doThrow(new HeapDumpException()).when(jmapDumper).dumpHeap(anyString(), anyString()); Response response = receiver.receive(request); - assertEquals(ResponseType.EXCEPTION, response.getType()); + assertEquals(ResponseType.ERROR, response.getType()); } @@ -137,7 +137,7 @@ Response response = receiver.receive(request); - assertEquals(ResponseType.EXCEPTION, response.getType()); + assertEquals(ResponseType.ERROR, response.getType()); } }
--- a/client/command/src/main/java/com/redhat/thermostat/client/command/cli/PingCommand.java Tue Dec 04 20:14:25 2012 -0500 +++ b/client/command/src/main/java/com/redhat/thermostat/client/command/cli/PingCommand.java Wed Dec 05 18:16:16 2012 -0500 @@ -79,14 +79,10 @@ case ERROR: out.println(translator.localize(LocaleResources.COMMAND_PING_RESPONSE_ERROR, request.getTarget().toString())); break; - case PONG: case OK: case NOOP: out.println(translator.localize(LocaleResources.COMMAND_PING_RESPONSE_OK, request.getTarget().toString())); break; - case EXCEPTION: - out.println(translator.localize(LocaleResources.COMMAND_PING_RESPONSE_EXCEPTION)); - break; case NOK: out.println(translator.localize(LocaleResources.COMMAND_PING_RESPONSE_REFUSED)); break;
--- a/client/command/src/main/java/com/redhat/thermostat/client/command/internal/LocaleResources.java Tue Dec 04 20:14:25 2012 -0500 +++ b/client/command/src/main/java/com/redhat/thermostat/client/command/internal/LocaleResources.java Wed Dec 05 18:16:16 2012 -0500 @@ -49,7 +49,6 @@ COMMAND_PING_NO_AGENT_INFO_DAO, COMMAND_PING_RESPONSE_ERROR, - COMMAND_PING_RESPONSE_EXCEPTION, COMMAND_PING_RESPONSE_OK, COMMAND_PING_RESPONSE_REFUSED, COMMAND_PING_RESPONSE_UNKNOWN,
--- a/client/command/src/main/java/com/redhat/thermostat/client/command/internal/ResponseHandler.java Tue Dec 04 20:14:25 2012 -0500 +++ b/client/command/src/main/java/com/redhat/thermostat/client/command/internal/ResponseHandler.java Wed Dec 05 18:16:16 2012 -0500 @@ -72,7 +72,7 @@ @Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { // TODO when response has support for parameters, provide the exception as well. - Response response = new Response(ResponseType.EXCEPTION); + Response response = new Response(ResponseType.ERROR); notifyListeners(response); }
--- a/client/command/src/main/resources/com/redhat/thermostat/client/command/internal/strings.properties Tue Dec 04 20:14:25 2012 -0500 +++ b/client/command/src/main/resources/com/redhat/thermostat/client/command/internal/strings.properties Wed Dec 05 18:16:16 2012 -0500 @@ -6,7 +6,6 @@ COMMAND_PING_NO_AGENT_INFO_DAO = Unable to access agent information: service not available COMMAND_PING_RESPONSE_ERROR = Error received from: {0} -COMMAND_PING_RESPONSE_EXCEPTION = The tubes, they are probably broken. COMMAND_PING_RESPONSE_OK = Response received from: {0} COMMAND_PING_RESPONSE_REFUSED = The server refused to PONG our PING? COMMAND_PING_RESPONSE_UNKNOWN = Unknown result from ping command \ No newline at end of file
--- a/common/command/src/main/java/com/redhat/thermostat/common/command/Response.java Tue Dec 04 20:14:25 2012 -0500 +++ b/common/command/src/main/java/com/redhat/thermostat/common/command/Response.java Wed Dec 05 18:16:16 2012 -0500 @@ -36,19 +36,26 @@ package com.redhat.thermostat.common.command; - - - public class Response implements Message { // TODO add parameter support to provide more information in some of these types. public enum ResponseType implements MessageType { - PONG, // Just here as response to PING. - OK, // Request has been acknowledged and completed agent-side. - NOK, // Request has been acknowledged and refused agent-side. - NOOP, // Request has been acknowledged, but no action deemed necessary agent-side. - ERROR, // An error on the agent side. - EXCEPTION; // Exception caught by channel handler. Agent-side status unknown. + /** Request has been acknowledged and completed agent-side */ + OK, + + /** Request has been acknowledged and refused agent-side. */ + NOK, + + /** + * Request has been acknowledged, but no action deemed necessary + * agent-side. + */ + NOOP, + + /** + * An error occurred. The status of the request is not known. + */ + ERROR, } ResponseType type;
--- a/common/command/src/test/java/com/redhat/thermostat/common/command/ResponseTest.java Tue Dec 04 20:14:25 2012 -0500 +++ b/common/command/src/test/java/com/redhat/thermostat/common/command/ResponseTest.java Wed Dec 05 18:16:16 2012 -0500 @@ -47,8 +47,8 @@ @Test public void testGetType() { - Response r = new Response(ResponseType.PONG); - assertEquals(ResponseType.PONG, r.getType()); + Response r = new Response(ResponseType.OK); + assertEquals(ResponseType.OK, r.getType()); r = new Response(ResponseType.ERROR); assertEquals(ResponseType.ERROR, r.getType()); }
--- a/killvm/client-swing/src/main/java/com/redhat/thermostat/killvm/client/internal/SwingVMKilledListener.java Tue Dec 04 20:14:25 2012 -0500 +++ b/killvm/client-swing/src/main/java/com/redhat/thermostat/killvm/client/internal/SwingVMKilledListener.java Wed Dec 05 18:16:16 2012 -0500 @@ -62,11 +62,6 @@ @Override public void fireComplete(Request request, Response response) { switch (response.getType()) { - case EXCEPTION: - logger.log(Level.SEVERE, - "Exception response from kill VM request. Command channel failure?"); - showErrorMessage(t.localize(LocaleResources.KILL_ACTION_EXCEPTION_RESPONSE_MSG)); - break; case ERROR: String vmId = request.getParameter("vm-id"); logger.log(Level.SEVERE, @@ -74,7 +69,6 @@ + vmId); showErrorMessage(t.localize(LocaleResources.KILL_ACTION_ERROR_RESPONSE_MSG, vmId)); break; - case PONG: // fall-through, also OK :) case OK: logger.log(Level.INFO, "VM with id " + request.getParameter("vm-id")
--- a/killvm/client-swing/src/main/java/com/redhat/thermostat/killvm/client/locale/LocaleResources.java Tue Dec 04 20:14:25 2012 -0500 +++ b/killvm/client-swing/src/main/java/com/redhat/thermostat/killvm/client/locale/LocaleResources.java Wed Dec 05 18:16:16 2012 -0500 @@ -42,7 +42,6 @@ ACTION_NAME, ACTION_DESCRIPTION, - KILL_ACTION_EXCEPTION_RESPONSE_MSG, KILL_ACTION_ERROR_RESPONSE_MSG, MISSING_INFO;
--- a/killvm/client-swing/src/main/resources/com/redhat/thermostat/killvm/client/locale/strings.properties Tue Dec 04 20:14:25 2012 -0500 +++ b/killvm/client-swing/src/main/resources/com/redhat/thermostat/killvm/client/locale/strings.properties Wed Dec 05 18:16:16 2012 -0500 @@ -1,5 +1,4 @@ ACTION_NAME = Kill Application ACTION_DESCRIPTION = Kill the selected VM Process MISSING_INFO = Missing Information -KILL_ACTION_EXCEPTION_RESPONSE_MSG = Channel Transport Error. Please check your configuration! KILL_ACTION_ERROR_RESPONSE_MSG = Failed to kill VM with pid {0} \ No newline at end of file
--- a/killvm/client-swing/src/test/java/com/redhat/thermostat/killvm/client/internal/SwingVMKilledListenerTest.java Tue Dec 04 20:14:25 2012 -0500 +++ b/killvm/client-swing/src/test/java/com/redhat/thermostat/killvm/client/internal/SwingVMKilledListenerTest.java Wed Dec 05 18:16:16 2012 -0500 @@ -53,15 +53,6 @@ public class SwingVMKilledListenerTest { @Test - public void exceptionShowsError() { - ResponseActionListener listener = new ResponseActionListener(); - Request request = mock(Request.class); - Response resp = new Response(ResponseType.EXCEPTION); - listener.fireComplete(request, resp); - assertTrue(listener.isActionPerformed()); - } - - @Test public void errorShowsError() { ResponseActionListener listener = new ResponseActionListener(); Request request = mock(Request.class);