Package org.mobicents.protocols.api

Examples of org.mobicents.protocols.api.Association


  protected void stop() throws Exception {
    FastList<String> tempAssociations = associations;
    for (FastList.Node<String> n = tempAssociations.head(), end = tempAssociations.tail(); (n = n.getNext()) != end;) {
      String assocName = n.getValue();
      Association associationTemp = this.management.getAssociation(assocName);
      if (associationTemp.isStarted()) {
        throw new Exception(String.format("Stop all the associations first. Association=%s is still started",
            associationTemp.getName()));
      }
    }

    synchronized (this.anonymAssociations) {
      // stopping all anonymous associations
View Full Code Here


    management.start();
    management.removeAllResourses();

    // Add association
    String[] arr = new String[]{"127.0.0.2", "127.0.0.3"};
    Association clientAss1 = management.addAssociation("localhost", 2905, "localhost", 2906, "ClientAssoc1", ipChannelType, arr);
    assertNotNull(clientAss1);

    // Try to add assoc with same name
    try {
      clientAss1 = management.addAssociation("localhost", 2907, "localhost", 2908, "ClientAssoc1", ipChannelType, null);
View Full Code Here

    management.setConnectDelay(10000);// Try connecting every 10 secs
    management.start();
    management.removeAllResourses();

    management.addServer(SERVER_NAME, SERVER_HOST, SERVER_PORT, ipChannelType, false, 0, null);
    Association serverAssociation = management.addServerAssociation(CLIENT_HOST, CLIENT_PORT, SERVER_NAME, SERVER_ASSOCIATION_NAME, ipChannelType);
    Association clientAssociation = management.addAssociation(CLIENT_HOST, CLIENT_PORT, SERVER_HOST, SERVER_PORT, CLIENT_ASSOCIATION_NAME, ipChannelType, null);

    management.startServer(SERVER_NAME);


    serverAssociation.setAssociationListener(new ServerAssociationListener());
    management.startAssociation(SERVER_ASSOCIATION_NAME);
    clientAssociation.setAssociationListener(new ClientAssociationListener());
    management.startAssociation(CLIENT_ASSOCIATION_NAME);

    for (int i1 = 0; i1 < 40; i1++) {
      if (serverAssociation.isConnected())
        break;
      Thread.sleep(1000 * 5);
    }
    Thread.sleep(1000 * 1);

    assertTrue(serverAssociation.isConnected());
    assertTrue(clientAssociation.isConnected());

    management.stop();

    assertFalse(serverAssociation.isConnected());
    assertFalse(clientAssociation.isConnected());

  }
 
View Full Code Here

    this.store();

    // Stop all associations
    FastMap<String, Association> associationsTemp = this.associations;
    for (FastMap.Entry<String, Association> n = associationsTemp.head(), end = associationsTemp.tail(); (n = n.getNext()) != end;) {
      Association associationTemp = n.getValue();
      if (associationTemp.isStarted()) {
        ((AssociationImpl) associationTemp).stop();
      }
    }

    FastList<Server> tempServers = servers;
    for (FastList.Node<Server> n = tempServers.head(), end = tempServers.tail(); (n = n.getNext()) != end;) {
      Server serverTemp = n.getValue();
      if (serverTemp.isStarted()) {
        try {
          ((ServerImpl) serverTemp).stop();
        } catch (Exception e) {
          logger.error(String.format("Exception while stopping the Server=%s", serverTemp.getName()), e);
        }
      }
    }

    if (this.executorServices != null) {
      for (int i = 0; i < this.executorServices.length; i++) {
        this.executorServices[i].shutdown();
      }
    }

    this.selectorThread.setStarted(false);
    this.socketSelector.wakeup(); // Wakeup selector so SelectorThread dies

    // waiting till stopping associations
    for (int i1 = 0; i1 < 20; i1++) {
      boolean assConnected = false;
      for (FastMap.Entry<String, Association> n = this.associations.head(), end = this.associations.tail(); (n = n.getNext()) != end;) {
        Association associationTemp = n.getValue();
        if (associationTemp.isConnected()) {
          assConnected = true;
          break;
        }
      }
      if (!assConnected)
View Full Code Here

      if (server == null) {
        throw new Exception(String.format("No Server found for name=%s", serverName));
      }

      for (FastMap.Entry<String, Association> n = this.associations.head(), end = this.associations.tail(); (n = n.getNext()) != end;) {
        Association associationTemp = n.getValue();

        if (peerAddress.equals(associationTemp.getPeerAddress()) && associationTemp.getPeerPort() == peerPort) {
          throw new Exception(String.format("Already has association=%s with same peer address=%s and port=%d", associationTemp.getName(),
              peerAddress, peerPort));
        }
      }

      if (server.getIpChannelType() != ipChannelType)
View Full Code Here

      throw new Exception("Association name cannot be null");
    }

    synchronized (this) {
      for (FastMap.Entry<String, Association> n = this.associations.head(), end = this.associations.tail(); (n = n.getNext()) != end;) {
        Association associationTemp = n.getValue();

        if (assocName.equals(associationTemp.getName())) {
          throw new Exception(String.format("Already has association=%s", associationTemp.getName()));
        }

        if (peerAddress.equals(associationTemp.getPeerAddress()) && associationTemp.getPeerPort() == peerPort) {
          throw new Exception(String.format("Already has association=%s with same peer address=%s and port=%d", associationTemp.getName(),
              peerAddress, peerPort));
        }

        if (hostAddress.equals(associationTemp.getHostAddress()) && associationTemp.getHostPort() == hostPort) {
          throw new Exception(String.format("Already has association=%s with same host address=%s and port=%d", associationTemp.getName(),
              hostAddress, hostPort));
        }

      }
View Full Code Here

  public Association getAssociation(String assocName) throws Exception {
    if (assocName == null) {
      throw new Exception("Association name cannot be null");
    }
    Association associationTemp = this.associations.get(assocName);

    if (associationTemp == null) {
      throw new Exception(String.format("No Association found for name=%s", assocName));
    }
    return associationTemp;
View Full Code Here

    if (assocName == null) {
      throw new Exception("Association name cannot be null");
    }

    Association associationTemp = this.associations.get(assocName);

    if (associationTemp == null) {
      throw new Exception(String.format("No Association found for name=%s", assocName));
    }

    if (associationTemp.isStarted()) {
      throw new Exception(String.format("Association=%s is already started", assocName));
    }

    ((AssociationImpl) associationTemp).start();
    this.store();
View Full Code Here

    if (assocName == null) {
      throw new Exception("Association name cannot be null");
    }

    Association association = this.associations.get(assocName);

    if (association == null) {
      throw new Exception(String.format("No Association found for name=%s", assocName));
    }
View Full Code Here

    if (assocName == null) {
      throw new Exception("Association name cannot be null");
    }

    synchronized (this) {
      Association association = this.associations.get(assocName);

      if (association == null) {
        throw new Exception(String.format("No Association found for name=%s", assocName));
      }

      if (association.isStarted()) {
        throw new Exception(String.format("Association name=%s is started. Stop before removing", assocName));
      }

      AssociationMap<String, Association> newAssociations = new AssociationMap<String, Association>();
      newAssociations.putAll(this.associations);
      newAssociations.remove(assocName);
      this.associations = newAssociations;
      // this.associations.remove(assocName);

      if (((AssociationImpl) association).getAssociationType() == AssociationType.SERVER) {
        for (FastList.Node<Server> n = this.servers.head(), end = this.servers.tail(); (n = n.getNext()) != end;) {
          Server serverTemp = n.getValue();
          if (serverTemp.getName().equals(association.getServerName())) {
            FastList<String> newAssociations2 = new FastList<String>();
            newAssociations2.addAll(((ServerImpl) serverTemp).associations);
            newAssociations2.remove(assocName);
            ((ServerImpl) serverTemp).associations = newAssociations2;
            // ((ServerImpl)
View Full Code Here

TOP

Related Classes of org.mobicents.protocols.api.Association

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.