io.airlift.log.Logger类的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(11.3k)|赞(0)|评价(0)|浏览(246)

本文整理了Java中io.airlift.log.Logger类的一些代码示例,展示了Logger类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger类的具体详情如下:
包路径:io.airlift.log.Logger
类名称:Logger

Logger介绍

暂无

代码示例

代码示例来源:origin: prestodb/presto

  1. @VisibleForTesting
  2. protected void setConfiguredEventListener(String name, Map<String, String> properties)
  3. {
  4. requireNonNull(name, "name is null");
  5. requireNonNull(properties, "properties is null");
  6. log.info("-- Loading event listener --");
  7. EventListenerFactory eventListenerFactory = eventListenerFactories.get(name);
  8. checkState(eventListenerFactory != null, "Event listener %s is not registered", name);
  9. EventListener eventListener = eventListenerFactory.create(ImmutableMap.copyOf(properties));
  10. this.configuredEventListener.set(Optional.of(eventListener));
  11. log.info("-- Loaded event listener %s --", name);
  12. }

代码示例来源:origin: prestodb/presto

  1. public PagesHashStrategy createPagesHashStrategy(List<Integer> joinChannels, OptionalInt hashChannel, Optional<List<Integer>> outputChannels)
  2. {
  3. try {
  4. return joinCompiler.compilePagesHashStrategyFactory(types, joinChannels, outputChannels)
  5. .createPagesHashStrategy(ImmutableList.copyOf(channels), hashChannel);
  6. }
  7. catch (Exception e) {
  8. log.error(e, "Lookup source compile failed for types=%s error=%s", types, e);
  9. }
  10. // if compilation fails, use interpreter
  11. return new SimplePagesHashStrategy(
  12. types,
  13. outputChannels.orElse(rangeList(types.size())),
  14. ImmutableList.copyOf(channels),
  15. joinChannels,
  16. hashChannel,
  17. Optional.empty(),
  18. functionRegistry,
  19. groupByUsesEqualTo);
  20. }

代码示例来源:origin: prestodb/presto

  1. private void doAbort()
  2. {
  3. Optional<Exception> rollbackException = Optional.empty();
  4. for (HiveWriter writer : writers) {
  5. // writers can contain nulls if an exception is thrown when doAppend expends the writer list
  6. if (writer != null) {
  7. try {
  8. writer.rollback();
  9. }
  10. catch (Exception e) {
  11. log.warn("exception '%s' while rollback on %s", e, writer);
  12. rollbackException = Optional.of(e);
  13. }
  14. }
  15. }
  16. if (rollbackException.isPresent()) {
  17. throw new PrestoException(HIVE_WRITER_CLOSE_ERROR, "Error rolling back write to Hive", rollbackException.get());
  18. }
  19. }

代码示例来源:origin: prestodb/presto

  1. public static void main(String[] args)
  2. {
  3. Logger log = Logger.get(ThriftTpchServer.class);
  4. try {
  5. start(ImmutableList.of());
  6. log.info("======== SERVER STARTED ========");
  7. }
  8. catch (Throwable t) {
  9. log.error(t);
  10. System.exit(1);
  11. }
  12. }
  13. }

代码示例来源:origin: prestodb/presto

  1. private void loadPlugin(URLClassLoader pluginClassLoader)
  2. {
  3. ServiceLoader<Plugin> serviceLoader = ServiceLoader.load(Plugin.class, pluginClassLoader);
  4. List<Plugin> plugins = ImmutableList.copyOf(serviceLoader);
  5. if (plugins.isEmpty()) {
  6. log.warn("No service providers of type %s", Plugin.class.getName());
  7. }
  8. for (Plugin plugin : plugins) {
  9. log.info("Installing %s", plugin.getClass().getName());
  10. installPlugin(plugin);
  11. }
  12. }

代码示例来源:origin: prestodb/presto

  1. @AfterTestWithContext
  2. public void cleanup()
  3. {
  4. try {
  5. aliceExecutor.executeQuery(format("DROP TABLE IF EXISTS %s", tableName));
  6. aliceExecutor.executeQuery(format("DROP VIEW IF EXISTS %s", viewName));
  7. }
  8. catch (Exception e) {
  9. Logger.get(getClass()).warn(e, "failed to drop table/view");
  10. }
  11. }

代码示例来源:origin: prestodb/presto

  1. private synchronized void callOomKiller(Iterable<QueryExecution> runningQueries)
  2. {
  3. List<QueryMemoryInfo> queryMemoryInfoList = Streams.stream(runningQueries)
  4. .map(this::createQueryMemoryInfo)
  5. .collect(toImmutableList());
  6. List<MemoryInfo> nodeMemoryInfos = nodes.values().stream()
  7. .map(RemoteNodeMemory::getInfo)
  8. .filter(Optional::isPresent)
  9. .map(Optional::get)
  10. .collect(toImmutableList());
  11. Optional<QueryId> chosenQueryId = lowMemoryKiller.chooseQueryToKill(queryMemoryInfoList, nodeMemoryInfos);
  12. if (chosenQueryId.isPresent()) {
  13. log.debug("Low memory killer chose %s", chosenQueryId.get());
  14. Optional<QueryExecution> chosenQuery = Streams.stream(runningQueries).filter(query -> chosenQueryId.get().equals(query.getQueryId())).collect(toOptional());
  15. if (chosenQuery.isPresent()) {
  16. // See comments in isLastKilledQueryGone for why chosenQuery might be absent.
  17. chosenQuery.get().fail(new PrestoException(CLUSTER_OUT_OF_MEMORY, "Query killed because the cluster is out of memory. Please try again in a few minutes."));
  18. queriesKilledDueToOutOfMemory.incrementAndGet();
  19. lastKilledQuery = chosenQueryId.get();
  20. logQueryKill(chosenQueryId.get(), nodeMemoryInfos);
  21. }
  22. }
  23. }

代码示例来源:origin: prestodb/presto

  1. public StageStateMachine(
  2. StageId stageId,
  3. URI location,
  4. Session session,
  5. PlanFragment fragment,
  6. ExecutorService executor,
  7. SplitSchedulerStats schedulerStats)
  8. {
  9. this.stageId = requireNonNull(stageId, "stageId is null");
  10. this.location = requireNonNull(location, "location is null");
  11. this.session = requireNonNull(session, "session is null");
  12. this.fragment = requireNonNull(fragment, "fragment is null");
  13. this.scheduledStats = requireNonNull(schedulerStats, "schedulerStats is null");
  14. stageState = new StateMachine<>("stage " + stageId, executor, PLANNED, TERMINAL_STAGE_STATES);
  15. stageState.addStateChangeListener(state -> log.debug("Stage %s is %s", stageId, state));
  16. finalStageInfo = new StateMachine<>("final stage " + stageId, executor, Optional.empty());
  17. }

代码示例来源:origin: prestodb/presto

  1. @Override
  2. public void cancelStage(StageId stageId)
  3. {
  4. requireNonNull(stageId, "stageId is null");
  5. log.debug("Cancel stage %s", stageId);
  6. queryTracker.tryGetQuery(stageId.getQueryId())
  7. .ifPresent(query -> query.cancelStage(stageId));
  8. }

代码示例来源:origin: prestodb/presto

  1. public static class DefaultFactory
  2. implements Factory
  3. {
  4. private final OrderingCompiler orderingCompiler;
  5. private final JoinCompiler joinCompiler;
  6. private final boolean eagerCompact;
  7. private final FunctionRegistry functionRegistry;
  8. private final boolean groupByUsesEqualTo;
  9. @Inject
  10. public DefaultFactory(OrderingCompiler orderingCompiler, JoinCompiler joinCompiler, FeaturesConfig featuresConfig, Metadata metadata)
  11. {
  12. this.orderingCompiler = requireNonNull(orderingCompiler, "orderingCompiler is null");
  13. this.joinCompiler = requireNonNull(joinCompiler, "joinCompiler is null");
  14. this.eagerCompact = requireNonNull(featuresConfig, "featuresConfig is null").isPagesIndexEagerCompactionEnabled();
  15. this.functionRegistry = requireNonNull(metadata, "metadata is null").getFunctionRegistry();
  16. this.groupByUsesEqualTo = featuresConfig.isGroupByUsesEqualTo();
  17. }
  18. @Override
  19. public PagesIndex newPagesIndex(List<Type> types, int expectedPositions)
  20. {
  21. return new PagesIndex(orderingCompiler, joinCompiler, functionRegistry, groupByUsesEqualTo, types, expectedPositions, eagerCompact);
  22. }
  23. }

代码示例来源:origin: prestodb/presto

  1. @Inject
  2. RedisMetadata(
  3. RedisConnectorId connectorId,
  4. RedisConnectorConfig redisConnectorConfig,
  5. Supplier<Map<SchemaTableName, RedisTableDescription>> redisTableDescriptionSupplier)
  6. {
  7. this.connectorId = requireNonNull(connectorId, "connectorId is null").toString();
  8. requireNonNull(redisConnectorConfig, "redisConfig is null");
  9. hideInternalColumns = redisConnectorConfig.isHideInternalColumns();
  10. log.debug("Loading redis table definitions from %s", redisConnectorConfig.getTableDescriptionDir().getAbsolutePath());
  11. this.redisTableDescriptionSupplier = Suppliers.memoize(redisTableDescriptionSupplier::get)::get;
  12. }

代码示例来源:origin: prestodb/presto

  1. private static List<File> listFiles(File dir)
  2. {
  3. if ((dir != null) && dir.isDirectory()) {
  4. File[] files = dir.listFiles();
  5. if (files != null) {
  6. log.debug("Considering files: %s", asList(files));
  7. return ImmutableList.copyOf(files);
  8. }
  9. }
  10. return ImmutableList.of();
  11. }

代码示例来源:origin: airlift/airlift

  1. @Test
  2. public void testInsufficientArgsLogsErrorForInfo()
  3. {
  4. String format = "some message: %s, %d";
  5. String param = "blah";
  6. logger.info(format, param);
  7. assertLogLike(Level.SEVERE, ImmutableList.of("Invalid format", "INFO", format, param), IllegalArgumentException.class);
  8. assertLog(Level.INFO, String.format("'%s' [%s]", format, param));
  9. }

代码示例来源:origin: io.airlift/log

  1. @Test
  2. public void testInsufficientArgsLogsOriginalExceptionForError()
  3. {
  4. Throwable exception = new Throwable("foo");
  5. String format = "some message: %s, %d";
  6. String param = "blah";
  7. logger.error(exception, format, param);
  8. assertLogLike(Level.SEVERE, ImmutableList.of("Invalid format", "ERROR", format, param), IllegalArgumentException.class);
  9. assertLog(Level.SEVERE, String.format("'%s' [%s]", format, param), exception);
  10. }

代码示例来源:origin: prestodb/presto

  1. @VisibleForTesting
  2. protected void setSystemAccessControl(String name, Map<String, String> properties)
  3. {
  4. requireNonNull(name, "name is null");
  5. requireNonNull(properties, "properties is null");
  6. checkState(systemAccessControlLoading.compareAndSet(false, true), "System access control already initialized");
  7. log.info("-- Loading system access control --");
  8. SystemAccessControlFactory systemAccessControlFactory = systemAccessControlFactories.get(name);
  9. checkState(systemAccessControlFactory != null, "Access control %s is not registered", name);
  10. SystemAccessControl systemAccessControl = systemAccessControlFactory.create(ImmutableMap.copyOf(properties));
  11. this.systemAccessControl.set(systemAccessControl);
  12. log.info("-- Loaded system access control %s --", name);
  13. }

代码示例来源:origin: prestodb/presto

  1. public boolean transitionToFailed(Throwable throwable)
  2. {
  3. requireNonNull(throwable, "throwable is null");
  4. failureCause.compareAndSet(null, Failures.toFailure(throwable));
  5. boolean failed = stageState.setIf(FAILED, currentState -> !currentState.isDone());
  6. if (failed) {
  7. log.error(throwable, "Stage %s failed", stageId);
  8. }
  9. else {
  10. log.debug(throwable, "Failure after stage %s finished", stageId);
  11. }
  12. return failed;
  13. }

代码示例来源:origin: prestodb/presto

  1. @Inject
  2. public ColumnCardinalityCache(Connector connector, AccumuloConfig config)
  3. {
  4. this.connector = requireNonNull(connector, "connector is null");
  5. int size = requireNonNull(config, "config is null").getCardinalityCacheSize();
  6. Duration expireDuration = config.getCardinalityCacheExpiration();
  7. // Create a bounded executor with a pool size at 4x number of processors
  8. this.coreExecutor = newCachedThreadPool(daemonThreadsNamed("cardinality-lookup-%s"));
  9. this.executorService = new BoundedExecutor(coreExecutor, 4 * Runtime.getRuntime().availableProcessors());
  10. LOG.debug("Created new cache size %d expiry %s", size, expireDuration);
  11. cache = CacheBuilder.newBuilder()
  12. .maximumSize(size)
  13. .expireAfterWrite(expireDuration.toMillis(), MILLISECONDS)
  14. .build(new CardinalityCacheLoader());
  15. }

代码示例来源:origin: airlift/airlift

  1. @Test
  2. public void testInsufficientArgsLogsOriginalExceptionForWarn()
  3. {
  4. Throwable exception = new Throwable("foo");
  5. String format = "some message: %s, %d";
  6. String param = "blah";
  7. logger.warn(exception, format, param);
  8. assertLogLike(Level.SEVERE, ImmutableList.of("Invalid format", "WARN", format, param), IllegalArgumentException.class);
  9. assertLog(Level.WARNING, String.format("'%s' [%s]", format, param), exception);
  10. }

代码示例来源:origin: airlift/airlift

  1. @Test
  2. public void testInsufficientArgsLogsErrorForDebug()
  3. {
  4. String format = "some message: %s, %d";
  5. String param = "blah";
  6. logger.debug(format, param);
  7. assertLogLike(Level.SEVERE, ImmutableList.of("Invalid format", "DEBUG", format, param), IllegalArgumentException.class);
  8. assertLog(Level.FINE, String.format("'%s' [%s]", format, param));
  9. }

代码示例来源:origin: io.airlift/log

  1. @Test
  2. public void testIsDebugEnabled()
  3. {
  4. inner.setLevel(Level.FINE);
  5. assertTrue(logger.isDebugEnabled());
  6. inner.setLevel(Level.INFO);
  7. assertFalse(logger.isDebugEnabled());
  8. inner.setLevel(Level.WARNING);
  9. assertFalse(logger.isDebugEnabled());
  10. inner.setLevel(Level.SEVERE);
  11. assertFalse(logger.isDebugEnabled());
  12. }

相关文章