Archived

This forum has been archived. Please start a new discussion on GitHub.

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:
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:
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:
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=

Comments

  • This is the client 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.
                        //
    [COLOR="Red"]                    if(!obj.ice_invoke("sendModel", Ice.OperationMode.Normal, out.finished(), null))
    [/COLOR]                    {
                            System.out.println("Unknown user exception");
                        }
                        out.destroy();	
    
  • marc
    marc Florida
    You should be able to find out what's wrong with tracing. Please have a look at this FAQ.
  • This is the trace I get on the client:
    [ 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:
    [ 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.
  • marc
    marc Florida
    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 ]
  • 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:
    [ 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:
    [ 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:
    [ 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:
    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
    
  • marc
    marc Florida
    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".
  • 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:
    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();
    
  • 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?
  • benoit
    benoit Rennes, France
    zhi wrote: »
    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.
  • benoit
    benoit Rennes, France
    Hi,
    zhi wrote: »
    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:
    [ 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.
  • 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.

    deploymentcm6.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:
    #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:
    <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
    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
    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:
    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)
    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;
    	}
    }
    
  • The client class:
    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:
    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 = communicator().stringToIdentity(properties.getProperty("Identity"));
            adapter.add(new AnalyserIBlobject(), id);
            adapter.activate();
            communicator().waitForShutdown();
            return 0;
        }
    
        static public void
        main(String[] args)
        {
    	Server app = new Server();
    	int status = app.main("Server", args, "iceconfig");
    	System.exit(status);
        }
    
    }
    

    I start the nodes like this:
    start icegridregistry --Ice.Config=registry.grid
    icegridadmin --Ice.Config=registry.grid -e "application add 'application.xml'"
    start icegridnode --Ice.Config=analyser.grid
    start icegridnode --Ice.Config=subanalyser1.grid
    start icegridnode --Ice.Config=subanalyser2.grid
    start icegridnode --Ice.Config=subanalyser3.grid
    java Client

    Would appreciate your help in getting the configurations correct.

    Thanks in advance.
  • benoit
    benoit Rennes, France
    I'll only point out few things you should look at as giving you full guidance is a bit ouf of the scope of the free support we can provide on the forums (of course, we could provide you with some consultancy services, if you're interested please contact info@zeroc.com).

    It's not clear from the client code how you retrieve the proxy on the "analyser" object as there's some commented out code. It looks like you don't use the property from the configuration file at all but instead use the proxy of the well-known object "analyser" (see the manual for more information on well-known objects). Such a proxy is in an "indirect proxy". If you use this proxy, you don't need to specify a property for the proxy in the client configuration file.

    The server configuration property "Analyser.Endpoints=default -p 12000" is useless in the client configuration file since the servers are managed by the IceGrid node. The IceGrid node creates the configuration files for each server from the configuration of the deployment descriptors.

    Why are you using a replica group for the sub analyser servers? A replica group is useful when you want to replicate some objects. In your case, it's not really the case as each sub analyser object has its own state.

    I would recommend to strip down your application to the minimum (e.g.: just try to get the "analyser" server with an empty implementation to work with the client) and then add more features step by step if everything works.

    I also encourage you to read the Ice manual and try the Ice demos included with your Ice distribution. You can also take a look at the Ice newsletter articles, "Teach Yourself IceGrid in 10 Minutes" from the issue 19 should give a good idea on IceGrid for instance.

    Cheers,
    Benoit.
  • I just wanna say thanks heaps for all your help. You have been very helpful. :)