Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 01-08-2007
zhi zhi is offline
Registered User
 
Name: Zhi Quan Lee
Organization: University of Auckland
Project: Dynamic Reconfiguration with Correctness Assurance
 
Join Date: Nov 2006
Location: Auckland
Posts: 32
Need Help with Streaming

Hi, could I get any help on this? I seem to be unable to send a stream from a client to a server which runs on another node. It should be just a config file issue but I am unable to spot my mistake.

The error thrown at the client:
Code:
Ice.ConnectionRefusedException
    error = 0
        at IceInternal.Network.doConnect(Network.java:284)
        at IceInternal.TcpConnector.connect(TcpConnector.java:25)
        at IceInternal.OutgoingConnectionFactory.create(OutgoingConnectionFactor
y.java:308)
        at IceInternal.RoutableReference.createConnection(RoutableReference.java
:379)
        at IceInternal.DirectReference.getConnection(DirectReference.java:192)
        at Ice._ObjectDelM.setup(_ObjectDelM.java:258)
        at Ice.ObjectPrxHelperBase.__getDelegate(ObjectPrxHelperBase.java:905)
        at Ice.ObjectPrxHelperBase.ice_invoke(ObjectPrxHelperBase.java:190)
        at Ice.ObjectPrxHelperBase.ice_invoke(ObjectPrxHelperBase.java:178)
        at Client.run(Client.java:113)
        at Ice.Application.main(Application.java:114)
        at Ice.Application.main(Application.java:57)
        at Client.main(Client.java:158)
Caused by: java.net.ConnectException: Connection refused: no further information

        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
        at IceInternal.Network.doConnect(Network.java:259)
        ... 12 more
The client and server iceconfig:
Code:
Ice.Default.LocatorCacheTimeout=0
Ice.Default.Locator=OpenRec2IceGrid/Locator:default -h 127.0.0.1 -p 12000
Analyser.Proxy=analyser:default -p 11000
Analyser.Endpoints=default -p 11000
The adapter object running on the server is configured like this:
Code:
IceGrid.InstanceName=OpenRec2IceGrid
Ice.Default.Locator=OpenRec2IceGrid/Locator:default -p 12000

IceGrid.Node.Name=openRec2Server
IceGrid.Node.Endpoints=default
IceGrid.Node.Data=db/node/analyser
IceGrid.Node.CollocateRegistry=0

IceGrid.Node.Trace.Activator=1
IceGrid.Node.Trace.Patch=
__________________
Zhi Quan Lee
University of Auckland
Department of Electrical and Computer Engineering
http://se.auckland.ac.nz

Project: An Integrated Automated Framework for Managing Dynamic Reconfiguration

Supervised by Dr. Ian Warren and Dr. Jing Sun.

With respect to their paper: http://csdl2.computer.org/persagen/D...09/ASE.2006.12

Homepage:
http://zhi-lee.com
Reply With Quote
  #2 (permalink)  
Old 01-08-2007
zhi zhi is offline
Registered User
 
Name: Zhi Quan Lee
Organization: University of Auckland
Project: Dynamic Reconfiguration with Correctness Assurance
 
Join Date: Nov 2006
Location: Auckland
Posts: 32
This is the client code:
Code:
					OpenRecModel sudoku = new MySudokuModel(3);
					
                    //
                    // Marshal the in parameter.
                    //
                    Ice.OutputStream out = Ice.Util.createOutputStream(communicator());
                    OpenRec2.KodkodModel model = new KodkodModelI(sudoku);
                    
                    KodkodModelHelper.write(out, model);
                    out.writePendingObjects();

                    //
                    // Invoke operation.
                    //
                    if(!obj.ice_invoke("sendModel", Ice.OperationMode.Normal, out.finished(), null))
                    {
                        System.out.println("Unknown user exception");
                    }
                    out.destroy();
__________________
Zhi Quan Lee
University of Auckland
Department of Electrical and Computer Engineering
http://se.auckland.ac.nz

Project: An Integrated Automated Framework for Managing Dynamic Reconfiguration

Supervised by Dr. Ian Warren and Dr. Jing Sun.

With respect to their paper: http://csdl2.computer.org/persagen/D...09/ASE.2006.12

Homepage:
http://zhi-lee.com
Reply With Quote
  #3 (permalink)  
Old 01-08-2007
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,781
You should be able to find out what's wrong with tracing. Please have a look at this FAQ.
Reply With Quote
  #4 (permalink)  
Old 01-08-2007
zhi zhi is offline
Registered User
 
Name: Zhi Quan Lee
Organization: University of Auckland
Project: Dynamic Reconfiguration with Correctness Assurance
 
Join Date: Nov 2006
Location: Auckland
Posts: 32
This is the trace I get on the client:
Code:
[ Network: trying to establish tcp connection to 192.168.1.2:11000 ]
[ Network: trying to establish tcp connection to 192.168.1.2:11000 ]
Ice.ConnectionRefusedException
    error = 0
        at IceInternal.Network.doConnect(Network.java:284)
        at IceInternal.TcpConnector.connect(TcpConnector.java:25)
        at IceInternal.OutgoingConnectionFactory.create(OutgoingConnectionFactor
y.java:308)
        at IceInternal.RoutableReference.createConnection(RoutableReference.java
:379)
        at IceInternal.DirectReference.getConnection(DirectReference.java:192)
        at Ice._ObjectDelM.setup(_ObjectDelM.java:258)
        at Ice.ObjectPrxHelperBase.__getDelegate(ObjectPrxHelperBase.java:905)
        at Ice.ObjectPrxHelperBase.ice_invoke(ObjectPrxHelperBase.java:190)
        at Ice.ObjectPrxHelperBase.ice_invoke(ObjectPrxHelperBase.java:178)
        at Client.run(Client.java:113)
        at Ice.Application.main(Application.java:114)
        at Ice.Application.main(Application.java:57)
        at Client.main(Client.java:158)
Caused by: java.net.ConnectException: Connection refused: no further information

        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
        at IceInternal.Network.doConnect(Network.java:259)
        ... 12 more
==> [ Network: shutting down tcp connection for writing
  local address = 127.0.0.1:3204
  remote address = 127.0.0.1:12000 ]
[ Network: closing tcp connection
  local address = 127.0.0.1:3204
  remote address = 127.0.0.1:12000 ]
[ Network: shutting down tcp connection for writing
  local address = 192.168.1.2:3217
  remote address = 192.168.1.2:3210 ]
[ Network: closing tcp connection
  local address = 192.168.1.2:3217
  remote address = 192.168.1.2:3210 ]
On the server:
Code:
[ OpenRec2Server: Network: shutting down tcp connection for writing
  local address = 192.168.1.2:3210
  remote address = 192.168.1.2:3217 ]
[ OpenRec2Server: Network: closing tcp connection
  local address = 192.168.1.2:3210
  remote address = 192.168.1.2:3217 ]
[ OpenRec2Server: Network: shutting down tcp connection for writing
  local address = 192.168.1.2:3251
  remote address = 192.168.1.2:3244 ]
[ OpenRec2Server: Network: closing tcp connection
  local address = 192.168.1.2:3251
  remote address = 192.168.1.2:3244 ]
[ OpenRec2Server: Network: shutting down tcp connection for writing
  local address = 192.168.1.2:3267
  remote address = 192.168.1.2:3229 ]
[ OpenRec2Server: Network: closing tcp connection
  local address = 192.168.1.2:3267
  remote address = 192.168.1.2:3229 ]
[ OpenRec2Server: Network: shutting down tcp connection for writing
  local address = 192.168.1.2:3268
  remote address = 192.168.1.2:3260 ]
[ OpenRec2Server: Network: closing tcp connection
  local address = 192.168.1.2:3268
  remote address = 192.168.1.2:3260 ]
[ OpenRec2Server: Network: shutting down tcp connection for writing
  local address = 192.168.1.2:3216
  remote address = 192.168.1.2:3124 ]
[ OpenRec2Server: Network: closing tcp connection
  local address = 192.168.1.2:3216
  remote address = 192.168.1.2:3124 ]
[ OpenRec2Server: Network: shutting down tcp connection for writing
  local address = 127.0.0.1:3211
  remote address = 127.0.0.1:12000 ]
[ OpenRec2Server: Network: closing tcp connection
  local address = 127.0.0.1:3211
  remote address = 127.0.0.1:12000 ]
Any ideas?

Much appreciated.
__________________
Zhi Quan Lee
University of Auckland
Department of Electrical and Computer Engineering
http://se.auckland.ac.nz

Project: An Integrated Automated Framework for Managing Dynamic Reconfiguration

Supervised by Dr. Ian Warren and Dr. Jing Sun.

With respect to their paper: http://csdl2.computer.org/persagen/D...09/ASE.2006.12

Homepage:
http://zhi-lee.com

Last edited by zhi : 01-08-2007 at 07:39 PM.
Reply With Quote
  #5 (permalink)  
Old 01-08-2007
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,781
The server log is incomplete. I see only messages for closing/shutdown, but no messages like this:

[ Network: attempting to bind to tcp socket xxx ]
[ Network: accepting tcp connections at xxx ]
Reply With Quote
  #6 (permalink)  
Old 01-08-2007
zhi zhi is offline
Registered User
 
Name: Zhi Quan Lee
Organization: University of Auckland
Project: Dynamic Reconfiguration with Correctness Assurance
 
Join Date: Nov 2006
Location: Auckland
Posts: 32
Thanks for the quick reply marc. My program does several things and works fine up till the point when it is expected to read from an input stream.

Here it is the full log:
Code:
[ icegridnode: Activator: activating server `OpenRec2Server' ]
[ OpenRec2Server: Network: attempting to bind to tcp socket 127.0.0.1:0 ]
[ OpenRec2Server: Network: accepting tcp connections at 127.0.0.1:3782 ]
[ OpenRec2Server: Network: attempting to bind to tcp socket 192.168.1.2:0 ]
[ OpenRec2Server: Network: accepting tcp connections at 192.168.1.2:3783 ]
~~~~~id: analyser
[ OpenRec2Server: Network: trying to establish tcp connection to 127.0.0.1:12000
 ]
[ OpenRec2Server: Network: tcp connection established
  local address = 127.0.0.1:3784
  remote address = 127.0.0.1:12000 ]
[ OpenRec2Server: Network: trying to establish tcp connection to 192.168.1.2:371
7 ]
[ OpenRec2Server: Network: tcp connection established
  local address = 192.168.1.2:3789
  remote address = 192.168.1.2:3717 ]
[ OpenRec2Server: Network: accepted tcp connection
  local address = 192.168.1.2:3783
  remote address = 192.168.1.2:3790 ]
// PROGRAM DOES SOME IRRELEVANT STUFF HERE (OUTPUT OMMITTED)

Then it waits for some timeout and gives me this:
Code:
[ OpenRec2Server: Network: shutting down tcp connection for writing
  local address = 192.168.1.2:3789
  remote address = 192.168.1.2:3717 ]
[ OpenRec2Server: Network: closing tcp connection
  local address = 192.168.1.2:3789
  remote address = 192.168.1.2:3717 ]
[ OpenRec2Server: Network: shutting down tcp connection for writing
  local address = 192.168.1.2:3783
  remote address = 192.168.1.2:3790 ]
[ OpenRec2Server: Network: closing tcp connection
  local address = 192.168.1.2:3783
  remote address = 192.168.1.2:3790 ]
[ OpenRec2Server: Network: shutting down tcp connection for writing
  local address = 127.0.0.1:3784
  remote address = 127.0.0.1:12000 ]
[ OpenRec2Server: Network: closing tcp connection
  local address = 127.0.0.1:3784
  remote address = 127.0.0.1:12000 ]
[ OpenRec2Server: Network: shutting down tcp connection for writing
  local address = 192.168.1.2:3843
  remote address = 192.168.1.2:3831 ]
[ OpenRec2Server: Network: closing tcp connection
  local address = 192.168.1.2:3843
  remote address = 192.168.1.2:3831 ]
[ OpenRec2Server: Network: shutting down tcp connection for writing
  local address = 192.168.1.2:3840
  remote address = 192.168.1.2:3802 ]
[ OpenRec2Server: Network: closing tcp connection
  local address = 192.168.1.2:3840
  remote address = 192.168.1.2:3802 ]
[ OpenRec2Server: Network: shutting down tcp connection for writing
  local address = 192.168.1.2:3822
  remote address = 192.168.1.2:3815 ]
[ OpenRec2Server: Network: closing tcp connection
  local address = 192.168.1.2:3822
  remote address = 192.168.1.2:3815 ]
Here is the client output again:
Code:
[ Network: trying to establish tcp connection to 192.168.1.2:12000 ]
[ Network: tcp connection established
  local address = 192.168.1.2:3850
  remote address = 192.168.1.2:12000 ]
Ice.ObjectNotExistException
    id.name = "analyser"
    id.category = ""
    facet = ""
    operation = "sendModel"
        at IceInternal.Outgoing.invoke(Outgoing.java:148)
        at Ice._ObjectDelM.ice_invoke(_ObjectDelM.java:185)
        at Ice.ObjectPrxHelperBase.ice_invoke(ObjectPrxHelperBase.java:191)
        at Ice.ObjectPrxHelperBase.ice_invoke(ObjectPrxHelperBase.java:178)
        at Client.run(Client.java:113)
        at Ice.Application.main(Application.java:114)
        at Ice.Application.main(Application.java:57)
        at Client.main(Client.java:158)
==> [ Network: shutting down tcp connection for writing
  local address = 127.0.0.1:3776
  remote address = 127.0.0.1:12000 ]
[ Network: closing tcp connection
  local address = 127.0.0.1:3776
  remote address = 127.0.0.1:12000 ]
[ Network: shutting down tcp connection for writing
  local address = 192.168.1.2:3790
  remote address = 192.168.1.2:3783 ]
[ Network: closing tcp connection
  local address = 192.168.1.2:3790
  remote address = 192.168.1.2:3783 ]
[ Network: shutting down tcp connection for writing
  local address = 192.168.1.2:3850
  remote address = 192.168.1.2:12000 ]
[ Network: closing tcp connection
  local address = 192.168.1.2:3850
  remote address = 192.168.1.2:12000 ]
I changed the Client and Server iceconfigs to have the proxy and object adapter endpoints bounded to port 12000:
Code:
Ice.Default.LocatorCacheTimeout=0
Ice.Default.Locator=OpenRec2IceGrid/Locator:default -h 127.0.0.1 -p 12000
Analyser.Proxy=analyser:default -p 12000
Analyser.Endpoints=default -p 12000
Ice.Trace.Network=2
__________________
Zhi Quan Lee
University of Auckland
Department of Electrical and Computer Engineering
http://se.auckland.ac.nz

Project: An Integrated Automated Framework for Managing Dynamic Reconfiguration

Supervised by Dr. Ian Warren and Dr. Jing Sun.

With respect to their paper: http://csdl2.computer.org/persagen/D...09/ASE.2006.12

Homepage:
http://zhi-lee.com
Reply With Quote
  #7 (permalink)  
Old 01-08-2007
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,781
It appears that you have fixed the first problem. You do not get a Ice.ConnectionRefusedException anymore.

The Ice.ObjectNotExistException you get indicates that the server does not host any object with the identity "analyser".
Reply With Quote
  #8 (permalink)  
Old 01-08-2007
zhi zhi is offline
Registered User
 
Name: Zhi Quan Lee
Organization: University of Auckland
Project: Dynamic Reconfiguration with Correctness Assurance
 
Join Date: Nov 2006
Location: Auckland
Posts: 32
Thanks marc.

Is it possible to have both the locator endpoints and the object adapter endpoints both listening on port 12000? I suspect that's why the server-client connection is being shutdown when the input stream is being read.

I did in fact host the "analyser" object on the server. If you look at line 6 of the server log:
~~~~~id: analyser

is the response to the following code:
Code:
Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Analyser");
        Ice.Properties properties = communicator().getProperties();
        Ice.Identity id = communicator().stringToIdentity(properties.getProperty("Identity"));
        System.out.println("~~~~~id: " + properties.getProperty("Identity"));
        adapter.add(new AnalyserI(), id);
        adapter.activate();
__________________
Zhi Quan Lee
University of Auckland
Department of Electrical and Computer Engineering
http://se.auckland.ac.nz

Project: An Integrated Automated Framework for Managing Dynamic Reconfiguration

Supervised by Dr. Ian Warren and Dr. Jing Sun.

With respect to their paper: http://csdl2.computer.org/persagen/D...09/ASE.2006.12

Homepage:
http://zhi-lee.com
Reply With Quote
  #9 (permalink)  
Old 01-08-2007
zhi zhi is offline
Registered User
 
Name: Zhi Quan Lee
Organization: University of Auckland
Project: Dynamic Reconfiguration with Correctness Assurance
 
Join Date: Nov 2006
Location: Auckland
Posts: 32
I think the problem is that my Analyser class does not extend Ice.Blobject. As Java is unable to support multiple inheritance (my Analyser already inherits from other classes) and an ICE proxy cannot have more than one object adapter bounded to it, how do you suggest I go about giving my Analyser the ability to receive from input streams?
__________________
Zhi Quan Lee
University of Auckland
Department of Electrical and Computer Engineering
http://se.auckland.ac.nz

Project: An Integrated Automated Framework for Managing Dynamic Reconfiguration

Supervised by Dr. Ian Warren and Dr. Jing Sun.

With respect to their paper: http://csdl2.computer.org/persagen/D...09/ASE.2006.12

Homepage:
http://zhi-lee.com
Reply With Quote
  #10 (permalink)  
Old 01-09-2007
benoit's Avatar
benoit benoit is online now
ZeroC Staff
 
Name: Benoit Foucher
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Rennes, France
Posts: 1,543
Quote:
Originally Posted by zhi View Post
Thanks marc.

Is it possible to have both the locator endpoints and the object adapter endpoints both listening on port 12000? I suspect that's why the server-client connection is being shutdown when the input stream is being read.
Only one process can listen on a given port on a given machine. If you try to start two processes which are listening on the same port, the object adapter initialization in one of the 2 processes will fail with an Ice::SocketException.

Cheers,
Benoit.
Reply With Quote
  #11 (permalink)  
Old 01-09-2007
benoit's Avatar
benoit benoit is online now
ZeroC Staff
 
Name: Benoit Foucher
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Rennes, France
Posts: 1,543
Hi,

Quote:
Originally Posted by zhi View Post
I think the problem is that my Analyser class does not extend Ice.Blobject. As Java is unable to support multiple inheritance (my Analyser already inherits from other classes) and an ICE proxy cannot have more than one object adapter bounded to it, how do you suggest I go about giving my Analyser the ability to receive from input streams?
If your Analyser class can't inherit from the Ice.Blobject class, you should create another class that extends Ice.Blobject, e.g.: AnalyserBlobjectI. The implementation of this class would delegate to your Analyer class.

Btw, I don't think the Ice.ObjectNotExistException that your client is getting has anything to do with this. From the network trace and your configuration, it simply looks like you're sending the request to the wrong endpoint:

Code:
[ Network: trying to establish tcp connection to 192.168.1.2:12000 ]
[ Network: tcp connection established
  local address = 192.168.1.2:3850
  remote address = 192.168.1.2:12000 ]
Ice.ObjectNotExistException
    id.name = "analyser"
    id.category = ""
    facet = ""
    operation = "sendModel"
        at IceInternal.Outgoing.invoke(Outgoing.java:148)
        at Ice._ObjectDelM.ice_invoke(_ObjectDelM.java:185)
        at Ice.ObjectPrxHelperBase.ice_invoke(ObjectPrxHelperBase.java:191)
        at Ice.ObjectPrxHelperBase.ice_invoke(ObjectPrxHelperBase.java:178)
        at Client.run(Client.java:113)
        at Ice.Application.main(Application.java:114)
        at Ice.Application.main(Application.java:57)
        at Client.main(Client.java:158)
It looks like the request is sent to the process which is listening on the port 12000 (which is probably the IceGrid registry from looking at your configuration).

You should first sort out your configuration problems. If you're using the IceGrid registry and nodes to activate your server, why do you also specify a configuration file for your server? Why does your client use a direct proxy (and proxy with endpoints rather than an adapter id)?

You should explain a little more your deployment if you want us to help your with the configuration of your application (please specify the different machines involved, what processes are running on each machine, the configuration files of the registry and nodes as well as the depoyment descriptor used to deploy the application).

Cheers,
Benoit.
Reply With Quote
  #12 (permalink)  
Old 01-09-2007
zhi zhi is offline
Registered User
 
Name: Zhi Quan Lee
Organization: University of Auckland
Project: Dynamic Reconfiguration with Correctness Assurance
 
Join Date: Nov 2006
Location: Auckland
Posts: 32
Thanks Marc and Benoit. I should describe my program and its deployment and perhaps you could give me some guidance?

This program is about Analysing a mathematical model distributedly and returning the results to the client.

http://img215.imageshack.us/img215/6...loymentcm6.gif
The client contacts the Analyser, which resides on a node, via the registry. It sends a KodkodModel or AlloyModel by serialization to the Analyser. The KodkodModel or AlloyModel is analysed by some programming logic with the workload distributed to SubAnalysers. The final results are serialized and sent back to the client.

Slice definition:
Code:
#ifndef INVOKE_ICE
#define INVOKE_ICE

module OpenRec2 {

	exception PrintFailure	{
	    string reason;
	};
	
	class AlloySubModel {};
	
	["java:type:java.util.ArrayList<AlloySubModel>"] sequence<AlloySubModel> AlloySubModels;
	class AlloyModel {
		AlloySubModels myAlloySubModels;
		void breakdownModel();
		AlloySubModels getAlloySubModels();
	};
	

	class KodkodModel {
		void solve();
	};

	class Analyser {
		void startAnalysis();
		void solveKodkodModel(KodkodModel model);
		idempotent void shutdown();
		idempotent void shutdownNodes();
	};
	
	interface GenericSubAnalyser {
		void performAnalysis();
		bool getResult();
	};
	
	class SubAnalyser implements GenericSubAnalyser{
		AlloySubModel myAlloySubModel;
		bool result;
		idempotent void shutdown();
	};
	
	["java:type:java.util.ArrayList<SubAnalyser>"] sequence<SubAnalyser> SubAnalysers;	
	class AlloyAnalyserFactory {
		SubAnalysers mySubAnalysers;
		SubAnalysers getSubAnalysers();
		void addSubAnalyser(SubAnalyser SubA);
		void generateSubAnalysers(AlloySubModels listOfAlloySubModels);
	};	
};

#endif
Application descriptor:
Code:
<icegrid>

  <application name="OpenRec2">
    
    
    <node name="openRec2Server">
      	<server id="OpenRec2Server" exe="java" activation="on-demand">
        	<option>Server</option>
			<adapter name="Analyser" endpoints="tcp" register-process="true">
	  			<object identity="analyser" type="::OpenRec2::Analyser"/>
			</adapter>
			<property name="Identity" value="analyser"/>
      	</server>
    </node>

    <server-template id="SubAnalyser">
      <parameter name="index"/>
      <server id="SubAnalyser-${index}" exe="java" activation="on-demand">
        <option>SubAnalyserServer</option>
        <adapter name="SubAnalyser" endpoints="tcp" register-process="true" replica-group="ReplicatedSubAnalyserAdapter"/>
        <property name="Identity" value="subAnalyser"/>
      </server>
    </server-template>

    <replica-group id="ReplicatedSubAnalyserAdapter">
      <load-balancing type="round-robin"/>
      <object identity="subAnalyser" type="::OpenRec2::SubAnalyser"/>
    </replica-group>

    <node name="subAnalyserServer1">
      <server-instance template="SubAnalyser" index="1"/>
    </node>
    
    <node name="subAnalyserServer2">    
      <server-instance template="SubAnalyser" index="2"/>
	</node>
	
    <node name="subAnalyserServer3">
      <server-instance template="SubAnalyser" index="3"/>
    </node>
    
       
  </application>

</icegrid>
analyser.grid
Code:
IceGrid.InstanceName=OpenRec2IceGrid

Ice.Default.Locator=OpenRec2IceGrid/Locator:default -p 12000

IceGrid.Node.Name=openRec2Server
IceGrid.Node.Endpoints=default
IceGrid.Node.Data=db/node/analyser
IceGrid.Node.CollocateRegistry=0

IceGrid.Node.Trace.Activator=1
IceGrid.Node.Trace.Patch=1
subanalyser.grid
Code:
IceGrid.InstanceName=OpenRec2IceGrid

Ice.Default.Locator=OpenRec2IceGrid/Locator:default -p 12000

IceGrid.Node.CollocateRegistry=0
IceGrid.Node.Name=subAnalyserServer1
IceGrid.Node.Endpoints=default
IceGrid.Node.Data=db/node/subanalyser1

IceGrid.Node.Trace.Activator=1
IceGrid.Node.Trace.Patch=1
Benoit mentioned that I shouldn't be using a direct proxy. How do I alter the following to use the adapter id?
iceconfig for both the client and Analyser server:
Code:
Ice.Default.LocatorCacheTimeout=0
Ice.Default.Locator=OpenRec2IceGrid/Locator:default -h 127.0.0.1 -p 12000
Analyser.Proxy=analyser:default -p 12000
Analyser.Endpoints=default -p 12000
Ice.Trace.Network=2
AnalyserI.java (This class does not inherit from Blobject but I have included an ice_invoke method)
Code:
import java.io.IOException;
import java.util.ArrayList;

import Ice.Current;
import OpenRec2.*;

/** This class is the request handler which is called by the client
 * It instantiates a factory and obtains a list of SubAnalysers to work on
 * The work is then dispatched to available nodes and the result is
 * finally consolidated at the end.
 */
public class AnalyserI extends OpenRec2.Analyser {
	
	ArrayList<SubAnalyser> mySubAnalysers = null;
	ArrayList<SubAnalyserPrx> subAnalyserNodes = null;
	
	
	/**
	 * Starts the analysis
	 * @return Result of analysis
	 */
	public void startAnalysis(Current __current) {
		
		//************ 
		System.out.println("Process Kodkod");
		MyApp app = new MyApp();
		app.run();
		//************
		
		System.out.println();
		System.out.println("[AnalyserI] Contacting AlloyAnalyserFactory...");
		AlloyAnalyserFactoryI factory = null;
		try {
			factory = new AlloyAnalyserFactoryI();
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		
		System.out.println();
		System.out.println("[AnalyserI] Obtaining list of subAnalysers from the factory...");
		mySubAnalysers = (ArrayList) factory.getSubAnalysers(__current);
		
		System.out.println("[AnalyserI] Connecting to SubAnalyserServer ...");
		
		// Keep a record of the nodes in a list
		subAnalyserNodes = new ArrayList<SubAnalyserPrx>();
		
		// The following code connects to the SubAnalyser Server (which may be replicated across nodes)
		SubAnalyserPrx subAnalyserNode = null;
		
		for (SubAnalyser sub: mySubAnalysers ){
			try {
				Ice.ObjectPrx basePrx = Ice.Application.communicator().stringToProxy("subAnalyser");
				
				subAnalyserNode = SubAnalyserPrxHelper.checkedCast(basePrx);
			} catch (Ice.NotRegisteredException e) {
				final String proxy = "OpenRec2IceGrid/Query";
				IceGrid.QueryPrx query = IceGrid.QueryPrxHelper.checkedCast(Ice.Application.communicator().stringToProxy(proxy));
				subAnalyserNode = SubAnalyserPrxHelper.checkedCast(query.findObjectByType("::OpenRec2::SubAnalyser"));
			}
			if(subAnalyserNode == null) {
				System.err.println("couldn't find a `::OpenRec2::SubAnalyser' object");
			}
			else {
				subAnalyserNodes.add(subAnalyserNode);
			}
		}
		
		
		boolean isMigrationSucessful = true;
		
		int noOfNodes = subAnalyserNodes.size();
		Thread[] subAnalyserThreads = new Thread[noOfNodes];
		
		for (int i = 0; i < noOfNodes; i++) {
			subAnalyserThreads[i] = new Thread(new SubAnalyserThread(subAnalyserNodes.get(i)));
			System.out.println("[AnalyserI] Thread spawned for SubAnalyserPrx: " + subAnalyserThreads[i].toString());
			subAnalyserThreads[i].start();
			System.out.println("[AnalyserI] Thread started.");
		}
		
		for (int i = 0; i < noOfNodes; i++) {
			try {
				subAnalyserThreads[i].join();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		
		System.out.println("[AnalyserI] Consolidating results from the sub-analysis'");
		for (SubAnalyserPrx sub : subAnalyserNodes) {
			if (!sub.getResult()) {
				isMigrationSucessful = false;
			}
		}
		
		
		if(isMigrationSucessful) {
			System.out.println();
			System.out.println("[AnalyserI] Migration is sucessful and the process is verified to be running correctly.");
		}
		else {
			System.out.println();
			System.out.println("[AnalyserI] The migrated process is not running correctly.");
		}
		
	}
	
	public void shutdown(Ice.Current current) {
		System.out.println(this.toString() + " shutting down Analyser server...");
		current.adapter.getCommunicator().shutdown();
	}
	
	public void shutdownNodes(Ice.Current current) {
		System.out.println(this.toString() + " shutting down SubAnalyser nodes...");
		for (SubAnalyserPrx subPrx : subAnalyserNodes) {
			subPrx.shutdown();
		}		
	}
	
	public void solveKodkodModel(KodkodModel model, Current __current) {
		System.out.println("[AnalyserI] Analyser is solving Kodkod model");
	}

	// For de-marshalling
	public boolean ice_invoke(byte[] inParams, Ice.ByteSeqHolder outParams, Ice.Current current) {
		Ice.Communicator communicator = current.adapter.getCommunicator();

        Ice.InputStream in = null;
        if(inParams.length > 0)
        {
            in = Ice.Util.createInputStream(communicator, inParams);
        }
        
        if(current.operation.equals("sendKodkod"))
        {
        	KodkodModelHolder modelHolder = new KodkodModelHolder();
            KodkodModelHelper.read(in, modelHolder);
            in.readPendingObjects();
            in.destroy();
            modelHolder.value.solve();
            return true;
        }
        return false;
	}
}
__________________
Zhi Quan Lee
University of Auckland
Department of Electrical and Computer Engineering
http://se.auckland.ac.nz

Project: An Integrated Automated Framework for Managing Dynamic Reconfiguration

Supervised by Dr. Ian Warren and Dr. Jing Sun.

With respect to their paper: http://csdl2.computer.org/persagen/D...09/ASE.2006.12

Homepage:
http://zhi-lee.com
Reply With Quote
  #13 (permalink)  
Old 01-09-2007
zhi zhi is offline
Registered User
 
Name: Zhi Quan Lee
Organization: University of Auckland
Project: Dynamic Reconfiguration with Correctness Assurance
 
Join Date: Nov 2006
Location: Auckland
Posts: 32
The client class:
Code:
import OpenRec2.*;

public class Client extends Ice.Application{

	private void menu() {
		System.out.println(
				"usage:\n" +
				"a: analyse an ALLOY model\n" +
				"s: shutdown server\n" +
				"n: shutdown all SubAnalyser nodes\n" +
				"x: exit\n" +
				"?: help\n");
	}


	public Client() {
	}

	public int run(String[] args) {
		AnalyserPrx analyser = null;
		KodkodModelPrx kodkod = null;
		
		Ice.Properties properties = communicator().getProperties();
        final String proxyProperty = "Analyser.Proxy";
        String proxy = properties.getProperty(proxyProperty);
        if(proxy.length() == 0)
        {
            System.err.println("property `" + proxyProperty + "' not set");
            return 1;
        }

        Ice.ObjectPrx obj = communicator().stringToProxy(proxy);

        
		try {
			Ice.ObjectPrx basePrx = Ice.Application.communicator().stringToProxy("analyser");
			analyser = AnalyserPrxHelper.checkedCast(basePrx);
			
			/*
			Ice.ObjectPrx kodkodBasePrx = Ice.Application.communicator().stringToProxy("kodkod");
			kodkod = KodkodModelPrxHelper.checkedCast(kodkodBasePrx);
			*/
			
		} catch (Ice.NotRegisteredException e) {
			proxy = "OpenRec2IceGrid/Query";
			IceGrid.QueryPrx query = IceGrid.QueryPrxHelper.checkedCast(communicator().stringToProxy(proxy));
			analyser = AnalyserPrxHelper.checkedCast(query.findObjectByType("::OpenRec2::Analyser"));
			
			/*
			final String kodkodProxy = "OpenRec2IceGrid/Query";
			IceGrid.QueryPrx kodkodQuery = IceGrid.QueryPrxHelper.checkedCast(communicator().stringToProxy(kodkodProxy));
			kodkod = KodkodModelPrxHelper.checkedCast(query.findObjectByType("::OpenRec2::Kodkod"));
			*/
		}
		if(analyser == null)
		{
			System.err.println("couldn't find a `::OpenRec2::Analyser' object");
			return 1;
		}
		 
		if(kodkod == null)
		{
			System.err.println("couldn't find a `::OpenRec2::Kodkod' object");
			return 1;
		}

		
		menu();

		java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));

		String line = null;
		do
		{
			try
			{
				System.out.print("==> ");
				System.out.flush();
				line = in.readLine();
				if(line == null)
				{
					break;
				}
				if(line.equals("a"))
				{
					analyser.startAnalysis();
					

					
					OpenRecModel sudoku = new MySudokuModel(3);
					
                    //
                    // Marshal the in parameter.
                    //
                    Ice.OutputStream out = Ice.Util.createOutputStream(communicator());
                    OpenRec2.KodkodModel model = new KodkodModelI(sudoku);
                    
                    KodkodModelHelper.write(out, model);
                    out.writePendingObjects();

                    //
                    // Invoke operation.
                    //
                    if(!obj.ice_invoke("sendModel", Ice.OperationMode.Normal, out.finished(), null))
                    {
                        System.out.println("Unknown user exception");
                    }
                    out.destroy();				
				}
				else if(line.equals("s"))
				{
					analyser.shutdown();
				}
				else if(line.equals("n"))
				{
					analyser.shutdownNodes();
				}
				else if(line.equals("x"))
				{
					// Nothing to do
				}
				else if(line.equals("?"))
				{
					menu();
				}
				else
				{
					System.out.println("unknown command `" + line + "'");
					menu();
				}
			}
			catch(java.io.IOException ex)
			{
				ex.printStackTrace();
			}
			catch(Ice.LocalException ex)
			{
				ex.printStackTrace();
			}
		}
		while(!line.equals("x"));

		return 0;
	}


	public static void main(String[] args) {
		Client app = new Client();
		int status = app.main("Client", args, "iceconfig");
		System.exit(status);
	}
}
The server class:
Code:
public class Server extends Ice.Application{

	public int run(String[] args) {
        Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Analyser");
        Ice.Properties properties = communicator().getProperties();
        Ice.Identity id =