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

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

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

Logger介绍

暂无

代码示例

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

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

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

public PagesHashStrategy createPagesHashStrategy(List<Integer> joinChannels, OptionalInt hashChannel, Optional<List<Integer>> outputChannels)
{
  try {
    return joinCompiler.compilePagesHashStrategyFactory(types, joinChannels, outputChannels)
        .createPagesHashStrategy(ImmutableList.copyOf(channels), hashChannel);
  }
  catch (Exception e) {
    log.error(e, "Lookup source compile failed for types=%s error=%s", types, e);
  }
  // if compilation fails, use interpreter
  return new SimplePagesHashStrategy(
      types,
      outputChannels.orElse(rangeList(types.size())),
      ImmutableList.copyOf(channels),
      joinChannels,
      hashChannel,
      Optional.empty(),
      functionRegistry,
      groupByUsesEqualTo);
}

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

private void doAbort()
{
  Optional<Exception> rollbackException = Optional.empty();
  for (HiveWriter writer : writers) {
    // writers can contain nulls if an exception is thrown when doAppend expends the writer list
    if (writer != null) {
      try {
        writer.rollback();
      }
      catch (Exception e) {
        log.warn("exception '%s' while rollback on %s", e, writer);
        rollbackException = Optional.of(e);
      }
    }
  }
  if (rollbackException.isPresent()) {
    throw new PrestoException(HIVE_WRITER_CLOSE_ERROR, "Error rolling back write to Hive", rollbackException.get());
  }
}

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

public static void main(String[] args)
  {
    Logger log = Logger.get(ThriftTpchServer.class);
    try {
      start(ImmutableList.of());
      log.info("======== SERVER STARTED ========");
    }
    catch (Throwable t) {
      log.error(t);
      System.exit(1);
    }
  }
}

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

private void loadPlugin(URLClassLoader pluginClassLoader)
{
  ServiceLoader<Plugin> serviceLoader = ServiceLoader.load(Plugin.class, pluginClassLoader);
  List<Plugin> plugins = ImmutableList.copyOf(serviceLoader);
  if (plugins.isEmpty()) {
    log.warn("No service providers of type %s", Plugin.class.getName());
  }
  for (Plugin plugin : plugins) {
    log.info("Installing %s", plugin.getClass().getName());
    installPlugin(plugin);
  }
}

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

@AfterTestWithContext
public void cleanup()
{
  try {
    aliceExecutor.executeQuery(format("DROP TABLE IF EXISTS %s", tableName));
    aliceExecutor.executeQuery(format("DROP VIEW IF EXISTS %s", viewName));
  }
  catch (Exception e) {
    Logger.get(getClass()).warn(e, "failed to drop table/view");
  }
}

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

private synchronized void callOomKiller(Iterable<QueryExecution> runningQueries)
{
  List<QueryMemoryInfo> queryMemoryInfoList = Streams.stream(runningQueries)
      .map(this::createQueryMemoryInfo)
      .collect(toImmutableList());
  List<MemoryInfo> nodeMemoryInfos = nodes.values().stream()
      .map(RemoteNodeMemory::getInfo)
      .filter(Optional::isPresent)
      .map(Optional::get)
      .collect(toImmutableList());
  Optional<QueryId> chosenQueryId = lowMemoryKiller.chooseQueryToKill(queryMemoryInfoList, nodeMemoryInfos);
  if (chosenQueryId.isPresent()) {
    log.debug("Low memory killer chose %s", chosenQueryId.get());
    Optional<QueryExecution> chosenQuery = Streams.stream(runningQueries).filter(query -> chosenQueryId.get().equals(query.getQueryId())).collect(toOptional());
    if (chosenQuery.isPresent()) {
      // See comments in  isLastKilledQueryGone for why chosenQuery might be absent.
      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."));
      queriesKilledDueToOutOfMemory.incrementAndGet();
      lastKilledQuery = chosenQueryId.get();
      logQueryKill(chosenQueryId.get(), nodeMemoryInfos);
    }
  }
}

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

public StageStateMachine(
    StageId stageId,
    URI location,
    Session session,
    PlanFragment fragment,
    ExecutorService executor,
    SplitSchedulerStats schedulerStats)
{
  this.stageId = requireNonNull(stageId, "stageId is null");
  this.location = requireNonNull(location, "location is null");
  this.session = requireNonNull(session, "session is null");
  this.fragment = requireNonNull(fragment, "fragment is null");
  this.scheduledStats = requireNonNull(schedulerStats, "schedulerStats is null");
  stageState = new StateMachine<>("stage " + stageId, executor, PLANNED, TERMINAL_STAGE_STATES);
  stageState.addStateChangeListener(state -> log.debug("Stage %s is %s", stageId, state));
  finalStageInfo = new StateMachine<>("final stage " + stageId, executor, Optional.empty());
}

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

@Override
public void cancelStage(StageId stageId)
{
  requireNonNull(stageId, "stageId is null");
  log.debug("Cancel stage %s", stageId);
  queryTracker.tryGetQuery(stageId.getQueryId())
      .ifPresent(query -> query.cancelStage(stageId));
}

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

public static class DefaultFactory
    implements Factory
{
  private final OrderingCompiler orderingCompiler;
  private final JoinCompiler joinCompiler;
  private final boolean eagerCompact;
  private final FunctionRegistry functionRegistry;
  private final boolean groupByUsesEqualTo;
  @Inject
  public DefaultFactory(OrderingCompiler orderingCompiler, JoinCompiler joinCompiler, FeaturesConfig featuresConfig, Metadata metadata)
  {
    this.orderingCompiler = requireNonNull(orderingCompiler, "orderingCompiler is null");
    this.joinCompiler = requireNonNull(joinCompiler, "joinCompiler is null");
    this.eagerCompact = requireNonNull(featuresConfig, "featuresConfig is null").isPagesIndexEagerCompactionEnabled();
    this.functionRegistry = requireNonNull(metadata, "metadata is null").getFunctionRegistry();
    this.groupByUsesEqualTo = featuresConfig.isGroupByUsesEqualTo();
  }
  @Override
  public PagesIndex newPagesIndex(List<Type> types, int expectedPositions)
  {
    return new PagesIndex(orderingCompiler, joinCompiler, functionRegistry, groupByUsesEqualTo, types, expectedPositions, eagerCompact);
  }
}

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

@Inject
RedisMetadata(
    RedisConnectorId connectorId,
    RedisConnectorConfig redisConnectorConfig,
    Supplier<Map<SchemaTableName, RedisTableDescription>> redisTableDescriptionSupplier)
{
  this.connectorId = requireNonNull(connectorId, "connectorId is null").toString();
  requireNonNull(redisConnectorConfig, "redisConfig is null");
  hideInternalColumns = redisConnectorConfig.isHideInternalColumns();
  log.debug("Loading redis table definitions from %s", redisConnectorConfig.getTableDescriptionDir().getAbsolutePath());
  this.redisTableDescriptionSupplier = Suppliers.memoize(redisTableDescriptionSupplier::get)::get;
}

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

private static List<File> listFiles(File dir)
{
  if ((dir != null) && dir.isDirectory()) {
    File[] files = dir.listFiles();
    if (files != null) {
      log.debug("Considering files: %s", asList(files));
      return ImmutableList.copyOf(files);
    }
  }
  return ImmutableList.of();
}

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

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

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

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

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

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

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

public boolean transitionToFailed(Throwable throwable)
{
  requireNonNull(throwable, "throwable is null");
  failureCause.compareAndSet(null, Failures.toFailure(throwable));
  boolean failed = stageState.setIf(FAILED, currentState -> !currentState.isDone());
  if (failed) {
    log.error(throwable, "Stage %s failed", stageId);
  }
  else {
    log.debug(throwable, "Failure after stage %s finished", stageId);
  }
  return failed;
}

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

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

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

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

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

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

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

@Test
public void testIsDebugEnabled()
{
  inner.setLevel(Level.FINE);
  assertTrue(logger.isDebugEnabled());
  inner.setLevel(Level.INFO);
  assertFalse(logger.isDebugEnabled());
  inner.setLevel(Level.WARNING);
  assertFalse(logger.isDebugEnabled());
  inner.setLevel(Level.SEVERE);
  assertFalse(logger.isDebugEnabled());
}

相关文章