Package lupos.event.communication

Examples of lupos.event.communication.TcpConnectInfo


  protected static SerializingMessageService connectToMaster(){
    // create communication channel
    SerializingMessageService msgService = null;
    try {
      msgService = new SerializingMessageService(TcpMessageTransport.class);
      msgService.connect(new TcpConnectInfo(JOptionPane.showInputDialog("Enter the host IP adress of the MasterBroker:", "localhost"), Integer.parseInt(JOptionPane.showInputDialog("Enter the host port of the MasterBroker:", "4444"))));
      msgService.sendMessage(new ConnectionRequest(ConnectionRequest.REQUESTTYPE_PRODUCER));
    } catch (Exception e) {
      e.printStackTrace();
    }
    return msgService;
View Full Code Here


      msgService.setConnectionPort(((ConnectionRequest)msg).getPort());
     
      switch (((ConnectionRequest) msg).getRequestType()){
     
      case ConnectionRequest.REQUESTTYPE_PRODUCER:
        TcpConnectInfo tcpInfo = getProducerConnectBroker();
        try {
          msgService.sendMessage(tcpInfo);
          System.out.println("Producer redirected to "+tcpInfo.getHost()+":"+tcpInfo.getPort());
        } catch (IOException e) {
          e.printStackTrace();
        }
        break;
       
      case ConnectionRequest.REQUESTTYPE_BROKER:
        // put this sub broker in a hashtable
        SubBrokerData subBroker = new SubBrokerData(msgService);
        this.subBrokers.put(subBroker.getID(), subBroker);
        subBroker.getMessageService().addDisconnectHandler(this);
        System.out.println("Registered a SubBroker connection: "+msgService.getConnectionInfo().getHost()+":"+msgService.getConnectionInfo().getPort());
       
        break;
       
      case ConnectionRequest.REQUESTTYPE_CONSUMER:
        TcpConnectInfo tcpInfo2 = getConsumerConnectBroker();
        try {
          msgService.sendMessage(tcpInfo2);
          System.out.println("Consumer redirected to "+tcpInfo2.getHost()+":"+tcpInfo2.getPort());
        } catch (IOException e) {
          e.printStackTrace();
        }
        break
      }
     
    }
   
    else if (msg instanceof ModelUpdateMessage){
      TcpConnectInfo tcpInfo = ((SerializingMessageService)src).getConnectionInfo();
      SubBrokerData subBroker = null;
      for (SubBrokerData sub : this.subBrokers.values()){
        if (sub.getMessageService().getConnectionInfo().equals(tcpInfo)){
          subBroker = sub;
          break;
        }
      }
      if (subBroker != null){
        // update model of this sub broker
        ModelUpdateMessage message = (ModelUpdateMessage)msg;
        subBroker.setRegisteredProducers(message.getProducers());
        subBroker.setRegisteredConsumers(message.getConsumers());
        System.out.println("Recieved and stored update from SubBroker "+tcpInfo.getHost()+":"+tcpInfo.getPort());
      }
    }
  }
View Full Code Here

  public static void main(String[] args) throws Exception {

    // create communication channel
    SerializingMessageService msgService = new SerializingMessageService(
        TcpMessageTransport.class);
    msgService.connect(new TcpConnectInfo(
        ProducerBase.askForHostOfBroker(), 4444));

    // create new AlarmWindow
    AlarmWindow aw = new AlarmWindow();
View Full Code Here

   */
  public static void main(String[] args) throws Exception {
    // create communication channel
    SerializingMessageService msgService = new SerializingMessageService(
        TcpMessageTransport.class);
    msgService.connect(new TcpConnectInfo("localhost", 4444));

    // start producer
    new MensaProducer(msgService, 30000).start();
  }
View Full Code Here

 
 
  public static void main(String[] args) throws Exception {
    // create communication channel
    SerializingMessageService msgService = new SerializingMessageService(TcpMessageTransport.class);
    msgService.connect(new TcpConnectInfo("localhost", 4444));
   
    // start producer
    new EbayProducer(msgService).start();
  }
View Full Code Here

TOP

Related Classes of lupos.event.communication.TcpConnectInfo

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.