org.apache.commons.logging.LogFactory Java Examples

The following examples show how to use org.apache.commons.logging.LogFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnnotationUtils.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Handle the supplied annotation introspection exception.
 * <p>If the supplied exception is an {@link AnnotationConfigurationException},
 * it will simply be thrown, allowing it to propagate to the caller, and
 * nothing will be logged.
 * <p>Otherwise, this method logs an introspection failure (in particular
 * {@code TypeNotPresentExceptions}) before moving on, assuming nested
 * Class values were not resolvable within annotation attributes and
 * thereby effectively pretending there were no annotations on the specified
 * element.
 * @param element the element that we tried to introspect annotations on
 * @param ex the exception that we encountered
 * @see #rethrowAnnotationConfigurationException
 */
static void handleIntrospectionFailure(AnnotatedElement element, Exception ex) {
	rethrowAnnotationConfigurationException(ex);

	Log loggerToUse = logger;
	if (loggerToUse == null) {
		loggerToUse = LogFactory.getLog(AnnotationUtils.class);
		logger = loggerToUse;
	}
	if (element instanceof Class && Annotation.class.isAssignableFrom((Class<?>) element)) {
		// Meta-annotation lookup on an annotation type
		if (loggerToUse.isDebugEnabled()) {
			loggerToUse.debug("Failed to introspect meta-annotations on [" + element + "]: " + ex);
		}
	}
	else {
		// Direct annotation lookup on regular Class, Method, Field
		if (loggerToUse.isInfoEnabled()) {
			loggerToUse.info("Failed to introspect annotations on [" + element + "]: " + ex);
		}
	}
}
 
Example #2
Source File: GoldTestBase.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected void runAllGoldReportsSerial() throws Exception {
  initializeTestEnvironment();

  List<Throwable> errors = Collections.synchronizedList( new ArrayList<Throwable>() );
  List<ExecuteReportRunner> reports = new ArrayList<ExecuteReportRunner>();
  reports.addAll( collectReports( "reports", ReportProcessingMode.legacy, errors ) );
  reports.addAll( collectReports( "reports", ReportProcessingMode.migration, errors ) );
  reports.addAll( collectReports( "reports", ReportProcessingMode.current, errors ) );
  reports.addAll( collectReports( "reports-4.0", ReportProcessingMode.migration, errors ) );
  reports.addAll( collectReports( "reports-4.0", ReportProcessingMode.current, errors ) );

  for ( ExecuteReportRunner report : reports ) {
    report.run();
  }
  if ( errors.isEmpty() == false ) {
    Log log = LogFactory.getLog( GoldTestBase.class );
    for ( Throwable throwable : errors ) {
      log.error( "Failed", throwable );
    }
    Assert.fail();
  }

  System.out.println( findMarker() );
}
 
Example #3
Source File: RedisHttpSessionConfiguration.java    From spring-session with Apache License 2.0 6 votes vote down vote up
@Override
public void afterPropertiesSet() {
	if (this.configure == ConfigureRedisAction.NO_OP) {
		return;
	}
	RedisConnection connection = this.connectionFactory.getConnection();
	try {
		this.configure.configure(connection);
	}
	finally {
		try {
			connection.close();
		}
		catch (Exception ex) {
			LogFactory.getLog(getClass()).error("Error closing RedisConnection", ex);
		}
	}
}
 
Example #4
Source File: HarvesterHeritrix.java    From webcurator with Apache License 2.0 6 votes vote down vote up
/** Default Constructor. */
public HarvesterHeritrix() throws HarvesterException {
    super();
    name = "HarvesterHeritrix-" + System.currentTimeMillis();
    try {
        heritrix = new Heritrix(name, true);            
    }
    catch (IOException e) {
    	if (log.isErrorEnabled()) {
    		log.error("Failed to create an instance of Heritrix " + e.getMessage(), e);
    	}
        throw new HarvesterException("Failed to create an instance of Heritrix " + e.getMessage(), e);
    }
    log = LogFactory.getLog(HarvesterHeritrix.class);
    if (log.isDebugEnabled()) {
    	log.debug("Created new harvester " + name);
    }
    status = new HarvesterStatusDTO(name);
}
 
Example #5
Source File: WebContext.java    From MaxKey with Apache License 2.0 6 votes vote down vote up
/**
 * get Request IpAddress by request.
 * 
 * @param request HttpServletRequest
 * @return String
 */
public static final String getRequestIpAddress(HttpServletRequest request) {
    String ipAddress = request.getHeader("x-forwarded-for");
    if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
        ipAddress = request.getHeader("Proxy-Client-IP");
    }
    if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
        ipAddress = request.getHeader("WL-Proxy-Client-IP");
    }
    if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
        ipAddress = request.getRemoteAddr();
    }
    LogFactory.getLog(WebContext.class).debug(
            "getRequestIpAddress() RequestIpAddress:" + ipAddress);
    return ipAddress;
}
 
Example #6
Source File: DatabaseTaskBase.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the logging.
 */
private void initLogging()
{
    if (_simpleLogging)
    {
        // For Ant, we're forcing DdlUtils to do logging via log4j to the console
        Properties props = new Properties();
        String     level = (_verbosity == null ? Level.INFO.toString() : _verbosity.getValue()).toUpperCase();

        props.setProperty("log4j.rootCategory", level + ",A");
        props.setProperty("log4j.appender.A", "org.apache.log4j.ConsoleAppender");
        props.setProperty("log4j.appender.A.layout", "org.apache.log4j.PatternLayout");
        props.setProperty("log4j.appender.A.layout.ConversionPattern", "%m%n");
        // we don't want debug logging from Digester
        props.setProperty("log4j.logger.org.apache.commons", "WARN");

        LogManager.resetConfiguration();
        PropertyConfigurator.configure(props);
    }
    _log = LogFactory.getLog(getClass());
}
 
Example #7
Source File: TesseractOCRParser.java    From CogStack-Pipeline with Apache License 2.0 6 votes vote down vote up
/**
 * Starts a thread that reads the contents of the standard output or error
 * stream of the given process to not block the process. The stream is closed
 * once fully processed.
 */
private void logStream(final String logType, final InputStream stream, final File file) {
    new Thread() {
        public void run() {
            Reader reader = new InputStreamReader(stream, UTF_8);
            StringBuilder out = new StringBuilder();
            char[] buffer = new char[1024];
            try {
                for (int n = reader.read(buffer); n != -1; n = reader.read(buffer))
                    out.append(buffer, 0, n);
            } catch (IOException e) {

            } finally {
                IOUtils.closeQuietly(stream);
            }

            String msg = out.toString();
            LogFactory.getLog(TesseractOCRParser.class).debug(msg);
        }
    }.start();
}
 
Example #8
Source File: RootClass.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void checkCompositeIdentifier() {
	if ( getIdentifier() instanceof Component ) {
		Component id = (Component) getIdentifier();
		if ( !id.isDynamic() ) {
			Class idClass = id.getComponentClass();
			if ( idClass != null && !ReflectHelper.overridesEquals( idClass ) ) {
				LogFactory.getLog(RootClass.class)
					.warn( "composite-id class does not override equals(): "
						+ id.getComponentClass().getName() );
			}
			if ( !ReflectHelper.overridesHashCode( idClass ) ) {
				LogFactory.getLog(RootClass.class)
					.warn( "composite-id class does not override hashCode(): "
						+ id.getComponentClass().getName() );
			}
			if ( !Serializable.class.isAssignableFrom( idClass ) ) {
				throw new MappingException( "composite-id class must implement Serializable: "
					+ id.getComponentClass().getName() );
			}
		}
	}
}
 
Example #9
Source File: HTTPUtil.java    From OpenAs2App with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public static byte[] readData(InputStream inStream, OutputStream outStream, Message msg) throws IOException, MessagingException {
    List<String> request = new ArrayList<String>(2);
    byte[] data = readHTTP(inStream, outStream, msg.getHeaders(), request);

    msg.setAttribute(MA_HTTP_REQ_TYPE, request.get(0));
    msg.setAttribute(MA_HTTP_REQ_URL, request.get(1));
    if (data == null) {
        String healthCheckUri = Properties.getProperty("health_check_uri", "healthcheck");
        if ("GET".equalsIgnoreCase(request.get(0)) && request.get(1).matches("^[/]{0,1}" + healthCheckUri + "*")) {
            if (outStream != null) {
                HTTPUtil.sendHTTPResponse(outStream, HttpURLConnection.HTTP_OK, null);
                msg.setAttribute("isHealthCheck", "true"); // provide means for caller to know what happened
            }
            return null;
        } else {
            HTTPUtil.sendHTTPResponse(outStream, HttpURLConnection.HTTP_LENGTH_REQUIRED, null);
            Log logger = LogFactory.getLog(HTTPUtil.class.getSimpleName());
            logger.error("Inbound HTTP request does not provide means to determine data length: " + request.get(0) + " " + request.get(1) + "\n\tHeaders: " + printHeaders(msg.getHeaders().getAllHeaders(), "==", ";;"));
            throw new IOException("Content-Length missing and no \"Transfer-Encoding\" header found to determine how to read message body.");
        }
    }
    cleanIdHeaders(msg.getHeaders());
    return data;
}
 
Example #10
Source File: Log4JAuditDestination.java    From ranger with Apache License 2.0 6 votes vote down vote up
@Override
public void init(Properties prop, String propPrefix) {
	super.init(prop, propPrefix);
	loggerName = MiscUtil.getStringProperty(props, propPrefix + "."
			+ PROP_LOG4J_LOGGER);
	if (loggerName == null || loggerName.isEmpty()) {
		loggerName = DEFAULT_LOGGER_PREFIX + "." + getName();
		logger.info("Logger property " + propPrefix + "."
				+ PROP_LOG4J_LOGGER + " was not set. Constructing default="
				+ loggerName);
	}
	logger.info("Logger name for " + getName() + " is " + loggerName);
	auditLogger = LogFactory.getLog(loggerName);
	logger.info("Done initializing logger for audit. name=" + getName()
			+ ", loggerName=" + loggerName);
}
 
Example #11
Source File: HadoopCfgUtils.java    From elasticsearch-hadoop with Apache License 2.0 6 votes vote down vote up
private static TaskID parseTaskIdFromTaskAttemptId(String taskAttemptId) {
    // Tez in particular uses an incorrect String task1244XXX instead of task_1244 which makes the parsing fail
    // this method try to cope with such issues and look at the numbers if possible
    if (taskAttemptId.startsWith("task")) {
        taskAttemptId = taskAttemptId.substring(4);
    }
    if (taskAttemptId.startsWith("_")) {
        taskAttemptId = taskAttemptId.substring(1);
    }
    List<String> tokenize = StringUtils.tokenize(taskAttemptId, "_");
    // need at least 4 entries from 123123123123_0001_r_0000_4
    if (tokenize.size() < 4) {
        LogFactory.getLog(HadoopCfgUtils.class).warn("Cannot parse task attempt (too little arguments) " + taskAttemptId);
        return null;
    }
    // we parse straight away - in case of an exception we can catch the new format
    try {
        return new TaskID(tokenize.get(0), Integer.parseInt(tokenize.get(1)), tokenize.get(2).startsWith("m"), Integer.parseInt(tokenize.get(3)));
    } catch (Exception ex) {
        LogFactory.getLog(HadoopCfgUtils.class).warn("Cannot parse task attempt " + taskAttemptId);
        return null;
    }
}
 
Example #12
Source File: VersionInfo.java    From hadoop with Apache License 2.0 6 votes vote down vote up
protected VersionInfo(String component) {
  info = new Properties();
  String versionInfoFile = component + "-version-info.properties";
  InputStream is = null;
  try {
    is = Thread.currentThread().getContextClassLoader()
      .getResourceAsStream(versionInfoFile);
    if (is == null) {
      throw new IOException("Resource not found");
    }
    info.load(is);
  } catch (IOException ex) {
    LogFactory.getLog(getClass()).warn("Could not read '" +
        versionInfoFile + "', " + ex.toString(), ex);
  } finally {
    IOUtils.closeStream(is);
  }
}
 
Example #13
Source File: Closer.java    From hbase-indexer with Apache License 2.0 5 votes vote down vote up
/**
 * Closes anything {@link Closeable}, catches any throwable that might occur during closing and logs it as an error.
 */
public static void close(Closeable closeable) {
    if (closeable != null) {
        try {
            closeable.close();
        } catch (Throwable t) {
            Log log = LogFactory.getLog(Closer.class);
            log.error("Error closing object of type " + closeable.getClass().getName(), t);
        }
    }
}
 
Example #14
Source File: HtmlParser.java    From gecco with MIT License 5 votes vote down vote up
public HtmlParser(String baseUri, String content) {
	long beginTime = System.currentTimeMillis();
	log = LogFactory.getLog(HtmlParser.class);
	this.baseUri = baseUri;
	if (isTable(content)) {
		this.document = Jsoup.parse(content, baseUri, Parser.xmlParser());
	} else {
		this.document = Jsoup.parse(content, baseUri);
	}
	long endTime = System.currentTimeMillis();
	if (log.isTraceEnabled()) {
		log.trace("init html parser : " + (endTime - beginTime) + "ms");
	}
}
 
Example #15
Source File: SdkInputStream.java    From ibm-cos-sdk-java with Apache License 2.0 5 votes vote down vote up
/**
 * Aborts with subclass specific abortion logic executed if needed.
 * Note the interrupted status of the thread is cleared by this method.
 * @throws AbortedException if found necessary.
 */
protected final void abortIfNeeded() {
    if (shouldAbort()) {
        try {
            abort();    // execute subclass specific abortion logic
        } catch (IOException e) {
            LogFactory.getLog(getClass()).debug("FYI", e);
        }
        throw new AbortedException();
    }
}
 
Example #16
Source File: ZipkinTracer.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Override
public Tracer getTracer(String serviceName) {
    String hostname = configuration.getFirstProperty(TracingConstants.ZIPKIN_CONFIG_HOST) != null ?
            configuration.getFirstProperty(TracingConstants.ZIPKIN_CONFIG_HOST)
            : TracingConstants.ZIPKIN_DEFAULT_HOST;

    int port = configuration.getFirstProperty(TracingConstants.ZIPKIN_CONFIG_PORT) != null ?
            Integer.parseInt(configuration.getFirstProperty(TracingConstants.ZIPKIN_CONFIG_PORT))
            : TracingConstants.ZIPKIN_DEFAULT_PORT;

    boolean tracerLogEnabled =
            Boolean.parseBoolean(configuration.getFirstProperty(TracingConstants.CONFIG_TRACER_LOG_ENABLED) != null ?
            configuration.getFirstProperty(TracingConstants.CONFIG_TRACER_LOG_ENABLED)
            : TracingConstants.DEFAULT_TRACER_LOG_ENABLED);

    OkHttpSender sender = OkHttpSender.create("http://" + hostname + ":" + port + TracingConstants.ZIPKIN_API_CONTEXT);
    Tracer tracer = BraveTracer.create(Tracing.newBuilder()
            .localServiceName(serviceName)
            .spanReporter(AsyncReporter.builder(sender).build())
            .propagationFactory(ExtraFieldPropagation.newFactory(B3Propagation.FACTORY, TracingConstants.REQUEST_ID))
            .build());

    if (tracerLogEnabled) {
        Reporter reporter = new TracingReporter(LogFactory.getLog(TracingConstants.TRACER));
        Tracer tracerR = new TracerR(tracer, reporter, new ThreadLocalScopeManager());
        GlobalTracer.register(tracerR);
        return tracerR;
    } else {
        GlobalTracer.register(tracer);
        return tracer;
    }
}
 
Example #17
Source File: ARM64SyscallHandler.java    From unidbg with Apache License 2.0 5 votes vote down vote up
private long mmap(Emulator<?> emulator) {
    Arm64RegisterContext context = emulator.getContext();
    UnicornPointer addr = context.getXPointer(0);
    int length = context.getXInt(1);
    int prot = context.getXInt(2);
    int flags = context.getXInt(3);
    int fd = context.getXInt(4);
    long offset = context.getXLong(5);

    int tag = fd >>> 24;
    if (tag != 0) {
        fd = -1;
    }

    boolean warning = length >= 0x10000000;
    long base = emulator.getMemory().mmap2(addr == null ? 0 : addr.peer, length, prot, flags, fd, (int) offset);
    String msg = "mmap addr=" + addr + ", base=0x" + Long.toHexString(base) + ", length=" + length + ", prot=0x" + Integer.toHexString(prot) + ", flags=0x" + Integer.toHexString(flags) + ", fd=" + fd + ", offset=" + offset + ", tag=" + tag + ", LR=" + context.getLRPointer();
    if (log.isDebugEnabled() || warning) {
        if (warning) {
            log.warn(msg);
        } else {
            log.debug(msg);
        }
    } else if(LogFactory.getLog("com.github.unidbg.ios.malloc").isDebugEnabled()) {
        log.debug(msg);
    }
    return base;
}
 
Example #18
Source File: APIUtilTest.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetHttpClient() throws Exception {
    Log log = Mockito.mock(Log.class);
    PowerMockito.mockStatic(LogFactory.class);
    Mockito.when(LogFactory.getLog(Mockito.any(Class.class))).thenReturn(log);

    SSLSocketFactory socketFactory = Mockito.mock(SSLSocketFactory.class);
    PowerMockito.mockStatic(SSLSocketFactory.class);
    Mockito.when(SSLSocketFactory.getSocketFactory()).thenReturn(socketFactory);

    ServiceReferenceHolderMockCreator holderMockCreator = new ServiceReferenceHolderMockCreator(1);
    ServiceReferenceHolderMockCreator.initContextService();

    HttpClient client = APIUtil.getHttpClient(3244, "http");

    Assert.assertNotNull(client);
    Scheme scheme = client.getConnectionManager().getSchemeRegistry().get("http");
    Assert.assertEquals(3244, scheme.getDefaultPort());

    client = APIUtil.getHttpClient(3244, "https");
    Assert.assertNotNull(client);
    scheme = client.getConnectionManager().getSchemeRegistry().get("https");
    Assert.assertEquals(3244, scheme.getDefaultPort());

    client = APIUtil.getHttpClient(-1, "http");
    Assert.assertNotNull(client);
    scheme = client.getConnectionManager().getSchemeRegistry().get("http");
    Assert.assertEquals(80, scheme.getDefaultPort());

    client = APIUtil.getHttpClient(-1, "https");
    Assert.assertNotNull(client);
    scheme = client.getConnectionManager().getSchemeRegistry().get("https");
    Assert.assertEquals(443, scheme.getDefaultPort());
}
 
Example #19
Source File: BookPubApplication.java    From Spring-Boot-2.0-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
@Bean
public CommandLineRunner configValuePrinter(
        @Value("${my.config.value:}") String configValue) {
    return args ->
            LogFactory.getLog(getClass()).
                    info("Value of my.config.value property is: " + configValue);
}
 
Example #20
Source File: BaseMessage.java    From OpenAs2App with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void trackMsgState(Session session) {
    // Log a start sending fail state but do not allow exceptions to stop the process
    try {
        options.put("OPTIONAL_MODULE", "true");
        session.getProcessor().handle(TrackingModule.DO_TRACK_MSG, this, options);
    } catch (Exception et) {
        setLogMsg("Unable to persist message tracking state: " + org.openas2.logging.Log.getExceptionMsg(et));
        LogFactory.getLog(BaseMessage.class.getSimpleName()).error(this, et);
    }

}
 
Example #21
Source File: BeanUtil.java    From MaxKey with Apache License 2.0 5 votes vote down vote up
public static void displayValues(Object bean) {
	Field[] flds = bean.getClass().getDeclaredFields();
	LogFactory.getLog(BeanUtil.class).debug("displayValues() *******************************************");
	LogFactory.getLog(BeanUtil.class).debug("displayValues() "+bean.getClass().getName());
	for (int i = 0; i < flds.length; i++) {
		String name = flds[i].getName();
		if(isGetProperty(bean.getClass(),name)){
			LogFactory.getLog(BeanUtil.class).debug("displayValues() Field "+(i+1)+" : "+name+" = "+BeanUtil.get(bean, name));
		}
	}
	
	LogFactory.getLog(BeanUtils.class).debug("displayValues() *******************************************");
	
}
 
Example #22
Source File: DerbyEmbeddedDatabaseConfigurer.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void shutdown(DataSource dataSource, String databaseName) {
	try {
		new EmbeddedDriver().connect(
				String.format(URL_TEMPLATE, databaseName, "drop=true"), new Properties());
	}
	catch (SQLException ex) {
		// Error code that indicates successful shutdown
		if (!"08006".equals(ex.getSQLState())) {
			LogFactory.getLog(getClass()).warn("Could not shut down embedded Derby database", ex);
		}
	}
}
 
Example #23
Source File: DropAndLog.java    From elasticsearch-hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void init(Properties properties) {
    String loggerName = properties.getProperty(CONF_LOGGER_NAME);
    String loggerClassName = properties.getProperty(CONF_LOGGER_CLASS);
    Class loggerClass;
    if (loggerClassName != null) {
        try {
            loggerClass = Class.forName(loggerClassName);
        } catch (ClassNotFoundException cnfe) {
            // Could not find class name
            throw new EsHadoopIllegalArgumentException("Could not locate logger class [" + loggerClassName + "].", cnfe);
        }
    } else {
        loggerClass = null;
    }

    if (loggerName != null && loggerClass != null) {
        throw new EsHadoopIllegalArgumentException("Both logger name and logger class provided for drop and log handler. Provide only one. Bailing out...");
    }

    if (loggerName != null) {
        logger = LogFactory.getLog(loggerName);
    } else if (loggerClass != null) {
        logger = LogFactory.getLog(loggerClass);
    } else {
        throw new EsHadoopIllegalArgumentException("No logger name or logger class provided for drop and log handler. Provide one. Bailing out...");
    }

    String rawLoggerLevel = properties.getProperty(CONF_LOGGER_LEVEL, LogLevel.WARN.name());
    if (!LogLevel.names.contains(rawLoggerLevel)) {
        throw new EsHadoopIllegalArgumentException("Invalid logger level [" + rawLoggerLevel + "] given. Available logging levels: " + LogLevel.names.toString());
    }
    loggerLevel = LogLevel.valueOf(rawLoggerLevel);
}
 
Example #24
Source File: TestJarFinder.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testJar() throws Exception {

  //picking a class that is for sure in a JAR in the classpath
  String jar = JarFinder.getJar(LogFactory.class);
  Assert.assertTrue(new File(jar).exists());
}
 
Example #25
Source File: Orcas.java    From orcas with Apache License 2.0 5 votes vote down vote up
public void mainRun( Parameters pParameters )
{
  try
  {
    _parameters = pParameters;

    _log = LogFactory.getLog( getLogName() );

    run();
  }
  catch( Exception e )
  {
    if( pParameters.isAbortJvmOnExit() )
    {
      if( _log != null )
      {
        _log.error( e, e );
      }
      else
      {
        e.printStackTrace();
      }
      System.exit( -1 );
    }
    else
    {
      throw new RuntimeException( e );
    }
  }
}
 
Example #26
Source File: GenericTypeAwarePropertyDescriptor.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public Method getWriteMethodForActualAccess() {
	Assert.state(this.writeMethod != null, "No write method available");
	Set<Method> ambiguousCandidates = this.ambiguousWriteMethods;
	if (ambiguousCandidates != null) {
		this.ambiguousWriteMethods = null;
		LogFactory.getLog(GenericTypeAwarePropertyDescriptor.class).warn("Invalid JavaBean property '" +
				getName() + "' being accessed! Ambiguous write methods found next to actually used [" +
				this.writeMethod + "]: " + ambiguousCandidates);
	}
	return this.writeMethod;
}
 
Example #27
Source File: BatchConfiguration.java    From messaging with Apache License 2.0 5 votes vote down vote up
@Bean
Job job(JobBuilderFactory jobBuilderFactory,
 StepBuilderFactory stepBuilderFactory, JdbcTemplate template,
 ItemReader<Contact> fileReader,
 ItemProcessor<Contact, Contact> emailProcessor,
 ItemWriter<Contact> jdbcWriter) {

 Step setup = stepBuilderFactory.get("clean-contact-table")
  .tasklet((contribution, chunkContext) -> {
   template.update("delete from CONTACT");
   return RepeatStatus.FINISHED;
  }).build();

 Step fileToJdbc = stepBuilderFactory.get("file-to-jdbc-fileToJdbc")
  .<Contact, Contact>chunk(5)
  // <1>
  .reader(fileReader).processor(emailProcessor).writer(jdbcWriter)
  .faultTolerant().skip(InvalidEmailException.class)
  // <2>
  .skipPolicy((Throwable t, int skipCount) -> {
   LogFactory.getLog(getClass()).info("skipping ");
   return t.getClass().isAssignableFrom(InvalidEmailException.class);
  }).retry(HttpStatusCodeException.class) // <3>
  .retryLimit(2).build();

 return jobBuilderFactory.get("etl") // <4>
  .start(setup).next(fileToJdbc).build();
}
 
Example #28
Source File: TestFiPipelines.java    From big-c with Apache License 2.0 5 votes vote down vote up
private static void initLoggers() {
  ((Log4JLogger) NameNode.stateChangeLog).getLogger().setLevel(Level.ALL);
  ((Log4JLogger) LogFactory.getLog(FSNamesystem.class)).getLogger().setLevel(Level.ALL);
  ((Log4JLogger) DataNode.LOG).getLogger().setLevel(Level.ALL);
  ((Log4JLogger) TestFiPipelines.LOG).getLogger().setLevel(Level.ALL);
  ((Log4JLogger) DFSClient.LOG).getLogger().setLevel(Level.ALL);
  ((Log4JLogger) FiTestUtil.LOG).getLogger().setLevel(Level.ALL);
  ((Log4JLogger) BlockReceiverAspects.LOG).getLogger().setLevel(Level.ALL);
  ((Log4JLogger) DFSClientAspects.LOG).getLogger().setLevel(Level.ALL);
}
 
Example #29
Source File: InitDestroyAnnotationBeanPostProcessor.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
	// Rely on default serialization; just initialize state after deserialization.
	ois.defaultReadObject();

	// Initialize transient fields.
	this.logger = LogFactory.getLog(getClass());
}
 
Example #30
Source File: TestSaslDataTransfer.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testServerSaslNoClientSasl() throws Exception {
  HdfsConfiguration clusterConf = createSecureConfig(
    "authentication,integrity,privacy");
  // Set short retry timeouts so this test runs faster
  clusterConf.setInt(DFSConfigKeys.DFS_CLIENT_RETRY_WINDOW_BASE, 10);
  startCluster(clusterConf);
  HdfsConfiguration clientConf = new HdfsConfiguration(clusterConf);
  clientConf.set(DFS_DATA_TRANSFER_PROTECTION_KEY, "");

  LogCapturer logs = GenericTestUtils.LogCapturer.captureLogs(
      LogFactory.getLog(DataNode.class));
  try {
    doTest(clientConf);
    Assert.fail("Should fail if SASL data transfer protection is not " +
        "configured or not supported in client");
  } catch (IOException e) {
    GenericTestUtils.assertMatches(e.getMessage(), 
        "could only be replicated to 0 nodes");
  } finally {
    logs.stopCapturing();
  }

  GenericTestUtils.assertMatches(logs.getOutput(),
      "Failed to read expected SASL data transfer protection " +
      "handshake from client at");
}