asmuts 02/02/24 00:20:37
Modified: src/java/org/apache/stratum/jcs/auxiliary/lateral/xmlrpc/utils
XMLRPCSocketOpener.java
src/conf log4j.properties
src/java/org/apache/stratum/jcs/auxiliary/lateral/xmlrpc
LateralXMLRPCSender.java
LateralXMLRPCReceiverConnection.java
src/java/org/apache/stratum/jcs/auxiliary/lateral
LateralCacheRestore.java
Log:
had to serialize cache element to get XMLRPC to work
can communicate, but I'm getting a strange end of file error.
Revision Changes Path
1.2 +11 -2
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/xmlrpc/utils/XMLRPCSocketOpener.java
Index: XMLRPCSocketOpener.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/xmlrpc/utils/XMLRPCSocketOpener.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XMLRPCSocketOpener.java 20 Feb 2002 05:30:51 -0000 1.1
+++ XMLRPCSocketOpener.java 24 Feb 2002 08:20:36 -0000 1.2
@@ -58,17 +58,25 @@
import org.apache.xmlrpc.XmlRpcClientLite;
import org.apache.xmlrpc.XmlRpcClient;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogSource;
+
+
/**
* Socket openere that will timeout on the initial connect rather than block
* forever. Technique from core java II.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Aaron Smuts</a>
* @created January 15, 2002
- * @version $Id: XMLRPCSocketOpener.java,v 1.1 2002/02/20 05:30:51 asmuts Exp $
+ * @version $Id: XMLRPCSocketOpener.java,v 1.2 2002/02/24 08:20:36 asmuts Exp $
*/
public class XMLRPCSocketOpener implements Runnable
{
+ private final static Log log =
+ LogSource.getInstance( XMLRPCSocketOpener.class );
+
+
private String host;
private int port;
//private Socket socket;
@@ -86,7 +94,7 @@
}
catch ( InterruptedException ire )
{
-
+ log.error( "Trouble opening socket", ire);
}
return opener.getSocket();
}
@@ -116,6 +124,7 @@
}
catch ( IOException ioe )
{
+ log.error( "Trouble creating client", ioe);
}
}
1.6 +2 -1 jakarta-turbine-stratum/src/conf/log4j.properties
Index: log4j.properties
===================================================================
RCS file: /home/cvs/jakarta-turbine-stratum/src/conf/log4j.properties,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- log4j.properties 24 Feb 2002 07:08:04 -0000 1.5
+++ log4j.properties 24 Feb 2002 08:20:36 -0000 1.6
@@ -30,7 +30,8 @@
log4j.category.org.apache.stratum.jcs.engine.memory.shrinking=ERROR,A1
log4j.category.org.apache.stratum.jcs.config=WARN,A1
log4j.category.org.apache.stratum.jcs.auxiliary.disk=WARN,WF
-log4j.category.org.apache.stratum.jcs.auxiliary.lateral=WARN,WF
+log4j.category.org.apache.stratum.jcs.auxiliary.lateral.javagroups=WARN,WF
+log4j.category.org.apache.stratum.jcs.auxiliary.lateral.xmlrpc=DEBUG,WF
log4j.category.org.apache.stratum.jcs.auxiliary.remote=WARN,WF
log4j.category.org.apache.stratum.jcs.utils=WARN,WF
1.2 +141 -57
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/xmlrpc/LateralXMLRPCSender.java
Index: LateralXMLRPCSender.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/xmlrpc/LateralXMLRPCSender.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LateralXMLRPCSender.java 20 Feb 2002 05:30:51 -0000 1.1
+++ LateralXMLRPCSender.java 24 Feb 2002 08:20:37 -0000 1.2
@@ -6,6 +6,7 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Serializable;
@@ -40,7 +41,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Aaron Smuts</a>
* @created January 15, 2002
- * @version $Id: LateralXMLRPCSender.java,v 1.1 2002/02/20 05:30:51 asmuts Exp $
+ * @version $Id: LateralXMLRPCSender.java,v 1.2 2002/02/24 08:20:37 asmuts Exp $
*/
public class LateralXMLRPCSender implements IXMLRPCConstants
{
@@ -68,7 +69,9 @@
// */
// private final static int timeOut = 10000;
//
- /** Only block for 5 seconds before timing out on startup. */
+ /**
+ * Only block for 5 seconds before timing out on startup.
+ */
private final static int openTimeOut = 5000;
@@ -90,7 +93,13 @@
}
- /** Description of the Method */
+ /**
+ * Description of the Method
+ *
+ * @param host
+ * @param port
+ * @exception IOException
+ */
protected void init( String host, int port )
throws IOException
{
@@ -100,7 +109,7 @@
try
{
- log.debug( "Attempting connection to " + address.getHostName() );
+ log.debug( "Attempting connection to " + address.getHostName() + ":" +
port );
//socket = new Socket( address, port );
xmlrpc = XMLRPCSocketOpener.openSocket( host, port, openTimeOut );
@@ -138,6 +147,7 @@
* Gets the addressByName attribute of the LateralXMLRPCSender object
*
* @return The addressByName value
+ * @param host
*/
private InetAddress getAddressByName( String host )
{
@@ -153,7 +163,12 @@
}
- /** Sends commands to the lateral cache listener. */
+ /**
+ * Sends commands to the lateral cache listener.
+ *
+ * @param led
+ * @exception IOException
+ */
public void send( LateralElementDescriptor led )
throws IOException
{
@@ -172,11 +187,11 @@
// if ( oos != null )
// {
- try
- {
- Vector params = new Vector();
- params.add((Serializable)led);
- xmlrpc.execute( this.HANDLERNAME, params );
+ try
+ {
+ Vector params = new Vector();
+ params.add( serialize( led ) );
+ Object junk = xmlrpc.execute( this.HANDLERNAME + ".execute", params );
// oos.writeObject( led );
// oos.flush();
@@ -188,18 +203,18 @@
// log.info( "Doing oos.reset()" );
// oos.reset();
// }
- }
- catch ( IOException e )
- {
- //oos = null;
- log.error( "Detected problem with connection: " + e );
- throw e;
- }
- catch ( Exception e )
- {
- log.error( "Detected problem with connection: " + e );
- throw new IOException( e.getMessage() );
- }
+ }
+ catch ( IOException e )
+ {
+ //oos = null;
+ log.error( "Detected problem with connection: " + e );
+ throw e;
+ }
+ catch ( Exception e )
+ {
+ log.error( "Detected problem with connection: " + e );
+ throw new IOException( e.getMessage() );
+ }
// }
}
@@ -209,6 +224,10 @@
* afraid that we could get into a pretty bad blocking situation here. This
* needs work. I just wanted to get some form of get working. Will need some
* sort of timeout.
+ *
+ * @return
+ * @param led
+ * @exception IOException
*/
public Serializable sendAndReceive( LateralElementDescriptor led )
throws IOException
@@ -230,36 +249,37 @@
// if ( oos != null )
// {
- try
- {
+ try
+ {
// oos.writeObject( led );
// oos.flush();
- try
- {
+ try
+ {
// ObjectInputStream ois = new ObjectInputStream(
socket.getInputStream() );
// Object obj = ois.readObject();
- Vector params = new Vector();
- params.add(led);
- Object obj = xmlrpc.execute( this.HANDLERNAME, params );
- ice = ( ICacheElement ) obj;
- if ( ice == null )
- {
- //p( "ice is null" );
- // TODO: coutn misses
- }
-
- }
- catch ( IOException ioe )
- {
- log.error( "Could not xmlrpc exceute " + xmlrpc, ioe );
- }
- catch ( Exception e )
+ Vector params = new Vector();
+ // this should call another method
+ params.add( serialize(led) );
+ Object obj = xmlrpc.execute( this.HANDLERNAME, params );
+ ice = ( ICacheElement ) obj;
+ if ( ice == null )
{
- log.error( e );
+ //p( "ice is null" );
+ // TODO: coutn misses
}
+ }
+ catch ( IOException ioe )
+ {
+ log.error( "Could not xmlrpc exceute " + xmlrpc, ioe );
+ }
+ catch ( Exception e )
+ {
+ log.error( e );
+ }
+
// if ( ++counter >= RESET_FREQUENCY )
// {
// counter = 0;
@@ -268,24 +288,30 @@
// log.info( "Doing oos.reset()" );
// oos.reset();
// }
- }
+ }
// catch ( IOException e )
// {
// //oos = null;
// log.error( "Detected problem with connection: " + e );
// throw e;
// }
- catch ( Exception e )
- {
- log.error( "Detected problem with connection: " + e );
- throw new IOException( e.getMessage() );
- }
+ catch ( Exception e )
+ {
+ log.error( "Detected problem with connection: " + e );
+ throw new IOException( e.getMessage() );
+ }
// }
return ice;
}// end sendAndReceive
// Service Methods //
- /** Description of the Method */
+ /**
+ * Description of the Method
+ *
+ * @param item
+ * @param requesterId
+ * @exception IOException
+ */
public void update( ICacheElement item, byte requesterId )
throws IOException
{
@@ -296,7 +322,13 @@
}
- /** Description of the Method */
+ /**
+ * Description of the Method
+ *
+ * @param cacheName
+ * @param key
+ * @exception IOException
+ */
public void remove( String cacheName, Serializable key )
throws IOException
{
@@ -304,7 +336,14 @@
}
- /** Description of the Method */
+ /**
+ * Description of the Method
+ *
+ * @param cacheName
+ * @param key
+ * @param requesterId
+ * @exception IOException
+ */
public void remove( String cacheName, Serializable key, byte requesterId )
throws IOException
{
@@ -316,7 +355,11 @@
}
- /** Description of the Method */
+ /**
+ * Description of the Method
+ *
+ * @exception IOException
+ */
public void release()
throws IOException
{
@@ -329,6 +372,9 @@
* conneciton. Dispose request should come into the facade and be sent to
* all lateral cache sevices. The lateral cache service will then call this
* method.
+ *
+ * @param cache
+ * @exception IOException
*/
public void dispose( String cache )
throws IOException
@@ -339,7 +385,12 @@
}
- /** Description of the Method */
+ /**
+ * Description of the Method
+ *
+ * @param cacheName
+ * @exception IOException
+ */
public void removeAll( String cacheName )
throws IOException
{
@@ -347,7 +398,13 @@
}
- /** Description of the Method */
+ /**
+ * Description of the Method
+ *
+ * @param cacheName
+ * @param requesterId
+ * @exception IOException
+ */
public void removeAll( String cacheName, byte requesterId )
throws IOException
{
@@ -359,14 +416,18 @@
}
- /** Description of the Method */
+ /**
+ * Description of the Method
+ *
+ * @param args
+ */
public static void main( String args[] )
{
try
{
LateralXMLRPCSender lur = null;
LateralCacheAttributes lca = new LateralCacheAttributes();
- lca.setHttpServer("localhost:8181");
+ lca.setHttpServer( "localhost:8181" );
lur = new LateralXMLRPCSender( lca );
// process user input till done
@@ -388,6 +449,29 @@
{
System.out.println( e.toString() );
}
+ }
+
+ /**
+ * Description of the Method
+ *
+ * @return
+ * @param obj
+ * @exception IOException
+ */
+ static byte[] serialize( Serializable obj )
+ throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream( baos );
+ try
+ {
+ oos.writeObject( obj );
+ }
+ finally
+ {
+ oos.close();
+ }
+ return baos.toByteArray();
}
}
1.2 +27 -7
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/xmlrpc/LateralXMLRPCReceiverConnection.java
Index: LateralXMLRPCReceiverConnection.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/xmlrpc/LateralXMLRPCReceiverConnection.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LateralXMLRPCReceiverConnection.java 20 Feb 2002 05:30:51 -0000 1.1
+++ LateralXMLRPCReceiverConnection.java 24 Feb 2002 08:20:37 -0000 1.2
@@ -57,6 +57,8 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.BufferedInputStream;
import java.io.Serializable;
import java.net.Socket;
import java.util.Vector;
@@ -133,9 +135,27 @@
{
// do nothing with method name for now, later the action code can be
// the method name
-
- // get the LED out of the params
- LateralElementDescriptor led = ( LateralElementDescriptor )
params.firstElement();
+ LateralElementDescriptor led = null;
+ try
+ {
+ // get the LED out of the params
+ byte[] data = ( byte[] ) params.firstElement();
+ ByteArrayInputStream bais = new ByteArrayInputStream( data );
+ BufferedInputStream bis = new BufferedInputStream( bais );
+ ObjectInputStream ois = new ObjectInputStream( bis );
+ try
+ {
+ led = ( LateralElementDescriptor ) ois.readObject();
+ }
+ finally
+ {
+ ois.close();
+ }
+ }
+ catch ( Exception e )
+ {
+ log.error( e );
+ }
return executeImpl( led );
}
@@ -153,14 +173,14 @@
try
{
- while ( true )
- {
+// while ( true )
+// {
// obj = ois.readObject();
// LateralElementDescriptor led = ( LateralElementDescriptor ) obj;
if ( led == null )
{
log.debug( "LateralElementDescriptor is null" );
- continue;
+ //continue;
}
if ( led.requesterId == LateralCacheInfo.listenerId )
{
@@ -200,7 +220,7 @@
//ilcl.handleGet( led.ce.getCacheName(), led.ce.getKey() );
}
}
- }
+// }
}
catch ( java.io.EOFException e )
{
1.8 +7 -0
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/LateralCacheRestore.java
Index: LateralCacheRestore.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/LateralCacheRestore.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- LateralCacheRestore.java 24 Feb 2002 07:08:04 -0000 1.7
+++ LateralCacheRestore.java 24 Feb 2002 08:20:37 -0000 1.8
@@ -9,6 +9,8 @@
import org.apache.stratum.jcs.auxiliary.lateral.javagroups.LateralJGService;
+import org.apache.stratum.jcs.auxiliary.lateral.xmlrpc.LateralXMLRPCService;
+
import org.apache.stratum.jcs.engine.behavior.ICacheRestore;
import org.apache.commons.logging.Log;
@@ -66,6 +68,11 @@
if ( lcm.lca.getTransmissionType() == lcm.lca.JAVAGROUPS )
{
lateralObj = new LateralJGService( lcm.lca );
+ }
+ else
+ if ( lcm.lca.getTransmissionType() == lcm.lca.XMLRPC )
+ {
+ lateralObj = new LateralXMLRPCService( lcm.lca );
}
else
if ( lcm.lca.getTransmissionType() == lcm.lca.TCP )
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>