List of usage examples for java.lang NumberFormatException printStackTrace
public void printStackTrace()
From source file:com.sonymobile.backlogtool.JSONController.java
@PreAuthorize("hasPermission(#areaName, 'isEditor')") @RequestMapping(value = "/updatestory/{areaName}", method = RequestMethod.POST) @Transactional//from w w w . j a va2s.c o m public @ResponseBody boolean updateStory(@PathVariable String areaName, @RequestBody NewStoryContainer updatedStory, @RequestParam boolean pushUpdate) { Session session = sessionFactory.openSession(); Transaction tx = null; try { tx = session.beginTransaction(); Story story = (Story) session.get(Story.class, updatedStory.getId()); if (!story.getArea().getName().equals(areaName)) { throw new Error("Trying to modify unauthorized object"); } boolean createIfDoesNotExist = true; Theme theme = getTheme(updatedStory.getThemeTitle(), story.getArea(), session, createIfDoesNotExist); Epic newEpic = getEpic(updatedStory.getEpicTitle(), theme, story.getArea(), session, createIfDoesNotExist); //Move story from old epic if it was changed if (updatedStory.getEpicTitle() != null) { Epic oldEpic = story.getEpic(); if (oldEpic != newEpic) { if (oldEpic != null) { oldEpic.getChildren().remove(story); oldEpic.rebuildChildrenOrder(); } if (newEpic != null) { newEpic.getChildren().add(story); story.setPrioInEpic(Integer.MAX_VALUE); //The prio gets rebuilt on newEpic.rebuildChildrenOrder(). newEpic.rebuildChildrenOrder(); } } } if (updatedStory.isArchived() && !story.isArchived()) { //Was moved to archive story.setDateArchived(new Date()); //Move up all stories under this one in rank Query query = session .createQuery("from Story where prio > ? and area.name like ? and archived=false"); query.setParameter(0, story.getPrio()); query.setParameter(1, areaName); List<Story> storyList = Util.castList(Story.class, query.list()); for (Story otherStory : storyList) { otherStory.setPrio(otherStory.getPrio() - 1); } story.setPrio(-1); } else if (!updatedStory.isArchived() && story.isArchived()) { //Was moved from archive story.setDateArchived(null); //Find the last story and place this one after Query storyQuery = session .createQuery("from Story where area.name like ? and archived=false order by prio desc"); storyQuery.setParameter(0, areaName); List<Story> storyList = Util.castList(Story.class, storyQuery.list()); if (storyList.isEmpty()) { story.setPrio(1); } else { int lastPrio = storyList.get(0).getPrio(); story.setPrio(lastPrio + 1); } } AttributeOption attr1 = null; try { attr1 = (AttributeOption) session.get(AttributeOption.class, Integer.parseInt(updatedStory.getStoryAttr1Id())); } catch (NumberFormatException e) { } //AttrId can be empty, in that case we want null as attr1. AttributeOption attr2 = null; try { attr2 = (AttributeOption) session.get(AttributeOption.class, Integer.parseInt(updatedStory.getStoryAttr2Id())); } catch (NumberFormatException e) { } AttributeOption attr3 = null; try { attr3 = (AttributeOption) session.get(AttributeOption.class, Integer.parseInt(updatedStory.getStoryAttr3Id())); } catch (NumberFormatException e) { } story.setStoryAttr1(attr1); story.setStoryAttr2(attr2); story.setStoryAttr3(attr3); story.setDescription(updatedStory.getDescription()); story.setTitle(updatedStory.getTitle()); story.setAdded(updatedStory.getAdded()); story.setDeadline(updatedStory.getDeadline()); story.setContributorSite(updatedStory.getContributorSite()); story.setCustomerSite(updatedStory.getCustomerSite()); story.setContributor(updatedStory.getContributor()); story.setCustomer(updatedStory.getCustomer()); story.setArchived(updatedStory.isArchived()); if (updatedStory.getThemeTitle() != null) { story.setTheme(theme); } if (updatedStory.getEpicTitle() != null) { story.setEpic(newEpic); } tx.commit(); } catch (Exception e) { e.printStackTrace(); if (tx != null) { tx.rollback(); } } finally { session.close(); } if (pushUpdate) { PushContext pushContext = PushContext.getInstance(context); pushContext.push(areaName); } return true; }
From source file:com.mozilla.SUTAgentAndroid.service.DoCommand.java
public String GetTemperatureInfo() { String sTempVal = "unknown"; String sDeviceFile = "/sys/bus/platform/devices/temp_sensor_hwmon.0/temp1_input"; try {/*w ww . ja v a 2 s .c o m*/ pProc = Runtime.getRuntime().exec(this.getSuArgs("cat " + sDeviceFile)); RedirOutputThread outThrd = new RedirOutputThread(pProc, null); outThrd.start(); outThrd.joinAndStopRedirect(5000); String output = outThrd.strOutput; // this only works on pandas (with the temperature sensors turned // on), other platforms we just get a file not found error... we'll // just return "unknown" for that case try { sTempVal = String.valueOf(Integer.parseInt(output.trim()) / 1000.0); } catch (NumberFormatException e) { // not parsed! probably not a panda } } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } return "Temperature: " + sTempVal; }
From source file:com.mozilla.SUTAgentAndroid.service.DoCommand.java
public String RegisterTheDevice(String sSrvr, String sPort, String sData) { String sRet = ""; String line = ""; // Debug.waitForDebugger(); if (sSrvr != null && sPort != null && sData != null) { try {//ww w . j a va 2s. c om int nPort = Integer.parseInt(sPort); Socket socket = new Socket(sSrvr, nPort); PrintWriter out = new PrintWriter(socket.getOutputStream(), false); BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); out.println(sData); if (out.checkError() == false) { socket.setSoTimeout(30000); while (socket.isInputShutdown() == false) { line = in.readLine(); if (line != null) { line = line.toLowerCase(); sRet += line; // ok means we're done if (line.contains("ok")) break; } else { // end of stream reached break; } } } out.close(); in.close(); socket.close(); } catch (NumberFormatException e) { sRet += "reg NumberFormatException thrown [" + e.getLocalizedMessage() + "]"; e.printStackTrace(); } catch (UnknownHostException e) { sRet += "reg UnknownHostException thrown [" + e.getLocalizedMessage() + "]"; e.printStackTrace(); } catch (IOException e) { sRet += "reg IOException thrown [" + e.getLocalizedMessage() + "]"; e.printStackTrace(); } } return (sRet); }
From source file:edu.harvard.iq.dvn.ingest.statdataio.impl.plugins.sav.SAVFileReader.java
void decodeRecordTypeData(BufferedInputStream stream) throws IOException { dbgLog.fine("***** decodeRecordTypeData(): start *****"); String fileUnfValue = null;//from w w w . ja v a 2 s.c om String[] unfValues = null; if (stream == null) { throw new IllegalArgumentException("stream == null!"); } if (isDataSectionCompressed) { decodeRecordTypeDataCompressed(stream); } else { decodeRecordTypeDataUnCompressed(stream); } unfValues = new String[varQnty]; dbgLog.fine("variableTypeFinal:" + Arrays.toString(variableTypeFinal)); for (int j = 0; j < varQnty; j++) { //int variableTypeNumer = variableTypelList.get(j) > 0 ? 1 : 0; int variableTypeNumer = variableTypeFinal[j]; try { dbgLog.finer("j = " + j); dbgLog.finer("dataTable2[j] = " + Arrays.deepToString(dataTable2[j])); dbgLog.warning("dateFormats[j] = " + Arrays.deepToString(dateFormats[j])); unfValues[j] = getUNF(dataTable2[j], dateFormats[j], variableTypeNumer, unfVersionNumber, j); dbgLog.fine(j + "th unf value" + unfValues[j]); } catch (NumberFormatException ex) { ex.printStackTrace(); } catch (UnfException ex) { ex.printStackTrace(); } catch (IOException ex) { //ex.printStackTrace(); throw ex; } catch (NoSuchAlgorithmException ex) { ex.printStackTrace(); } } dbgLog.fine("unf set:\n" + Arrays.deepToString(unfValues)); try { fileUnfValue = UNF5Util.calculateUNF(unfValues); } catch (NumberFormatException ex) { ex.printStackTrace(); } catch (IOException ex) { //ex.printStackTrace(); throw ex; } dbgLog.fine("file-unf=" + fileUnfValue); savDataSection.setUnf(unfValues); savDataSection.setFileUnf(fileUnfValue); smd.setVariableUNF(unfValues); smd.getFileInformation().put("fileUNF", fileUnfValue); dbgLog.fine("unf values:\n" + unfValues); savDataSection.setData(dataTable2); dbgLog.fine("dataTable2:\n" + Arrays.deepToString(dataTable2)); dbgLog.fine("***** decodeRecordTypeData(): end *****"); }
From source file:ispyb.client.mx.results.ViewResultsAction.java
@SuppressWarnings("unchecked") public void getAutoprocessingDetails(ActionMapping mapping, ActionForm actForm, HttpServletRequest request, HttpServletResponse response) {/*from www. j a va 2s .c o m*/ LOG.debug("getAutoprocessingDetails"); try { String autoProcIdS = request.getParameter("autoProcId"); AutoProcessingDetail autoProcDetail = new AutoProcessingDetail(); try { DecimalFormat df1 = (DecimalFormat) NumberFormat.getInstance(Locale.US); df1.applyPattern("#####0.0"); Integer autoProcId = Integer.parseInt(autoProcIdS); AutoProc3VO apv = apService.findByPk(autoProcId); autoProcDetail.setAutoProcId(autoProcId); AutoProcScalingStatistics3VO apssv_overall = apssService .getBestAutoProcScalingStatistic(apssService.findByAutoProcId(autoProcId, "overall")); AutoProcScalingStatistics3VO apssv_outer = apssService .getBestAutoProcScalingStatistic(apssService.findByAutoProcId(autoProcId, "outerShell")); if (apssv_overall != null) { autoProcDetail.setOverallCompleteness("" + apssv_overall.getCompleteness() + "%"); autoProcDetail.setOverallResolution("" + apssv_overall.getResolutionLimitLow() + "-" + apssv_overall.getResolutionLimitHigh() + " Å"); autoProcDetail.setOverallIOverSigma("" + apssv_overall.getMeanIoverSigI()); if (apssv_overall.getRmerge() == null) autoProcDetail.setOverallRsymm(""); else { autoProcDetail.setOverallRsymm("" + apssv_overall.getRmerge() + "%"); } autoProcDetail.setOverallMultiplicity("" + (apssv_overall.getMultiplicity() == null ? "" : new Double(df1.format(apssv_overall.getMultiplicity())))); } if (apssv_outer != null) { autoProcDetail.setOuterCompleteness("" + apssv_outer.getCompleteness() + "%"); autoProcDetail.setOuterResolution("" + apssv_outer.getResolutionLimitLow() + "-" + apssv_overall.getResolutionLimitHigh() + " Å"); autoProcDetail.setOuterIOverSigma("" + apssv_outer.getMeanIoverSigI()); autoProcDetail.setOuterRsymm("" + apssv_outer.getRmerge() + "%"); autoProcDetail.setOuterMultiplicity("" + (apssv_outer.getMultiplicity() == null ? "" : (new Double(df1.format(apssv_outer.getMultiplicity()))))); } double refinedCellA = ((double) ((int) (apv.getRefinedCellA() * 10))) / 10; double refinedCellB = ((double) ((int) (apv.getRefinedCellB() * 10))) / 10; double refinedCellC = ((double) ((int) (apv.getRefinedCellC() * 10))) / 10; autoProcDetail.setUnitCellA("" + refinedCellA + " Å"); // angstrom symbol autoProcDetail.setUnitCellB("" + refinedCellB + " Å"); autoProcDetail.setUnitCellC("" + refinedCellC + " Å"); autoProcDetail.setUnitCellAlpha("" + apv.getRefinedCellAlpha() + " °"); // degree symbol autoProcDetail.setUnitCellBeta("" + apv.getRefinedCellBeta() + " °"); autoProcDetail.setUnitCellGamma("" + apv.getRefinedCellGamma() + " °"); // List<AutoProcStatus3VO> autoProcEvents = new ArrayList<AutoProcStatus3VO>(); if (autoProcId != null) { List<AutoProcIntegration3VO> autoProcIntegrations = autoProcIntegrationService .findByAutoProcId(autoProcId); if (!autoProcIntegrations.isEmpty()) { autoProcEvents = (autoProcIntegrations.iterator().next()).getAutoProcStatusList(); } } autoProcDetail.setAutoProcEvents(autoProcEvents); // attachments List<IspybAutoProcAttachment3VO> listOfAutoProcAttachment = (List<IspybAutoProcAttachment3VO>) request .getSession().getAttribute(Constants.ISPYB_AUTOPROC_ATTACH_LIST); Integer autoProcProgramId = null; if (apv != null) autoProcProgramId = apv.getAutoProcProgramVOId(); if (autoProcId != null) { List<AutoProcIntegration3VO> autoProcIntegrations = autoProcIntegrationService .findByAutoProcId(autoProcId); if (!autoProcIntegrations.isEmpty()) { autoProcProgramId = (autoProcIntegrations.iterator().next()).getAutoProcProgramVOId(); } } List<AutoProcProgramAttachment3VO> attachments = null; List<AutoProcAttachmentWebBean> autoProcProgAttachmentsWebBeans = new ArrayList<AutoProcAttachmentWebBean>(); LOG.debug("autoProcProgramId = " + autoProcProgramId); if (autoProcProgramId != null) { attachments = new ArrayList<AutoProcProgramAttachment3VO>( appService.findByPk(autoProcProgramId, true).getAttachmentVOs()); if (!attachments.isEmpty()) { // attachmentWebBeans = new AutoProcAttachmentWebBean[attachments.size()]; LOG.debug("nb attachments = " + attachments.size()); for (Iterator<AutoProcProgramAttachment3VO> iterator = attachments.iterator(); iterator .hasNext();) { AutoProcProgramAttachment3VO att = iterator.next(); AutoProcAttachmentWebBean attBean = new AutoProcAttachmentWebBean(att); // gets the ispyb auto proc attachment file IspybAutoProcAttachment3VO aAutoProcAttachment = getAutoProcAttachment( attBean.getFileName(), listOfAutoProcAttachment); if (aAutoProcAttachment == null) { // by default in XDS tab and output files aAutoProcAttachment = new IspybAutoProcAttachment3VO(null, attBean.getFileName(), "", "XDS", "output", false); } attBean.setIspybAutoProcAttachment(aAutoProcAttachment); autoProcProgAttachmentsWebBeans.add(attBean); } } else LOG.debug("attachments is empty"); } // Issue 1507: Correction files for ID29 & ID23-1 if (Constants.SITE_IS_ESRF()) { Integer dataCollectionId = null; if (BreadCrumbsForm.getIt(request).getSelectedDataCollection() != null) dataCollectionId = BreadCrumbsForm.getIt(request).getSelectedDataCollection() .getDataCollectionId(); if (dataCollectionId != null) { DataCollection3VO dataCollection = dataCollectionService.findByPk(dataCollectionId, false, false); String beamLineName = dataCollection.getDataCollectionGroupVO().getSessionVO() .getBeamlineName(); String[] correctionFiles = ESRFBeamlineEnum .retrieveCorrectionFilesNameWithName(beamLineName); if (correctionFiles != null) { for (int k = 0; k < correctionFiles.length; k++) { String correctionFileName = correctionFiles[k]; String dir = ESRFBeamlineEnum.retrieveDirectoryNameWithName(beamLineName); if (dir != null) { String correctionFilePath = "/data/pyarch/" + dir + "/" + correctionFileName; String fullFilePath = PathUtils.FitPathToOS(correctionFilePath); File f = new File(fullFilePath); if (f != null && f.exists()) { // fake attachment AutoProcProgramAttachment3VO att = new AutoProcProgramAttachment3VO(-1, null, "Correction File", correctionFileName, correctionFilePath, null); AutoProcAttachmentWebBean attBean = new AutoProcAttachmentWebBean(att); IspybAutoProcAttachment3VO aAutoProcAttachment = new IspybAutoProcAttachment3VO( null, correctionFileName, "correction file", "XDS", "correction", false); attBean.setIspybAutoProcAttachment(aAutoProcAttachment); autoProcProgAttachmentsWebBeans.add(attBean); attachments.add(attBean); } } } // end for } } } autoProcDetail.setAutoProcProgAttachmentsWebBeans(autoProcProgAttachmentsWebBeans); } catch (NumberFormatException e) { } request.getSession().setAttribute("lastAutoProcIdSelected", autoProcDetail.getAutoProcId()); // HashMap<String, Object> data = new HashMap<String, Object>(); // context path data.put("contextPath", request.getContextPath()); // autoProcDetail data.put("autoProcDetail", autoProcDetail); // data => Gson GSonUtils.sendToJs(response, data, "dd-MM-yyyy HH:mm:ss"); } catch (Exception e) { e.printStackTrace(); } }
From source file:ispyb.client.mx.results.ViewResultsAction.java
@SuppressWarnings("unchecked") public void getAutoProcessingData(ActionMapping mapping, ActionForm actForm, HttpServletRequest request, HttpServletResponse response) {/* w w w . j a v a2 s .c o m*/ LOG.debug("getAutoProcessingData"); List<String> errors = new ArrayList<String>(); try { // get the autoProc and the file String id = request.getParameter("autoProcProgramAttachmentId"); Integer autoProcProgramAttachmentId = null; boolean xscaleFile = false; boolean truncateLog = false; List<AutoProcessingData> listAutoProcessingData = new ArrayList<AutoProcessingData>(); try { autoProcProgramAttachmentId = Integer.parseInt(id); } catch (NumberFormatException e) { } if (autoProcProgramAttachmentId != null) { AutoProcProgramAttachment3VO attachment = appaService.findByPk(autoProcProgramAttachmentId); // o[0] is a boolean xscaleFile // o[1] is a boolean truncateLog // o[2] is List<AutoProcessingData> try { Object[] o = ViewResultsAction.readAttachment(attachment); xscaleFile = (Boolean) o[0]; truncateLog = (Boolean) o[1]; listAutoProcessingData = (List<AutoProcessingData>) o[2]; } catch (Exception e) { e.printStackTrace(); errors.add("Error while reading the file: " + e); HashMap<String, Object> data = new HashMap<String, Object>(); data.put("errors", errors); // data => Gson GSonUtils.sendToJs(response, data, "dd-MM-yyyy HH:mm:ss"); return; } } HashMap<String, Object> data = new HashMap<String, Object>(); // context path data.put("contextPath", request.getContextPath()); // autoProc data data.put("autoProcessingData", listAutoProcessingData); // type data data.put("xscaleLpData", xscaleFile); data.put("truncateLogData", truncateLog); // data => Gson GSonUtils.sendToJs(response, data, "dd-MM-yyyy HH:mm:ss"); } catch (Exception e) { e.printStackTrace(); } }
From source file:edu.ku.brc.specify.ui.db.AskForNumbersDlg.java
/** * @return/*from w ww. j a va 2s .c om*/ */ protected boolean processNumbers() { dataObjsIds.clear(); numbersList.clear(); numErrorList.clear(); numMissingList.clear(); errorPanel.setNumbers(null); missingPanel.setNumbers(null); DBTableInfo ti = DBTableIdMgr.getInstance().getByClassName(dataClass.getName()); DBFieldInfo fi = ti.getFieldByName(fieldName); boolean hasColMemID = ti.getFieldByColumnName("CollectionMemberID", true) != null; UIFieldFormatterIFace formatter = fi.getFormatter(); // Check for a dash in the format char rangeSeparator = formatter != null ? formatter.hasDash() ? '/' : '-' : ' '; boolean isOK = true; String fieldStr = textArea.getText().trim(); if (formatter != null && formatter.isNumeric() && ti.getTableId() == 1 && fieldName.equals("catalogNumber")) { fieldStr = CatalogNumberFormatter.preParseNumericCatalogNumbers(fieldStr, formatter); } if (StringUtils.isNotEmpty(fieldStr)) { DataProviderSessionIFace session = null; try { session = DataProviderFactory.getInstance().createSession(); String[] toks = StringUtils.split(fieldStr, ','); for (String fldStr : toks) { String numToken = fldStr.trim(); if (formatter != null && formatter.isNumeric() && StringUtils.contains(numToken, rangeSeparator)) { String fldNum = null; String endFldNum = null; String[] tokens = StringUtils.split(numToken, rangeSeparator); if (tokens.length == 2) { try { if (formatter.isNumeric()) { if (!StringUtils.isNumeric(fldNum) || !StringUtils.isNumeric(endFldNum)) { numErrorList.add(fldStr.trim()); isOK = false; continue; } } fldNum = (String) formatter.formatFromUI(tokens[0].trim()); endFldNum = (String) formatter.formatFromUI(tokens[1].trim()); } catch (java.lang.NumberFormatException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(AskForNumbersDlg.class, ex); numErrorList.add(numToken); isOK = false; } String sql = String.format("SELECT id FROM %s WHERE %s >= '%s' AND %s <= '%s' %s", ti.getClassName(), fieldName, fldNum, fieldName, endFldNum, (hasColMemID ? AND_COLLID : "")); sql = QueryAdjusterForDomain.getInstance().adjustSQL(sql); List<?> list = session.getDataList(sql); for (Object obj : list) { dataObjsIds.add((Integer) obj); } numbersList.add(numToken); } else { numErrorList.add(numToken); isOK = false; } continue; } String fldValForDB = numToken; try { if (formatter != null) { if (formatter.isNumeric()) { if (!StringUtils.isNumeric(numToken)) { numErrorList.add(numToken); isOK = false; continue; } } fldValForDB = (String) formatter.formatFromUI(numToken); } else { fldValForDB = numToken; } } catch (java.lang.NumberFormatException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(AskForNumbersDlg.class, ex); numErrorList.add(numToken); isOK = false; } if (StringUtils.isNotEmpty(fldValForDB)) { String sql = String.format("SELECT id FROM %s WHERE %s = '%s' %s", ti.getClassName(), fieldName, fldValForDB, (hasColMemID ? AND_COLLID : "")); sql = QueryAdjusterForDomain.getInstance().adjustSQL(sql); //log.debug(sql); Integer recordId = (Integer) session.getData(sql); if (recordId != null) { dataObjsIds.add(recordId); numbersList.add(numToken); } else { numMissingList.add(numToken); isOK = false; } } } } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(AskForNumbersDlg.class, ex); log.error(ex); ex.printStackTrace(); } finally { if (session != null) { session.close(); } } } buildNumberList(numbersList, textArea); pb.getPanel().removeAll(); CellConstraints cc = new CellConstraints(); pb.addSeparator(UIRegistry.getResourceString(labelKey), cc.xy(1, 1)); pb.add(UIHelper.createScrollPane(textArea), cc.xy(1, 3)); int y = 5; if (numErrorList.size() > 0) { errorPanel.setNumbers(numErrorList); pb.add(UIHelper.createScrollPane(errorPanel), cc.xy(1, y)); y += 2; } if (numMissingList.size() > 0) { missingPanel.setNumbers(numMissingList); pb.add(UIHelper.createScrollPane(missingPanel), cc.xy(1, y)); y += 2; } if (numErrorList.isEmpty() && numMissingList.isEmpty() && dataObjsIds.isEmpty()) { UIRegistry.showLocalizedError("BT_NO_NUMS_ERROR"); return false; } if (!isOK) { pack(); } return isOK; }
From source file:edu.umass.cs.gnsclient.client.integrationtests.ServerIntegrationTest_test010OnlyTest.java
/** * * @throws Exception//from w w w. ja v a2s. co m */ @BeforeClass public static void setUpBeforeClass() throws Exception { // Run the server. String waitString = System.getProperty("waitTillAllServersReady"); if (waitString != null) { WAIT_TILL_ALL_SERVERS_READY = Integer.parseInt(waitString); } Properties logProps = new Properties(); logProps.load(new FileInputStream(System.getProperty(DefaultProps.LOGGING_PROPERTIES.key))); String logFiles = logProps.getProperty("java.util.logging.FileHandler.pattern").replaceAll("%.*", "").trim() + "*"; if (System.getProperty("startServer") != null && System.getProperty("startServer").equals("true")) { // clear explicitly if gigapaxos if (useGPScript()) { RunServer.command("kill -s TERM `ps -ef | grep GNS.jar | grep -v grep | " + "grep -v ServerIntegrationTest | grep -v \"context\" | awk '{print $2}'`", "."); System.out.println(System.getProperty(DefaultProps.SERVER_COMMAND.key) + " " + getGigaPaxosOptions() + " forceclear all"); RunServer.command(System.getProperty(DefaultProps.SERVER_COMMAND.key) + " " + getGigaPaxosOptions() + " forceclear all", "."); /* We need to do this to limit the number of files used by mongo. * Otherwise failed runs quickly lead to more failed runs because * index files created in previous runs are not removed. */ dropAllDatabases(); options = getGigaPaxosOptions() + " restart all"; } else { options = SCRIPTS_OPTIONS; } // fragile code // String logFile = System.getProperty(DefaultProps.LOGGING_PROPERTIES.key); // ArrayList<String> output = RunServer.command("cat " + logFile + " | grep \"java.util.logging.FileHandler.pattern\" | sed 's/java.util.logging.FileHandler.pattern = //g'", ".", false); // String logFiles = output.get(0) + "*"; System.out.println("Trying to delete log files " + logFiles); RunServer.command("rm -f " + logFiles, ".", false); System.out.println(System.getProperty(DefaultProps.SERVER_COMMAND.key) + " " + options); ArrayList<String> output = RunServer .command(System.getProperty(DefaultProps.SERVER_COMMAND.key) + " " + options, "."); if (output != null) { for (String line : output) { System.out.println(line); } } else { failWithStackTrace("Server command failure: ; aborting all tests."); } } String gpConfFile = System.getProperty(DefaultProps.GIGAPAXOS_CONFIG.key); String logFile = System.getProperty(DefaultProps.LOGGING_PROPERTIES.key); // fragile code // Properties logProps = new Properties(); // logProps.load(new FileInputStream(logFile)); // String logFiles = logProps.getProperty("java.util.logging.FileHandler.pattern").replaceAll("%.*", "").trim() + "*"; int numServers = PaxosConfig.getActives().size() + ReconfigurationConfig.getReconfigurators().size(); ArrayList<String> output; int numServersUp = 0; // sleeping ensures that there is time for at least one log file to get created Thread.sleep(1000); do { output = RunServer.command("cat " + logFiles + " | grep -a \"server ready\" | wc -l ", ".", false); String temp = output.get(0); temp = temp.replaceAll("\\s", ""); try { numServersUp = Integer.parseInt(temp); } catch (NumberFormatException e) { // can happen if no files have yet gotten created System.out.println(e); } System.out.println(Integer.toString(numServersUp) + " out of " + Integer.toString(numServers) + " servers are ready."); Thread.sleep(2000); } while (numServersUp < numServers); System.out.println("Starting client"); client = new GNSClientCommands(); //client = new GNSClientCommandsV2(); // Make all the reads be coordinated client.setForceCoordinatedReads(true); //Set default read timoeut client.setReadTimeout(DEFAULT_READ_TIMEOUT); // arun: connectivity check embedded in GNSClient constructor boolean connected = client instanceof GNSClient; if (connected) { System.out.println("Client created and connected to server."); } // int tries = 5; boolean accountCreated = false; long t = System.currentTimeMillis(); Thread.sleep(WAIT_TILL_ALL_SERVERS_READY); do { try { System.out.println("Creating account guid: " + (tries - 1) + " attempt remaining."); masterGuid = GuidUtils.lookupOrCreateAccountGuid(client, accountAlias, PASSWORD, true); accountCreated = true; } catch (Exception e) { e.printStackTrace(); ThreadUtils.sleep((5 - tries) * 5000); } } while (!accountCreated && --tries > 0); if (accountCreated == false) { failWithStackTrace("Failure setting up account guid; aborting all tests."); } }
From source file:com.znsx.cms.web.controller.TmDeviceController.java
@InterfaceDescription(logon = true, method = "List_Fire_Detector", cmd = "2234") @RequestMapping("/list_fire_detector.json") public void listFireDetector(HttpServletRequest request, HttpServletResponse response) throws Exception { String organId = request.getParameter("organId"); if (StringUtils.isBlank(organId)) { throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [organId]"); }/*from w w w .ja v a 2 s . co m*/ String name = request.getParameter("name"); name = StringUtils.replace(name, " ", "+"); String standardNumber = request.getParameter("standardNumber"); String stakeNumber = request.getParameter("stakeNumber"); stakeNumber = StringUtils.replace(stakeNumber, " ", "+"); Integer startIndex = 0; String start = request.getParameter("startIndex"); if (StringUtils.isNotBlank(start)) { try { startIndex = Integer.parseInt(start); } catch (NumberFormatException n) { n.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter startIndex[" + start + "] invalid !"); } } Integer limit = 1000; String limitString = request.getParameter("limit"); if (StringUtils.isNotBlank(limitString)) { try { limit = Integer.parseInt(limitString); } catch (NumberFormatException n) { n.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter limit[" + limitString + "] invalid !"); } } Integer totalCount = deviceManager.countFireDetector(organId, name, standardNumber, stakeNumber); if (startIndex != 0 && totalCount.intValue() != 0) { if (startIndex.intValue() >= totalCount.intValue()) { startIndex -= ((startIndex.intValue() - totalCount.intValue()) / limit + 1) * limit; } } List<GetFireDetectorVO> fireDetectorList = deviceManager.listFireDetector(organId, name, standardNumber, stakeNumber, startIndex, limit); ListFireDetectorDTO dto = new ListFireDetectorDTO(); dto.setCmd("2234"); dto.setFireDetectorList(fireDetectorList); dto.setMethod("List_Fire_Detector"); dto.setTotalCount(totalCount + ""); writePage(response, dto); }
From source file:com.znsx.cms.web.controller.TmDeviceController.java
@InterfaceDescription(logon = true, method = "List_Covi", cmd = "2244") @RequestMapping("/list_covi.json") public void listCovi(HttpServletRequest request, HttpServletResponse response) throws Exception { String organId = request.getParameter("organId"); if (StringUtils.isBlank(organId)) { throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [organId]"); }//from w w w . ja v a 2s.c o m String name = request.getParameter("name"); name = StringUtils.replace(name, " ", "+"); String standardNumber = request.getParameter("standardNumber"); String stakeNumber = request.getParameter("stakeNumber"); stakeNumber = StringUtils.replace(stakeNumber, " ", "+"); Integer startIndex = 0; String start = request.getParameter("startIndex"); if (StringUtils.isNotBlank(start)) { try { startIndex = Integer.parseInt(start); } catch (NumberFormatException n) { n.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter startIndex[" + start + "] invalid !"); } } Integer limit = 1000; String limitString = request.getParameter("limit"); if (StringUtils.isNotBlank(limitString)) { try { limit = Integer.parseInt(limitString); } catch (NumberFormatException n) { n.printStackTrace(); throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Parameter limit[" + limitString + "] invalid !"); } } Integer totalCount = deviceManager.countCovi(organId, name, standardNumber, stakeNumber); if (startIndex != 0 && totalCount.intValue() != 0) { if (startIndex.intValue() >= totalCount.intValue()) { startIndex -= ((startIndex.intValue() - totalCount.intValue()) / limit + 1) * limit; } } List<GetCoviVO> coviList = deviceManager.listCovi(organId, name, standardNumber, stakeNumber, startIndex, limit); ListCoviDTO dto = new ListCoviDTO(); dto.setCmd("2244"); dto.setCoviList(coviList); dto.setMethod("List_Covi"); dto.setTotalCount(totalCount + ""); writePage(response, dto); }