Package org.apache.uima.ducc.cli.ws.json

Examples of org.apache.uima.ducc.cli.ws.json.MachineFactsList


    }
    return reserveSize;
  }
 
  public MachineFactsList getMachineFactsList() {
    MachineFactsList factsList = new MachineFactsList();
    ConcurrentSkipListMap<MachineInfo,String> sortedMachines = getSortedMachines();
    Iterator<MachineInfo> iterator;
    iterator = sortedMachines.keySet().iterator();
    while(iterator.hasNext()) {
      MachineInfo machineInfo = iterator.next();
      String status = machineInfo.getStatus();
      String ip = machineInfo.getIp();
      String name = machineInfo.getName();
      String reserve = getReserveSize(machineInfo);
      String memory = machineInfo.getMemTotal();
      String swap = machineInfo.getMemSwap();
      List<String> aliens = machineInfo.getAliensPidsOnly();
      String sharesTotal = machineInfo.getSharesTotal();
      String sharesInuse = machineInfo.getSharesInuse();
      String heartbeat = ""+machineInfo.getElapsed();
      MachineFacts facts = new MachineFacts(status,ip,name,reserve,memory,swap,aliens,sharesTotal,sharesInuse,heartbeat);
      factsList.add(facts);
    }
    return factsList;
  }
View Full Code Here


    MachineFacts machineFacts = new MachineFacts(status,ip,name, reserve, memory, swap, aliens, sharesTotal, sharesInuse, heartbeat);
    return machineFacts;
  }
 
  private MachineFactsList createMachineFactsList() {
    MachineFactsList machineFactsList = new MachineFactsList();
    for(int i=0; i<10; i++) {
      machineFactsList.add(createMachineFacts());
    }
    return machineFactsList;
  }
View Full Code Here

  }

  @Test
  public void testMachineFacts() {
    MachineFactsTest machineFactsTest = new MachineFactsTest();
    MachineFactsList machineFactsList = machineFactsTest.createMachineFactsList();
    Gson gson = new Gson();
    String jSon = gson.toJson(machineFactsList);
    MachineFactsList reconstituted = gson.fromJson(jSon, MachineFactsList.class);
    for(int i=0; i<machineFactsList.size(); i++) {
      MachineFacts m1 = machineFactsList.get(i);
      MachineFacts m2 = reconstituted.get(i);
      if(!compare(m1,m2)) {
        fail("missing "+"name="+m1.name);
      }
    }
  }
View Full Code Here

    StringBuffer row;
    StringBuffer data = new StringBuffer();
   
    DuccMachinesData instance = DuccMachinesData.getInstance();
   
    MachineFactsList factsList = instance.getMachineFactsList();
    if(factsList.size() > 0) {
      // Total
      listIterator = factsList.listIterator();
      while(listIterator.hasNext()) {
        MachineFacts facts = listIterator.next();
        try {
          sumReserve += Integer.parseInt(facts.reserve);
          sumMemory += Integer.parseInt(facts.memory);
          sumSwap += Integer.parseInt(facts.swap);
          sumAliens += facts.aliens.size();
          sumSharesTotal += Integer.parseInt(facts.sharesTotal);
          sumSharesInuse += Integer.parseInt(facts.sharesInuse);
        }
        catch(Exception e) {
          duccLogger.error(methodName, jobid, e);
        }
      }
      row = new StringBuffer();
      row.append("<tr>");
      // Release ALL Stuck JPs
      row.append("<td>");
      String releaseAll = buildReleaseAll(request, factsList);
      row.append(releaseAll);
      row.append("</td>");
      // Status
      row.append("<td>");
      row.append(""+"Total");
      row.append("</td>");
      // IP
      row.append("<td>");
      row.append("");
      row.append("</td>");
      // Name
      row.append("<td>");
      row.append("");
      row.append("</td>");
      // Reserve: total
      row.append("<td align=\"right\">");
      row.append(""+sumReserve);
      row.append("</td>");
      // Memory: total
      row.append("<td align=\"right\">");
      row.append(""+sumMemory);
      row.append("</td>");
      // Swap: inuse
      row.append("<td align=\"right\">");
      row.append(""+sumSwap);
      row.append("</td>");
      // Alien PIDs
      row.append("<td align=\"right\">");
      row.append(""+sumAliens);
      row.append("</td>");
      // Shares: total
      row.append("<td align=\"right\">");
      row.append(""+sumSharesTotal);
      row.append("</td>");
      // Shares:inuse
      row.append("<td align=\"right\">");
      row.append(""+sumSharesInuse);
      row.append("</td>");
      // Heartbeat: last
      row.append("<td align=\"right\">");
      row.append("");
      row.append("</td>");
      row.append("</tr>");
      data.append(row);
      // Individual Machines
      listIterator = factsList.listIterator();
      while(listIterator.hasNext()) {
        MachineFacts facts = listIterator.next();
        row = new StringBuffer();
        row.append((trGet(counter)));
        // Release Machine Stuck JPs
View Full Code Here

    JsonArray row;
    StringBuffer sb;
   
    DuccMachinesData instance = DuccMachinesData.getInstance();
   
    MachineFactsList factsList = instance.getMachineFactsList();
    if(factsList.size() > 0) {
      // Total
      listIterator = factsList.listIterator();
      while(listIterator.hasNext()) {
        MachineFacts facts = listIterator.next();
        try {
          sumReserve += Integer.parseInt(facts.reserve);
          sumMemory += Integer.parseInt(facts.memory);
          sumSwap += Integer.parseInt(facts.swap);
          sumAliens += facts.aliens.size();
          sumSharesTotal += Integer.parseInt(facts.sharesTotal);
          sumSharesInuse += Integer.parseInt(facts.sharesInuse);
        }
        catch(Exception e) {
          duccLogger.error(methodName, jobid, e);
        }
      }
      row = new JsonArray();
      // Release ALL Stuck JPs
      String releaseAll = buildReleaseAll(request, factsList);
      row.add(new JsonPrimitive(releaseAll));
      // Status
      row.add(new JsonPrimitive("Total"));
      // IP
      row.add(new JsonPrimitive(""));
      // Name
      row.add(new JsonPrimitive(""));
      // Reserve: total
      row.add(new JsonPrimitive(sumReserve));
      // Memory: total
      row.add(new JsonPrimitive(sumMemory));
      // Swap: inuse
      row.add(new JsonPrimitive(sumSwap));
      // Alien PIDs
      row.add(new JsonPrimitive(sumAliens));
      // Shares: total
      row.add(new JsonPrimitive(sumSharesTotal));
      // Shares:inuse
      row.add(new JsonPrimitive(sumSharesInuse));
      // Heartbeat: last
      row.add(new JsonPrimitive(""));
      data.add(row);
      // Individual Machines
      listIterator = factsList.listIterator();
      while(listIterator.hasNext()) {
        MachineFacts facts = listIterator.next();
        row = new JsonArray();
        // Release Machine Stuck JPs
        String releaseMachine = buildReleaseMachine(request, facts);
View Full Code Here

    duccLogger.trace(methodName, jobid, messages.fetch("enter"));
    StringBuffer sb = new StringBuffer();
   
    DuccMachinesData instance = DuccMachinesData.getInstance();
   
    MachineFactsList factsList = instance.getMachineFactsList();
   
    Gson gson = new Gson();
    String jSon = gson.toJson(factsList);
    sb.append(jSon);
    duccLogger.debug(methodName, jobid, sb);
View Full Code Here

    URL url = new URL(getUrlString());
    URLConnection ucon = url.openConnection();
    BufferedReader br = new BufferedReader(new InputStreamReader(ucon.getInputStream()));
    String jSon = br.readLine();
    Gson gson = new Gson();
    MachineFactsList fl = gson.fromJson(jSon, MachineFactsList.class);
        br.close();
        return fl;
  }
View Full Code Here

      System.out.println("?");
    }
  }
 
  private void main_instance(String[] args) throws Exception {
    MachineFactsList fl = get();
    display(fl);
  }
View Full Code Here

        response.getWriter().println(result);
      }
      else {
        if(type.equalsIgnoreCase("jobs")) {
          ArrayList<String> nodeList = new ArrayList<String>();
          MachineFactsList mfl = DuccMachinesData.getInstance().getMachineFactsList();
          Iterator<MachineFacts> mfIterator = mfl.iterator();
          while(mfIterator.hasNext()) {
            MachineFacts mf = mfIterator.next();
            if(mf.status != null) {
              if(mf.status != "up") {
                if(mf.name != null) {
View Full Code Here

TOP

Related Classes of org.apache.uima.ducc.cli.ws.json.MachineFactsList

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.