Package mephi.cybernetics.dhcn.common.data.result

Examples of mephi.cybernetics.dhcn.common.data.result.ResultPool


                {
                    System.out.println("Task");
                    DataTask task = (DataTask)message;
                    if (task.getTypeNode() == Config.NODE_CLIENT)
                    {
                        this.pools.add(new ResultPool(1, task.getTaskId(), this.counterPoolId, task.getNodeId(), true, task.getNumOfMessage()));
                        task.setTargetId(this.counterPoolId);
                        this.counterPoolId++;
                    }
                    switch (task.getTaskId())
                    {
                        case Config.MATRIX_MULT_NUM:
                        {
                            System.out.println("Matrix multi num");
                            break;
                        }
                        case Config.VECTOR_MULT_NUM:
                        {
                            System.out.println("Vector multi num");
                            break;
                        }
                        case Config.NUM_MULT_NUM:
                        {
                            System.out.println("Num multi num");
                            break;
                        }
                    }
                    if (!this.writeTask(task))
                    {
                        this.messages.add(message);
                    }
                    continue;
                   
                }
                if ( DataResult.class.isAssignableFrom(message.getClass()))
                {
                     DataResult result = (DataResult)message;
                     if (DataMatrixMultNumResult.class.isAssignableFrom(result.getClass()))
                     {
                          System.out.println("ResultMatrixMultiNum");
                     }
                     if (DataVectorMultNumResult.class.isAssignableFrom(result.getClass()))
                     {
                         System.out.println("ResultVectorMultiNum");
                     }
                     if (DataNumMultNumResult.class.isAssignableFrom(result.getClass()))
                     {
                         System.out.println("ResultNumMultiNum");
                     }
                    
                     ResultPool pool = searchPool(result.getIdTarget());
                     if (pool != null)
                     {
                         pool.addToPool(result);
                         nodeFree(result.getNodeId());
                         System.out.println("Add to pool");
                         if (pool.isFull())
                         {
                             if (pool.IsResultClient())
                             {
                                 this.writeMessage(pool.getElemPool(0), pool.getTargetId());
                                 this.pools.remove(pool);
                                 System.out.println("Size pool array: " + this.pools.size());
                             }
                             else
                             {
                                 this.messages.add(pool);
                                 this.pools.remove(pool);
                             }
                         }
                        
                     }
                    continue;
                }
                if ( ResultPool.class.isAssignableFrom(message.getClass()))
                {
                   System.out.println("Sent pool");
                   if(!this.writePool((ResultPool)message))
                   {
                       this.messages.add(message);
                   }
                   continue;
                }
               
                if ( MDispatcherID.class.isAssignableFrom(message.getClass()))
                {
                    MDispatcherID dispatcherId = (MDispatcherID)message;
                    this.id = dispatcherId.id;
                    continue;
                }

                if ( INodeInfo.class.isAssignableFrom(message.getClass()))
                {
                    if (NodeInfoSocket.class.isAssignableFrom(message.getClass()))
                    {
                        System.out.println("New Node");
                        NodeInfoSocket info = (NodeInfoSocket)message;
                        switch (info.getType())
                        {
                            case Config.NODE_CLIENT :
                            {
                                System.out.println("Client");
                                break;
                            }
                            case Config.NODE_SOLVER :
                            {
                                System.out.println("Solver");
                                break;
                            }
                            case Config.NODE_DISPATCHER :
                            {
                                System.out.println("Dispatcher");
                                break;
                            }
                        }
//                        INodeConfig config = null;
//                        if ((info.getType() == Config.NODE_CLIENT) || (info.getType() == Config.NODE_SOLVER))
//                        {
//                            config = new NodeConfigSocket(info.getIp(), info.getPort(), this.counterNodeId, info.getType(), info.getTaskTypes());
//                        }
//                        if (info.getType() == Config.NODE_DISPATCHER)
//                        {
//                            config = new NodeConfigSocket(info.getIp(), info.getPort(), this.counterNodeId, info.getType(), info.getTaskTypes());
//                            NodeInfoSocket dispatcherInfo = new NodeInfoSocket(this.ip, this.port, this.counterNodeId, null, this.id);
//                            this.manager.writeData(dispatcherInfo, config);
//                        }
                        INodeConfig config = new NodeConfigSocket(info.getIp(), info.getPort(), this.counterNodeId, info.getType(), info.getTaskTypes());
                        this.nodes.add(config);
                        counterNodeId++;
                    }
                    continue;
                }
               
                if ( NewPoolResultConfig.class.isAssignableFrom(message.getClass()))
                {
                   
                    NewPoolResultConfig config = (NewPoolResultConfig)message;
                    System.out.println("Pool new Size: "  + config.getSizePool() + "TaskId: " + config.getTaskId());
                    this.pools.add(new ResultPool(config.getSizePool(), config.getTaskId(), this.counterPoolId, config.getTargetId(), false, config.getNumOfMessage()));
                    for (int i = 0; i < config.getSizePool(); i++)
                    {
                        DataTask task = config.getTask(i);
                        task.setTargetId(this.counterPoolId);
                        this.messages.add(task);
View Full Code Here


            return null;
        }
       
        if ( ResultPool.class.isAssignableFrom(data.getClass()))
        {
            ResultPool pool = (ResultPool)data;
            for (int i = 0; i < this.solvers.size(); i++)
            {
                if (pool.getTaskId() == solvers.get(i).getTaskId())
                {
                    return solvers.get(i).assembly(pool);
                }
            }
            return null;
View Full Code Here

TOP

Related Classes of mephi.cybernetics.dhcn.common.data.result.ResultPool

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.