Beispiel #1
0
 public void run() {
   try {
     Thread.sleep(1000);
     System.exit(0);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  // -------------------------------------------------------------------------------------
  public static void main(String[] args) {
    ClusterViewer view;
    if (args.length != 1) {
      System.err.println("usage: clusterViewer <baseUrl>");
      System.exit(1);
    }

    view = new ClusterViewer(args[0].trim());
  } // main
  public static void main(String args[]) {
    try {
      // ReceiveMessageInterface rmiclient;
      RmiServer server = new RmiServer();
      // rmiclient=(ReceiveMessageInterface)(registry.lookup("rmiclient"));
      // rmiclient.generateKeys(publicKey);
      KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
      keyGen.initialize(1024);
      KeyPair keypair = keyGen.genKeyPair();
      publicKey = keypair.getPublic();
      privateKey = keypair.getPrivate();

      BufferedImage image = ImageIO.read(new File("/home/subba/Desktop/test/iris1.bmp"));

      // write it to byte array in-memory (jpg format)
      ByteArrayOutputStream b = new ByteArrayOutputStream();
      ImageIO.write(image, "bmp", b);

      // do whatever with the array...
      byte[] jpgByteArray = b.toByteArray();

      // convert it to a String with 0s and 1s
      StringBuilder sb = new StringBuilder();
      int i = 0;
      for (byte by : jpgByteArray) {
        i++;
        if (i > 366) break;
        sb.append(Integer.toBinaryString(by & 0xFF));
      }
      sb.append("0000000000000000000000000000000000000000000");
      System.out.println(sb.toString().length());
      System.out.println(sb.toString());
      int token = 170;
      StringBuilder sb1 = new StringBuilder();
      sb1.append(Integer.toBinaryString(token));
      for (int j = 0; j < 102; j++) {
        sb1.append("00000000000000000000");
      }
      System.out.println("Binary is " + sb1.length());
      for (i = 0; i < sb.length(); i++) {
        bioTemplate.append(sb.charAt(i) ^ sb1.charAt(i));
      }

      /*MessageDigest digest = MessageDigest.getInstance("SHA-256");
      byte[] hashvalue=serviceProviderKey.getBytes();
      digest.update(hashvalue);
      Phashdigest=digest.digest();
      */

      securePassword = getSecurePassword(serviceProviderKey, "200");
      System.out.println(securePassword);
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }
  }
Beispiel #4
0
  public boolean shutdown(String server) throws RemoteException {
    if (server.equalsIgnoreCase(FORCE_SHUTDOWN)) {
      System.exit(0);
      return true;

    } else if (server.equalsIgnoreCase("middleware")) {
      // Shutdown the cars group.
      shutdownGroup(this.carGroup);

      // Shutdown the rooms group.
      shutdownGroup(this.roomGroup);

      // Shutdown the flights group.
      shutdownGroup(this.flightGroup);

      // Shutdown all the middleware servers except yourself.
      for (MemberInfo m : this.currentMembers) {
        if (!m.equals(this.myInfo)) {
          shutdownMember(m);
        }
      }

      // Shut yourself down.
      System.exit(0);
      return true;

    } else if (server.equalsIgnoreCase("cars")) {
      shutdownGroup(this.carGroup);
      return true;

    } else if (server.equalsIgnoreCase("rooms")) {
      shutdownGroup(this.roomGroup);
      return true;

    } else if (server.equalsIgnoreCase("flights")) {
      shutdownGroup(this.flightGroup);
      return true;

    } else {
      return false;
    }
  }
  public static void main(String args[]) {
    try {
      String serverName = args[0];

      Solver solver = new Solver();
      String rmiObServer = "rmi://" + HOST + "/" + serverName;
      Naming.rebind(rmiObServer, solver);
      System.out.println("Server ready");
    } catch (ArrayIndexOutOfBoundsException ex) {
      System.out.println("Error! E' necessario specificare il nome del server");
    } catch (RemoteException r) {
      System.out.println("Error while rebind object");
      r.printStackTrace();
      System.exit(1);
    } catch (MalformedURLException m) {
      System.out.println("Error! Malformed url require");
    }
  }
  protected void initProperties(String propFileName) {

    // Create instance of Class Properties
    props = new Properties(System.getProperties());

    // Try to load property list
    try {
      props.load(new BufferedInputStream(new FileInputStream(propFileName)));
    } catch (IOException ex) {
      ex.printStackTrace();
      System.out.println("Exception in SpaceAccessor");
      System.exit(-3);
    }

    // Output property list (can be ommitted - testing only)

    System.out.println("jiniURL   = " + props.getProperty("jiniURL"));
    // Assign values to fields

    jiniURL = props.getProperty("jiniURL");
  }
Beispiel #7
0
  public static void main(String[] args) {
    if (args.length != 1) {
      System.out.println("Usage : java Client <machine du Serveur:port du rmiregistry>");
      System.exit(0);
    }
    try {
      int[][] a = {{1, 0, 0}, {0, 2, 0}, {0, 0, 3}};
      int[][] b = {{1, 2, 3}, {1, 2, 3}, {1, 2, 3}};

      int[][] res;

      OpMatrice op = (OpMatrice) Naming.lookup("rmi://" + args[0] + "/Matrice");
      res = op.multiplicationMatrice(a, b);
      op.AffichageMatrice(res);
    } catch (NotBoundException re) {
      System.out.println(re);
    } catch (RemoteException re) {
      System.out.println(re);
    } catch (MalformedURLException e) {
      System.out.println(e);
    }
  }
Beispiel #8
0
  /**
   * Generate random data and assign it to a variable in a belief network. The command line
   * arguments are:
   *
   * <pre>
   *   java riso.remote_data.RandomEvidence [-h rmi-host] [-s server-name]
   * </pre>
   *
   * The <tt>rmi-host</tt> is the name of the host running <tt>rmiregistry</tt>. The
   * <tt>server-name</tt> is the name by which this data source will be known.
   */
  public static void main(String[] args) {
    String bn_name = null, variable_name = null;
    int i, j;

    for (i = 0; i < args.length; i++) {
      switch (args[i].charAt(1)) {
        case 'b':
          bn_name = args[++i];
          break;
        case 'x':
          variable_name = args[++i];
          break;
      }
    }

    System.err.println("RandomEvidence: bn_name: " + bn_name + " variable_name: " + variable_name);

    try {
      String url = "rmi://" + bn_name;
      AbstractBeliefNetwork bn = (AbstractBeliefNetwork) Naming.lookup(url);
      AbstractVariable v = (AbstractVariable) bn.name_lookup(variable_name);
      Distribution p = bn.get_posterior(v);
      System.err.println("RandomEvidence: sample from: ");
      System.err.println(p.format_string("\t"));

      while (true) {
        double[] x = p.random();
        bn.assign_evidence(v, x[0]);
        try {
          Thread.sleep(10000);
        } catch (InterruptedException e) {
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }
  }
  public static void main(String args[]) {
    if (args.length != 2) {
      System.err.println("Uso: ObservadorCentralita hostregistro numPuertoRegistro");
      return;
    }

    // Instancia gestor de seguridad
    if (System.getSecurityManager() == null) {
      System.setSecurityManager(new SecurityManager());
    }
    try {
      // Obtiene referencia remota del servicio de rmiregistry
      ServicioCentralita srv =
          (ServicioCentralita) Naming.lookup("//" + args[0] + ":" + args[1] + "/Centralita");
      //                                                            |               |-> Número de
      // puerto escucha
      //                                                            |-> Host en el que se ejecuta el
      // servicio

      String nombreServicio = "default";

      while (nombreServicio == "default") {
        // Captura el nombre del servicio
        System.out.println(
            "Elija el servicio:\n\t[1] Bomberos\n\t[2] Sanitarios\n\t[3] Policía\n\t[4] Guardia Civil");
        Scanner input = new Scanner(System.in);
        String tipoServicio = input.nextLine();

        switch (tipoServicio) {
          case "1":
            nombreServicio = "Bomberos";
            break;
          case "2":
            nombreServicio = "Sanitarios";
            break;
          case "3":
            nombreServicio = "Policia";
            break;
          case "4":
            nombreServicio = "Guardia Civil";
            break;
          default:
            nombreServicio = "default";
            break;
        }
      }

      // Crea nuevo observador y lo registra en la lista
      ObservadorImpl o = new ObservadorImpl(nombreServicio);

      // Llamada al método remoto 'addObservador' del servicio
      srv.addObservador(o, nombreServicio);

      // Comrpeuba el nombre del servicio para imprimir código de color
      if (nombreServicio.equals("Bomberos")) {
        System.out.println(
            "\u001B[31mObservador " + nombreServicio + " registrado en la centralita\u001B[0m\n");
      } else if (nombreServicio.equals("Sanitarios")) {
        System.out.println(
            "\u001B[35mObservador " + nombreServicio + " registrado en la centralita\u001B[0m\n");
      } else if (nombreServicio.equals("Policia")) {
        System.out.println(
            "\u001B[34mObservador " + nombreServicio + " registrado en la centralita\u001B[0m\n");
      } else if (nombreServicio.equals("Guardia Civil")) {
        System.out.println(
            "\u001B[32mObservador " + nombreServicio + " registrado en la centralita\u001B[0m\n");
      }

      // Se mantiene esperando hasta que se para con Ctrl+D
      System.out.println("Para salir, pulsar Ctrl+D\n");
      Scanner sleep = new Scanner(System.in);
      while (sleep.hasNextInt()) {}

      // Elimina de la lista al observador. Llamada al método remoto 'delObservador' del servicio
      srv.delObservador(o, nombreServicio);
      System.exit(0);
    }
    // Excepción RMI
    catch (RemoteException e) {
      System.err.println("Error de comunicación: " + e.toString());
    }
    // Excepción cliente
    catch (Exception e) {
      System.err.println("Excepción en ObservadorCentralita: ");
      e.printStackTrace();
    }
  }
 // -------------------------------------------------------------------------------------
 public void doExit() {
   connector.disconnectFromGaggle(true);
   System.exit(0);
 }
Beispiel #11
0
 public void exit() throws RemoteException {
   System.exit(0);
 }
  public static void main(String args[])
      throws RemoteException, InvalidTransactionException, TransactionAbortedException {
    System.setSecurityManager(new RMISecurityManager());

    String rmiPort = System.getProperty("rmiPort");
    if (rmiPort == null) {
      rmiPort = "";
    } else if (!rmiPort.equals("")) {
      rmiPort = "//:" + rmiPort + "/";
    }

    try {
      TransactionManagerImpl obj = new TransactionManagerImpl();
      Naming.rebind(rmiPort + TransactionManager.RMIName, obj);
      System.out.println("TM bound");
    } catch (Exception e) {
      System.err.println("TM not bound:" + e);
      System.exit(1);
    }

    enlistList = new HashMap<Integer, Set<ResourceManager>>();
    File f = new File(enlistFile);
    if (f.exists()) {
      try {
        ObjectInputStream fin = new ObjectInputStream(new FileInputStream(f));
        enlistList = (HashMap<Integer, Set<ResourceManager>>) fin.readObject();
        fin.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    protocolDB = new HashMap<Integer, Map<String, TwoPC_ST>>();
    File f2 = new File(protocolDBFile);
    if (f2.exists()) {
      try {
        ObjectInputStream fin2 = new ObjectInputStream(new FileInputStream(f2));
        protocolDB = (HashMap<Integer, Map<String, TwoPC_ST>>) fin2.readObject();
        fin2.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
      // recovery
      for (Integer i : protocolDB.keySet()) {
        if (i > xidCounter) {
          xidCounter = i + 1;
        }
        Map<String, TwoPC_ST> lastST = protocolDB.get(i);
        boolean re1 = true;
        for (TwoPC_ST st : lastST.values()) re1 &= (st == TwoPC_ST.Committed);
        if (re1) {
          protocolDB.remove(i);
          enlistList.remove(i);
          continue;
        }

        System.out.println("TM recovery xid: " + i + " from half commit.");
        Set<ResourceManager> commitSet = enlistList.get(i);
        boolean re2 = true;
        Set<ResourceManager> commitSet2 = new HashSet<ResourceManager>();
        for (ResourceManager r : commitSet) {
          if (r.getStatus(i) == TwoPC_ST.Prepared) {
            System.out.println("TM recovery " + i + " in " + r.getMyRMIName());
            commitSet2.add(r);
          } else if (r.getStatus(i) == TwoPC_ST.Committed) ;
          else re2 = false;
        }
        System.out.println("here 1");
        if (re2) {
          for (ResourceManager r : commitSet2) {
            r.commit(i);
          }
          protocolDB.remove(i);
          enlistList.remove(i);
        }
      }
    }
  }
 public void crash() {
   System.exit(0);
 }
Beispiel #14
0
      public void actionPerformed(ActionEvent e) {
        if (e.getSource() == Connect) {
          if (nbr < 3) {
            if (nom.getText().length() == 0
                || pwd.getPassword().length == 0
                || jTextField1.getText().length() == 0) {
              JOptionPane.showMessageDialog(
                  null,
                  "Vous devez donner votre pseudonyme, votre mot de passe ainsi que l'adresse du serveur de chat",
                  "Informations manquantes",
                  JOptionPane.WARNING_MESSAGE);
              nbr++;
            } else {
              try {
                J = (Contrat) Naming.lookup("rmi://" + jTextField1.getText() + ":1099/JChat");
              } catch (RemoteException ex4) {
                JOptionPane.showMessageDialog(
                    null,
                    "La connexion au serveur a échoué",
                    "Serveur non démarré",
                    JOptionPane.WARNING_MESSAGE);
                System.out.println(ex4);
                nbr++;
              } catch (MalformedURLException ex4) {
                JOptionPane.showMessageDialog(
                    null, "Connexion 2", "Erreur de connexion", JOptionPane.WARNING_MESSAGE);
                nbr++;
              } catch (NotBoundException ex4) {
                JOptionPane.showMessageDialog(
                    null,
                    "Serveur non joignable",
                    "Erreur de connexion",
                    JOptionPane.WARNING_MESSAGE);
                System.out.println(ex4);
                System.exit(0);
              }
              if (J != null) {
                try { // de la méthode connect distante
                  // Récupération de l'adresse de la machine du client
                  try {
                    adr = InetAddress.getLocalHost().getHostName();
                  } catch (UnknownHostException ex3) {
                  }
                  // Si le nom et le mot de passe fournies par le client sont valides
                  // Envoi du nom et mot de passe pour la vérification de la validité de ce client
                  // ainsi que le num de port
                  // , adresse de la machine du client et nom de l'objet distant du client pour
                  // pouvoir l'invoquer ultérieurementulté
                  num_port = J.get_num_port();
                  if (J.connect(nom.getText(), new String(pwd.getPassword()), adr, num_port)) {
                    srv_Adr = jTextField1.getText();
                    srv_state = true;
                    // fermeture de la fenetre de connexion
                    fermer();
                    try {
                      java.rmi.registry.LocateRegistry.createRegistry(num_port);
                      System.out.println("Ecoute sur le port : " + num_port);
                      // Placement de l'objet distant du client sur sa machine : localhost dans le
                      // registre pour le numéro de port spécifié
                      Naming.rebind("//" + adr + ":" + num_port + "/" + nom.getText(), retourObj());
                      System.out.println(Naming.list("//" + adr + ":" + num_port)[0]);
                    } catch (MalformedURLException ex2) {
                      System.out.println(ex2);
                    } catch (RemoteException ex1) {
                      System.out.println(ex1);
                    }
                    // Constructeur graphique de la classe Client
                    C = new Client(nom.getText(), new String(pwd.getPassword()));
                    Essai essai = new Essai();
                    SplashWindowApp splash = new SplashWindowApp(C, 2000, essai);
                    if (J.getnbrcon() >= 2) {
                      System.out.println("Mise à jour de la liste du nouveau connecté");
                      // Mise à jour de la liste des destinataires du nouveau connecté
                      for (int i = 0; i < J.getnbrcon(); i++)
                        if (J.list_con()[i].compareTo(nom.getText()) != 0) C.ajout(J.list_con()[i]);
                    }
                  } else {
                    JOptionPane.showMessageDialog(
                        null, "Vérifiez votre pseudonyme ou mot de passe");
                    nbr++;
                  }

                } catch (RemoteException ex) {
                  System.out.println(ex);
                }
              }
            }
            if (nbr == 3) {
              JOptionPane.showMessageDialog(null, "Nombre maximum d'essai est atteint");
              System.exit(0);
            }
          }
        } else {
          if (e.getSource() == Annuler) System.exit(0);
        }
      }
 public boolean dieNow() throws RemoteException {
   System.exit(1);
   return true; // We won't ever get here since we exited above;
   // but we still need it to please the compiler.
 }
Beispiel #16
0
  public static void main(String[] args) {
    boolean all_x = false, do_bind = false;
    String bn_name = "", context_name = "";
    int i;

    for (i = 0; i < args.length; i++) {
      if (args[i].charAt(0) != '-') continue;

      switch (args[i].charAt(1)) {
        case 'b':
          bn_name = args[++i];
          break;
        case 'c':
          context_name = args[++i];
          break;
        case 'r':
          do_bind = true;
          break;
      }
    }

    AbstractBeliefNetworkContext bnc = null;
    AbstractBeliefNetwork bn = null;
    AbstractVariable x = null, e_var = null;

    try {
      if ("".equals(context_name)) {
        BeliefNetworkContext local_bnc = new BeliefNetworkContext(null);
        bnc = local_bnc;
      } else {
        String url = "rmi://" + context_name;
        System.err.println("Informativeness: url: " + url);
        long t0 = System.currentTimeMillis();
        bnc = (AbstractBeliefNetworkContext) Naming.lookup(url);
        long tf = System.currentTimeMillis();
        System.err.println(
            "Informativeness: Naming.lookup complete (for belief net context), elapsed time: "
                + ((tf - t0) / 1000.0)
                + " [s]");
      }

      bn = (AbstractBeliefNetwork) bnc.load_network(bn_name);
      if (do_bind) {
        System.err.println("Informativeness: bind belief net.");
        bnc.bind(bn);
      }

      String e_name, x_name;
      double e_value;

      for (i = 0; i < args.length; i++) {
        if (args[i].charAt(0) != '-') continue;

        switch (args[i].charAt(1)) {
          case 'x':
            if ("-xall".equals(args[i])) {
              AbstractVariable[] u = bn.get_variables();
              for (int j = 0; j < u.length; j++) {
                Distribution xposterior = bn.get_posterior(u[j]);
                System.out.println("Informativeness: posterior for " + u[j].get_name() + ":");
                System.out.print("  " + xposterior.format_string("  "));
              }
            } else {
              x_name = args[++i];
              long t0 = System.currentTimeMillis();
              x = (AbstractVariable) bn.name_lookup(x_name);
              long tf = System.currentTimeMillis();
              System.err.println(
                  "Informativeness: Naming.lookup complete (for variable ref), elapsed time: "
                      + ((tf - t0) / 1000.0)
                      + " [s]");
              if (x == null) throw new Exception("name_lookup failed: x: " + x_name);
              Distribution xposterior = bn.get_posterior(x);
              System.out.println("Informativeness: posterior for " + x.get_name() + ":");
              System.out.print("  " + xposterior.format_string("  "));
            }
            break;
          case 'e':
            if (args[i].length() > 2 && args[i].charAt(2) == '-') {
              e_name = args[++i];
              System.err.println("Informativeness.main: evidence: clear " + e_name);
              e_var = (AbstractVariable) bn.name_lookup(e_name);
              bn.clear_posterior(e_var);
            } else {
              e_name = args[++i];
              e_value = Double.parseDouble(args[++i]);
              System.err.println(
                  "Informativeness.main: evidence: set " + e_name + " to " + e_value);

              long t0 = System.currentTimeMillis();
              e_var = (AbstractVariable) bn.name_lookup(e_name);
              long tf = System.currentTimeMillis();
              System.err.println(
                  "Informativeness: Naming.lookup complete (for variable ref), elapsed time: "
                      + ((tf - t0) / 1000.0)
                      + " [s]");
              bn.assign_evidence(e_var, e_value);
            }
            break;
          default:
            continue;
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    System.exit(0);
  }
Beispiel #17
0
  public static void main(String[] args) {
    boolean do_compile_all = false;
    String bn_name = "", x1_name = "", x2_name = "";
    Vector evidence_names = new Vector();

    for (int i = 0; i < args.length; i++) {
      if (args[i].charAt(0) != '-') continue;

      switch (args[i].charAt(1)) {
        case 'b':
          bn_name = args[++i];
          break;
        case 'a':
          do_compile_all = true;
          break;
        case 'x':
          if (args[i].charAt(2) == '1') x1_name = args[++i];
          else if (args[i].charAt(2) == '2') x2_name = args[++i];
          else System.err.println("PathAnalysis.main: " + args[i] + " -- huh???");
          break;
        case 'e':
          evidence_names.addElement(args[++i]);
          break;
        default:
          System.err.println("PathAnalysis.main: " + args[i] + " -- huh???");
      }
    }

    try {
      BeliefNetworkContext bnc = new BeliefNetworkContext(null);
      bnc.add_path("/bechtel/users10/krarti/dodier/belief-nets/assorted");
      AbstractBeliefNetwork bn = bnc.load_network(bn_name);
      Hashtable path_sets;
      Enumeration p;

      if ((p = PathAnalysis.has_directed_cycle(bn)) == null)
        System.err.println("PathAnalysis: no directed cycles found in " + bn_name);
      else {
        System.err.println("PathAnalysis.main: " + bn_name + " has a directed cycle; quit.");
        System.err.print(" cycle is: ");
        while (p.hasMoreElements()) {
          System.err.print(((AbstractVariable) p.nextElement()).get_name());
          if (p.hasMoreElements()) System.err.print(" -> ");
          else System.err.println("");
        }

        System.exit(1);
      }

      Vector evidence = new Vector();
      if (evidence_names.size() > 0) {
        for (int i = 0; i < evidence_names.size(); i++)
          evidence.addElement(bn.name_lookup((String) (evidence_names.elementAt(i))));
      }

      if (do_compile_all) {
        path_sets = PathAnalysis.compile_all_paths(bn);
      } else {
        AbstractVariable x1 = (AbstractVariable) bn.name_lookup(x1_name);
        AbstractVariable x2 = (AbstractVariable) bn.name_lookup(x2_name);
        path_sets = new Hashtable();
        PathAnalysis.compile_paths(x1, x2, path_sets);

        if (PathAnalysis.are_d_connected(x1, x2, evidence))
          System.err.print(
              x1.get_name() + " and " + x2.get_name() + " are d-connected given evidence ");
        else
          System.err.print(
              x1.get_name() + " and " + x2.get_name() + " are NOT d-connected given evidence ");

        for (int i = 0; i < evidence.size(); i++)
          System.err.print(((AbstractVariable) evidence.elementAt(i)).get_name() + " ");
        System.err.println("");
      }

      System.err.println("PathAnalysis.main: results of path finding:");

      AbstractVariable[] u = bn.get_variables();
      for (int i = 0; i < u.length; i++) {
        System.err.println(" --- paths from: " + u[i].get_name() + " ---");

        for (int j = i + 1; j < u.length; j++) {
          VariablePair vp = new VariablePair(u[i], u[j]);
          Vector path_set = (Vector) path_sets.get(vp);
          if (path_set == null) continue;

          Enumeration path_set_enum = path_set.elements();
          while (path_set_enum.hasMoreElements()) {
            AbstractVariable[] path = (AbstractVariable[]) path_set_enum.nextElement();
            System.err.print(" path: ");
            for (int k = 0; k < path.length; k++) System.err.print(path[k].get_name() + " ");
            System.err.println("");
          }
        }
      }

      System.exit(0);
    } catch (Exception e) {
      System.err.println("PathAnalysis.main:");
      e.printStackTrace();
      System.exit(1);
    }
  }
  private void startProcess(String WebNmsHome, String Database) {

    // Connection con=null;

    String webnmshome = WebNmsHome + File.separator;
    System.out.println("WEBNMS HOME... :  " + webnmshome);
    PureUtils.rootDir = webnmshome;
    PureUtils.usersDir = webnmshome;
    String db1 = Database.toUpperCase();
    System.out.println("DATA BASE..... :  " + db1);
    System.out.println();

    try {
      if (db1.equals("MYSQL")) {
        con = getMYSQLConnection();
      } else if (db1.equals("ORACLE")) {
        con = getORACLEConnection();
      } else if (db1.equals("TIMESTEN")) {
        con = getTIMESTENConnection();
      } else if (db1.equals("SOLID")) {
        con = getSOLIDConnection();
      } else if (db1.equals("SYBASE")) {
        con = getSYBASEConnection();
      } else {
        System.out.println("DATABASE NOT SELECTED");
        System.exit(0);
      }

      // sunilg
      dbxmlutil = DBXmlUtility.getInstance(con);
      String parseFileName = PureUtils.rootDir + "conf" + "/" + "database_params.conf";
      File parseFile = new File(parseFileName);
      DBParamsParser parse =
          DBParamsParser.getInstance(
              parseFile); // Database related details are read to create a DB connection.
      String url = parse.getURL();
      String user = parse.getUserName();
      String driver = parse.getDriverName();
      String passwd = parse.getPassword();
      RelationalAPI relapi = new RelationalAPI(url, user, passwd, driver, false);
      RelationalUtil.init(relapi);
    } catch (Exception e) {
      // return new OperationResult(userName,"Failed", "Failed", e.toString());
      e.printStackTrace();
    }
    try {
      // CustomViewUtilities for all are created to register in DBXmlUtility to get update for CV
      // related tables.
      AlertCustomViewUtility acvu = new AlertCustomViewUtility(con);
      EventCustomViewUtility ecvu = new EventCustomViewUtility(con);
      TopoCustomViewUtility tcvu = new TopoCustomViewUtility(con);
      AuditCustomViewUtility aucvu = new AuditCustomViewUtility(con);
      PerfCustomViewUtility pcvu = new PerfCustomViewUtility(con);
      JdbcAPI jdbc = (JdbcAPI) JdbcAPIImpl.getAPI();

      PureServerUtils.getDatabaseParams();

      acvu.setJDBCAPI(jdbc);
      ecvu.setJDBCAPI(jdbc);
      tcvu.setJDBCAPI(jdbc);
      pcvu.setJDBCAPI(jdbc);
      aucvu.setJDBCAPI(jdbc);

      SeverityFEAPIImpl sevAPI = (SeverityFEAPIImpl) SeverityFEAPIImpl.getAPI();
      acvu.setSeverityAPI(sevAPI);
      ecvu.setSeverityAPI(sevAPI);
      tcvu.setSeverityAPI(sevAPI);
      pcvu.setSeverityAPI(sevAPI);
      aucvu.setSeverityAPI(sevAPI);

      // Register to update Custonview related table when DB is updated
      dbxmlutil.registerObjectForTable("Alerts", acvu);
      dbxmlutil.registerObjectForTable("Events", ecvu);
      dbxmlutil.registerObjectForTable("Network Database", tcvu);
      dbxmlutil.registerObjectForTable("Audit", aucvu);
      dbxmlutil.registerObjectForTable("Stats Admin", pcvu);

    } catch (Exception e) {
      System.out.println("unable to instantiate DBXmlUtility");
      e.printStackTrace();
      System.exit(0);
    }

    /* try
    {

    //String sr = dbxmlutil.getPreviousNode("root","Alerts");
    String sr = dbxmlutil.getPreviousNodeForNodeIndex("root","Fault",2);
    System.out.println("The previous node is ... "+sr);
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }   */
    // sunil
    /*executeTestCase004();
    executeTestCase028();
    executeTestCase029();
    executeTestCase034();
    executeTestCase075();*/

    // executeTestCase084();
    // executeTestCase085();
    // executeTestCase086();
    // executeTestCase087();
    executeTestCase108();
    executeTestCase122();
    // sunil

    // System.out.println(" DBXmlUpdate object is successfully created");
    /*executeTestCase025();

          	executeTestCase001();
    executeTestCase002();
    executeTestCase012();
           executeTestCase026();
    executeTestCase029_1();
    executeTestCase075();
    executeTestCase109();
    executeTestCase116();

    executeTestCase123();
    executeTestCase124();
    System.out.println();*/
    System.exit(0);
  }
Beispiel #19
0
 public void crash() throws RemoteException {
   System.out.println("CRASHING.");
   System.exit(-1);
 }
Beispiel #20
0
  /**
   * Main program - starts the middleware. The middleware looks for the resource managers' RMI
   * servers and registers itself to the RMI registry on the machine.
   *
   * @param args
   */
  public static void main(String args[]) {
    String carMachine, flightMachine, roomMachine;
    String carServiceName, flightServiceName, roomServiceName;
    String myRole, myGroupName, myServiceName, configFile;

    carMachine = flightMachine = roomMachine = "localhost";

    HavocadoFlesh obj = null;
    if (args.length == 10) {
      // A master is born...
      myRole = args[0];
      myServiceName = args[1];
      myGroupName = args[2];
      carMachine = args[3];
      carServiceName = args[4];
      flightMachine = args[5];
      flightServiceName = args[6];
      roomMachine = args[7];
      roomServiceName = args[8];
      configFile = args[9];
      boolean isMaster = myRole.equalsIgnoreCase(MASTER_ROLE);
      if (isMaster) {
        // create the master:
        try {
          obj =
              new HavocadoFlesh(
                  true,
                  myServiceName,
                  myGroupName,
                  carMachine,
                  carServiceName,
                  flightMachine,
                  flightServiceName,
                  roomMachine,
                  roomServiceName,
                  configFile);
        } catch (Exception e) {
          System.out.println("Server Exception.");
          e.printStackTrace();
          System.exit(1);
        }
      } else {
        System.out.println("Wrong argument - first argument should be 'master' in this case.");
        System.exit(1);
      }
    } else if (args.length == 4) {
      // A poor slave is born...
      myRole = args[0];
      myServiceName = args[1];
      myGroupName = args[2];
      configFile = args[3];
      boolean isSlave = myRole.equalsIgnoreCase(SLAVE_ROLE);
      if (isSlave) {
        // create the slave:
        try {
          obj = new HavocadoFlesh(false, myServiceName, myGroupName, configFile);
        } catch (Exception e) {
          System.out.println("Server Exception.");
          e.printStackTrace();
          System.exit(1);
        }
      } else {
        System.out.println("Wrong argument - first argument should be 'slave' in this case.");
        System.exit(1);
      }
    } else {
      System.err.println("Wrong usage");
      System.out.println("Usage: ");
      System.out.println(
          "master: 'java ResImpl.HavocadoFlesh master <myRMIServiceName> <myGroupName> "
              + "<carMachineName> <carRMIServiceName> <flightMachineName> <flightRMIServiceName> <roomMachineName> <roomRMIServiceName> <configFile>'");
      System.out.println(
          "slave: 'java ResImpl.HavocadoFlesh slave <myRMIServiceName> <myGroupName> <configFile>'");
      System.exit(1);
    }

    System.out.println("Server ready");
  }