Changeset 2745


Ignore:
Timestamp:
07/02/12 02:02:49 (2 years ago)
Author:
lowjoel
Message:

Some code cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/EraserService/Eraser.Manager/RemoteExecutor.cs

    r2742 r2745  
    2828using System.Runtime.Remoting.Channels; 
    2929using System.Runtime.Remoting.Channels.Ipc; 
     30using System.Runtime.Serialization.Formatters; 
    3031using System.Security.Principal; 
    31 //using System.Security.AccessControl; 
    3232 
    3333namespace Eraser.Manager 
     
    6969 
    7070 
    71             // Expose an object for remote calls. 
    72             RemotingConfiguration.RegisterWellKnownServiceType( 
    73                 typeof(DirectExecutor), ServerName, 
    74                 System.Runtime.Remoting.WellKnownObjectMode.Singleton); 
     71            //Expose the DirectExecutor object for remote calls. 
     72            RemotingServices.Marshal(this, ServerName); 
    7573 
     74            //Expose a factory for Task objects. 
     75            RemotingConfiguration.RegisterActivatedServiceType(typeof(Task)); 
    7676        } 
    7777 
     
    8383 
    8484    /// <summary> 
    85     /// The RemoteExecutorServer class is the client half required for remote execution 
     85    /// The RemoteExecutorClient class is the client half required for remote execution 
    8686    /// of tasks, sending requests to the server running on the local computer. 
    8787    /// </summary> 
     88    /// <remarks>If a RemoteExecutorClient object has been constructed, all Task objects can 
     89    /// only be used with RemoteExecutorServer. 
     90    ///  
     91    /// TODO: For this restriction to be lifted, every Executor needs to have a factory method 
     92    /// to get the Task type for each executor. 
     93    /// See http://msdn.microsoft.com/en-us/library/ff650208.aspx 
     94    /// </remarks> 
    8895    public class RemoteExecutorClient : Executor 
    8996    { 
    9097        public RemoteExecutorClient() 
    9198        { 
    92             // Create the channel. 
     99            //Create the channel. 
    93100            IpcChannel channel = new IpcChannel(); 
    94101 
    95             // Register the channel. 
     102            //Register the channel. 
    96103            ChannelServices.RegisterChannel(channel, true); 
    97104 
    98             // Register as client for remote object. 
    99             WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry( 
    100                 typeof(RemoteExecutorServer), 
    101                 "ipc://localhost:9090/" + RemoteExecutorServer.ServerName); 
    102             RemotingConfiguration.RegisterWellKnownClientType(remoteType); 
    103  
     105            //Register the Client-activated Task class. 
     106            RemotingConfiguration.RegisterActivatedClientType(typeof(Task), 
     107                "ipc://localhost:9090"); 
    104108            Run(); 
    105109        } 
     
    119123            try 
    120124            { 
     125                //TODO: is there a better way to verify that we can connect to our Remote instance? 
    121126                //Create an instance of the remote object. 
    122                 DirectExecutor client = (DirectExecutor)Activator.GetObject(typeof(DirectExecutor), 
     127                Task task2 = new Task(); 
     128                Client = (DirectExecutor)Activator.GetObject(typeof(DirectExecutor), 
    123129                    "ipc://localhost:9090/" + RemoteExecutorServer.ServerName); 
    124  
    125                 //Try to connect to the server instance. 
    126                 //TODO: is there a better way? 
    127                 int x = client.Tasks.Count; 
    128                 Client = client; 
    129130                IsConnected = true; 
    130131            } 
     
    153154            Client.QueueRestartTasks(); 
    154155        } 
    155  
     156         
    156157        internal override bool IsTaskQueued(Task task) 
    157158        { 
Note: See TracChangeset for help on using the changeset viewer.