Ejemplo n.º 1
0
 /// <summary>
 /// Internal execute function to be called asynchronously.
 /// </summary>
 /// <param id="state">The server state object associated with the execution.</param>
 private static void execute(ServerState state)
 {
     Interlocked.Increment(ref runningJobs);
     //get the execution context
     SerializationEngine serializer = new SerializationEngine ();
     Transfers.ExecutionContext context = (Transfers.ExecutionContext)serializer.Deserialize(state.GetDataArray());
     byte[] res = DomainManager.ExecuteIncoming(context);
     Transfers.ExecutionResult result = new Transfers.ExecutionResult(res, context.ContextID, context.DomainKey, ClusterManager.NodeID);
     state.Write(MessageType.EXECUTION_COMPLETE, serializer.Serialize(result));
     Interlocked.Decrement(ref runningJobs);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// A dispatch event to be rasied upon reception of an assembly from the Presto client application.
 /// </summary>
 /// <param id="state">The server state object recieved along with this event.</param>
 private static void recieveAssemblyMaster(ServerState state)
 {
     //close the socket
     state.CloseSocket();
     //create a new domain and add the assembly to it
     string domainkey = Generator.RandomAlphaNumeric(Config.UIDLength);
     DomainManager.CreateDomain(domainkey);
     DomainManager.LoadAssemblyIntoDomain(domainkey, state.GetDataArray());
     //push assembly onto executor to be executed
     Executor.ExecuteModule(domainkey);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// A dispatch event to be rasied upon reception of an assembly from another Presto server..
 /// </summary>
 /// <param id="state">The server state object recieved along with this event.</param>
 private static void recieveAssemblySlave(ServerState state)
 {
     //get the slave assembly struct
     SerializationEngine serializer = new SerializationEngine ();
     SlaveAssembly slaveAssembly = (SlaveAssembly)serializer.Deserialize(state.GetDataArray());
     //create the domain and add the assembly to it
     DomainManager.CreateDomain(slaveAssembly.DomainKey);
     if(!DomainManager.DomainHasAssembly(slaveAssembly.DomainKey, slaveAssembly.AssemblyName)){
         DomainManager.LoadAssemblyIntoDomain(slaveAssembly.DomainKey, slaveAssembly.AssemblyImage);
     }
     Presto.Remote.Node from = Nodes.GetNodeByID(slaveAssembly.NodeID);
     if (from != null)
     {
         from.SetLoadedAssembly(slaveAssembly.AssemblyName);
         from.SetLoadedDomain(slaveAssembly.DomainKey);
     }
     //send back assembly transfer complete message
     state.Write(MessageType.ASSEMBLY_TRANSFER_COMPLETE);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Recieve a user message from a remote node.
 /// </summary>
 /// <param name="state">The server state object of this transfer.</param>
 private static void receiveMessage(ServerState state)
 {
     SerializationEngine serializer = new SerializationEngine ();
     UserMessage message = (UserMessage)serializer.Deserialize(state.GetDataArray());
     DomainManager.DeliverMessage(message);
 }