From: Marek P. <ma...@us...> - 2001-08-12 07:35:35
|
Update of /cvsroot/javaprofiler/library/src2 In directory usw-pr-cvs1:/tmp/cvs-serv724/src2 Modified Files: CommunShMem.java CommunSocket.java IProf.java Added Files: CommunSetup.java CommunSetupShMem.java CommunSetupSocket.java Log Message: changes in library setups; now, library can run in server or client mode (java part not implemented yet) --- NEW FILE: CommunSetup.java --- public abstract class CommunSetup { public static final int COMMUN_SOCKET = 0; public static final int COMMUN_SHMEM = 1; public int communType; public CommunSetup() { this( COMMUN_SOCKET); } public CommunSetup( int communType) { this.communType = communType; } }; --- NEW FILE: CommunSetupShMem.java --- public class CommunSetupShMem extends CommunSetup { public String shmemId = new String( "com"); public int shmemSize = 256*1024; public CommunSetupShMem() { super( COMMUN_SHMEM); } public CommunSetupShMem( String shmemId, int shmemSize) { super( COMMUN_SHMEM); this.shmemId = new String( shmemId); this.shmemSize = shmemSize; } }; --- NEW FILE: CommunSetupSocket.java --- public class CommunSetupSocket extends CommunSetup { public static final int SERVER_MODE = 0; public static final int CLIENT_MODE = 1; public int connectMode = SERVER_MODE; public String hostname = new String( "127.0.0.1"); public int port = 25595; public CommunSetupSocket() { super( COMMUN_SOCKET); } public CommunSetupSocket( int connectMode, String hostname, int port) { super( COMMUN_SOCKET); this.connectMode = connectMode; this.hostname = new String( hostname); this.port = port; } }; Index: CommunShMem.java =================================================================== RCS file: /cvsroot/javaprofiler/library/src2/CommunShMem.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** CommunShMem.java 2001/08/09 23:22:55 1.1 --- CommunShMem.java 2001/08/12 07:35:31 1.2 *************** *** 1,4 **** --- 1,18 ---- public class CommunShMem implements Commun { + private String shmemId; + + private int shmemSize; + + + private long data = 0; + + + public CommunShMem( String shmemId, int shmemSize) { + + this.shmemId = new String( shmemId); + this.shmemSize = shmemSize; + } + public native boolean initialize(); Index: CommunSocket.java =================================================================== RCS file: /cvsroot/javaprofiler/library/src2/CommunSocket.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** CommunSocket.java 2001/08/09 23:22:55 1.2 --- CommunSocket.java 2001/08/12 07:35:31 1.3 *************** *** 5,11 **** --- 5,14 ---- public class CommunSocket implements Commun { + private int _connectMode; + private String _host; private int _port; + private boolean _failed = false; *************** *** 20,27 **** ! public CommunSocket( String host, int port) { ! _host = new String( host); ! _port = port; } --- 23,31 ---- ! public CommunSocket( int connectMode, String host, int port) { ! _connectMode = _connectMode; ! _host = new String( host); ! _port = port; } *************** *** 30,33 **** --- 34,42 ---- try { + if( _connectMode == 0) { // server + + // not implemented yet + } + _sock = new Socket( _host, _port); *************** *** 97,100 **** --- 106,115 ---- try { + + if( _connectMode == 0) { // server + + // not implemented yet + } + _in .close(); _out.close(); Index: IProf.java =================================================================== RCS file: /cvsroot/javaprofiler/library/src2/IProf.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** IProf.java 2001/08/09 23:22:55 1.2 --- IProf.java 2001/08/12 07:35:31 1.3 *************** *** 2,26 **** public class IProf { - - private static final int DEFAULT_PORT = 25595; ! public IProf( String hostname) { ! ! this( hostname, DEFAULT_PORT); } - public IProf( int port) { - - this( "127.0.0.1", port); - } - private Commun _commun; - - public IProf( String hostname, int port) { ! _commun = new CommunSocket( hostname, port); } --- 2,27 ---- public class IProf { + public IProf() { ! this( new CommunSetupShMem()); } private Commun _commun; ! public IProf( CommunSetup setup) { ! ! if( setup.communType == CommunSetup.COMMUN_SOCKET) { ! ! CommunSetupSocket s = (CommunSetupSocket)setup; ! _commun = new CommunSocket( s.connectMode, s.hostname, s.port); ! } ! else { ! ! CommunSetupShMem s = (CommunSetupShMem)setup; ! _commun = new CommunShMem( s.shmemId, s.shmemSize); ! } } *************** *** 43,47 **** } catch( Exception e) { ! _timer.cancel(); } --- 44,48 ---- } catch( Exception e) { ! _timer.cancel(); } |