-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.0
-
x86
-
windows_nt
Name: skT45625 Date: 05/03/2000
C:\dev\eas_test\rmi_cases\event>java -version
java version "1.2.2"
Classic VM (build JDK-1.2.2-001, native threads, symcjit)
I have an RMI-IIOP client that spawns 10 client threads. Each client thread
does a lookup and gets its own reference to the remote object. Each client
thread, then, executes the remote method 'n' amount of times. If 'n' is 1000 or
less, everything works. If 'n' is 2000 or more, some clients will most likely
get blocked and some will finish successfully. A CORBA MARSHAL exception
is also thrown sometimes, but rarely.
To reproduce run 'java isol.FaultServer 2000' in one window.
Run 'java isol.FaultClient 2000' in another. Of course 'tnameserv' must be
running.
Again, if the above number is 1000, it will most likely run fine.
If the number is 2000, it will most likely block. If it doesn't run it again.
//Remote Interface:
package isol;
import java.rmi.*;
public interface FaultService
extends Remote
{
public Alarm getEvent(int seq) throws RemoteException;
}
// Server side implementation of the above interface
package isol;
import java.rmi.*;
import java.util.*;
public class FaultServiceImpl
extends javax.rmi.PortableRemoteObject
implements FaultService
{
public FaultServiceImpl(int noEvt)
throws RemoteException
{
v = new Vector();
for(int i = 0; i < noEvt; ++i)
{
List li = new LinkedList();
li.add(new Integer(i));
Alarm a = new Alarm(1000, 1000, "name",
new Integer(i), "type", "sev", "add",
true, "ct", true, false, new Integer(i), 1, li);
v.add(a);
}
System.out.println("initialized Fault service with " + noEvt + "
events");
}
public synchronized Alarm getEvent(int seq)
throws RemoteException
{
Alarm a = (Alarm)v.get(seq - 1);
return a;
}
Vector v;
}
// Server
package isol;
import java.rmi.*;
import java.util.*;
import javax.naming.*;
public class FaultServer
{
public static void main(String argv[])
{
try
{
FaultServiceImpl fs = new
FaultServiceImpl(Integer.parseInt(argv[0]));
Hashtable props = new Hashtable();
props.put(CONTEXT_PROP, DEF_CONTEXT);
props.put(URL_PROP, "iiop://" + DEF_HOST + ":" +
DEF_PORT);
Context ctx = new InitialContext(props);
ctx.rebind("fs", fs);
System.out.println("Registered fault service");
}
catch(Throwable e)
{
e.printStackTrace();
}
}
public static final String CONTEXT_PROP =
javax.naming.Context.INITIAL_CONTEXT_FACTORY;
public static final String URL_PROP = javax.naming.Context.PROVIDER_URL;
public static final String DEF_HOST = "localhost";
public static final int DEF_PORT = 900;
public static final String DEF_CONTEXT =
"com.sun.jndi.cosnaming.CNCtxFactory";
}
// Client
package isol;
import java.rmi.*;
import java.util.*;
import javax.naming.*;
import javax.rmi.*;
public class FaultClient
implements Runnable
{
FaultClient(int noEvt, int num)
throws Throwable
{
Hashtable props = new Hashtable();
props.put(CONTEXT_PROP, DEF_CONTEXT);
props.put(URL_PROP, "iiop://" + DEF_HOST + ":" + DEF_PORT);
Context ctx = new InitialContext(props);
fs = (FaultService)PortableRemoteObject.narrow(
ctx.lookup("fs"), FaultService.class);
no = num;
this.noEvt = noEvt;
}
public void begin()
throws Throwable
{
t = new Thread(this, "Client: " + no);
t.start();
}
public void run()
{
try
{
for(int i = 0; i < noEvt; i++)
{
Alarm a = fs.getEvent(i+1);
//System.out.println("Client: " + no + " getting
" + i);
}
}
catch(Throwable e)
{
e.printStackTrace();
}
System.out.println("Client: " + no + " finished getting " +
noEvt + " events...");
}
public static void main(String argv[])
{
try
{
Vector v = new Vector(10);
for(int i = 0; i < 10; ++i)
{
System.out.println("initializing client: " +
(i+1));
v.add(new FaultClient(Integer.parseInt(argv[0]),
i+1));
}
Iterator it = v.iterator();
while(it.hasNext())
{
FaultClient fc = (FaultClient)it.next();
fc.begin();
}
}
catch(Throwable e)
{
e.printStackTrace();
}
}
public static final String CONTEXT_PROP =
javax.naming.Context.INITIAL_CONTEXT_FACTORY;
public static final String URL_PROP = javax.naming.Context.PROVIDER_URL;
public static final String DEF_HOST = "localhost";
public static final int DEF_PORT = 900;
public static final String DEF_CONTEXT =
"com.sun.jndi.cosnaming.CNCtxFactory";
private FaultService fs;
private int no;
private int noEvt;
private Thread t;
}
// Serializable Alarm class
package isol;
import java.io.*;
import java.util.*;
public class Alarm
implements Serializable
{
Alarm( long creTime, int seq, String name,
Serializable src, String type, String sev,
String add, boolean isSA, String ct, boolean isC, boolean
isCNE,
Serializable ack, int neEventId, List ad)
{
this.type = type;
this.sev = sev;
this.add = add;
this.isSA = isSA;
this.ct = ct;
this.isC = isC;
this.isCNE = isCNE;
this.ack = ack;
this.neEventId = neEventId;
this.ad = ad;
}
private final String type;
private final String sev;
private final String add;
private final boolean isSA;
private final String ct;
private boolean isC;
private boolean isCNE;
private Serializable ack;
private final List ad;
private final int neEventId;
}
(Review ID: 104437)
======================================================================
- duplicates
-
JDK-4321532 race condition in IIOPConnection.java
-
- Resolved
-