/**
   * The read admin list reads in admin objects from a readfile
   *
   * @return
   * @throws FileNotFoundException
   */
  public LinkedList<Admin> readAdminList() throws FileNotFoundException {
    FileInputStream fstream = new FileInputStream("adminList.csv");
    LinkedList<Admin> adminList = new LinkedList<Admin>();
    Scanner input = new Scanner(fstream);
    input.useDelimiter(",");

    try {
      // reads file
      while (input.hasNext()) {
        String firstName = input.next();
        String lastName = input.next();
        String userName = input.next();
        String password = input.next();
        String email = input.next();
        String office = input.next();
        String phoneNumber = input.nextLine();

        // creates admin
        Admin newAdmin =
            new Admin(userName, password, email, firstName, lastName, office, phoneNumber);

        adminList.add(newAdmin);
      }
      fstream.close();
    } catch (Exception e) {
      adminList = null;
    }

    Collections.sort(adminList);

    return adminList;
  }
Exemple #2
0
  public static void main(String[] args) throws IOException {

    // reads in text file
    Scanner file = new Scanner(new FileReader("input.txt"));
    String message = file.useDelimiter("\\A").next();

    // capitalizes all letters and gets rid of blank spaces
    message = message.toUpperCase();
    message = message.replaceAll("\\s+", "");

    int cipher, encrypt_decrypt;

    // asks user of they want to encrypt or decrypt a message
    System.out.println("Do you want to encrypt or decrypt?");
    System.out.println("1 - Encrypt a message");
    System.out.println("2 - Decrypt a message");
    encrypt_decrypt = cin.nextInt();

    // asks user which algorithm to use
    System.out.println("Which cipher do you want to use?");
    System.out.println("1 - Shift Cipher");
    System.out.println("2 - Affine Cipher");
    System.out.println("3 - Substitution Cipher");
    System.out.println("4 - Vigenere Cipher");
    cipher = cin.nextInt();

    ciphers(message, cipher, encrypt_decrypt);
  }
  /**
   * reads faculty list file
   *
   * @return LinkedList<Faculty>
   * @throws FileNotFoundException
   */
  public LinkedList<Faculty> readFacultyList() throws FileNotFoundException {
    FileInputStream fstream = new FileInputStream("facultyList.csv");
    LinkedList<Faculty> facultyList = new LinkedList<Faculty>();
    Scanner input = new Scanner(fstream);
    input.useDelimiter(",");

    try {
      // reads file
      while (input.hasNext()) {
        String firstName = input.next();
        String lastName = input.next();
        String userName = input.next();
        String password = input.next();
        String email = input.next();
        String office = input.next();
        String phoneNumber = input.nextLine();
        // creates faculty member
        Faculty newFaculty =
            new Faculty(userName, password, email, firstName, lastName, office, phoneNumber);

        facultyList.add(newFaculty);
      }
      fstream.close();
    } catch (Exception e) {
      facultyList = null;
    }

    Collections.sort(facultyList);

    return facultyList;
  }
Exemple #4
0
  /*
  Method: parseInputLine - text parser
  Purpose: parse the line of text and returns a TreeNode
  Parameters:
      String line   the line of text being parsed
  Returns:
      Entry - the Object parsed from the text line
  */
  private TreeNode parseInputLine(String line) {
    if (line.equals("")) {
      // returns a null object if the line is empty
      // only null entry source in code
      return null;
    }

    // a new empty TreeNode object
    TreeNode returnNode = new TreeNode(ENTRY); // is an entry
    // Scanner to scan the line of text
    Scanner lineScanner = new Scanner(line);
    lineScanner.useDelimiter("/");

    // sets the entry's word
    returnNode.setMyString(lineScanner.next());

    while (lineScanner.hasNext()) {
      // the next word in the line
      String nextWord = lineScanner.next();
      // end of line and 'a//b/c' blank words
      if (!(nextWord == null) && !(nextWord.equals(""))) {
        // adds each word in alphabet order to the
        // synonym linkedList
        returnNode.addSynonymInOrder(nextWord);
        // might not have any synonyms
      }
    }
    // returns the finished entry object
    return returnNode;
  }
  public static void main(String[] args) throws IOException {
    in = new Scanner(new FileReader("wordFreq.in"));
    out = new PrintWriter(new FileWriter("wordFreq.out"));

    WordInfo[] wordTable = new WordInfo[N + 1];
    for (int h = 1; h <= N; h++) wordTable[h] = new WordInfo();

    int first = -1; // points to first word in alphabetical order
    int numWords = 0;

    in.useDelimiter("[^a-zA-Z]+");
    while (in.hasNext()) {
      String word = in.next().toLowerCase();
      int loc = search(wordTable, word);
      if (loc > 0) wordTable[loc].freq++;
      else // this is a new word
      if (numWords < MaxWords) { // if table is not full
        first = addToTable(wordTable, word, -loc, first);
        ++numWords;
      } else out.printf("'%s' not added to table\n", word);
    }
    printResults(wordTable, first);
    in.close();
    out.close();
  } // end main
 private void readInventoryFromFile() {
   try {
     Scanner scan = new Scanner(new File("inventory.txt"));
     while (scan.hasNext()) {
       scan.useDelimiter(", ");
       String id = scan.next().trim();
       String title = scan.next().trim();
       scan.useDelimiter("\n");
       double price = Double.parseDouble(scan.next().replace(",", "").trim());
       Book book = new Book(id, title, price);
       inventory.add(book);
     }
   } catch (FileNotFoundException e) {
     System.out.println("DEBUG: -----Start-----\n" + e + "DEBUG: ------End------\n");
   }
 }
Exemple #7
0
 public void readSearchWordsFile() throws FileNotFoundException {
   Scanner sc = new Scanner(new FileReader("src\\LW_5\\Files\\input2.txt"));
   sc.useDelimiter("[;\n\r]+");
   while (sc.hasNextLine()) {
     searchWordsList.add(sc.next());
   }
   sc.close();
 }
  /**
   * reads course list file
   *
   * @return LinkedList<CurrentCourse>
   * @throws FileNotFoundException
   */
  public LinkedList<CurrentCourse> readCourseList() throws FileNotFoundException {
    FileInputStream fstream = new FileInputStream("courseList.csv");
    LinkedList<CurrentCourse> courseList = new LinkedList<CurrentCourse>();
    Scanner input = new Scanner(fstream);

    input.useDelimiter(",");
    try {
      // read file
      while (input.hasNextLine()) {

        String crn;
        crn = input.next();
        String course = input.next();
        int section = input.nextInt();
        String title = input.next();
        String prer = input.next();
        int credits = input.nextInt();
        String time = input.next();
        String days = input.next();
        String building = input.next();
        String room = input.next();
        int totalSeats = input.nextInt();
        int filledSeats = input.nextInt();
        String tempWaiting = input.next();
        String professor = input.nextLine();
        professor = professor.substring(1, professor.length());

        // create current course
        CurrentCourse newCourse =
            new CurrentCourse(
                crn,
                course,
                section,
                title,
                prer,
                credits,
                time,
                days,
                building,
                room,
                professor,
                totalSeats,
                filledSeats,
                tempWaiting);

        courseList.add(newCourse);

        fstream.close();
      }
    } catch (Exception e) {
      courseList = null;
    }

    Collections.sort(courseList);

    return courseList;
  }
Exemple #9
0
 public void readHtmlFile() throws FileNotFoundException {
   Scanner sc = new Scanner(new FileReader("src\\LW_5\\Files\\input1.html"));
   sc.useDelimiter("[ \t]+");
   while (sc.hasNextLine()) {
     tempStrBuilder.append(sc.nextLine());
     tempStrBuilder.append("\n");
   }
   sc.close();
 }
Exemple #10
0
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    try {
      s = new Scanner(new BufferedReader(new FileReader("system.properties")));
    } catch (IOException e) {
      e.printStackTrace();
    }
    s.useDelimiter("\\n|=");
    s.next();
    int n = s.nextInt();
    s.next();
    int m = s.nextInt();
    int[] stime = new int[n];
    int[] otime = new int[n];
    int k = 0;
    while (s.hasNext()) {
      s.next();
      stime[k] = s.nextInt();
      s.next();
      otime[k] = s.nextInt();
      k++;
    }

    FileWriter report = null;
    try {
      report = new FileWriter("output.log", false);
    } catch (IOException h) {

    }
    FileWriter event = null;
    try {
      event = new FileWriter("event.log", false);
    } catch (IOException g) {

    }
    Start.out = new PrintWriter(report);
    PrintWriter ev = new PrintWriter(event);
    Tree t = new Tree(n);
    TreeVisitor[] p = new TreeVisitor[n];
    String times = "";
    for (int i = 0; i < n; i++) p[i] = new TreeVisitor(n + i, m, t, stime[i], otime[i]);

    for (int i = 0; i < n; i++) p[i].start();
    for (int i = 0; i < n; i++) {
      try {
        p[i].join();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
    ev.println("sequence:\n");
    ev.print(Start.runtimes);
    Start.out.close();
    ev.close();
  }
  /**
   * reads student list file
   *
   * @return LinkedList<Student>
   * @throws FileNotFoundException
   */
  public LinkedList<Student> readStudentList() throws FileNotFoundException {
    FileInputStream fstream = new FileInputStream("studentList.csv");
    LinkedList<Student> studentList = new LinkedList<Student>();
    Scanner input = new Scanner(fstream);
    input.useDelimiter(",");

    try {
      // reads file
      while (input.hasNext()) {
        String idNumber = input.next();
        String firstName = input.next();
        String lastName = input.next();
        String userName = input.next();
        String password = input.next();
        String email = input.next();
        String major = input.next();
        String minor = input.next();
        int approvedCredits = input.nextInt();
        int creditHoursEnrolled = input.nextInt();
        String currentSchudule = input.next();
        String hold = input.nextLine();
        hold = hold.substring(1, hold.length());

        boolean holds;
        if (hold.equalsIgnoreCase("True")) holds = true;
        else holds = false;

        // creates student
        Student newStudent =
            new Student(
                idNumber,
                firstName,
                lastName,
                userName,
                password,
                email,
                major,
                minor,
                approvedCredits,
                creditHoursEnrolled,
                currentSchudule,
                holds);

        studentList.add(newStudent);

        fstream.close();
      }
    } catch (Exception e) {
      studentList = null;
    }

    Collections.sort(studentList);

    return studentList;
  }
Exemple #12
0
  public static LinkedList<profile> importer() throws IOException {

    LinkedList<profile> people = new LinkedList<profile>();
    Scanner sFile;
    profile entry;

    try {
      sFile =
          new Scanner(new File("/Users/richarddavies/NetBeansProjects/typ_MatlabGraph/users.dat"));
      sFile.nextLine();
      while (sFile.hasNext()) {

        String profile = sFile.nextLine();
        // System.out.println(profile);

        Scanner profScan = new Scanner(profile);
        profScan.useDelimiter(",");

        while (profScan.hasNext()) {

          Long id = profScan.nextLong();
          String ident = String.valueOf(id);
          String rot_Id = rot13.encrypt(ident);
          Long rot_IntId = Long.parseLong(rot_Id);

          String fname = profScan.next();
          String rot_Name = rot13.encrypt(fname);
          // String sname = profScan.next();
          // int age = profScan.nextInt();
          String gender = profScan.next();
          String nat = profScan.next();

          entry = new profile(id, fname, gender, nat);
          // System.out.println("id: "+id+" name: "+fname+" gender: "+gender+" nationality: "+nat);
          // System.out.println("id: "+rot_IntId+" name: "+rot_Name+" gender: "+gender+"
          // nationality: "+nat);
          people.add(entry);
        }
      }

    } catch (IOException ex) {
      // return people;

      System.out.println("(No System File profile.txt)" + ex);
    }
    return people;
  }
  private synchronized void getZkRunning() throws Exception {
    LOG.debug("Reading " + parentZnode + Constants.DEFAULT_ZOOKEEPER_ZNODE_SERVERS_RUNNING);
    List<String> children =
        getChildren(
            parentZnode + Constants.DEFAULT_ZOOKEEPER_ZNODE_SERVERS_RUNNING, new RunningWatcher());

    if (!children.isEmpty()) {
      for (String child : children) {
        // If stop-wms.sh is executed and WMS_MANAGES_ZK then zookeeper
        // is stopped abruptly.
        // Second scenario is when ZooKeeper fails for some reason
        // regardless of whether WMS
        // manages it. When either happens the WmsServer running znodes
        // still exist in ZooKeeper
        // and we see them at next startup. When they eventually timeout
        // we get node deleted events for a server that no longer
        // exists. So, only recognize
        // WmsServer running znodes that have timestamps after last
        // WmsMaster startup.
        Scanner scn = new Scanner(child);
        scn.useDelimiter(":");
        String hostName = scn.next();
        String instance = scn.next();
        int infoPort = Integer.parseInt(scn.next());
        long serverStartTimestamp = Long.parseLong(scn.next());
        scn.close();

        if (serverStartTimestamp < startupTimestamp) continue;

        if (!runningServers.contains(child)) {
          LOG.debug("Watching running [" + child + "]");
          zkc.exists(
              parentZnode + Constants.DEFAULT_ZOOKEEPER_ZNODE_SERVERS_RUNNING + "/" + child,
              new RunningWatcher());
          runningServers.add(child);
        }
      }
      metrics.setTotalRunning(runningServers.size());
    } else {
      metrics.setTotalRunning(0);
    }
  }
Exemple #14
0
  public void readFile() throws IOException, FileNotFoundException {
    Scanner inp = new Scanner(System.in);
    System.out.print("Enter the name of the file to process:  ");
    String file;
    file = inp.nextLine();
    System.out.println(file);
    Scanner fileScan = new Scanner(new FileReader(file));
    fileScan.useDelimiter(",");

    numBars = fileScan.nextInt();
    values = new int[numBars];
    labels = new String[numBars];
    for (int i = 0; i < numBars - 1; i++) {
      values[i] = fileScan.nextInt();
      labels[i] = fileScan.next();
      System.out.println(values[i] + " " + labels[i]);
    }
    inp.close();
    fileScan.close();
  }
  private synchronized void restartServer(String znodePath) throws Exception {
    String child =
        znodePath.replace(
            parentZnode + Constants.DEFAULT_ZOOKEEPER_ZNODE_SERVERS_RUNNING + "/", "");
    Scanner scn = new Scanner(child);
    scn.useDelimiter(":");
    String hostName = scn.next();
    String instance = scn.next();
    int infoPort = Integer.parseInt(scn.next());
    long serverStartTimestamp = Long.parseLong(scn.next());
    scn.close();

    LOG.error("WmsServer [" + hostName + ":" + instance + "] failed.");

    if (runningServers.contains(child)) {
      LOG.debug("Found [" + child + "], deleting from running servers list");
      runningServers.remove(child);
      metrics.setTotalRunning(runningServers.size());
    }

    RestartHandler handler = new RestartHandler(child);
    restartQueue.add(handler);
  }
  /**
   * reads past course list file
   *
   * @return LinkedList<PastCourse>
   * @throws FileNotFoundException
   */
  public LinkedList<PastCourse> readPastCourseList() throws FileNotFoundException {
    FileInputStream fstream = new FileInputStream("pastCourses.csv");
    LinkedList<PastCourse> courseList = new LinkedList<PastCourse>();
    Scanner input = new Scanner(fstream);

    input.useDelimiter(",");
    try {
      // read files
      while (input.hasNextLine()) {

        String crn;
        crn = input.next();
        String course = input.next();
        int section = input.nextInt();
        String title = input.next();
        int credits = input.nextInt();
        String professor = input.next();
        String grade = input.next();
        String user = input.nextLine();
        user = user.substring(1, user.length());

        // creates past course list
        PastCourse pastCourse =
            new PastCourse(crn, course, section, title, credits, professor, grade, user);

        courseList.add(pastCourse);

        fstream.close();
      }
    } catch (Exception e) {
      courseList = null;
    }

    Collections.sort(courseList);

    return courseList;
  }
Exemple #17
0
  public ReadIn(String filename) {
    Scanner fileReader = null;
    try {
      fileReader = new Scanner(new File(filename));
    } catch (FileNotFoundException ex) {
      System.out.println(ex + " FILE NOT FOUND ");
    }
    fileReader.useDelimiter(",");
    int rowIndex = 0;
    while (fileReader
        .hasNext()) { // Not .hasNextLine(); now it reads all cells on each row. Before, it only
                      // read one cell in each row.
      /*  if (fileReader.next().contains("/")){
          rowIndex++;
      }*/
      for (int j = 0; j < 6; j++) {
        data[rowIndex][j] = fileReader.next();
        System.out.println("At (" + rowIndex + ", " + j + "): " + data[rowIndex][j]);
      }
      rowIndex++;
      fileReader.nextLine();
    }

    System.out.println("---------------------------------");
    System.out.println("The daily pivots divided by 3:" + "\n");

    // for calculating the daily pivot / 3
    double dailyPivotby3N1;
    double dailyPivotby3N2;
    double dailyPivotby3N3;
    double dailyPivotby3;
    DecimalFormat df = new DecimalFormat("####0.00");
    for (int i = 0; i < rows; i++) {
      // System.out.print(data[i][1]); System.out.print(data[i][2]); System.out.print(data[i][3]);
      dailyPivotby3N1 = Double.parseDouble(data[i][2]);
      dailyPivotby3N2 = Double.parseDouble(data[i][3]);
      dailyPivotby3N3 = Double.parseDouble(data[i][4]);
      dailyPivotby3 = (dailyPivotby3N1 + dailyPivotby3N2 + dailyPivotby3N3) / 3;

      System.out.println("Pivot (/3) for " + data[i][0] + " is " + df.format(dailyPivotby3));
    }

    System.out.println("-------------------------------------------");
    System.out.println("The daily pivots divided by 4:" + "\n");

    // for calculating the daily pivot (/4)
    double dailyPivotby4;
    double dailyPivotby4N1;
    double dailyPivotby4N2;
    double dailyPivotby4N3;
    double dailyPivotby4N4;
    for (int i = 0; i < rows; i++) {
      dailyPivotby4N1 = Double.parseDouble(data[i][1]);
      dailyPivotby4N2 = Double.parseDouble(data[i][2]);
      dailyPivotby4N3 = Double.parseDouble(data[i][3]);
      dailyPivotby4N4 = Double.parseDouble(data[i][4]);
      dailyPivotby4 = (dailyPivotby4N1 + dailyPivotby4N2 + dailyPivotby4N3 + dailyPivotby4N4) / 4;
      System.out.println("Pivot (/4) for " + data[i][0] + " is " + df.format(dailyPivotby4));
    }

    System.out.println("-------------------------------------------");
    System.out.println("Daily Second Number:" + "\n");

    // for calculating second number (high + low) / 2

    double secondNumber;
    double secondNumberN1;
    double secondNumberN2;
    for (int i = 0; i < rows; i++) {
      secondNumberN1 = Double.parseDouble(data[i][2]);
      secondNumberN2 = Double.parseDouble(data[i][3]);
      secondNumber = (secondNumberN1 + secondNumberN2) / 2;
      System.out.println("For " + data[i][0] + ", second number is " + df.format(secondNumber));
    }

    System.out.println("-------------------------------------------");
    System.out.println("Pivot differential for daily pivot: " + "\n");

    // for calculating pivot differential (Daily pivot - 2nd number)

    double pivotDifferential;
    for (int i = 0; i < rows; i++) {
      secondNumberN1 = Double.parseDouble(data[i][2]);
      secondNumberN2 = Double.parseDouble(data[i][3]);
      secondNumber = (secondNumberN1 + secondNumberN2) / 2;
      dailyPivotby3N1 = Double.parseDouble(data[i][2]);
      dailyPivotby3N2 = Double.parseDouble(data[i][3]);
      dailyPivotby3N3 = Double.parseDouble(data[i][4]);
      dailyPivotby3 = (dailyPivotby3N1 + dailyPivotby3N2 + dailyPivotby3N3) / 3;
      pivotDifferential = dailyPivotby3 - secondNumber;
      System.out.println(
          "For " + data[i][0] + ", pivot differential is " + df.format(pivotDifferential));
    }

    System.out.println("-------------------------------------------");
    System.out.println("Pivot range high for daily pivot: " + "\n");

    // for calculating the pivot range high (daily pivot price + pivot differential)

    double dailyPivotby3High;
    for (int i = 0; i < rows; i++) {
      secondNumberN1 = Double.parseDouble(data[i][2]);
      secondNumberN2 = Double.parseDouble(data[i][3]);
      secondNumber = (secondNumberN1 + secondNumberN2) / 2;
      dailyPivotby3N1 = Double.parseDouble(data[i][2]);
      dailyPivotby3N2 = Double.parseDouble(data[i][3]);
      dailyPivotby3N3 = Double.parseDouble(data[i][4]);
      dailyPivotby3 = (dailyPivotby3N1 + dailyPivotby3N2 + dailyPivotby3N3) / 3;
      pivotDifferential = dailyPivotby3 - secondNumber;
      dailyPivotby3High = dailyPivotby3 + pivotDifferential;
      System.out.println(
          "For " + data[i][0] + ", pivot range high is " + df.format(dailyPivotby3High));
    }

    System.out.println("-------------------------------------------");
    System.out.println("Pivot range low for daily pivot: " + "\n");

    // for calculating the pivot range low (daily pivot price - pivot differential)

    double dailyPivotby3Low;
    for (int i = 0; i < rows; i++) {
      secondNumberN1 = Double.parseDouble(data[i][2]);
      secondNumberN2 = Double.parseDouble(data[i][3]);
      secondNumber = (secondNumberN1 + secondNumberN2) / 2;
      dailyPivotby3N1 = Double.parseDouble(data[i][2]);
      dailyPivotby3N2 = Double.parseDouble(data[i][3]);
      dailyPivotby3N3 = Double.parseDouble(data[i][4]);
      dailyPivotby3 = (dailyPivotby3N1 + dailyPivotby3N2 + dailyPivotby3N3) / 3;
      pivotDifferential = dailyPivotby3 - secondNumber;
      dailyPivotby3Low = dailyPivotby3 - pivotDifferential;
      System.out.println(
          "For " + data[i][0] + ", pivot range low is " + df.format(dailyPivotby3Low));
    }
  }
    @Override
    public ScriptContext call() throws Exception {
      try {
        Scanner scn = new Scanner(znodePath);
        scn.useDelimiter(":");
        String hostName = scn.next(); // host name
        String instance = scn.next(); // instance
        int infoPort = Integer.parseInt(scn.next()); // UI info port
        long serverStartTimestamp = Long.parseLong(scn.next());
        scn.close();

        // Get the --config property from classpath...it's always first
        // in the classpath
        String cp = System.getProperty("java.class.path");
        scn = new Scanner(cp);
        scn.useDelimiter(":");
        String confDir = scn.next();
        scn.close();
        LOG.debug("conf dir [" + confDir + "]");

        // Get -Dwms.home.dir
        String wmsHome = System.getProperty("wms.home.dir");

        // If stop-wms.sh is executed and WMS_MANAGES_ZK then zookeeper
        // is stopped abruptly.
        // Second scenario is when ZooKeeper fails for some reason
        // regardless of whether WMS
        // manages it. When either happens the WmsServer running znodes
        // still exist in ZooKeeper
        // and we see them at next startup. When they eventually timeout
        // we get node deleted events for a server that no longer
        // exists. So, only recognize
        // WmsServer running znodes that have timestamps after last
        // WmsMaster startup.
        if (serverStartTimestamp > startupTimestamp) {
          scriptContext.setHostName(hostName);
          scriptContext.setScriptName("sys_shell.py");
          if (hostName.equalsIgnoreCase(ia.getCanonicalHostName()))
            scriptContext.setCommand(
                "bin/wms-daemon.sh --config " + confDir + " start server " + instance);
          else
            scriptContext.setCommand(
                "pdsh -w "
                    + hostName
                    + " \"cd "
                    + wmsHome
                    + ";bin/wms-daemon.sh --config "
                    + confDir
                    + " start server "
                    + instance
                    + "\"");

          RetryCounter retryCounter = retryCounterFactory.create();
          while (true) {
            if (scriptContext.getStdOut().length() > 0)
              scriptContext.getStdOut().delete(0, scriptContext.getStdOut().length());
            if (scriptContext.getStdErr().length() > 0)
              scriptContext.getStdErr().delete(0, scriptContext.getStdErr().length());
            LOG.info(
                "Restarting WmsServer ["
                    + hostName
                    + ":"
                    + instance
                    + "], script [ "
                    + scriptContext.toString()
                    + " ]");
            ScriptManager.getInstance().runScript(scriptContext);

            if (scriptContext.getExitCode() == 0) {
              LOG.info("WmsServer [" + hostName + ":" + instance + "] restarted");
              break;
            } else {
              StringBuilder sb = new StringBuilder();
              sb.append("exit code [" + scriptContext.getExitCode() + "]");
              if (!scriptContext.getStdOut().toString().isEmpty())
                sb.append(", stdout [" + scriptContext.getStdOut().toString() + "]");
              if (!scriptContext.getStdErr().toString().isEmpty())
                sb.append(", stderr [" + scriptContext.getStdErr().toString() + "]");
              LOG.error(sb.toString());

              if (!retryCounter.shouldRetry()) {
                LOG.error(
                    "WmsServer ["
                        + hostName
                        + ":"
                        + instance
                        + "] restart failed after "
                        + retryCounter.getMaxRetries()
                        + " retries");
                break;
              } else {
                retryCounter.sleepUntilNextRetry();
                retryCounter.useRetry();
              }
            }
          }
        } else {
          LOG.debug(
              "No restart for "
                  + znodePath
                  + "\nbecause WmsServer start time ["
                  + DateFormat.getDateTimeInstance().format(new Date(serverStartTimestamp))
                  + "] was before WmsMaster start time ["
                  + DateFormat.getDateTimeInstance().format(new Date(startupTimestamp))
                  + "]");
        }
      } catch (Exception e) {
        e.printStackTrace();
        LOG.error(e);
      }

      return scriptContext;
    }
Exemple #19
0
  public static LinkedList<edge> importer(MatlabProxy proxy)
      throws IOException, MatlabConnectionException, MatlabInvocationException {

    Scanner sFile;
    edge entry;
    LinkedList<edge> tie = new LinkedList<edge>();
    Long k, p;

    try {
      sFile =
          new Scanner(new File("/Users/richarddavies/NetBeansProjects/typ_MatlabGraph/edges.dat"));

      System.out.println(sFile.nextLine());

      while (sFile.hasNext()) {

        String edge = sFile.nextLine();
        // System.out.println(edge);

        Scanner edgeScan = new Scanner(edge);
        edgeScan.useDelimiter(",");

        while (edgeScan.hasNext()) {

          k = edgeScan.nextLong();
          System.out.print(k + " ");

          String ident_k = String.valueOf(k);
          String rot_Id_k = rot13.encrypt(ident_k);
          Long rot_k = Long.parseLong(rot_Id_k);

          p = edgeScan.nextLong();
          System.out.print(p);

          String ident_p = String.valueOf(p);
          String rot_Id_p = rot13.encrypt(ident_p);
          Long rot_p = Long.parseLong(rot_Id_p);

          // System.out.println(rot_k+" : "+rot_p);
          entry = new edge(k, p);

          int n = search.search(k);
          int m = search.search(p);
          System.out.print(
              " : "
                  + Typ_MatlabGraph.people.get(n).idProf
                  + " "
                  + Typ_MatlabGraph.people.get(m).idProf);
          System.out.println("");
          n++;
          m++;

          proxy.eval("adjMatrix(" + n + "," + m + ") = 1");

          tie.add(entry);
        }
      }

    } catch (IOException ex) {

      System.out.println("(No System File profile.txt)" + ex);
    }

    return tie;
  }