Example usage for java.rmi RemoteException printStackTrace

List of usage examples for java.rmi RemoteException printStackTrace

Introduction

In this page you can find the example usage for java.rmi RemoteException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:condorclient.MainFXMLController.java

@FXML
public void releaseJobFired(ActionEvent event) {

    int releaseNo = 0;
    int releaseClusterId = 0;
    int n = JOptionPane.showConfirmDialog(null, "??", "",
            JOptionPane.YES_NO_OPTION);
    if (n == JOptionPane.YES_OPTION) {

        //checkboxclusterId
        System.out.print(Thread.currentThread().getName() + "\n");

        URL url = null;/*  www .  j a v a2  s.  c om*/
        XMLHandler handler = new XMLHandler();
        String scheddStr = handler.getURL("schedd");
        try {
            url = new URL(scheddStr);
            //url = new URL("http://localhost:9628");
        } catch (MalformedURLException e3) {
            // TODO Auto-generated catch block
            e3.printStackTrace();
        }
        Schedd schedd = null;

        try {
            schedd = new Schedd(url);
        } catch (ServiceException ex) {
            Logger.getLogger(CondorClient.class.getName()).log(Level.SEVERE, null, ex);
        }

        //ClassAdStructAttr[]
        ClassAd ad = null;//birdbath.ClassAd;
        ClassAdStructAttr[][] classAdArray = null;

        int tmp1 = 0;

        final List<?> selectedNodeList = new ArrayList<>(table.getSelectionModel().getSelectedItems());
        for (Object o : selectedNodeList) {
            if (o instanceof ObservableDisplayedClassAd) {
                releaseClusterId = Integer.parseInt(((ObservableDisplayedClassAd) o).getClusterId());
            }
        }
        //e
        int job = 0;
        Transaction xact = schedd.createTransaction();
        try {
            xact.begin(30);

        } catch (RemoteException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        System.out.println("releaseClusterId:" + releaseClusterId);

        // String findreq = "owner==\"htcondor\"&&ClusterId==" + releaseClusterId;
        String findreq = "owner==\"" + condoruser + "\"&&ClusterId==" + releaseClusterId;
        try {
            classAdArray = schedd.getJobAds(findreq);
        } catch (RemoteException ex) {
            Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex);
        }
        String showJobStatus = null;
        for (ClassAdStructAttr[] x : classAdArray) {
            ad = new ClassAd(x);
            job = Integer.parseInt(ad.get("ProcId"));

            status = Integer.valueOf(ad.get("JobStatus"));
            showJobStatus = statusName[status];
            try {
                if (showJobStatus.equals("")) {
                    xact.releaseJob(releaseClusterId, job, "");
                } else {//????
                    if (showJobStatus.equals("?") || showJobStatus.equals("?")
                            || showJobStatus.equals("") || showJobStatus.equals("")
                            || showJobStatus.equals("")) {
                        JOptionPane.showMessageDialog(null, "?????");
                        return;
                    }

                }
                System.out.print("ts.releaseClusterId():" + releaseClusterId + "job" + job + "\n");
            } catch (RemoteException ex) {
                Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        try {
            xact.commit();
        } catch (RemoteException e) {

            e.printStackTrace();
        }
        //??

    } else if (n == JOptionPane.NO_OPTION) {
        System.out.println("qu xiao");

    }
}

From source file:net.sf.mpaxs.spi.computeHost.Host.java

/**
 * Erstellt ein RemoteObject vom Typ IRemoteHost und trgt es in die lokale
 * RMI Registry ein. ber dieses RemoteObject knnen Jobs an diesen
 * ComputeHoste gesendet werden.//from  ww w  .j  av a 2 s .  c  om
 */
private void getReadyForClients() {
    Logger.getLogger(Host.class.getName()).log(Level.FINE, "Trying to create registry at {0}:{1}",
            new Object[] { settings.getLocalIp(), settings.getLocalPort() });
    try {
        LocateRegistry.createRegistry(settings.getLocalPort());
        Logger.getLogger(Host.class.getName()).log(Level.FINE, "Started own RMI-Registry on port {0}",
                settings.getLocalPort());
    } catch (RemoteException ex) {
        if (!settings.getSilentMode()) {
            Logger.getLogger(Host.class.getName()).log(Level.FINE, "RMI-Registry already running on port {0}.",
                    settings.getLocalPort());
            Logger.getLogger(Host.class.getName()).log(Level.FINE,
                    "ComputeHost will use the already running Registry.");
        }
    }
    try {

        // RemoteObject erstellen
        IComputeHost remObj = new ComputeHostImpl(this, settings);
        String bindString = "//" + settings.getLocalIp() + ":" + settings.getLocalPort() + "/"
                + settings.getName();
        Logger.getLogger(Host.class.getName()).log(Level.FINE, "Trying to bind {0}", bindString);
        Naming.bind(bindString, remObj);
    } catch (Exception ex) {
        ex.printStackTrace();
        System.exit(1);
    }
}

From source file:de.ipbhalle.metfusion.main.SubstructureSearch.java

private List<ResultSubstructure> queryDatabase(String substrucPresent) {
    List<ResultSubstructure> candidates = new ArrayList<ResultSubstructure>();

    // convert input SMILES to MOL format for ChemSpider service
    SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    //      sp.setPreservingAromaticity(false);
    //      String mol = "";
    //      String s = "";
    //      try {
    //         IMolecule temp = sp.parseSmiles(substrucPresent);
    //         System.out.println("aromatic Hueckel? -> " + CDKHueckelAromaticityDetector.detectAromaticity(temp));
    //         System.out.println("aromatic double bond? -> " + DoubleBondAcceptingAromaticityDetector.detectAromaticity(temp));
    //         // create coordinates
    //            StructureDiagramGenerator sdg = new StructureDiagramGenerator();
    //            sdg.setMolecule(temp);
    //            sdg.generateCoordinates();
    //            IMolecule layedOutMol = sdg.getMolecule();
    //            //
    //            
    //         byte[] b = null;
    //         ByteArrayOutputStream bos = new ByteArrayOutputStream();
    //         MDLV2000Writer writer = new MDLV2000Writer(bos);
    //         IOSetting[] ios = writer.getIOSettings();
    //         for (int i = 0; i < ios.length; i++) {
    //            System.out.println(ios[i].getName() + "\t" + ios[i].getSetting());
    //         }/*w  ww .  j av a 2 s . com*/
    //         Properties customSettings = new Properties();
    //         customSettings.setProperty("ForceWriteAs2DCoordinates", "true");
    //         customSettings.setProperty("WriteAromaticBondTypes", "true");
    //         PropertiesListener listener = new PropertiesListener(customSettings);
    //         writer.addChemObjectIOListener(listener);
    //          
    //         writer.write(layedOutMol);
    //         writer.close();
    //         b = bos.toByteArray();
    //         mol = new String(b, "UTF-8");
    //         System.out.println(mol);
    //         MassBankUtilities mbu = new MassBankUtilities();
    //         IAtomContainer test2 = mbu.getContainer(mol);
    //         //IAtomContainer test2 = mbu.getContainerUnmodified("c1cccc2nnnc12", "/home/mgerlich/projects/metfusion_tp/BTs/");
    //         System.out.println("aromatic Hueckel? -> " + CDKHueckelAromaticityDetector.detectAromaticity(test2));
    //         System.out.println("aromatic? -> " + DoubleBondAcceptingAromaticityDetector.detectAromaticity(test2));
    //         SmilesGenerator sg = new SmilesGenerator(true);
    //         s = sg.createSMILES(layedOutMol);
    //         System.out.println("old smiles -> " + substrucPresent);
    //         System.out.println("smiles -> " + s);
    //      } catch (InvalidSmilesException e2) {
    //         // TODO Auto-generated catch block
    //         e2.printStackTrace();
    //      } catch (CDKException e) {
    //         // TODO Auto-generated catch block
    //         e.printStackTrace();
    //      } catch (IOException e) {
    //         // TODO Auto-generated catch block
    //         e.printStackTrace();
    //      }
    OpenBabelLocator obl = new OpenBabelLocator();
    String obmol = "";
    //      try {
    //         OpenBabelSoap obsoap = obl.getOpenBabelSoap();
    //         obmol = obsoap.convert(substrucPresent, "smi", "mol");
    //         System.out.println("obmol\n" + obmol);
    //      } catch (ServiceException e2) {
    //         // TODO Auto-generated catch block
    //         e2.printStackTrace();
    //      } catch (RemoteException e) {
    //         // TODO Auto-generated catch block
    //         e.printStackTrace();
    //      }

    MassSpecAPISoapProxy chemSpiderProxy = new MassSpecAPISoapProxy();
    SearchSoapProxy ssp = new SearchSoapProxy();
    SubstructureSearchOptions sso = new SubstructureSearchOptions(substrucPresent, false);
    //sso.setMatchTautomers(false);
    //sso.setMolecule(substrucPresent);

    CommonSearchOptions cso = new CommonSearchOptions(EComplexity.Single, EIsotopic.NotLabeled, false, false);
    //cso.setComplexity(EComplexity.Single);
    //cso.setIsotopic(EIsotopic.NotLabeled);   // NotLabeled when using Formula search
    //      cso.setComplexity(EComplexity.Any);
    //      cso.setIsotopic(EIsotopic.Any);
    //cso.setHasSpectra(false);
    //cso.setHasPatents(false);
    String transactionID = "";
    ERequestStatus ers = null;

    try {
        transactionID = ssp.substructureSearch(sso, cso, token);
        System.out.println("transaction id -> " + transactionID);
        ers = ssp.getAsyncSearchStatus(transactionID, token);
        while (ers.equals(ERequestStatus.Processing)) {
            Thread.sleep(2000);
            ers = ssp.getAsyncSearchStatus(transactionID, token);
        }
    } catch (RemoteException e1) {
        e1.printStackTrace();
        return candidates;
    } catch (InterruptedException e) {
        e.printStackTrace();
        return candidates;
    }

    if (ers.equals(ERequestStatus.Failed)) {
        System.out.println("failed");
        return candidates;
    }

    if (ers.equals(ERequestStatus.ResultReady)) {
        int[] CSIDs = null;
        System.out.println("woohoo");
        try {
            CSIDs = ssp.getAsyncSearchResult(transactionID, token);
        } catch (RemoteException e) {
            System.err.println("Error retrieving information and parsing results.");

            String resultURL = "http://www.chemspider.com/Search.asmx/GetAsyncSearchResult?rid=%s&token=%s";
            String format = String.format(resultURL, transactionID, token);
            try {
                URL u = new URL(format);
                URLConnection con = u.openConnection();
                InputStream is = con.getInputStream();
                String ids = IOUtils.toString(is);
                is.close();

                Document doc = Jsoup.parse(ids);
                Elements elem = doc.getElementsByTag("int");
                CSIDs = new int[elem.size()];
                for (int i = 0; i < CSIDs.length; i++) {
                    CSIDs[i] = Integer.parseInt(elem.get(i).text().trim());
                }
            } catch (MalformedURLException e1) {
                System.err.println("Wrong URL for retrieving results!\n" + format);
            } catch (IOException e1) {
                System.err.println("Error parsing results!");
            }
        }

        if (CSIDs == null || CSIDs.length == 0)
            return candidates;

        System.out.println("#CSIDs -> " + CSIDs.length);
        int arrLength = CSIDs.length;
        int splitLength = 1000;
        //            if(CSIDs.length > splitLength)
        //               CSIDs = Arrays.copyOf(CSIDs, splitLength);
        int[] temp = new int[1];
        int numSplits = arrLength / splitLength;
        int remaining = arrLength % splitLength;
        if (numSplits == 0) {
            try {
                chemspiderInfo = chemSpiderProxy.getExtendedCompoundInfoArray(CSIDs, token);
            } catch (RemoteException e) {
                System.err.println("Error retrieving information and parsing results.");
                return candidates;
            }
        } else {
            int pos = 0;
            int current = 0;
            List<ExtendedCompoundInfo> eci = new ArrayList<ExtendedCompoundInfo>();
            for (int i = 0; i < numSplits; i++) {
                System.out.println("split [" + i + "] from " + numSplits);
                temp = Arrays.copyOfRange(CSIDs, pos, pos + splitLength);
                ExtendedCompoundInfo[] part;
                try {
                    part = chemSpiderProxy.getExtendedCompoundInfoArray(temp, token);
                } catch (RemoteException e1) {
                    System.err
                            .println("Error retrieving information and parsing results for split [" + i + "].");
                    pos = pos + splitLength;
                    continue;
                }
                for (int j = 0; j < part.length; j++) {
                    eci.add(part[j]);
                    //chemspiderInfo[current] = part[j];
                    current++;
                }
                pos = pos + splitLength;
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    System.err.println("Error while thread sleep!");
                }
            }
            // add remaining stuff
            if (remaining > 0) {
                temp = Arrays.copyOfRange(CSIDs, pos, pos + remaining);
                ExtendedCompoundInfo[] part;
                try {
                    part = chemSpiderProxy.getExtendedCompoundInfoArray(temp, token);
                } catch (RemoteException e) {
                    System.err.println("Error retrieving information and parsing results.");
                    return candidates;
                }
                for (int j = 0; j < part.length; j++) {
                    eci.add(part[j]);
                    //chemspiderInfo[current] = part[j];
                    current++;
                }
            }

            // copy list into array
            chemspiderInfo = new ExtendedCompoundInfo[eci.size()];
            for (int i = 0; i < chemspiderInfo.length; i++) {
                chemspiderInfo[i] = eci.get(i);
            }
        }

        //         chemspiderInfo = chemSpiderProxy.getExtendedCompoundInfoArray(CSIDs, token);
        //         chemspiderInfo = new ExtendedCompoundInfo[CSIDs.length];
        //         for (int i = 0; i < chemspiderInfo.length; i++) {
        //            chemspiderInfo[i] = chemSpiderProxy.getExtendedCompoundInfo(CSIDs[i], token);
        //         }
        boolean writeSDF = true;
        String filename = batchFileHandler.getBatchFile().getName();
        int idx = filename.lastIndexOf(".");
        String ending = ".sdf";
        filename = filename.substring(0, idx) + "_original" + ending;
        File originalSDF = new File(batchFileHandler.getBatchFile().getParent(), filename);
        MDLV2000Writer writer = null;
        try {
            writer = new MDLV2000Writer(new FileOutputStream(originalSDF));
        } catch (FileNotFoundException e1) {
            System.err
                    .println("File [" + originalSDF.getAbsolutePath() + "] not found for original SDF writer!");
            writeSDF = false;
        }
        if (writeSDF) {

        }

        System.out.println("# matches -> " + chemspiderInfo.length);
        for (int i = 0; i < chemspiderInfo.length; i++) {
            System.out.println(chemspiderInfo[i].getCSID() + "\t" + chemspiderInfo[i].getSMILES());
            IAtomContainer ac = null;
            boolean used = false;
            try {
                // TODO check for kekule on new CDK SmilesParser to retain all candidates
                ac = sp.parseSmiles(chemspiderInfo[i].getSMILES());
                used = true;
            } catch (InvalidSmilesException ise) {
                ac = null;
                used = false;
                System.err.println("skipping " + chemspiderInfo[i].getCSID());
            }

            candidates.add(new ResultSubstructure(chemspiderInfo[i], ac, used));
            if (used && writeSDF) {
                try {
                    Map<Object, Object> props = ac.getProperties();
                    props.put("CSID", chemspiderInfo[i].getCSID());
                    props.put("SMILES", chemspiderInfo[i].getSMILES());
                    props.put("name", chemspiderInfo[i].getCommonName());
                    props.put("ALogP", chemspiderInfo[i].getALogP());
                    props.put("XLogP", chemspiderInfo[i].getXLogP());
                    props.put("InChI", chemspiderInfo[i].getInChI());
                    props.put("InChIKey", chemspiderInfo[i].getInChIKey());
                    props.put("MF", chemspiderInfo[i].getMF());

                    ac.setProperties(props);
                    writer.write(ac);
                } catch (CDKException e) {
                    System.err.println("Error writing " + chemspiderInfo[i].getCSID() + " to file ["
                            + originalSDF.getAbsolutePath() + "]!");
                }
            }
        }

        try {
            writer.close();
        } catch (IOException e) {
            System.err.println("Error finalizing original SDF output file!");
        }
    }

    return candidates;
}

From source file:condorclient.MainFXMLController.java

@FXML
void reScheduleFired(ActionEvent event) {
    //cluster?/*from   w  w w  .j  a v  a  2s  .c  o m*/
    int oldId = 0;//??
    int delNo = 0;
    int reScheduleId = 0;

    URL url = null;

    // String scheddURLStr="http://localhost:9628";
    XMLHandler handler = new XMLHandler();
    String scheddStr = handler.getURL("schedd");
    try {
        url = new URL(scheddStr);
    } catch (MalformedURLException e3) {
        // TODO Auto-generated catch block
        e3.printStackTrace();
    }
    Schedd schedd = null;

    int n = JOptionPane.showConfirmDialog(null, "?????", "",
            JOptionPane.YES_NO_OPTION);
    if (n == JOptionPane.YES_OPTION) {

        //checkboxclusterId
        System.out.print(Thread.currentThread().getName() + "\n");

        try {
            schedd = new Schedd(url);
        } catch (ServiceException ex) {
            Logger.getLogger(CondorClient.class.getName()).log(Level.SEVERE, null, ex);
        }
        //ClassAdStructAttr[]

        ClassAd ad = null;//birdbath.ClassAd;
        ClassAdStructAttr[][] classAdArray = null;
        ClassAdStructAttr[][] classAdArray2 = null;
        String taskStatus = "";

        final List<?> selectedNodeList = new ArrayList<>(table.getSelectionModel().getSelectedItems());
        for (Object o : selectedNodeList) {
            if (o instanceof ObservableDisplayedClassAd) {
                oldId = Integer.parseInt(((ObservableDisplayedClassAd) o).getClusterId());
                taskStatus = ((ObservableDisplayedClassAd) o).getJobStatus();
                if (taskStatus.equals("") || taskStatus.equals("?") || taskStatus.equals("")) {
                    JOptionPane.showMessageDialog(null, "??????");
                    return;
                }

            }
        }
        //e
        int job = 0;
        Transaction xact = schedd.createTransaction();
        try {
            xact.begin(30);

        } catch (RemoteException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        System.out.println("oldId:" + oldId);

        String findreq = "owner==\"" + condoruser + "\"&&ClusterId==" + oldId;
        try {
            classAdArray = schedd.getJobAds(findreq);
            classAdArray2 = schedd.getJobAds(findreq);
        } catch (RemoteException ex) {
            Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex);
        }
        //?jobclassAd?
        int newClusterId = 0;
        try {
            newClusterId = xact.createCluster();

        } catch (RemoteException e) {
        }
        int newJobId = 0;
        //            XMLHandler handler = new XMLHandler();
        String oldname = handler.getJobName("" + oldId);
        String transferInput = "";
        String jobdir = null;
        //?job??job
        int jobcount = 0;
        String timestamp = (new SimpleDateFormat("yyyyMMddHHmmss")).format(new Date());
        System.out.println("oldname" + oldname);
        jobdir = handler.getTaskDir("" + oldId);
        String expfilename = handler.getExpFile("" + oldId);
        String infofilename = handler.getInfoFile("" + oldId);
        for (ClassAdStructAttr[] x : classAdArray) {

            ad = new ClassAd(x);
            job = Integer.parseInt(ad.get("ProcId"));
            ClassAdStructAttr[] attributes = null;// {new ClassAdStructAttr()};

            System.out.println("jobdir:===" + jobdir);

            //??
            // 
            File[] files = { new File(expfilename), new File(infofilename) };// new File[2];

            System.out.println(expfilename + "===" + infofilename);

            //
            String oldiwd = jobdir.substring(0, jobdir.length() - 14);//D:\tmp\test\dirtest\20140902200811;
            String resultdirstr = oldiwd + timestamp + "\\" + job;//job
            // new String(handler.getTaskDir(oldname).getBytes(),"UTF-8");
            //
            //attributes[0] = new ClassAdStructAttr("Iwd", ClassAdAttrType.value3, resultdirstr);
            File newjobdir = new File(resultdirstr);
            try {
                System.out.println("resultdirstr:" + resultdirstr);
                FileUtils.forceMkdir(newjobdir);
            } catch (IOException ex) {
                Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex);
            }
            //?
            /* for (int j = 0; j < inputfilecount; j++) {
              System.out.println("j:" + j);
              try {
              FileUtils.copyFileToDirectory(files[j], newjobdir);
              } catch (IOException ex) {
              Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex);
              }
              }*/

            try {
                newJobId = xact.createJob(newClusterId);
            } catch (RemoteException ex) {
                Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex);
            }
            try {

                xact.submit(newClusterId, newJobId, condoruser, UniverseType.VANILLA, ad.get("Cmd"),
                        ad.get("Arguments"), ad.get("Requirements"), attributes, files);
                xact.closeSpool(oldId, job);
            } catch (RemoteException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch (FileNotFoundException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
        //s
        try {
            xact.removeCluster(oldId, "");
        } catch (RemoteException ex) {
            Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex);
        }

        try {
            xact.commit();
        } catch (RemoteException e) {

            e.printStackTrace();
        }
        try {
            schedd.requestReschedule();
        } catch (RemoteException ex) {
            Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex);
        }

        System.out.println("comit:" + oldname);

        String olddir = handler.getTaskDir("" + oldId);

        System.out.println("olddir:" + olddir);
        // olddir.substring(0, olddir.length() - 14);//??14?
        String newdir = olddir.substring(0, olddir.length() - 14) + timestamp;
        System.out.println("newdir:" + newdir);
        //  System.out.println(olddir+"\nmm"+newdir);
        handler.removeJob("" + oldId);
        handler.addJob(oldname, "" + newClusterId, newdir, expfilename, infofilename);

        // reConfigureButtons();
    } else if (n == JOptionPane.NO_OPTION) {
        System.out.println("qu xiao");

    }

    System.out.print("recreateTransaction succeed\n");

}

From source file:condorclient.CreateJobDialogController.java

@FXML
private void runJobFired(ActionEvent event) {

    nrun = Integer.parseInt(sampleNumText.getText().trim());
    if (nrun == 0) {
        return;//from   w  w w.j a v a  2s. c  o  m
    }
    int eachrun = 0;

    // System.out.println("map:" + map.toString());
    ObservableList<String> slotname = FXCollections.observableArrayList();
    XMLHandler handler = new XMLHandler();
    if (allocMthod == 0) {//slot?

        if (!slotNumIsOk()) {
            return;
        }
        int i = 0;
        for (String s : map.keySet()) {
            if (i >= useslotnum) {
                break;
            }
            i = i + map.get(s).size();
            if (i <= useslotnum) {//?

                slotname.addAll(map.get(s));
            } else {
                i = i - map.get(s).size();
                for (String rest : map.get(s)) {
                    if (i >= useslotnum) {
                        break;
                    }
                    slotname.add(rest);
                    i++;
                }
            }
        } //slotname
          //??
          // System.out.println("allocMthod:" + allocMthod + "useslotnum:" + useslotnum + "\nslotname:" + slotname.toString());
    } else if (allocMthod == 1) {//?
        //  
        if (!nodeNumInputIsOk()) {//???
            return;
        }
        int i = 0;
        for (String s : map.keySet()) {
            if (i >= usenodenum) {
                break;
            }
            i++;
            if (slotname.size() + map.get(s).size() <= nrun) {
                slotname.addAll(map.get(s));
            } else if (slotname.size() < nrun) {//??ip?
                for (String rs : map.get(s)) {

                    slotname.add(rs);
                    if (slotname.size() == nrun) {
                        break;
                    }
                }
                break;
            }
        }
        //System.out.println("allocMthod:" + allocMthod + "usenodenum:" + usenodenum + "\nslotname:" + slotname.toString());
    } else if (allocMthod == 2) {//?
        int i = 0;
        for (String s : apponitmap.keySet()) {
            // slotname.addAll(map.get(s));//apponitmap?keylist
            if (i >= nrun) {
                break;
            }
            i++;
            //s
            if (slotname.size() + map.get(s).size() <= nrun) {
                slotname.addAll(map.get(s));
            } else if (slotname.size() < nrun) {//??machine?slot
                for (String rs : map.get(s)) {
                    slotname.add(rs);
                    if (slotname.size() == nrun) {
                        break;
                    }
                }
                break;
            }
        }
        if (slotname.size() == 0) {
            //System.out.println("+++++"+otherError.getText());
            otherError.setText("?");
            return;
        }

        //System.out.println("allocMthod:" + allocMthod + "zhi ding ge shu:" + apponitmap.keySet().size() + "\nslotname:" + slotname.toString());
    } else if (allocMthod == 3) {//????????
        int aptNum = 0;
        if (slotNum <= nrun) {//??
            aptNum = slotNum;
        } else {
            aptNum = nrun;
        }
        for (int i = 0; i < aptNum; i++) {//slotNum
            slotname.add("");
        }
    }
    eachrun = nrun / slotname.size();
    int restrun = nrun - eachrun * slotname.size();//?slot
    //System.out.println("eachrun" + eachrun + "restrun" + restrun);

    URL url = null;

    String scheddStr = handler.getURL("schedd");
    try {

        url = new URL(scheddStr);
    } catch (MalformedURLException e3) {
        // TODO Auto-generated catch block
        e3.printStackTrace();
    }
    Schedd schedd = null;
    try {
        schedd = new Schedd(url);
    } catch (ServiceException e2) {
    }

    int j = 0;
    //
    String timestamp = (new SimpleDateFormat("yyyyMMddHHmmss")).format(new Date());
    String resultdirstr = resultFileText.getText().trim() + "\\" + jobNameText.getText().trim() + "\\"
            + timestamp;
    System.out.println(resultdirstr);
    try {
        FileUtils.forceMkdir(new File(resultdirstr));
    } catch (IOException ex) {
        Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex);
    }

    System.out.println(timestamp);
    //?
    File infoFile = new File(infoFileText.getText().trim());
    File expFile = new File(expFileText.getText().trim());

    File[] transfiles = { infoFile, expFile };

    Transaction xact = schedd.createTransaction();
    try {
        xact.begin(30);

    } catch (RemoteException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    int clusterId = 0;
    try {
        clusterId = xact.createCluster();

    } catch (RemoteException e) {
    }
    for (String name : slotname) {//3slot??
        j++;
        int jobId = 0;
        try {
            jobId = xact.createJob(clusterId);
        } catch (RemoteException e) {
        }
        String jobdirstr = resultdirstr + "\\" + jobId;
        File jobdir = new File(jobdirstr);
        try {
            FileUtils.forceMkdir(jobdir);//?job
        } catch (IOException ex) {
            Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex);
        }
        //??job
        /*  for (File f : transfiles) {
           try {
           FileUtils.copyFileToDirectory(f, jobdir);
           } catch (IOException ex) {
           Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex);
           }
                
           }*/

        if (j == slotname.size()) {
            eachrun = eachrun + restrun;
        }
        String eachrunstr = "" + eachrun;

        String argumentsStr = infoFile.getName() + " " + expFile.getName() + " " + eachrunstr;// null;//".exl .ixl nrun"
        String requirementsStr = "Name==\"" + name + "\"";//Name=slot1@Lenovo-PC;String req="Name==\"slot1@Lenovo-PC\"";
        if (name.equals("")) {
            requirementsStr = null;//??
        }
        System.out.println("requirementsStr:" + requirementsStr + "eachrunstr:" + eachrunstr);

        ClassAdStructAttr[] attributes = null;// {new ClassAdStructAttr()};

        // ClassAdStructAttr attribute =new ClassAdStructAttr("WhenToTransferOutput",ClassAdAttrType.value3,"ON_EXIT_OR_EVICT");
        //  attributes[0] = new ClassAdStructAttr("Iwd", ClassAdAttrType.value3, jobdirstr);
        // attributes[1] = new ClassAdStructAttr("JobLeaseDuration", ClassAdAttrType.value1,"1200");
        String commandStr = handler.getexecutableFile();//?

        try {
            xact.submit(clusterId, jobId, "htcondor", UniverseType.VANILLA, commandStr, argumentsStr,
                    requirementsStr, attributes, transfiles);

        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
    try {
        xact.commit();
    } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        schedd.requestReschedule();//
    } catch (RemoteException ex) {
        Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex);
    }
    String jobName = jobNameText.getText();
    handler.addJob(jobName, "" + clusterId, resultdirstr, expFileText.getText().trim(),
            infoFileText.getText().trim());//jobItem

    exeCreate = 1;
    stage.close();

}

From source file:is.idega.idegaweb.egov.cases.presentation.CasesStatistics.java

private int addResults(Map<CaseStatus, Integer> totals, Table2 table, TableRowGroup group, IWContext iwc,
        IWResourceBundle iwrb, Layer section, Collection<Result> results, Collection<CaseStatus> statuses,
        String header, boolean useSubCats, boolean isSubCategory, int iRow, IWTimestamp fromDate,
        IWTimestamp toDate) {//  w  w w  . j ava 2  s .c  o m
    if (totals == null) {
        totals = new LinkedHashMap<CaseStatus, Integer>();

        for (Iterator<CaseStatus> statIter = statuses.iterator(); statIter.hasNext();) {
            CaseStatus status = statIter.next();
            totals.put(status, 0);
        }
    }

    if (table == null) {
        Heading2 heading2 = new Heading2(header);
        section.add(heading2);

        table = new Table2();
        table.setWidth("100%");
        table.setCellpadding(0);
        table.setCellspacing(0);
        table.setStyleClass("adminTable");
        table.setStyleClass("ruler");
        section.add(table);

        TableColumnGroup columnGroup = table.createColumnGroup();
        TableColumn column = columnGroup.createColumn();
        column.setSpan(3);
        column = columnGroup.createColumn();
        column.setSpan(2);
        column.setWidth("12");

        group = table.createHeaderRowGroup();
        TableRow row = group.createRow();
        TableCell2 cell = row.createHeaderCell();
        cell.setStyleClass("firstColumn");
        cell.setStyleClass("name");
        cell.add(new Text(getResourceBundle().getLocalizedString("name", "Name")));

        CaseStatus status;
        for (Iterator<CaseStatus> statIter = statuses.iterator(); statIter.hasNext();) {
            status = statIter.next();
            cell = row.createHeaderCell();
            cell.setStyleClass(status.getStatus());
            String statusLabel = null;
            try {
                statusLabel = getCasesBusiness().getLocalizedCaseStatusDescription(null, status,
                        iwc.getCurrentLocale());
            } catch (RemoteException e) {
                e.printStackTrace();
            }
            cell.add(new Text(StringUtil.isEmpty(statusLabel) ? status.getStatus() : statusLabel));
        }

        cell = row.createHeaderCell();
        cell.setStyleClass("total lastColumn");
        cell.add(new Text(getResourceBundle().getLocalizedString("total", "Total")));

        group = table.createBodyRowGroup();
    }

    if (!ListUtil.isEmpty(results)) {
        for (Iterator<Result> iter = results.iterator(); iter.hasNext();) {
            ++iRow;
            Result res = iter.next();
            boolean hasSubCats = false;
            Collection<Result> subCats = null;
            if (useSubCats) {
                subCats = getResults(iwc, true, res.getID(), res.isUseDefaultHandlerIfNotFoundResultsProvider(),
                        fromDate, toDate);
                hasSubCats = !ListUtil.isEmpty(subCats);
            }
            addResultToTable(totals, statuses, group, iRow, res, isSubCategory, !hasSubCats);
            if (hasSubCats) {
                iRow = addResults(totals, table, group, iwc, iwrb, section, subCats, statuses, header,
                        useSubCats, true, iRow, fromDate, toDate);
            }
        }
    }

    if (!isSubCategory) {
        group = table.createFooterRowGroup();
        TableRow row = group.createRow();

        TableCell2 cell = row.createCell();
        cell.setStyleClass("total");
        cell.setStyleClass("firstColumn");
        cell.add(new Text(iwrb.getLocalizedString("total", "Total")));

        int total = 0;

        for (Iterator<CaseStatus> caseStatusIter = totals.keySet().iterator(); caseStatusIter.hasNext();) {
            CaseStatus status = caseStatusIter.next();
            Integer statusTotal = totals.get(status);
            total += statusTotal.intValue();

            cell = row.createCell();
            cell.setStyleClass(status.getStatus());
            cell.add(new Text(statusTotal.toString()));
        }

        cell = row.createCell();
        cell.setStyleClass("total");
        cell.setStyleClass("lastColumn");
        cell.add(new Text(String.valueOf(total)));
    }

    return iRow;
}

From source file:condorclient.CreateJobDialogController.java

@FXML
private void saveJobFired(ActionEvent event) {

    nrun = Integer.parseInt(sampleNumText.getText().trim());
    if (nrun == 0) {
        return;//  www . j  av a2  s  .com
    }
    int eachrun = 0;

    // System.out.println("map:" + map.toString());
    ObservableList<String> slotname = FXCollections.observableArrayList();
    XMLHandler handler = new XMLHandler();
    if (allocMthod == 0) {//slot?

        if (!slotNumIsOk()) {
            return;
        }

        int i = 0;
        for (String s : map.keySet()) {
            if (i >= useslotnum) {
                break;
            }

            i = i + map.get(s).size();
            if (i <= useslotnum) {//?

                slotname.addAll(map.get(s));
            } else {
                i = i - map.get(s).size();
                for (String rest : map.get(s)) {
                    if (i >= useslotnum) {
                        break;
                    }
                    slotname.add(rest);
                    i++;
                }
            }
        } //slotname
          //??
          // System.out.println("allocMthod:" + allocMthod + "useslotnum:" + useslotnum + "\nslotname:" + slotname.toString());
    } else if (allocMthod == 1) {//?
        if (!nodeNumInputIsOk()) {
            return;
        }
        int i = 0;
        for (String s : map.keySet()) {
            if (i >= usenodenum) {
                break;
            }
            i++;
            //s
            if (slotname.size() + map.get(s).size() <= nrun) {
                slotname.addAll(map.get(s));
            } else if (slotname.size() < nrun) {//??ip?
                for (String rs : map.get(s)) {
                    slotname.add(rs);
                    if (slotname.size() == nrun) {
                        break;
                    }
                }
                break;
            }

        }

        //System.out.println("allocMthod:" + allocMthod + "usenodenum:" + usenodenum + "\nslotname:" + slotname.toString());
    } else if (allocMthod == 2) {//?
        int i = 0;
        for (String s : apponitmap.keySet()) {
            // slotname.addAll(map.get(s));//apponitmap?keylist  
            ///eee
            if (i >= nrun) {
                break;
            }
            i++;
            //s
            if (slotname.size() + map.get(s).size() <= nrun) {
                slotname.addAll(map.get(s));
            } else if (slotname.size() < nrun) {//??machine?slot
                for (String rs : map.get(s)) {
                    slotname.add(rs);
                    if (slotname.size() == nrun) {
                        break;
                    }
                }
                break;
            }
            ///eee
        }
        if (slotname.size() == 0) {
            // System.out.println("+++++"+otherError.getText());
            otherError.setText("?");
            return;
        }

        //System.out.println("allocMthod:" + allocMthod + "zhi ding ge shu:" + apponitmap.keySet().size() + "\nslotname:" + slotname.toString());
    } else if (allocMthod == 3) {//??
        //e
        int aptNum = 0;
        if (slotNum <= nrun) {//??
            aptNum = slotNum;
        } else {
            aptNum = nrun;
        }
        for (int i = 0; i < aptNum; i++) {//slotNum
            slotname.add("");
        }
        //e
    }
    eachrun = nrun / slotname.size();
    int restrun = nrun - eachrun * slotname.size();//?slot
    //System.out.println("eachrun" + eachrun + "restrun" + restrun);
    URL url = null;

    String scheddStr = handler.getURL("schedd");

    try {
        url = new URL(scheddStr);
        // url = new URL("http://localhost:9628");
    } catch (MalformedURLException e3) {
        // TODO Auto-generated catch block
        e3.printStackTrace();
    }
    Schedd schedd = null;
    try {
        schedd = new Schedd(url);
    } catch (ServiceException e2) {
    }
    //s
    String timestamp = (new SimpleDateFormat("yyyyMMddHHmmss")).format(new Date());
    String resultdirstr = resultFileText.getText().trim() + "\\" + jobNameText.getText().trim() + "\\"
            + timestamp;
    System.out.println(resultdirstr);
    try {
        FileUtils.forceMkdir(new File(resultdirstr));
    } catch (IOException ex) {
        Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex);
    }

    System.out.println(timestamp);
    //?
    File infoFile = new File(infoFileText.getText().trim());
    File expFile = new File(expFileText.getText().trim());
    // File testFile = new File("D:\\HTCondor\\test\\2\\inputfile.txt");
    File[] transfiles = { infoFile, expFile };

    //e
    Transaction xact = schedd.createTransaction();
    try {

        if (xact != null) {
            xact.begin(3000);
        }
    } catch (RemoteException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    int clusterId = 0;
    try {
        clusterId = xact.createCluster();

    } catch (RemoteException e) {
    }
    int j = 0;
    for (String name : slotname) {//3slot??
        j++;
        int jobId = 0;
        try {
            jobId = xact.createJob(clusterId);
        } catch (RemoteException e) {
        }
        //s
        String jobdirstr = resultdirstr + "\\" + jobId;

        File jobdir = new File(jobdirstr);
        try {
            FileUtils.forceMkdir(jobdir);//?job
        } catch (IOException ex) {
            Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex);
        }
        //??job
        /* for (File f : transfiles) {
          try {
          FileUtils.copyFileToDirectory(f, jobdir);
          } catch (IOException ex) {
          Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex);
          }
                
          }*/
        //e
        if (j == slotname.size()) {
            eachrun = eachrun + restrun;
        }
        String eachrunstr = "" + eachrun;

        String argumentsStr = infoFile.getName() + " " + expFile.getName() + " " + eachrunstr;// "" + eachrunstr;// null;//".exl .ixl nrun"
        String requirementsStr = "Name==\"" + name + "\"";//Name=slot1@Lenovo-PC;String req="Name==\"slot1@Lenovo-PC\"";

        if (name.equals("")) {
            requirementsStr = null;//??
        }
        ClassAdStructAttr[] attributes = null;// {new ClassAdStructAttr()};
        // ClassAdStructAttr attribute =new ClassAdStructAttr("WhenToTransferOutput",ClassAdAttrType.value3,"ON_EXIT_OR_EVICT");
        //attributes[0] = new ClassAdStructAttr("Iwd", ClassAdAttrType.value3, jobdirstr);
        //JobLeaseDuration
        //            attributes[1] = new ClassAdStructAttr("JobLeaseDuration", ClassAdAttrType.value1,"1200");
        String commandStr = handler.getexecutableFile();//?

        try {
            xact.submit(clusterId, jobId, "htcondor", UniverseType.VANILLA, commandStr, argumentsStr,
                    requirementsStr, attributes, transfiles);

        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        try {
            xact.holdJob(clusterId, jobId, "");//
        } catch (RemoteException ex) {
            Logger.getLogger(CreateJobDialogController.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
    try {
        xact.commit();
    } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    String jobName = jobNameText.getText();
    handler.addJob(jobName, "" + clusterId, resultdirstr, expFileText.getText().trim(),
            infoFileText.getText().trim());

    // System.out.print("createTransaction succeed haha!!\n");
    exeCreate = 1;
    stage.close();

}

From source file:de.bps.course.assessment.AssessmentMainController.java

/**
 * This methods calls the OnyxReporter and shows it in an iframe.
 * /*from   ww  w .j  a  va 2  s.  c o  m*/
 * @param ureq The UserRequest for getting the identity and role of the current user.
 */
private boolean showOnyxReporter(final UserRequest ureq) {
    if (OnyxModule.isOnyxTest(currentCourseNode.getReferencedRepositoryEntry().getOlatResource())) {
        final OnyxReporterWebserviceManager onyxReporter = OnyxReporterWebserviceManagerFactory.getInstance()
                .fabricate("OnyxReporterWebserviceClient");
        if (onyxReporter != null) {
            if (this.identitiesList == null) {
                this.identitiesList = getAllIdentitisFromGroupmanagement();
            }
            String iframeSrc = "";
            try {
                iframeSrc = onyxReporter.startReporter(ureq, this.identitiesList, currentCourseNode, false);
            } catch (final RemoteException e) {
                e.printStackTrace();
                return false;
            } catch (final OnyxReporterException orE) {
                if (orE.getMessage().equals("noresults")) {
                    onyxReporterVC.contextPut("iframeOK", Boolean.FALSE);
                    onyxReporterVC.contextPut("showBack", Boolean.TRUE);
                    onyxReporterVC.contextPut("message", translate("no.testresults"));
                    setContent(onyxReporterVC);
                    return true;
                }
                return false;
            }
            onyxReporterVC.contextPut("showBack", Boolean.TRUE);
            onyxReporterVC.contextPut("iframeOK", Boolean.TRUE);
            onyxReporterVC.contextPut("onyxReportLink", iframeSrc);
            setContent(onyxReporterVC);
            return true;
        } else {
            userChoose.contextPut("iframeOK", Boolean.FALSE);
            return false;
        }
    } else {
        return false;
    }
}

From source file:com.idega.block.article.bean.ArticleItemBean.java

/**
 * Constructs the path for the article file as follows
 * First it gets the folder location of the article, this is typically generated by
 * ArticleUtil.getArticleYearMonthPath()
 * Then it appends a unique filename based on time, followed by .article
 * Example returnstring: /files/cms/article/2005/02/20050222-1246.article/en.xml
 * @param service/* ww w . j  a  va2  s.c  o  m*/
 * @return
 */
protected String generateArticleResourcePath(IWContext iwc) {
    BuilderService service = null;
    try {
        service = BuilderServiceFactory.getBuilderService(iwc);
    } catch (RemoteException e) {
        e.printStackTrace();
        return null;
    }

    return service.generateResourcePath(getBaseFolderLocation(), CoreConstants.ARTICLE_FILENAME_SCOPE,
            CoreConstants.ARTICLE_FILENAME_SCOPE);
}

From source file:is.idega.idegaweb.egov.gumbo.webservice.client.business.DOFWSClientRealWebservice.java

public MillifaerslaTypeUser[] getTransfers(BigDecimal shipNr, String type, String period) {
    try {/* ww  w.ja va  2  s  .  com*/
        GetmillifaerslurbyskipElement parameters = new GetmillifaerslurbyskipElement(shipNr, type, period);
        return getTransfersPort().getmillifaerslurbyskip(parameters);
    } catch (RemoteException e) {
        e.printStackTrace();
    }

    return null;
}