Esempio n. 1
1
 public void fireEvent(NCCPConnection.ConnectionEvent e) {
   ConnectionListener l;
   int max = listeners.size();
   for (int i = 0; i < max; ++i) {
     ExpCoordinator.print(
         new String(
             "NCCPConnection.fireEvent ("
                 + toString()
                 + ") event: "
                 + e.getType()
                 + " max:"
                 + max
                 + " i:"
                 + i),
         2);
     l = (ConnectionListener) (listeners.elementAt(i));
     switch (e.getType()) {
       case ConnectionEvent.CONNECTION_FAILED:
         l.connectionFailed(e);
         break;
       case ConnectionEvent.CONNECTION_CLOSED:
         l.connectionClosed(e);
         break;
       case ConnectionEvent.CONNECTION_OPENED:
         ExpCoordinator.printer.print(
             new String("Opened control connection (" + toString() + ")"));
         l.connectionOpened(e);
     }
   }
 }
Esempio n. 2
0
 public void setConnected(boolean b, boolean process_pending) {
   if (b && state != ConnectionEvent.CONNECTION_OPENED) {
     if (host.length() > 0)
       ExpCoordinator.print(
           "NCCPConnection open connection to ipaddress " + host + " port " + port);
     state = ConnectionEvent.CONNECTION_OPENED;
     // connected = true;
     fireEvent(new ConnectionEvent(this, state));
     ExpCoordinator.printer.print("NCCPConnection.setConnected " + b + " event fired", 8);
     if (process_pending) {
       int max = pendingMessages.size();
       ExpCoordinator.printer.print(new String("   pendingMessages " + max + " elements"), 8);
       for (int i = 0; i < max; ++i) {
         sendMessage((NCCP.Message) pendingMessages.elementAt(i));
       }
       pendingMessages.removeAllElements();
     }
   } else {
     if (!b
         && (state != ConnectionEvent.CONNECTION_CLOSED
             || state != ConnectionEvent.CONNECTION_FAILED)) {
       if (host.length() > 0)
         ExpCoordinator.print(
             new String(
                 "NCCPConnection.setConnected -- Closed control socket for " + host + "." + port));
       state = ConnectionEvent.CONNECTION_CLOSED;
       fireEvent(new ConnectionEvent(this, state));
     }
   }
 }
Esempio n. 3
0
 public void mouseReleased(MouseEvent e) {
   if (ltool.isEnabled()) {
     if (endComponent instanceof GigEDescriptor)
       endComponent = ((GigEDescriptor) endComponent).getUnlinkedPort();
     if (!ltool.addLink(linkGraphic, endComponent)) {
       ExpCoordinator.print(
           new String(
               "LinkTool.ComponentListener::mouseReleased from "
                   + startComponent.getLabel()
                   + " cancelled"),
           TEST_ADD);
       if (ltool.isVirtualTopology())
         ltool
             .expCoordinator
             .getCurrentExp()
             .getVirtualTopology()
             .getTopologyPanel()
             .removeLink(linkGraphic);
       else ExpCoordinator.getMainWindow().getTopologyPanel().removeLink(linkGraphic);
     }
     startComponent = null;
     endComponent = null;
     linkGraphic = null;
     ltool.setEnabled(false);
   }
 }
Esempio n. 4
0
  protected void addLink(LinkGraphic lg) {
    LinkDescriptor comp = (LinkDescriptor) lg.getONLComponent();
    ExpCoordinator.print(
        new String(
            "LinkTool::addLink "
                + comp.getPoint1().getLabel()
                + " to "
                + comp.getPoint2().getLabel()));

    lg.getONLComponent().setLabel(new String("explink" + count));
    expCoordinator.getCurrentExp().addLink(comp);
    ++count;
  }
Esempio n. 5
0
 public Object getUIRep() {
   if (uiRepCopy == null) {
     if (field == null)
       ExpCoordinator.print(
           new String("FieldParam(" + getLabel() + ").getUIRep field is null"), TEST_UIREP);
     else
       ExpCoordinator.print(
           new String("FieldParam(" + getLabel() + ").getUIRep field:" + field.toString()),
           TEST_UIREP);
     uiRepCopy = field.getUIRepCopy(isEditable());
     setUIRep(uiRepCopy.getComponent());
   }
   return (super.getUIRep());
 }
Esempio n. 6
0
 public void mousePressed(MouseEvent e) {
   if (ltool.isEnabled()) {
     startComponent = ((ONLComponentButton) e.getSource()).getONLComponent();
     if (startComponent instanceof GigEDescriptor) {
       ExpCoordinator.print(
           new String(
               "LinkTool.ComponentListener.mousePressed gige startComponent:"
                   + startComponent.getLabel()),
           TEST_GIGE);
       startComponent = ((GigEDescriptor) startComponent).getUnlinkedPort();
       if (startComponent != null)
         ExpCoordinator.print(
             new String("  unlinked port: " + startComponent.getLabel()), TEST_GIGE);
       else ExpCoordinator.print("  unlinked port: null", TEST_GIGE);
     }
     if (startComponent instanceof HardwareHost)
       startComponent = ((HardwareHost) startComponent).getPort(0);
     endComponent = null;
     if (startComponent.isLinkable() && (!startComponent.isLinked())) {
       LinkDescriptor ld =
           ltool.createLinkDescriptor(
               startComponent); // new LinkDescriptor(ltool.getNextLabel(), startComponent,
                                // ltool.currentBW, ltool.expCoordinator);
       linkGraphic = (LinkGraphic) ld.getGraphic();
       if (linkGraphic.getONLComponent() == null)
         ExpCoordinator.print("LinkTool.ComponentListener::mousePressed onlcomp == null", 2);
       // linkGraphic = new LinkGraphic();
       // linkGraphic.setPoint1(startComponent.getGraphic());
       linkGraphic.setVisible(true);
       ltool
           .getTopologyPanel()
           .addLink(linkGraphic); // expCoordinator.getMainWindow().getTopologyPanel()
       // System.out.println("LinkTool.ComponentListener::mousePressed component " +
       // startComponent.getLabel());
       setIntermediate(
           e.getPoint(), ((ONLComponentButton) e.getSource()).getONLComponent().getGraphic());
     } else {
       ExpCoordinator.print(
           new String(
               "LinkTool::mousePressed startComponent "
                   + startComponent.getLabel()
                   + " is Linked"),
           2);
       startComponent = null;
       ltool.setEnabled(false);
     }
   }
 }
Esempio n. 7
0
  private boolean connectSPPMon() {
    if (state == ConnectionEvent.CONNECTION_PENDING) {
      ExpCoordinator.print(
          new String("NCCPConnection(" + host + ", " + port + ").connect connection pending"), 0);
      while (state == ConnectionEvent.CONNECTION_PENDING) {
        try {
          Thread.sleep(500);
        } catch (java.lang.InterruptedException e) {
        }
      }
      return (isConnected());
    }

    state = ConnectionEvent.CONNECTION_PENDING;
    if (nonProxy != null) {
      try {
        nonProxy.connect();
      } catch (UnknownHostException e) {
        boolean rtn = informUserError("Don't know about host: " + host + ":" + e.getMessage());
        return rtn;
      } catch (SocketTimeoutException e) {
        boolean rtn = informUserError("Socket time out for " + host + ":" + e.getMessage());
        return rtn;
      } catch (IOException e) {
        boolean rtn = informUserError("Couldnt get I/O for " + host + ":" + e.getMessage());
        return rtn;
      }
    }
    return (isConnected());
  }
Esempio n. 8
0
 public boolean connect() {
   ExpCoordinator.printer.print("NCCPConnection.connect", 3);
   if (host.length() == 0) {
     ExpCoordinator.printer.print("NCCPConnection.connect host is not set", 6);
     return false;
   }
   if (proxy == null && nonProxy == null) {
     ExpCoordinator.printer.print("NCCPConnection.connect proxy null");
     return false;
   }
   if (ExpCoordinator.isSPPMon()) return (connectSPPMon());
   if (state == ConnectionEvent.CONNECTION_CLOSED || state == ConnectionEvent.CONNECTION_FAILED) {
     state = ConnectionEvent.CONNECTION_PENDING;
     if (proxy != null) {
       proxy.openConnection(this);
     }
   }
   /*
   if (nonProxy != null && proxy == null)
   {
   	return (nonProxy.connect());
   }
   */
   return true;
 }
Esempio n. 9
0
 public void read(ONL.Reader rdr) throws java.io.IOException {
   setHost(new String(rdr.readString()));
   setPort(rdr.readInt());
   short cid = (short) rdr.readShort();
   ExpCoordinator.print(
       new String("NCCPConnection.read host:" + getHost() + " port:" + getPort() + " cid:" + cid),
       5);
   if (proxy != null) proxy.setConnectionID(this, cid);
 }
Esempio n. 10
0
 protected boolean informUserError(String msg) // this is just for SPPmon
     {
   if (!ExpCoordinator.isSPPMon()) return false;
   final String opt0 = "Try Again";
   final String opt1 = "Cancel";
   JLabel lbl = new JLabel(msg);
   TextFieldwLabel tfaddress = new TextFieldwLabel(30, "daemon addr:");
   tfaddress.setText(host);
   TextFieldwLabel tfport = new TextFieldwLabel(30, "daemon port:");
   tfport.setText(String.valueOf(port));
   Object[] params = {lbl, tfaddress, tfport};
   Object[] options = {opt0, opt1};
   int rtn =
       JOptionPane.showOptionDialog(
           ExpCoordinator.getMainWindow(),
           params,
           "Connection Error",
           JOptionPane.YES_NO_OPTION,
           JOptionPane.WARNING_MESSAGE,
           null,
           options,
           options[0]);
   if (rtn == JOptionPane.NO_OPTION) {
     connectionFailed();
     return false;
   } else {
     String tmp_host = host;
     boolean change = false;
     if (tfaddress.getText().length() > 0) tmp_host = tfaddress.getText();
     int tmp_port = port;
     if (tfport.getText().length() > 0) tmp_port = Integer.parseInt(tfport.getText());
     if (!tmp_host.equals(host)) {
       host = new String(tmp_host);
       change = true;
     }
     if (port != tmp_port) {
       port = tmp_port;
       change = true;
     }
     if (change) fireEvent(new ConnectionEvent(this, ConnectionEvent.ADDRESS_CHANGED));
     state = ConnectionEvent.CONNECTION_CLOSED;
     return (connect());
   }
 }
Esempio n. 11
0
 public FieldParam(FieldParam p) {
   super((Param) p);
   field = p.field;
   fieldOwner = p.fieldOwner;
   // uiRepCopy = field.getUIRepCopy();//REMOVED 8/10/10
   // setUIRep(uiRepCopy.getComponent());//REMOVED 8/10/10
   ExpCoordinator.print(
       new String("FieldParam(" + label + ")(FieldParam) default:" + p.getDefaultValue()),
       TEST_FIELDPARAM);
 }
Esempio n. 12
0
    public void print(int dlevel) {
      if (msgtype == NCCP.MessageResponse)
        ExpCoordinator.print(
            new String("NCCPConnection.Message Response size = " + msgsize), dlevel);
      else
        ExpCoordinator.print(
            new String("NCCPConnection.Message type = " + msgtype + " size = " + msgsize), dlevel);
      String tmp_str = "";
      int max = msgsize - 2;
      for (int i = 0; i < max; ++i) {
        for (int j = 0; j < 4; ++j) {
          if (i < max) {
            tmp_str = tmp_str.concat(new String(msgbytes[i] + " "));
            ++i;
          }
        }

        ExpCoordinator.print(new String("     " + tmp_str), dlevel);
        tmp_str = "";
      }
    }
Esempio n. 13
0
 public void setConnectionID(short cid) {
   ExpCoordinator.print(
       new String(
           "NCCPConnection.setConnectionID host:"
               + getHost()
               + " port:"
               + getPort()
               + " cid:"
               + cid),
       5);
   if (proxy != null) proxy.setConnectionID(this, cid);
 }
Esempio n. 14
0
 public FieldParam(ParamSpec fps, ONLComponent pc, Command cs) {
   super((ParamSpec) fps, pc, cs);
   if (cs.getFieldOwner() == null && pc instanceof Field.Owner) fieldOwner = (Field.Owner) pc;
   else fieldOwner = cs.getFieldOwner();
   getField();
   setDefaultValue(fps.getDefaultValue());
   ExpCoordinator.print(
       new String(
           "FieldParam("
               + label
               + ")(ParamSpec, ONLComponent, Command) command:"
               + cs.getLabel()
               + " default:"
               + fps.getDefaultValue()),
       TEST_FIELDPARAM);
 }
Esempio n. 15
0
 public void processMessage(DataInputStream dataIn) throws IOException {
   count = 0;
   int msgsize = dataIn.readInt();
   count = 1;
   int msgtype = 0;
   if (msgsize >= 2) msgtype = dataIn.readUnsignedShort();
   else {
     if (msgsize == 1) dataIn.readByte();
     ExpCoordinator.printer.print(
         new String("ERROR:NCCPConnection.run msgsize(" + msgsize + ") < 2 msgtype = " + msgtype));
     ExpCoordinator.printer.printHistory();
     return;
   }
   count = 2;
   switch (msgtype) {
     case NCCP.MessageResponse:
       ExpCoordinator.print(
           new String(
               "NCCPConnection::run message is  NCCP.MessageResponse " + msgsize + " " + msgtype),
           3);
       MessageRunnable tmp_msg = new MessageRunnable(msgsize, msgtype, dataIn);
       tmp_msg.print(5);
       SwingUtilities.invokeLater(tmp_msg);
       break;
     case NCCP.MessagePeriodic:
       ExpCoordinator.printer.print(
           new String(
               "NCCPConnection::run message is  NCCP.MessagePeriodic " + msgsize + " " + msgtype),
           3);
       processPeriodicMsg(msgsize, msgtype, dataIn);
       break;
     default:
       ExpCoordinator.printer.print(
           new String("NCCPConnection::run message is  Other " + msgsize + " " + msgtype));
       SwingUtilities.invokeLater(new MessageRunnable(msgsize, msgtype, dataIn));
   }
 }
Esempio n. 16
0
  protected boolean addLink(
      LinkGraphic lg, ONLComponent end_comp) // returns true if successfully added
      {
    if (lg == null) return false;
    LinkDescriptor comp = (LinkDescriptor) lg.getONLComponent();
    ONLComponent start_comp = comp.getPoint1();
    // fail link if end_comp is not a component, it's a loop, the end_comp is unlinkable or is
    // already linked
    if (end_comp == null
        || end_comp == start_comp
        || !end_comp.isLinkable()
        || end_comp.isLinked()) {
      if (end_comp == null)
        ExpCoordinator.print(
            new String("LinkTool.addLink " + comp.toString() + " fail end is null"), TEST_ADD);
      else {
        if (end_comp == start_comp)
          ExpCoordinator.print(
              new String(
                  "LinkTool.addLink "
                      + comp.toString()
                      + " fail end("
                      + end_comp.getLabel()
                      + ") is same as start"),
              TEST_ADD);
        if (!end_comp.isLinkable() || end_comp.isLinked())
          ExpCoordinator.print(
              new String(
                  "LinkTool.addLink "
                      + comp.toString()
                      + " fail diend("
                      + end_comp.getLabel()
                      + ") unlinkable isLinkable:"
                      + end_comp.isLinkable()
                      + " isLinked:"
                      + end_comp.isLinked()),
              TEST_ADD);
      }
      return false;
    } else {
      // 10G change for gige to gige connections remove GigE to GigE restriction
      // if (((start_comp instanceof GigEDescriptor.Port) || (start_comp instanceof GigEDescriptor))
      // &&
      //  ((end_comp instanceof GigEDescriptor.Port) || (end_comp instanceof GigEDescriptor)))
      // return false;
      // 10G change return false if interface types not equal & not a GigE-GigE link
      if (!start_comp.getInterfaceType().equals(end_comp.getInterfaceType())
          && !(((start_comp instanceof GigEDescriptor.Port)
                  || (start_comp instanceof GigEDescriptor))
              && ((end_comp instanceof GigEDescriptor.Port)
                  || (end_comp instanceof GigEDescriptor)))) {
        ExpCoordinator.print(
            new String(
                "LinkTool.addLink "
                    + comp.toString()
                    + " fail diff interface start:"
                    + start_comp.getLabel()
                    + "("
                    + start_comp.getInterfaceType()
                    + ")  end:"
                    + end_comp.getLabel()
                    + "("
                    + end_comp.getInterfaceType()
                    + ")"),
            TEST_ADD);
        return false;
      }

      // SUBNET:add call SubnetManager addLink here
      try {
        if (ExpCoordinator.isOldSubnet()) {
          // check for cycles
          if (expCoordinator.getTopology().isCycle(start_comp, end_comp)) return false;
          OldSubnetManager.addLink(
              (ONLComponent.PortBase) start_comp, (ONLComponent.PortBase) end_comp);
        } else
          SubnetManager.addLink(
              (ONLComponent.PortBase) start_comp, (ONLComponent.PortBase) end_comp);
      } catch (SubnetManager.SubnetException e) {
        ExpCoordinator.print(
            new String(
                "LinkTool.addLink failed ("
                    + start_comp.getLabel()
                    + ", "
                    + end_comp.getLabel()
                    + ") -- "
                    + e.getMessage()));
        return false;
      }
    }
    comp.setPoint2(end_comp);
    addLink(lg);
    return true;
  }
Esempio n. 17
0
 protected TopologyPanel getTopologyPanel() {
   return (expCoordinator.getMainWindow().getTopologyPanel());
 }