// Default implementation public void setBlock(Player player, World level, Position pos, int mode, int type) { logger.debug("Setting block mode {} type {}", mode, type); if (mode == 1 && false && !player.isAuthorized(Permission.BUILD)) { logger.info("Not permitted to build."); try { // player.getSession().getActionSender().sendBlock(pos, // level.getBlock(pos),level.getBlockMeta(pos)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } else if (mode == 0 && false && !player.isAuthorized(Permission.DESTROY)) { logger.info("Not permitted to destroy."); try { // player.getSession().getActionSender().sendBlock(pos, level.getBlock(pos), // level.getBlockMeta(pos)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { logger.debug("Building is OK!"); level.setBlock(pos, (byte) (mode == 1 ? type : 0)); } }
/** 基类实现消息监听接口,加上打印metaq监控日志的方法 */ @Override public ConsumeConcurrentlyStatus consumeMessage( List<MessageExt> msgs, ConsumeConcurrentlyContext context) { long startTime = System.currentTimeMillis(); logger.info("receive_message:{}", msgs.toString()); if (msgs == null || msgs.size() < 1) { logger.error("receive empty msg!"); return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; } List<Serializable> msgList = new ArrayList<>(); for (MessageExt message : msgs) { msgList.add(decodeMsg(message)); } final int reconsumeTimes = msgs.get(0).getReconsumeTimes(); MsgObj msgObj = new MsgObj(); msgObj.setReconsumeTimes(reconsumeTimes); msgObj.setMsgList(msgList); msgObj.setContext(context); context.setDelayLevelWhenNextConsume(getDelayLevelWhenNextConsume(reconsumeTimes)); ConsumeConcurrentlyStatus status = doConsumeMessage(msgObj); logger.info( "ConsumeConcurrentlyStatus:{}|cost:{}", status, System.currentTimeMillis() - startTime); return status; }
@Test public void testLevels() throws Exception { FileLoggerMock mockFileLogger = setFileLoggerInstanceField(activity); LogPersister.setContext(activity); Logger logger = Logger.getLogger("package"); LogPersister.storeLogs(true); final String hi = "hi"; // no calls should create a file: LogPersister.setLogLevel(LEVEL.ERROR); logger.warn(hi); waitForNotify(logger); logger.info(hi); waitForNotify(logger); logger.debug(hi); waitForNotify(logger); LogPersister.setLogLevel(LEVEL.WARN); logger.info(hi); waitForNotify(logger); logger.debug(hi); waitForNotify(logger); LogPersister.setLogLevel(LEVEL.INFO); logger.debug(hi); waitForNotify(logger); // "hi" should not appear in the file assertEquals(0, mockFileLogger.getAccumulatedLogCalls().length()); }
public void execute(JdbcTemplate template) { if (template.queryForInt("select count(*) from version where version = 6") == 0) { LOG.info("Updating database schema to version 6."); template.execute("insert into version values (6)"); } if (!columnExists(template, "last_fm_enabled", "user_settings")) { LOG.info("Database columns 'user_settings.last_fm_*' not found. Creating them."); template.execute( "alter table user_settings add last_fm_enabled boolean default false not null"); template.execute("alter table user_settings add last_fm_username varchar null"); template.execute("alter table user_settings add last_fm_password varchar null"); LOG.info("Database columns 'user_settings.last_fm_*' were added successfully."); } if (!columnExists(template, "transcode_scheme", "user_settings")) { LOG.info("Database column 'user_settings.transcode_scheme' not found. Creating it."); template.execute( "alter table user_settings add transcode_scheme varchar default '" + TranscodeScheme.OFF.name() + "' not null"); LOG.info("Database column 'user_settings.transcode_scheme' was added successfully."); } }
@SneakyThrows(NoSuchAlgorithmException.class) public DependencyLoader downloadDependencies(DependencySet dependencySet) throws IOException { initDependencyStore(); for (Dependency dependency : dependencySet.getDependencies()) { URL cached = dependencyStore.getCachedDependency(dependency); if (cached == null) { logger.info("Downloading " + dependency.getUrl()); MessageDigest digest = MessageDigest.getInstance("SHA-512"); @SuppressWarnings("resource") ByteArrayOutputStream memoryStream = new ByteArrayOutputStream(); try (InputStream stream = dependency.getUrl().openStream()) { byte[] buf = new byte[4096]; int len; while ((len = stream.read(buf)) >= 0) { digest.update(buf, 0, len); memoryStream.write(buf, 0, len); } } byte[] hash = digest.digest(); if (!Arrays.equals(hash, dependency.getSha512sum())) { throw new IOException( "Mismatched hash on " + dependency.getUrl() + ": expected " + DatatypeConverter.printHexBinary(dependency.getSha512sum()) + " but got " + DatatypeConverter.printHexBinary(hash)); } cached = dependencyStore.saveDependency(dependency, memoryStream.toByteArray()); } urls.add(cached); } logger.info("Added " + dependencySet.getDependencies().size() + " dependencies."); return this; }
private static void initializeProperties() throws IOException, FileNotFoundException { { // Default properties are in resource 'one-jar.properties'. Properties properties = new Properties(); String props = "one-jar.properties"; InputStream is = Boot.class.getResourceAsStream("/" + props); if (is != null) { LOGGER.info("loading properties from " + props); properties.load(is); } // Merge in anything in a local file with the same name. if (new File(props).exists()) { is = new FileInputStream(props); if (is != null) { LOGGER.info("merging properties from " + props); properties.load(is); } } // Set system properties only if not already specified. Enumeration _enum = properties.propertyNames(); while (_enum.hasMoreElements()) { String name = (String) _enum.nextElement(); if (System.getProperty(name) == null) { System.setProperty(name, properties.getProperty(name)); } } } }
/** * Persists an SorPerson on update. * * @param sorPerson the person to update. * @return serviceExecutionResult. */ public ServiceExecutionResult<SorPerson> updateSorPerson(final SorPerson sorPerson) { final Set validationErrors = this.validator.validate(sorPerson); if (!validationErrors.isEmpty()) { Iterator iter = validationErrors.iterator(); while (iter.hasNext()) { logger.info("validation errors: " + iter.next()); } // since because of existing design we cannot raise exception, we can only rollback the // transaction through code // OR-384 if (TransactionAspectSupport.currentTransactionStatus() != null) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); } return new GeneralServiceExecutionResult<SorPerson>(validationErrors); } // do reconciliationCheck to make sure that modifications do not cause person to reconcile to a // different person if (!this.reconciler.reconcilesToSamePerson(sorPerson)) { throw new IllegalStateException(); } // Iterate over any sorRoles setting sorid and source id if not specified by SoR. for (final SorRole sorRole : sorPerson.getRoles()) { setRoleIdAndSource(sorRole, sorPerson.getSourceSor()); } // Save Sor Person final SorPerson savedSorPerson = this.personRepository.saveSorPerson(sorPerson); Person person = this.findPersonById(savedSorPerson.getPersonId()); Assert.notNull(person, "person cannot be null."); logger.info( "Verifying Number of calculated Roles before the calculate: " + person.getRoles().size()); // Iterate over sorRoles. SorRoles may be new or updated. for (final SorRole savedSorRole : savedSorPerson.getRoles()) { logger.info( "DefaultPersonService: savedSorPersonRole Found, savedSorRoleID: " + savedSorRole.getId()); logger.info("DefaultPersonService: savedSorPersonRole Found, Role Must be newly added."); // let sor role elector decide if this new role can be converted to calculated one sorRoleElector.addSorRole(savedSorRole, person); logger.info( "Verifying Number of calculated Roles after calculate: " + person.getRoles().size()); } for (final IdentifierAssigner ia : this.identifierAssigners) { ia.addIdentifierTo(sorPerson, person); } person = recalculatePersonBiodemInfo(person, savedSorPerson, RecalculationType.UPDATE, false); person = this.personRepository.savePerson(person); return new GeneralServiceExecutionResult<SorPerson>(savedSorPerson); }
protected void executeQuery(Statement stmt, String q) throws SQLException { q = q.replace("$PREFIX", getPrefix()); LOG.info(" Executing " + q); ResultSet rs = stmt.executeQuery(q); StringBuilder header = new StringBuilder(); for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { if (i > 1) { header.append("|"); } header.append(rs.getMetaData().getColumnName(i)); } LOG.info(header); int seq = 0; while (true) { boolean valid = rs.next(); if (!valid) break; seq++; StringBuilder line = new StringBuilder(); for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { if (i > 1) { line.append("|"); } line.append(rs.getString(i)); } LOG.info(seq + ":" + line); } }
public ServiceExecutionResult<ReconciliationResult> reconcile( final ReconciliationCriteria reconciliationCriteria) throws IllegalArgumentException { Assert.notNull(reconciliationCriteria, "reconciliationCriteria cannot be null"); logger.info("reconcile start"); final Set validationErrors = this.validator.validate(reconciliationCriteria); if (!validationErrors.isEmpty()) { Iterator iter = validationErrors.iterator(); while (iter.hasNext()) { logger.info("validation errors: " + iter.next()); } logger.info("reconcile start"); // since because of existing design we cannot raise exception, we can only rollback the // transaction through code // OR-384 if (TransactionAspectSupport.currentTransactionStatus() != null) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); } return new GeneralServiceExecutionResult<ReconciliationResult>(validationErrors); } final ReconciliationResult result = this.reconciler.reconcile(reconciliationCriteria); // (reconciliationCriteria, result); return new GeneralServiceExecutionResult<ReconciliationResult>(result); }
/** * Jirecon packets processing logic. * * <p>{@inheritDoc} */ @Override public void processPacket(Packet packet) { JireconIq recording = (JireconIq) packet; if (JireconIq.Action.INFO != recording.getAction() && IQ.Type.RESULT == recording.getType() || StringUtils.isNullOrEmpty(recording.getRid())) { logger.warn("Discarded: " + recording.toXML()); return; } if (!recording.getRid().equals(recordingId)) { logger.warn("Received IQ for unknown session: " + recording.toXML()); return; } if (status != recording.getStatus()) { status = recording.getStatus(); logger.info("Recording " + recordingId + " status: " + status); if (status == JireconIq.Status.STOPPED) { logger.info("Recording STOPPED: " + recordingId); recordingId = null; } } else { logger.info("Ignored status change: " + recording.toXML()); } }
@PreAuthorize("hasPermission(#sorRole, 'admin')") public ServiceExecutionResult<SorRole> validateAndSaveRoleForSorPerson( final SorPerson sorPerson, final SorRole sorRole) { logger.info(" validateAndSaveRoleForSorPerson start"); Assert.notNull(sorPerson, "SorPerson cannot be null."); Assert.notNull(sorRole, "SorRole cannot be null."); // check if the SoR Role has an ID assigned to it already and assign source sor setRoleIdAndSource(sorRole, sorPerson.getSourceSor()); final Set validationErrors = this.validator.validate(sorRole); if (!validationErrors.isEmpty()) { // since because of existing design we cannot raise exception, we can only rollback the // transaction through code // OR-384 if (TransactionAspectSupport.currentTransactionStatus() != null) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); } return new GeneralServiceExecutionResult<SorRole>(validationErrors); } final SorPerson newSorPerson = this.personRepository.saveSorPerson(sorPerson); Person person = this.personRepository.findByInternalId(newSorPerson.getPersonId()); final SorRole newSorRole = newSorPerson.findSorRoleBySorRoleId(sorRole.getSorId()); // let sor role elector decide if this new role can be converted to calculated one sorRoleElector.addSorRole(newSorRole, person); person = recalculatePersonBiodemInfo(person, newSorPerson, RecalculationType.UPDATE, false); this.personRepository.savePerson(person); logger.info("validateAndSaveRoleForSorPerson end"); return new GeneralServiceExecutionResult<SorRole>(newSorRole); }
@Test public void testFileRecreated() throws Exception { // don't use the mock FileLogger in this test LogPersister.setContext(activity); LogPersister.setLogLevel(LEVEL.DEBUG); File file = new File(activity.getFilesDir(), FILE_NAME0); Logger logger = Logger.getLogger("package"); LogPersister.storeLogs(true); logger.info("a message"); waitForNotify(logger); assertTrue(file.exists()); // If I deleted it instead of letting java.util.logger manage the files, will // java.util.logger recreate it? Let's make sure it does. file.delete(); assertFalse(file.exists()); logger.info("another message"); waitForNotify(logger); assertTrue(file.exists()); }
public static void estimateKeyDerivationTime() { // This is run in the background after startup. If we haven't recorded it before, do a key // derivation to see // how long it takes. This helps us produce better progress feedback, as on Windows we don't // currently have a // native Scrypt impl and the Java version is ~3 times slower, plus it depends a lot on CPU // speed. checkGuiThread(); estimatedKeyDerivationTime = Main.instance.prefs.getExpectedKeyDerivationTime(); if (estimatedKeyDerivationTime == null) { new Thread( () -> { log.info("Doing background test key derivation"); KeyCrypterScrypt scrypt = new KeyCrypterScrypt(SCRYPT_PARAMETERS); long start = System.currentTimeMillis(); scrypt.deriveKey("test password"); long msec = System.currentTimeMillis() - start; log.info("Background test key derivation took {}msec", msec); Platform.runLater( () -> { estimatedKeyDerivationTime = Duration.ofMillis(msec); Main.instance.prefs.setExpectedKeyDerivationTime(estimatedKeyDerivationTime); }); }) .start(); } }
/** * Processes the session initiation {@link SessionIQ} that we were created with, passing its * content to the media handler and then sends either a "session-info/ringing" or a "terminate" * response. * * @param sessionInitIQ The {@link SessionIQ} that created the session that we are handling here. */ protected synchronized void processSessionInitiate(SessionIQ sessionInitIQ) { // Do initiate the session. this.sessionInitIQ = sessionInitIQ; this.initiator = true; RtpDescriptionPacketExtension description = null; for (PacketExtension ext : sessionInitIQ.getExtensions()) { if (ext.getElementName().equals(RtpDescriptionPacketExtension.ELEMENT_NAME)) { description = (RtpDescriptionPacketExtension) ext; break; } } if (description == null) { logger.info("No description in incoming session initiate"); // send an error response; String reasonText = "Error: no description"; SessionIQ errResp = GTalkPacketFactory.createSessionTerminate( sessionInitIQ.getTo(), sessionInitIQ.getFrom(), sessionInitIQ.getID(), Reason.INCOMPATIBLE_PARAMETERS, reasonText); setState(CallPeerState.FAILED, reasonText); getProtocolProvider().getConnection().sendPacket(errResp); return; } try { getMediaHandler().processOffer(description); } catch (Exception ex) { logger.info("Failed to process an incoming session initiate", ex); // send an error response; String reasonText = "Error: " + ex.getMessage(); SessionIQ errResp = GTalkPacketFactory.createSessionTerminate( sessionInitIQ.getTo(), sessionInitIQ.getFrom(), sessionInitIQ.getID(), Reason.INCOMPATIBLE_PARAMETERS, reasonText); setState(CallPeerState.FAILED, reasonText); getProtocolProvider().getConnection().sendPacket(errResp); return; } // If we do not get the info about the remote peer yet. Get it right // now. if (this.getDiscoveryInfo() == null) { String calleeURI = sessionInitIQ.getFrom(); retrieveDiscoveryInfo(calleeURI); } }
public static void main(String[] args) { Map<Long, String> m = new LinkedHashMap<Long, String>(); if (m instanceof LinkedHashMap) { logger.info("true"); LinkedHashMap<Long, String> l = (LinkedHashMap) m; if (l instanceof LinkedHashMap) logger.info("true"); } }
@Test public void t04_TestTxtLogger() throws BasicIOException { final String filename1 = "test01.log"; final String filename2 = "test01.txt"; final LogFile logFile = new LogFile(_testLocation, filename1); Logger logger = new Logger(logFile); // The file should be created immediately: File file = _testLocation.getFile(filename1); if (file == null) { fail(); } // It should be locked: try { file.getOutputStream(); fail(); } catch (FileLockedException fle) { println(fle); } // The .txt file should NOT have been created: if (_testLocation.exists(filename2)) { fail(); } // Change output, should delete the file: logger.setOutput(System.out); if (_testLocation.exists(filename1)) { fail(); } // Again open the same file: logger.setOutput(logFile); assertEquals(file.getSize(), 0L); logger.info("first message"); long size = file.getSize(); assertTrue(size > 0); // Change to stdout and check the file is still there: logger.setOutput(System.out); if (!_testLocation.exists(filename1)) { fail(); } // We can now open it: ExtendedReader in = new ExtendedReader(file.getInputStream()); assertTrue(in.readLine().startsWith("INFO")); in.close(); // Ensure that if we disable the logger it does not write to the file: logger.setOutput(logFile); logger.setEnabled(false); logger.info("second message"); logger.setOutput(System.out); assertEquals(file.getSize(), size); file.delete(); // Print an exception to stdout: logger.setEnabled(true); logger.error("Oops!", new Exception()); // Print an exception to TXT: logger.setOutput(logFile); logger.error("Oops!", new Exception()); logger.setOutput(System.out); file.delete(); }
/* (non-Javadoc) * @see com.lexst.thread.VirtualThread#process() */ @Override public void process() { Logger.info("WorkPool.process, into..."); while (!isInterrupted()) { this.check(); this.delay(1000); } Logger.info("WorkPool.process, exit"); }
public void run() { int numOfCdrs = 0; // System.out.println("Getting data from queue table"); Logger.info("CDRServer:", "Getting data from queue table"); while (CDRServer.running) { try { this.readCDRinQueueEx(); if ("VMS".equals(Preference.mobileOperator.toUpperCase())) { // CdrFileCopier4vms cdrcopy = new CdrFileCopier4vms(); // System.out.println("Starting FTP"); Logger.info("FTP:", " starting FTP cdr file"); Ftp2CdrServer ftp = new Ftp2CdrServer(); // .start(); ftp.runftp(); } else { // System.out.println("Invalid mobile operator: " + // Preference.mobileOperator); Logger.info("Invalid mobile operator:", Preference.mobileOperator); exit(); } sleep10Minutes(); } catch (InterruptedException ex) { } catch (DBException ex) { // when lost connection to db // System.out.println("DBScanner::" + ex.getMessage()); Logger.info("DBScanner:", ex.getMessage()); try { dbTools.log_alert( "Billing system", "-> ERROR: Ket noi Database bi loi: " + ex.getMessage(), 1, 0, "serious", Preference.alert_person); } catch (Exception e) { } GatewayCDR.rebuildDBConnections(1); // 1 connection } catch (Exception ex) { // System.out.println("DBScanner::" + ex.getMessage()); Logger.info("DBScanner:", ex.getMessage()); try { // dbTools.log_alert(Preference.sourceAddressList.toString(), // "CDR->DBSCanner", // "<-" + Preference.mobileOperator + "-> ERROR: " + // ex.getMessage(), // 1, Preference.alert_person, // Preference.alert_mobile); dbTools.log_alert( "Billing system", "-> ERROR: Loi dinh dang MOBILE OPERATOR: " + ex.getMessage(), 1, 0, "serious", Preference.alert_person); } catch (Exception e) { } } } }
public static void cleanInodeTableData() throws DotDataException { Map map = new HashMap(); try { map = HibernateUtil.getSession().getSessionFactory().getAllClassMetadata(); } catch (HibernateException e) { throw new DotDataException(e.getMessage(), e); } Iterator it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry) it.next(); Class x = (Class) pairs.getKey(); if (!x.equals(Inode.class)) { Object o; try { o = x.newInstance(); } catch (Exception e) { Logger.info(MaintenanceUtil.class, "Unable to instaniate object"); Logger.debug(MaintenanceUtil.class, "Unable to instaniate object", e); continue; } if (o instanceof Inode) { Inode i = (Inode) o; String type = i.getType(); String tableName = ((net.sf.hibernate.persister.AbstractEntityPersister) map.get(x)).getTableName(); cleanInodeTableData(tableName, type); } } } it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry) it.next(); Class x = (Class) pairs.getKey(); if (!x.equals(Inode.class)) { Object o; try { o = x.newInstance(); } catch (Exception e) { Logger.info(MaintenanceUtil.class, "Unable to instaniate object"); Logger.debug(MaintenanceUtil.class, "Unable to instaniate object", e); continue; } if (o instanceof Inode) { Inode i = (Inode) o; String type = i.getType(); String tableName = ((net.sf.hibernate.persister.AbstractEntityPersister) map.get(x)).getTableName(); removeOphanedInodes(tableName, type); } } } }
// Gets a property. static String getStringProperty(String propName) { String temp = getConfigValue(propName); String result = ""; if (temp != null) { result = temp; Logger.info("{DB}-" + propName + ":" + result); } else { result = properties.getProperty(propName); Logger.info("{FILE}-" + propName + ":" + result); } return result; }
protected void doInitialize() throws Exception { DSCaptureDevice devices[] = DSManager.getInstance().getCaptureDevices(); boolean captureDeviceInfoIsAdded = false; for (int i = 0, count = (devices == null) ? 0 : devices.length; i < count; i++) { long pixelFormat = devices[i].getFormat().getPixelFormat(); int ffmpegPixFmt = (int) DataSource.getFFmpegPixFmt(pixelFormat); Format format = null; if (ffmpegPixFmt != FFmpeg.PIX_FMT_NONE) { format = new AVFrameFormat(ffmpegPixFmt, (int) pixelFormat); } else { logger.warn( "No support for this webcam: " + devices[i].getName() + "(format " + pixelFormat + " not supported)"); continue; } if (logger.isInfoEnabled()) { for (DSFormat f : devices[i].getSupportedFormats()) { if (f.getWidth() != 0 && f.getHeight() != 0) logger.info( "Webcam available resolution for " + devices[i].getName() + ":" + f.getWidth() + "x" + f.getHeight()); } } CaptureDeviceInfo device = new CaptureDeviceInfo( devices[i].getName(), new MediaLocator(LOCATOR_PROTOCOL + ':' + devices[i].getName()), new Format[] {format}); if (logger.isInfoEnabled()) logger.info("Found[" + i + "]: " + device.getName()); CaptureDeviceManager.addDevice(device); captureDeviceInfoIsAdded = true; } if (captureDeviceInfoIsAdded && !MediaServiceImpl.isJmfRegistryDisableLoad()) CaptureDeviceManager.commit(); DSManager.dispose(); }
@Path("log") @POST @Consumes(MediaType.APPLICATION_JSON) public Response doLog(String logsAsJson) { ServiceLogs logs = ServiceLogs.fromJson(logsAsJson); LogDAO logger = new LogDAO(); log.info("Apple wants to tell us something:"); for (String line : logs.getLogs()) { logger.store(line); log.info("{}", line); } return Response.status(Response.Status.OK).build(); }
// Gets a property and converts it into integer. static int getIntProperty(String propName, int defaultValue) { String temp = getConfigValue(propName); int result = defaultValue; if (temp != null) { result = Integer.parseInt(temp); Logger.info("{DB}-" + propName + ":" + result); } else { result = Integer.parseInt(properties.getProperty(propName, Integer.toString(defaultValue)).trim()); Logger.info("{FILE}-" + propName + ":" + result); } return result; }
public ServiceExecutionResult<Person> addPerson( final ReconciliationCriteria reconciliationCriteria) throws ReconciliationException, IllegalArgumentException, SorPersonAlreadyExistsException { Assert.notNull(reconciliationCriteria, "reconciliationCriteria cannot be null"); logger.info("addPerson start"); if (reconciliationCriteria.getSorPerson().getSorId() != null && this.findBySorIdentifierAndSource( reconciliationCriteria.getSorPerson().getSourceSor(), reconciliationCriteria.getSorPerson().getSorId()) != null) { // throw new IllegalStateException("CANNOT ADD SAME SOR RECORD."); throw new SorPersonAlreadyExistsException( this.findBySorIdentifierAndSource( reconciliationCriteria.getSorPerson().getSourceSor(), reconciliationCriteria.getSorPerson().getSorId())); } final Set validationErrors = this.validator.validate(reconciliationCriteria); if (!validationErrors.isEmpty()) { Iterator iter = validationErrors.iterator(); while (iter.hasNext()) { logger.info("validation errors: " + iter.next()); } // since because of existing design we cannot raise exception, we can only rollback the // transaction through code // OR-384 if (TransactionAspectSupport.currentTransactionStatus() != null) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); } return new GeneralServiceExecutionResult<Person>(validationErrors); } final ReconciliationResult result = this.reconciler.reconcile(reconciliationCriteria); switch (result.getReconciliationType()) { case NONE: return new GeneralServiceExecutionResult<Person>( saveSorPersonAndConvertToCalculatedPerson(reconciliationCriteria)); case EXACT: return new GeneralServiceExecutionResult<Person>( addNewSorPersonAndLinkWithMatchedCalculatedPerson(reconciliationCriteria, result)); } this.criteriaCache.put(reconciliationCriteria, result); logger.info("addPerson start"); throw new ReconciliationException(result); }
@Override protected void checkConfig() { int port = getPort(); PrintStream out = getOutput(); Logger.info("Configuration:"); Logger.info(HOST + ": " + getHost()); Logger.info(PORT + ": " + port); Logger.info( OUTPUT + ": " + (config.getProperty(OUTPUT).equals("") ? "Stdout" : config.getProperty(OUTPUT))); Logger.setOutput(out); }
/** * Start the swing notification service * * @param bc * @throws java.lang.Exception */ public void start(BundleContext bc) throws Exception { if (logger.isInfoEnabled()) logger.info("Swing Notification ...[ STARTING ]"); bundleContext = bc; PopupMessageHandler handler = null; handler = new PopupMessageHandlerSwingImpl(); getConfigurationService(); bc.registerService(PopupMessageHandler.class.getName(), handler, null); if (logger.isInfoEnabled()) logger.info("Swing Notification ...[REGISTERED]"); }
// Gets a property and converts it into byte. static byte getByteProperty(String propName, byte defaultValue) { String temp = getConfigValue(propName); byte result = defaultValue; if (temp != null) { result = Byte.parseByte(temp); Logger.info("{DB}-" + propName + ":" + result); } else { result = Byte.parseByte(properties.getProperty(propName, Byte.toString(defaultValue)).trim()); Logger.info("{FILE}-" + propName + ":" + result); } return result; }
@Test public void testDiffRatios() { logger.info("\ntesting diffRatios()"); double[] input = null; double[] result = null; assertEquals(0, MathUtil.diffRatios(input).length); input = new double[] {}; assertEquals(0, MathUtil.diffRatios(input).length); input = new double[] {1}; assertEquals(0, MathUtil.diffRatios(input).length); input = new double[] {1, 2}; result = MathUtil.diffRatios(input); assertEquals(1, result.length); assertEquals(2.0, result[0], 0.0); input = new double[] {1, 2, 1, 5}; result = MathUtil.diffRatios(input); assertEquals(3, result.length); assertEquals(2.0, result[0], 0.0); assertEquals(0.5, result[1], 0.0); assertEquals(5.0, result[2], 0.0); input = new double[] {1, 2, 0, 5, 8}; result = MathUtil.diffRatios(input); logger.debug(ListArrayUtil.arrayToString(result)); assertEquals(true, Double.isInfinite(result[2])); assertEquals(false, Double.isNaN(result[2])); }
@Test public void testProd_double_array_Range() { logger.info("\ntesting prod(List<Double> list, int start, int end)"); double[] input = null; assertEquals(0.0, MathUtil.prod(input), 0.0); input = new double[] {}; assertEquals(0.0, MathUtil.prod(input), 0.0); input = new double[] {4, 1.0, 0.5, 27.0}; assertEquals(4.0, MathUtil.prod(input, 0, 0), 0.0); assertEquals(4.0, MathUtil.prod(input, 0, 1), 0.0); assertEquals(2.0, MathUtil.prod(input, 0, 2), 0.0); assertEquals(54.0, MathUtil.prod(input, 0, 3), 0.0); assertEquals(1.0, MathUtil.prod(input, 1, 1), 0.0); assertEquals(0.5, MathUtil.prod(input, 1, 2), 0.0); assertEquals(13.5, MathUtil.prod(input, 1, 3), 0.0); assertEquals(54.0, MathUtil.prod(input, -1, 4), 0.0); assertEquals(54.0, MathUtil.prod(input, 0, 4), 0.0); assertEquals(54.0, MathUtil.prod(input, 3, 0), 0.0); assertEquals(54.0, MathUtil.prod(input, 4, -1), 0.0); }
@Test public void testProd_List_Double_Range() { logger.info("\ntesting prod(List<Double> list, int start, int end)"); List<Double> input = null; assertEquals(0.0, MathUtil.prod(input, 0, 0), 0.0); input = new ArrayList<Double>(); assertEquals(0.0, MathUtil.prod(input, 0, 0), 0.0); input.add(4.0); input.add(1.0); input.add(.5); input.add(27.0); assertEquals(4.0, MathUtil.prod(input, 0, 0), 0.0); assertEquals(4.0, MathUtil.prod(input, 0, 1), 0.0); assertEquals(2.0, MathUtil.prod(input, 0, 2), 0.0); assertEquals(54.0, MathUtil.prod(input, 0, 3), 0.0); assertEquals(1.0, MathUtil.prod(input, 1, 1), 0.0); assertEquals(0.5, MathUtil.prod(input, 1, 2), 0.0); assertEquals(13.5, MathUtil.prod(input, 1, 3), 0.0); assertEquals(54.0, MathUtil.prod(input, -1, 4), 0.0); assertEquals(54.0, MathUtil.prod(input, 0, 4), 0.0); assertEquals(54.0, MathUtil.prod(input, 3, 0), 0.0); assertEquals(54.0, MathUtil.prod(input, 4, -1), 0.0); }