/**
   * Constructor. Creates a datagram send socket and connects it to the Ganglia hypertable extension
   * listen port. Initializes mPrefix to "ht." + <code>component</code> + ".".
   *
   * @param component Hypertable component ("fsbroker", "hyperspace, "master", "rangeserver", or
   *     "thriftbroker")
   * @param props Configuration properties
   */
  public MetricsCollectorGanglia(String component, Properties props) {
    mPrefix = "ht." + component + ".";

    String str = props.getProperty("Hypertable.Metrics.Ganglia.Port", "15860");
    mPort = Integer.parseInt(str);

    str = props.getProperty("Hypertable.Metrics.Ganglia.Disabled");
    if (str != null && str.equalsIgnoreCase("true")) mDisabled = true;

    try {
      mAddr = InetAddress.getByName("localhost");
    } catch (UnknownHostException e) {
      System.out.println("UnknownHostException : 'localhost'");
      e.printStackTrace();
      System.exit(-1);
    }

    try {
      mSocket = new DatagramSocket();
    } catch (SocketException e) {
      e.printStackTrace();
      System.exit(-1);
    }

    mSocket.connect(mAddr, mPort);
    mConnected = true;
  }
Пример #2
0
  public static void main(String[] args) {
    if (args.length < 1) {
      System.out.println("Usage: evaluateCustomMath formula [model containing values]");
      System.exit(1);
    }

    String formula = args[0];
    String filename = args.length == 2 ? args[1] : null;

    ASTNode math = libsbml.parseFormula(formula);
    if (math == null) {
      System.out.println("Invalid formula, aborting.");
      System.exit(1);
    }

    SBMLDocument doc = null;
    if (filename != null) {
      doc = libsbml.readSBML(filename);
      if (doc.getNumErrors(libsbml.LIBSBML_SEV_ERROR) > 0) {
        System.out.println("The models contains errors, please correct them before continuing.");
        doc.printErrors();
        System.exit(1);
      }
      // the following maps a list of ids to their corresponding model values
      // this makes it possible to evaluate expressions involving SIds.
      SBMLTransforms.mapComponentValues(doc.getModel());
    } else {
      // create dummy document
      doc = new SBMLDocument(3, 1);
    }

    double result = SBMLTransforms.evaluateASTNode(math, doc.getModel());
    System.out.println(String.format("%s = %s", formula, result));
  }
Пример #3
0
  /**
   * Entry point.
   *
   * @param args[0] Domain controller name.
   * @param args[1] Domain user name.
   * @param args[2] Domain password.
   * @param args[3] Optional file name. Default is mp3Spider.out
   */
  public static void main(String args[]) throws IOException, InterruptedException {

    String domCtrl = null;
    String domName = null;
    String domUser = null;
    String domPass = null;
    // File to write to
    FileWriter fwrite = null;

    try {
      domCtrl = args[0];
      domName = args[1];
      domUser = args[2];
      domPass = args[3];
    } catch (ArrayIndexOutOfBoundsException e) {
      System.err.println("Usage:");
      System.err.println(
          "java mp3Spider <Domain controller> "
              + "<Domain Name> <Username> <Password> [<Out file>]");
      System.exit(1);
    }

    if (args.length == 5) fwrite = new FileWriter(args[5]);
    else fwrite = new FileWriter("mp3Spider.out");

    // Get list of machines on the domain
    CifsLogin login = new CifsLogin(domUser, domPass);
    CifsRemoteAdmin admin = null;
    CifsServerInfo mach[] = null;
    try {
      admin = CifsSessionManager.connectRemoteAdmin("Mach_list_all", domCtrl, login);

      mach = admin.listServersInfo(domName, CifsServerInfo.SV_TYPE_ALL);
      admin.disconnect();
    } catch (CifsIOException e) {
      System.err.println("Session failed: " + e);
      e.printStackTrace();
      System.exit(1);
    }

    // Create a thread and start shareVu() for every machine
    ShareVu t[] = new ShareVu[mach.length];
    for (int i = 0; i < mach.length; i++) {
      System.out.println("Mach: " + mach[i].getComputerName());
      // Create the thread
      t[i] = new ShareVu(mach[i].getComputerName(), login, fwrite);
    }

    // Wait for all threads to finito

    for (int i = 0; i < mach.length; i++) {
      try {
        t[i].t.join();
      } catch (InterruptedException e) {
        System.out.println("Join error " + e);
      }
    }
  }
Пример #4
0
  public static void main(String[] args) throws LBMException {
    LBMContext ctx = null; /* Context object: container for UM "instance". */
    LBMSource src = null; /* Source object: for sending messages. */

    SrcCB srccb = new SrcCB();

    /** * Initialization: create necessary UM objects. ** */
    try {
      LBMTopic topic = null;
      LBMSourceAttributes srcAttr = null;

      ctx = new LBMContext();
      srcAttr = new LBMSourceAttributes();
      srcAttr.setValue("ume_store", "127.0.0.1:29999");
      srcAttr.setValue("ume_store_behavior", "qc");
      topic = ctx.allocTopic("test.topic", srcAttr);
      src = ctx.createSource(topic, srccb, null, null);
    } catch (LBMException ex) {
      System.err.println("Error initializing LBM objects: " + ex.toString());
      System.exit(1);
    }

    while (true) {
      if (srcReady == 1) {
        /** * Send a message. ** */
        try {
          src.send("test".getBytes(), "test".getBytes().length, LBM.MSG_FLUSH | LBM.SRC_NONBLOCK);
        } catch (LBMException ex) {
          /* Error trying to send, wait 1 second and try again */
          try {
            Thread.sleep(1000);
          } catch (InterruptedException tex) {
            System.err.println("Error Thread.sleep interrupted: " + tex.toString());
            System.exit(1);
          }
        }
      } else {
        /* No quorum, wait 1 second and check again */
        System.out.println("Source is not ready to send (no quorum)");
        try {
          Thread.sleep(1000);
        } catch (InterruptedException tex) {
          System.err.println("Error Thread.sleep interrupted: " + tex.toString());
          System.exit(1);
        }
      }
    }
  } /* main */
Пример #5
0
  public static void main(String a[]) throws Exception {

    boolean bool = false;

    try {
      InputStreamReader in = new InputStreamReader(System.in);
      BufferedReader br = new BufferedReader(in);

      do {
        Socket clientSocket = new Socket("localhost", 6789);
        TCPClient client = new TCPClient(clientSocket);
        client.talkOnSocket();

        System.out.println("Do you want tranfer another file : Y/N");
        String choise = br.readLine().trim();
        if (choise.equalsIgnoreCase("y")) {
          bool = true;
        } else if (choise.equalsIgnoreCase("n")) {
          bool = false;
        } else {
          bool = false;
          System.out.println("Invalid entry. Clsoing.");
        }
      } while (bool);
      in.close();
      br.close();

    } catch (Exception e) {
      System.out.println("Server might not be up and running....");
      System.exit(0);
    }
  }
Пример #6
0
 static void checkSyntax(String[] args) {
   if (args.length == 0) {
     err.printf("Usage: %s [-ilnv] regex [filename...]%n", messages.program_name);
     exit(messages.exit_status = messages.EXIT_FAILURE);
   }
   if (args[0].startsWith("-")) optionsPresent = true;
 }
Пример #7
0
  /** @param args the command line arguments */
  public static void saisieInteractive() {
    for (; ; ) {
      String str =
          Saisie.lireChaine(
              "Taper D pour renter un devis ou "
                  + "taper C pour créer un client Et Q pour quitter\nTaper LV,"
                  + " LC, ou LP pour lister les voyages, les clients ou les "
                  + "pays\n");

      if (str.equals("C") || str.equals("c")) {
        Service.SaisirClient();
      }

      if (str.equals("D") || str.equals("d")) {
        Service.SaisirDevis();
      }

      if (str.equals("Q") || str.equals("q")) {
        System.out.println("Fin de l'application");
        exit(0);
      }
      if (str.equals("LC") || str.equals("lc")) {
        Service.listerClients();
      }
      if (str.equals("LV") || str.equals("lv")) {
        Service.listerTousLesVoyages();
      }
      if (str.equals("LP") || str.equals("lp")) {
        Service.listerTousLesPays();
      }
    }
  }
Пример #8
0
  public void handleNotification(Notification notification, Object handback) {

    SnmpTableEntryNotification notif = (SnmpTableEntryNotification) notification;
    SnmpMibTable table = (SnmpMibTable) notif.getSource();
    String type = notif.getType();

    try {
      if (type.equals(SnmpTableEntryNotification.SNMP_ENTRY_ADDED)) {
        java.lang.System.out.println(
            "NOTE: TableEntryListenerImpl " + "received event \"Entry added\":");
        SsoServerAuthModulesEntryImpl added = (SsoServerAuthModulesEntryImpl) notif.getEntry();
        java.lang.System.out.println("    ModuleName = " + added.getAuthModuleName());
        java.lang.System.out.println("    FailureCount = " + added.getAuthModuleFailureCount());
        java.lang.System.out.println("    SuccessCount = " + added.getAuthModuleSuccessCount());
      } else if (type.equals(SnmpTableEntryNotification.SNMP_ENTRY_REMOVED)) {
        java.lang.System.out.println(
            "NOTE: TableEntryListenerImpl " + "received event " + "\"Entry removed\":");
      } else {
        java.lang.System.out.println("\n    >> Unknown event type (?)\n");
      }
    } catch (Exception e) {
      e.printStackTrace();
      java.lang.System.exit(1);
    }
  }
  public static void main(String[] args) {
    if (args.length != 1) {
      err.println("Test sorting algorithms for a N number array.");
      err.println("Usage: java -ea p83 <N>");
      exit(1);
    }

    int n = Integer.valueOf(args[0]);
    int[] x = randomArray(n, n / 2);

    long time = nanoTime(); // To calculate execution time
    sequentialSort(x, 0, x.length);
    long elapsedTime = nanoTime() - time;

    out.println("Elapsed time = " + elapsedTime);

    int seg = (int) (elapsedTime / 1000000000L);
    elapsedTime -= seg * 1000000000L;
    int min = seg / 60;
    seg = seg % 60;
    int mseg = (int) (elapsedTime / 1000000L);

    out.printf("%-16s | %-14s | %10s | %10s\n", "Algorithm", "Array", "Dimension", "Time (m:s:ms)");
    out.printf("-----------------|----------------|------------|---------------\n");
    out.printf(
        "%-16s | %-14s | %10d |     %03d:%02d:%03d\n", "Sequential", "random", n, min, seg, mseg);
  }
Пример #10
0
  private int Load_Edges(DataInputStream inStream, int num) {
    String line;
    String item1, item2, item3;
    int source_node;
    int dest_node;
    int value;
    int n_nodes, edge_cnt;
    // Node nodes_array[] = new Node[num]; // Wil
    Edge edge;
    n_nodes = num;
    Node nodes_array[];
    nodes_array = new Node[n_nodes];
    nodes_array = this.Node_Array(); // Wil
    edge_cnt = 0;

    try {
      while ((line = inStream.readLine()) != null) {
        StringTokenizer Data = new StringTokenizer(line, " ");
        item1 = Data.nextToken();
        item2 = Data.nextToken();
        item3 = Data.nextToken();
        source_node = Integer.parseInt(item1);
        dest_node = Integer.parseInt(item2);
        value = Integer.parseInt(item3);
        edge = new Edge(nodes_array[source_node - 1], nodes_array[dest_node - 1], value);
        this.Add_Edge(edge);
        edge_cnt++;
      }
      // inFile.close();
    } catch (IOException e) {
      System.err.println("Error in accessing URL: " + e.toString());
      System.exit(1);
    }
    return edge_cnt;
  }
Пример #11
0
  /*  Ejemplo de uso de funciones de resumen Hash
   *  carga el fichero que recibe como parametro y genera el resumen
   */
  public static void main(String[] args) throws Exception {
    // Comprobar argumentos
    if (args.length != 1) {
      mensajeAyuda();
      System.exit(1);
    }

    /* Cargar "provider" (sólo si no se usa el que viene por defecto) */
    Security.addProvider(new BouncyCastleProvider()); // Usa provider BC

    /* Crear función resumen */
    // MessageDigest messageDigest = MessageDigest.getInstance("MD5"); // Usa MD5
    MessageDigest messageDigest = MessageDigest.getInstance("SHA-1"); // Usar SHA-1

    /* Leer fichero de 1k en 1k y pasar fragmentos leidos a la funcion resumen */
    byte[] buffer = new byte[1000];
    int leidos = in.read(buffer, 0, 1000);
    while (leidos != -1) {
      messageDigest.update(buffer); // Pasa texto claro a la función resumen
      leidos = in.read(buffer, 0, 1000);
    }
    in.close();

    byte[] resumen = messageDigest.digest(); // Completar el resumen

    // Mostrar resumen
    System.out.println("RESUMEN:");
    mostrarBytes(resumen);
    System.out.println();
  }
Пример #12
0
 /**
  * The main method.
  *
  * @param args the arguments
  */
 public static void main(String[] args) {
   try {
     FEMultiplayer game = new FEMultiplayer();
     //			SoundTrack.enabled = false;
     game.init(480, 320, "Fire Emblem Multiplayer");
     /* Testing code */
     //			game.testFightStage();
     //			game.testOverworldStage();
     //			game.testDraftStage();
     game.loop();
   } catch (Exception e) {
     System.err.println("Exception occurred, writing to logs...");
     e.printStackTrace();
     try {
       File errLog =
           new File(
               "error_log_client"
                   + LocalDateTime.now().toString().replace("T", "@").replace(":", "-")
                   + ".log");
       PrintWriter pw = new PrintWriter(errLog);
       e.printStackTrace(pw);
       pw.close();
     } catch (IOException e2) {
       e2.printStackTrace();
     }
     System.exit(0);
   }
 }
Пример #13
0
  public static void main(String argv[]) throws Exception {
    RetsSession session = new RetsSession("http://demo.crt.realtors.org:6103/rets/login");

    try {
      if (!session.Login("Joe", "Schmoe")) {
        System.out.println("Invalid login");
        System.exit(2);
      }

      LoginResponse response = session.GetLoginResponse();
      CapabilityUrls capurls = session.GetCapabilityUrls();

      System.out.println("Member name: " + response.GetMemberName());
      System.out.println("Search URL: " + capurls.GetSearchUrl());

      String version = "1.0";
      if (session.GetDetectedRetsVersion() == RetsVersion.RETS_1_5) {
        version = "1.5";
      }

      System.out.println("RETS Version: " + version);

      LogoutResponse logout = session.Logout();

      System.out.println("Billing info: " + logout.GetBillingInfo());
      System.out.println("Logout Message:  " + logout.GetLogoutMessage());
      System.out.println("Connect time: " + logout.GetConnectTime());
    } catch (RetsHttpException ex) {
      System.out.println(ex.getMessage());
    }
  }
Пример #14
0
  public static void main(String[] args) {
    double n1;
    double n2;
    double n3;
    double sum;
    double average;

    String in, out;
    in = JOptionPane.showInputDialog("Enter the first number");
    n1 = Double.parseDouble(in);
    in = JOptionPane.showInputDialog("Enter the second number");
    n2 = Double.parseDouble(in);
    in = JOptionPane.showInputDialog("Enter the third number");
    n3 = Double.parseDouble(in);

    sum = n1 + n2 + n3;
    average = sum / 3;

    // Build the out String
    out = "";
    out = out + "The sum of " + n1 + "," + n2 + " and " + n3 + " is " + sum;
    out = out + "\nThe average of " + n1 + "," + n2 + " and " + n3 + " is " + average;

    JOptionPane.showMessageDialog(null, out);
    System.exit(0);
  }
Пример #15
0
 /**
  * Disconnect from game. Allows for resetting server and client if triggered, but is not used in
  * all situations.
  *
  * @param message the message
  */
 public static void disconnectGame(String message) {
   /*
   //wouldn't be hard to use something like this to reset to lobby rather than quit the game:
   //at the moment this disconnect is only in a few places between stages, i.e. while waiting
   //so it's not too bad to quit the game.
   Player leaver = null;
   for(Player p : session.getPlayers()) {
   	if(p.getID() == message.origin) {
   		leaver = p;
   	}
   }
   session.removePlayer(leaver);
   System.out.println(leaver.getName()+" LEFT THE GAME");
    * */
   if (FEServer.getServer() != null) {
     // boot the server back to lobby
     FEServer.resetToLobbyAndKickPlayers();
   } else {
     // exit the client
     if (message != null && !message.equals("")) {
       Sys.alert("FE:MP", message);
     }
     System.exit(0);
   }
 }
Пример #16
0
 @Override
 protected int onDecodeInstruction() {
   switch (((int) IR.getQ() & 0xFFFF)) {
       // NOP
     case 0x0000:
       return 3;
       // JMP
     case 0x4000:
       return 10;
       // LDA
     case 0x8000:
       return 15;
       // ADD
     case 0x0200:
       return 20;
       // CALL
     case 0xc000:
       return 25;
       // RET
     case 0xc001:
       return 35;
     default:
       java.lang.System.out.printf(
           "Error: unknown instruction code [%04x]\n", (int) IR.getQ());
       java.lang.System.exit(1);
   }
   return 0;
 }
 private void btmMenuPrincipalOkActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btmMenuPrincipalOkActionPerformed
   if (rbtProduto.isSelected()) {
     Produtos p = new Produtos();
     p.setVisible(true);
   }
   if (rbtClientes.isSelected()) {
     Clientes c = new Clientes();
     c.setVisible(true);
   }
   if (rbtRealizarCompra.isSelected()) {
     RealizarCompra rc = new RealizarCompra();
     rc.setVisible(true);
   }
   if (rbtExibirRelatorio.isSelected()) {
     Relatorio r = new Relatorio();
     r.setVisible(true);
   }
   if (rbtFechar.isSelected()) {
     int escolha =
         JOptionPane.showConfirmDialog(
             null, "Voce deseja realmente sair?", null, JOptionPane.YES_NO_OPTION);
     if (escolha == JOptionPane.YES_OPTION) {
       exit(0);
     }
   }
 } // GEN-LAST:event_btmMenuPrincipalOkActionPerformed
  /** @param args the command line arguments */
  public static void main(String[] args) {
    org.apache.log4j.Logger.getRootLogger()
        .addAppender(new ConsoleAppender(new PatternLayout("%c %-5p %m%n"), "System.err"));
    logger.setLevel(org.apache.log4j.Level.INFO);
    logger.info("Analyze Tool starting ... ");
    try {

      PerfCorderHTMLViewGenerator htmlGen = new PerfCorderHTMLViewGenerator();
      StreamSource streamSource = new StreamSource(System.in);
      htmlGen.generateView(streamSource, System.out);
      exit(0);
    } catch (IOException | TransformerException ex) {
      Logger.getLogger(PerfCorderHtmlGenApp.class.getName()).log(Level.SEVERE, null, ex);
      printInfo();
      exit(-1);
    }
  }
Пример #19
0
 public static void main(String[] args) {
   checkSyntax(args);
   if (optionsPresent) setOptions(args);
   compileRegex(args);
   parseFiles(args);
   searchFiles();
   exit(messages.exit_status);
 }
Пример #20
0
 static {
   try {
     System.loadLibrary("librets");
   } catch (UnsatisfiedLinkError e) {
     System.err.println("Unable to load the librets native library.\n" + e);
     System.exit(1);
   }
 }
Пример #21
0
 public synchronized void send(String msg) {
   try {
     streamOut.writeUTF(msg);
   } catch (IOException ioe) {
     System.err.println("Sending error: " + ioe.getMessage());
     System.exit(0);
   }
 }
Пример #22
0
  /**
   * Loads the SWIG-generated libSBML Java module when this class is loaded, or reports a sensible
   * diagnostic message about why it failed.
   */
  static {
    String varname;
    String shlibname;

    if (System.getProperty("os.name").startsWith("Mac OS")) {
      varname = "DYLD_LIBRARY_PATH"; // We're on a Mac.
      shlibname = "'libsbmlj.jnilib'";
    } else {
      varname = "LD_LIBRARY_PATH"; // We're not on a Mac.
      shlibname = "'libsbmlj.so' and/or 'libsbml.so'";
    }

    try {
      System.loadLibrary("sbmlj");
      // For extra safety, check that the jar file is in the classpath.
      Class.forName("org.sbml.libsbml.libsbml");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Error encountered while attempting to load libSBML:");
      e.printStackTrace();
      System.err.println(
          "Please check the value of your "
              + varname
              + " environment variable and/or"
              + " your 'java.library.path' system property"
              + " (depending on which one you are using) to"
              + " make sure it list the directories needed to"
              + " find the "
              + shlibname
              + " library file and the"
              + " libraries it depends upon (e.g., the XML parser).");
      System.exit(1);
    } catch (ClassNotFoundException e) {
      System.err.println(
          "Error: unable to load the file 'libsbmlj.jar'."
              + " It is likely that your -classpath command line "
              + " setting or your CLASSPATH environment variable "
              + " do not include the file 'libsbmlj.jar'.");
      System.exit(1);
    } catch (SecurityException e) {
      System.err.println("Error encountered while attempting to load libSBML:");
      e.printStackTrace();
      System.err.println(
          "Could not load the libSBML library files due to a" + " security exception.\n");
      System.exit(1);
    }
  }
Пример #23
0
  private int Load_Nodes(DataInputStream inStream) {
    // need to open file and load data
    int node_id;
    int x_cor;
    int y_cor;
    // int n_nodes, n_edges, node_cnt, arrow_status;
    Node n;
    String line;
    String item1, item2, item3, item4;

    node_id = 0;
    x_cor = 0;
    y_cor = 0;
    // n_nodes = 0;
    // n_edges = 0;
    // arrow_status = -1;

    try {

      if ((line = inStream.readLine()) != null) {
        StringTokenizer Data = new StringTokenizer(line, " ");
        item1 = Data.nextToken();
        n_nodes = Integer.parseInt(item1);
        item2 = Data.nextToken();
        n_edges = Integer.parseInt(item2);
        item3 = Data.nextToken();
        arrow_status = Integer.parseInt(item3);
        // item4 = Data.nextToken();
        // type = Integer.parseInt( item4 );
        // graph = new GraphClass( n_nodes, n_edges, arrow_status );
        nodes = new Node[n_nodes];
        edges = new Edge[n_edges];

        // ???

        while ((this.Node_Cnt() < n_nodes) && ((line = inStream.readLine()) != null)) {
          Data = new StringTokenizer(line, " ");
          item1 = Data.nextToken();
          item2 = Data.nextToken();
          item3 = Data.nextToken();
          node_id = Integer.parseInt(item1);
          x_cor = Integer.parseInt(item2);
          y_cor = Integer.parseInt(item3);
          n = new Node(node_id, x_cor, y_cor);
          this.Add_Node(n);
        }
        if (n_nodes != 0) {
          source_node = nodes[0];
        }
      }
    } catch (IOException e) {
      System.err.println("error in file" + e.toString());
      System.exit(1);
    }
    return this.Node_Cnt();
  }
Пример #24
0
 public void stop() {
   try {
     if (streamOut != null) streamOut.close();
     if (socket != null) socket.close();
   } catch (IOException ioe) {
     System.err.println("Error closing ...");
     System.exit(0);
   }
   loginThread.close();
 }
Пример #25
0
 public void windowClosing(WindowEvent e) {
   try {
     Libgist.close();
   } catch (LibgistException exc) {
     // can't do very much at this point
     System.err.println("Could not close " + exc);
   }
   opThread.stopNow();
   System.exit(0);
 }
Пример #26
0
 public static void error(Exception exception, String error, boolean fatal) {
   JOptionPane.showMessageDialog(
       null, error + "\n\nException text: " + exception, "Error", JOptionPane.ERROR_MESSAGE);
   if (exception != null) {
     exception.printStackTrace(RXR.log);
   }
   if (fatal) {
     java.lang.System.exit(0);
   }
 }
Пример #27
0
 private static void usage() {
   Print.logInfo("Usage:");
   Print.logInfo("  java ... " + URIArg.class.getName() + " {options}");
   Print.logInfo("Options:");
   Print.logInfo("  -encode=<ASCII>    Encode ASCII string to URL argument string");
   Print.logInfo("  -decode=<args>     Decode URL argument string to ASCII");
   Print.logInfo("  -rtpEnc=<url>      RTP Encode URL [key = 'rtp']");
   Print.logInfo("  -rtpDec=<url>      RTP Decode URL [key = 'rtp']");
   System.exit(1);
 }
Пример #28
0
 private void inicializaLabirinto() {
   salas = new Sala[50];
   salas[0] = new Sala();
   countSalas = 1;
   try {
     leLabirinto(new Scanner(new FileInputStream("labirinto.txt")));
   } catch (Exception e) {
     err.println(e.getMessage());
     exit(1);
   }
 }
Пример #29
0
  public static void main(String[] args) throws Exception {

    Configuration.addDefaultResource("hdfs-default.xml");
    Configuration.addDefaultResource("hdfs-site.xml");

    Crush crusher = new Crush();

    int exitCode = ToolRunner.run(crusher, args);

    System.exit(exitCode);
  }
Пример #30
0
  public static void main(String arr[]) {

    MessagingAPI msgapi = new MessagingAPI();
    boolean rval;

    /*
    int con = msgapi.connect(host_name, server_port);
    if (con == 1)
        System.out.println("Client C connected");
    */
    while (true) {
      try {
        System.out.println("Select from three following Choices : - ");
        System.out.println("1. Send Message");
        System.out.println("2. Receive Message");
        System.out.println("3. Exit");

        brt = new BufferedReader(new InputStreamReader(System.in));
        int choice = 0;
        try {
          choice = Integer.parseInt(brt.readLine());
        } catch (NumberFormatException ne) {
          System.out.println("Improper Format");
        }
        switch (choice) {
          case 1:
            int con = msgapi.connect(host_name, server_port);
            if (con == 1) System.out.println("Client C connected");
            System.out.print("To : ");
            String cName = brt.readLine();
            System.out.print("Message : ");
            String message = brt.readLine();
            rval = msgapi.send(cName, message);
            if (rval) {
              System.out.println("Message Sent Sucessfully");
            }
            break;
          case 2:
            int con1 = msgapi.connect(host_name, server_port);
            if (con1 == 1) System.out.println("Client C connected");
            System.out.println("Message Received : " + msgapi.receive("ClientC"));
            break;
          case 3:
            exit(0);
            break;
          default:
            System.out.println("Wrong Option");
            break;
        }
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
  }