summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authoreea1 <eea1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-05-12 21:23:31 +0000
committereea1 <eea1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-05-12 21:23:31 +0000
commitf1bb15a8014dfd6a75dae7ea9f1063bcd3162f08 (patch)
tree1615610d5ec55d03bc2d15c91764312f5d8dae27 /java
parent0971648a64465a1f7531b5b6bea7f985ae0b3566 (diff)
downloadATCD-f1bb15a8014dfd6a75dae7ea9f1063bcd3162f08.tar.gz
Added a client for the logger (same as the C++ ACE direct_logging client,
but it's nice to see how to do it in Java), and made another small change for compatibility in LogRecord.
Diffstat (limited to 'java')
-rw-r--r--java/netsvcs/Logger/LogClient.java71
-rw-r--r--java/netsvcs/Logger/LogRecord.java2
-rw-r--r--java/netsvcs/Logger/Makefile1
3 files changed, 72 insertions, 2 deletions
diff --git a/java/netsvcs/Logger/LogClient.java b/java/netsvcs/Logger/LogClient.java
new file mode 100644
index 00000000000..3b5b64456b4
--- /dev/null
+++ b/java/netsvcs/Logger/LogClient.java
@@ -0,0 +1,71 @@
+/*************************************************
+ *
+ * = PACKAGE
+ * netsvcs.Logger
+ *
+ * = FILENAME
+ * LogClient.java
+ *
+ *@author Everett Anderson
+ *
+ *************************************************/
+package netsvcs.Logger;
+
+import JACE.SOCK_SAP.*;
+import JACE.OS.*;
+import java.net.*;
+import java.io.*;
+import java.util.*;
+import java.lang.*;
+
+/**
+ * Simple direct logging client to test the logging service. This is similar to
+ * C++ ACE's direct_logging example. Command line parameters are the port
+ * and host to log to.
+ */
+public class LogClient
+{
+ public static void main(String [] args)
+ {
+
+ if (args.length != 2) {
+ ACE.ERROR("Command line arguments: <port> <hostname>");
+ System.exit(1);
+ }
+
+ Socket sock = null;
+ try {
+
+ ACE.DEBUG("Trying: " + args[1] + " port " + args[0]);
+
+ Integer port = new Integer(args[0]);
+
+ sock = new Socket(args[1], port.intValue());
+
+ } catch (UnknownHostException e) {
+ ACE.ERROR("" + e);
+ System.exit(1);
+ } catch (IOException e) {
+ ACE.ERROR("Couldn't get socket");
+ System.exit(1);
+ }
+
+ try {
+
+ DataOutputStream dos = new DataOutputStream(sock.getOutputStream());
+
+ LogRecord log = new LogRecord();
+ log.msgData("hello world.");
+
+ log.streamOutTo(dos);
+
+ sock.close();
+
+ } catch (IOException e) {
+ ACE.ERROR("Error sending message");
+ System.exit(1);
+ }
+ }
+}
+
+
diff --git a/java/netsvcs/Logger/LogRecord.java b/java/netsvcs/Logger/LogRecord.java
index c2f1e4bdeee..0043c040f74 100644
--- a/java/netsvcs/Logger/LogRecord.java
+++ b/java/netsvcs/Logger/LogRecord.java
@@ -111,7 +111,6 @@ public class LogRecord
// Order here must match layout order in the C++ class.
// This, of course, is VERY fragile, and ought not be used as
// a model for anything except how NOT to do anything.
-
length(dis.readInt());
type(dis.readInt());
this.timeStamp((long)dis.readInt() * 1000);
@@ -134,7 +133,6 @@ public class LogRecord
{
dos.writeInt(length());
dos.writeInt(type());
- dos.writeInt(length());
dos.writeInt((int)(this.msec_ / 1000));
dos.writeInt(0);
dos.writeInt(pid());
diff --git a/java/netsvcs/Logger/Makefile b/java/netsvcs/Logger/Makefile
index a15f673eba0..d4277260f92 100644
--- a/java/netsvcs/Logger/Makefile
+++ b/java/netsvcs/Logger/Makefile
@@ -11,6 +11,7 @@ doc:
files = LogMessageReceiver.java \
DefaultLMR.java \
+ LogClient.java \
LogRecord.java \
ServerLoggingAcceptor.java \
ServerLoggingHandler.java