Package fr.dyade.aaa.agent.conf

Examples of fr.dyade.aaa.agent.conf.A3CMLConfig


    if (logger.isLoggable(BasicLevel.DEBUG))
      logger.log(BasicLevel.DEBUG,
                 "ServerConfigHelper.addDomain(" + domainName + ',' + network + ',' + routerId + ',' + port + ')');

    // Check configuration consistency (may fail)
    A3CMLConfig a3cmlConfig = AgentServer.getConfig();
   
    if (a3cmlConfig.domains.get(domainName) != null)
      throw new NameAlreadyUsedException("Domain name already used: " + domainName);
   
    if (a3cmlConfig.servers.get(new Short((short)routerId)) == null)
      throw new Exception("Server not found: " + routerId);
   
    // Update the configuration (can't fail)
    A3CMLDomain domain = new A3CMLDomain(domainName, network);
    a3cmlConfig.addDomain(domain);
    A3CMLServer a3cmlServer = a3cmlConfig.getServer((short) routerId);
    domain.addServer(a3cmlServer);
    A3CMLNetwork a3cmlNetwork = new A3CMLNetwork(domainName, port);
    a3cmlServer.addNetwork(a3cmlNetwork);

    A3CMLServer root = a3cmlConfig.getServer(AgentServer.getServerId());
    a3cmlConfig.configure(root);

    boolean res = false;
    if (routerId == AgentServer.getServerId()) {
      // Create and start the run-time entities (may fail)
      Network net = (Network) Class.forName(network).newInstance();
     
      // GS: Network name is set earlier than normal to have a well formed name
      // for the MBean in addConsumer method.
      net.name = AgentServer.getName() + '.' + domainName;
      AgentServer.addConsumer(domainName, net);
     
      try {
        short[] sids = new short[1];
        sids[0] = (short) routerId;
        net.init(domainName, port, sids);
        net.start();
      } catch (Exception exc) {
        if (logger.isLoggable(BasicLevel.ERROR))
          logger.log(BasicLevel.ERROR, "", exc);
        // Rollback the network addition
        AgentServer.removeConsumer(domainName);

        a3cmlServer.removeNetwork(domainName);
        a3cmlConfig.removeDomain(domainName);
        a3cmlConfig.configure(root);

        throw new StartFailureException(exc.getMessage());
      }
     
      res = true;
View Full Code Here


    if (logger.isLoggable(BasicLevel.DEBUG))
      logger.log(BasicLevel.DEBUG,
                 "ServerConfigHelper.removeDomain(" +
                 domainName + ')');

    A3CMLConfig a3cmlConfig = AgentServer.getConfig();
    A3CMLDomain domain = a3cmlConfig.getDomain(domainName);

    if (logger.isLoggable(BasicLevel.DEBUG))
      logger.log(BasicLevel.DEBUG,
                 " -> domain.servers = " + domain.servers);

    // Check that there is only one server left inside the domain:
    // the router. If there is more than one server, the domain
    // can't be removed. The servers belonging to the domain must
    // first be removed.
    if (domain.servers.size() > 1)
      throw new Exception("Can't remove domain: it contains more than one server.");

    A3CMLServer router = null;   
    if (domain.servers.size() == 1) {
      router = (A3CMLServer) domain.servers.elementAt(0);
    }
   
    // Update the configuration and the run-time entities
    // at the same time (can't fail)
    a3cmlConfig.removeDomain(domainName);
   
    if (router != null) {
      router.removeNetwork(domainName);
    }

    A3CMLServer root = a3cmlConfig.getServer(AgentServer.getServerId());
    a3cmlConfig.configure(root);

    boolean res = false;
    if (router != null &&
        router.sid == AgentServer.getServerId()) {
     
View Full Code Here

      logger.log(BasicLevel.DEBUG,
                 "ServerConfigHelper.addServer(" + sid + ',' + hostName + ',' + domainName + ',' + port + ',' + name + ')');
   
    // Adds the server in the ACML configuration graph
   
    A3CMLConfig a3cmlConfig = AgentServer.getConfig();
    if (a3cmlConfig.servers.get(new Integer(sid)) != null)
      throw new ServerIdAlreadyUsedException("Server id already used: " + sid);
   
    A3CMLDomain domain = a3cmlConfig.getDomain(domainName);
   
    A3CMLServer server = new A3CMLServer((short)sid, name, hostName);
    a3cmlConfig.addServer(server);

    A3CMLNetwork network = new A3CMLNetwork(domainName, port);
    server.addNetwork(network);
    domain.addServer(server);
    server.domain = domainName;

    A3CMLServer root = a3cmlConfig.getServer(AgentServer.getServerId());
    a3cmlConfig.configure(root);
   
    // Adds the server in the configuration structure
   
    ServerDesc desc = new ServerDesc((short)sid, name, hostName, -1);
    AgentServer.addServerDesc(desc);
View Full Code Here

    if (logger.isLoggable(BasicLevel.DEBUG))
      logger.log(BasicLevel.DEBUG,
                 "ServerConfigHelper.removeServer(" +
                 sid + ')');
    if (sid != AgentServer.getServerId()) {
      A3CMLConfig a3cmlConfig = AgentServer.getConfig();
      A3CMLServer a3cmlServer = a3cmlConfig.getServer((short)sid);
     
      if (logger.isLoggable(BasicLevel.DEBUG))
      logger.log(BasicLevel.DEBUG,
                 " -> server.networks = " + a3cmlServer.networks);

      // Check that the server doesn't belong to more than one
      // domain.
      if (a3cmlServer.networks.size() > 1)
        throw new Exception(
          "Can't remove server: it belongs to more than one domain.");

      a3cmlConfig.removeServer((short)sid);
     
      A3CMLServer root = a3cmlConfig.getServer(AgentServer.getServerId());
      a3cmlConfig.configure(root);
     
      ServerDesc servDesc =
        AgentServer.removeServerDesc((short)sid);
     
      if (servDesc.getDomain() instanceof Network) {
View Full Code Here

                         String args)
    throws Exception {
    if (logger.isLoggable(BasicLevel.DEBUG))
      logger.log(BasicLevel.DEBUG,
                 "ServerConfigHelper.addService(" + sid + ',' + className + ',' + args + ')');
    A3CMLConfig a3cmlConfig = AgentServer.getConfig();
    A3CMLServer a3cmlServer = a3cmlConfig.getServer((short)sid);
    A3CMLService a3cmlService = new A3CMLService(className, args);
    a3cmlServer.addService(a3cmlService);
   
    if (sid == AgentServer.getServerId()) {
      try {
View Full Code Here

    throws Exception {
    if (logger.isLoggable(BasicLevel.DEBUG))
      logger.log(BasicLevel.DEBUG,
                 "ServerConfigHelper.addService(" +
                 sid + ',' + className + ')');
    A3CMLConfig a3cmlConfig = AgentServer.getConfig();
    A3CMLServer a3cmlServer = a3cmlConfig.getServer((short)sid);
   
    if (sid == AgentServer.getServerId()) {
      ServiceManager.stop(className);
    }
View Full Code Here

    if (autoCommit) commit();
  }

  public void commit() throws Exception {
    A3CMLConfig a3cmlConfig = AgentServer.getConfig();
    if (AgentServer.getTransaction() instanceof fr.dyade.aaa.util.NullTransaction) {
      // TODO (AF): NullTransaction is not significant.
      String cfgDir = System.getProperty(AgentServer.CFG_DIR_PROPERTY, AgentServer.DEFAULT_CFG_DIR);
      String cfgFile = System.getProperty(AgentServer.CFG_FILE_PROPERTY, AgentServer.DEFAULT_CFG_FILE);
      FileOutputStream fos = new FileOutputStream(new File(cfgDir, cfgFile));
      PrintWriter out = new PrintWriter(fos);
      A3CML.toXML(a3cmlConfig, out);
      out.flush();
      fos.flush();
      fos.getFD().sync();
      out.close();
      fos.close();
    } else {
      a3cmlConfig.save();
    }
  }
View Full Code Here

        } else if (cmd.equals(NONE)) {
        } else if (cmd.equals(PING)) {
          writer.println(AgentServer.getServerId());
        } else if (cmd.equals(CONFIG)) {
          try {
            A3CMLConfig a3CMLConfig = AgentServer.getConfig();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            PrintWriter out = new PrintWriter(baos);
            A3CML.toXML(a3CMLConfig, out);
            out.flush();
            baos.flush();
View Full Code Here

          logmon.log(BasicLevel.WARN, "Generate default configuration");
          A3CMLDomain d = new A3CMLDomain(ADMIN_DOMAIN, SimpleNetwork.class.getName());
          A3CMLServer s = new A3CMLServer((short) 0, ADMIN_SERVER, "localhost");
          s.networks.addElement(new A3CMLNetwork(ADMIN_DOMAIN, 27300));
          d.addServer(s);
          a3config = new A3CMLConfig();
          a3config.addDomain(d);
          a3config.addServer(s);
        }
      }
View Full Code Here

      // extract the a3servers.xml file from joram-config.jar in the tmp dir
      extractFromJAR(tmpDir + JORAM_CONFIG_JAR, A3SERVERS_XML);
    }

    // update A3SERVERS_XML
    A3CMLConfig conf = A3CML.getXMLConfig(tmpDir + A3SERVERS_XML);
    A3CMLServer server = conf.getServer(serverId);
    server.hostname = hostName;
    A3CMLService service =
      server.getService("org.objectweb.joram.mom.proxies.tcp.TcpProxyService");
    service.args = port;
    // write changes to A3SERVERS_XML file
View Full Code Here

TOP

Related Classes of fr.dyade.aaa.agent.conf.A3CMLConfig

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.