com.proofpoint.log.Logger.error()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(11.1k)|赞(0)|评价(0)|浏览(123)

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

Logger.error介绍

[英]Logs a message at ERROR level.

Usage example:

logger.error("something really bad happened when connecting to %s:%d", host, port);

If the format string is invalid or the arguments are insufficient, an error will be logged and execution will continue.
[中]在错误级别记录消息。
用法示例:

logger.error("something really bad happened when connecting to %s:%d", host, port);

如果格式字符串无效或参数不足,将记录错误并继续执行。

代码示例

代码示例来源:origin: com.proofpoint.platform/log

/**
 * Logs a message at ERROR level.
 * <p>
 * Usage example:
 * <pre>
 *    logger.error("something really bad happened when connecting to %s:%d", host, port);
 * </pre>
 * If the format string is invalid or the arguments are insufficient, an error will be logged and execution
 * will continue.
 *
 * @param format a format string compatible with String.format()
 * @param args arguments for the format string
 */
public void error(String format, Object... args)
{
  error(null, format, args);
}

代码示例来源:origin: com.proofpoint.galaxy/galaxy-coordinator

private void expectedStateStoreDown(Exception e)
{
  if (storeUp.compareAndSet(true, false)) {
    log.error(e, "Expected state store is down");
  }
}

代码示例来源:origin: com.proofpoint.platform/concurrent

private void drainQueue()
  {
    // INVARIANT: queue has at least one task available when this method is called
    do {
      try {
        queue.poll().run();
      }
      catch (Throwable e) {
        log.error(e, "Task failed");
      }
    }
    while (queueSize.getAndDecrement() > maxThreads);
  }
}

代码示例来源:origin: com.proofpoint.platform/concurrent

@Override
public void execute(Runnable task)
{
  checkState(!failed.get(), "BoundedExecutor is in a failed state");
  queue.add(task);
  int size = queueSize.incrementAndGet();
  if (size <= maxThreads) {
    // If able to grab a permit (aka size <= maxThreads), then we are short exactly one draining thread
    try {
      coreExecutor.execute(this::drainQueue);
    }
    catch (Throwable e) {
      failed.set(true);
      log.error("BoundedExecutor state corrupted due to underlying executor failure");
      throw e;
    }
  }
}

代码示例来源:origin: com.proofpoint.galaxy/galaxy-coordinator

@Override
  public void run()
  {
    try {
      updateAllCoordinators();
    }
    catch (Throwable e) {
      log.error(e, "Unexpected exception updating coordinators");
    }
    try {
      updateAllAgents();
    }
    catch (Throwable e) {
      log.error(e, "Unexpected exception updating agents");
    }
  }
}, 0, (long) statusExpiration.toMillis(), TimeUnit.MILLISECONDS);

代码示例来源:origin: com.proofpoint.galaxy/galaxy-coordinator

@Override
  public void setExpectedState(ExpectedSlotStatus slotStatus)
  {
    Preconditions.checkNotNull(slotStatus, "slotStatus is null");
    try {
      Files.write(codec.toJson(slotStatus), new File(dataDir, slotStatus.getId().toString() + ".json"), Charsets.UTF_8);
    }
    catch (Exception e) {
      log.error(e, "Error writing expected slot status");
    }
  }
}

代码示例来源:origin: com.proofpoint.platform/bootstrap

private Bootstrap(Module applicationNameModule, Iterable<? extends Module> modules, boolean initializeLogging)
{
  if (initializeLogging) {
    logging = Logging.initialize();
    Thread.setDefaultUncaughtExceptionHandler((t, e) -> log.error(e, "Uncaught exception in thread %s", t.getName()));
  }
  else {
    logging = null;
  }
  this.modules = ImmutableList.<Module>builder()
      .add(requireNonNull(applicationNameModule, "applicationNameModule is null"))
      .add(new LifeCycleModule())
      .addAll(modules)
      .build();
}

代码示例来源:origin: com.proofpoint.platform/bootstrap

private void stopList(Queue<Object> instances, Class<? extends Annotation> annotation)
{
  List<Object> reversedInstances = Lists.newArrayList(instances);
  Collections.reverse(reversedInstances);
  for (Object obj : reversedInstances) {
    log.debug("Stopping %s", obj.getClass().getName());
    LifeCycleMethods methods = methodsMap.get(obj.getClass());
    for (Method preDestroy : methods.methodsFor(annotation)) {
      log.debug("\t%s()", preDestroy.getName());
      try {
        preDestroy.invoke(obj);
      }
      catch (Exception e) {
        log.error(e, "Stopping %s.%s() failed:", obj.getClass().getName(), preDestroy.getName());
      }
    }
  }
}

代码示例来源:origin: com.proofpoint.galaxy/galaxy-coordinator

private void createInstanceTagsWithRetry(List<String> instanceIds, List<Tag> tags)
{
  Exception lastException = null;
  for (int i = 0; i < 5; i++) {
    try {
      ec2Client.createTags(new CreateTagsRequest(instanceIds, tags));
      return;
    }
    catch (Exception e) {
      lastException = e;
    }
  }
  log.error(lastException, "failed to create tags for instances: %s", instanceIds);
}

代码示例来源:origin: com.proofpoint.galaxy/galaxy-agent

@Override
public SlotLifecycleState start(Deployment deployment)
{
  updateNodeConfig(deployment);
  Command command = createCommand("start", deployment, launcherTimeout);
  try {
    command.execute(executor);
    return RUNNING;
  }
  catch (CommandFailedException e) {
    log.error("ENVIRONMENT:\n    %s", Joiner.on("\n    ").withKeyValueSeparator("=").join(command.getEnvironment()));
    throw new RuntimeException("start failed: " + e.getMessage());
  }
}

代码示例来源:origin: com.proofpoint.platform/cassandra-experimental

@Override
public void stopRPCServer()
{
  synchronized (this) {
    if (isRunning) {
      log.info("Cassandra shutting down...");
      server.stopServer();
      try {
        server.join();
      }
      catch (InterruptedException e) {
        log.error(e, "Interrupted while waiting for thrift server to stop");
        Thread.currentThread().interrupt();
      }
      isRunning = false;
    }
  }
}

代码示例来源:origin: com.proofpoint.platform/rack

Logger.get(Main.class).error(e);
System.err.flush();
System.out.flush();

代码示例来源:origin: com.proofpoint.galaxy/galaxy-coordinator

@Override
public void setServiceInventory(List<ServiceDescriptor> serviceInventory)
{
  if (agentStatus.getState() == ONLINE) {
    Preconditions.checkNotNull(serviceInventory, "serviceInventory is null");
    URI internalUri = agentStatus.getInternalUri();
    try {
      Request request = RequestBuilder.preparePut()
          .setUri(uriBuilderFrom(internalUri).appendPath("/v1/serviceInventory").build())
          .setHeader(CONTENT_TYPE, APPLICATION_JSON)
          .setBodyGenerator(jsonBodyGenerator(serviceDescriptorsCodec, new ServiceDescriptorsRepresentation(environment, serviceInventory)))
          .build();
      httpClient.execute(request, createStatusResponseHandler());
      if (serviceInventoryUp.compareAndSet(false, true)) {
        log.info("Service inventory put succeeded for agent at %s", internalUri);
      }
    }
    catch (Exception e) {
      if (serviceInventoryUp.compareAndSet(true, false) && !log.isDebugEnabled()) {
        log.error("Unable to post service inventory to agent at %s: %s", internalUri, e.getMessage());
      }
      log.debug(e, "Unable to post service inventory to agent at %s: %s", internalUri, e.getMessage());
    }
  }
}

代码示例来源:origin: com.proofpoint.galaxy/galaxy-coordinator

@Override
public SlotStatus terminate()
{
  try {
    Request request = RequestBuilder.prepareDelete()
        .setUri(slotStatus.getSelf())
        .setHeader(GALAXY_AGENT_VERSION_HEADER, agent.status().getVersion())
        .setHeader(GALAXY_SLOT_VERSION_HEADER, slotStatus.getVersion())
        .build();
    SlotStatusRepresentation slotStatusRepresentation = httpClient.execute(request, createJsonResponseHandler(slotStatusCodec, Status.OK.getStatusCode()));
    updateStatus(slotStatusRepresentation.toSlotStatus(slotStatus.getInstanceId()));
    return slotStatus;
  }
  catch (Exception e) {
    log.error(e);
    return setErrorStatus(e.getMessage());
  }
}

代码示例来源:origin: com.proofpoint.galaxy/galaxy-coordinator

@Override
  public SlotStatus stop()
  {
    try {
      Request request = RequestBuilder.preparePut()
          .setUri(uriBuilderFrom(slotStatus.getSelf()).appendPath("lifecycle").build())
          .setHeader(GALAXY_AGENT_VERSION_HEADER, agent.status().getVersion())
          .setHeader(GALAXY_SLOT_VERSION_HEADER, slotStatus.getVersion())
          .setBodyGenerator(createStaticBodyGenerator("stopped", UTF_8))
          .build();
      SlotStatusRepresentation slotStatusRepresentation = httpClient.execute(request, createJsonResponseHandler(slotStatusCodec, Status.OK.getStatusCode()));

      updateStatus(slotStatusRepresentation.toSlotStatus(slotStatus.getInstanceId()));
      return slotStatus;
    }
    catch (Exception e) {
      log.error(e);
      return setErrorStatus(e.getMessage());
    }
  }
}

代码示例来源:origin: com.proofpoint.galaxy/galaxy-coordinator

@Override
public SlotStatus start()
{
  try {
    Request request = RequestBuilder.preparePut()
        .setUri(uriBuilderFrom(slotStatus.getSelf()).appendPath("lifecycle").build())
        .setHeader(GALAXY_AGENT_VERSION_HEADER, agent.status().getVersion())
        .setHeader(GALAXY_SLOT_VERSION_HEADER, slotStatus.getVersion())
        .setBodyGenerator(createStaticBodyGenerator("running", UTF_8))
        .build();
    SlotStatusRepresentation slotStatusRepresentation = httpClient.execute(request, createJsonResponseHandler(slotStatusCodec, Status.OK.getStatusCode()));
    updateStatus(slotStatusRepresentation.toSlotStatus(slotStatus.getInstanceId()));
    return slotStatus;
  }
  catch (Exception e) {
    log.error(e);
    return setErrorStatus(e.getMessage());
  }
}

代码示例来源:origin: com.proofpoint.galaxy/galaxy-coordinator

@Override
public SlotStatus restart()
{
  try {
    Request request = RequestBuilder.preparePut()
        .setUri(uriBuilderFrom(slotStatus.getSelf()).appendPath("lifecycle").build())
        .setHeader(GALAXY_AGENT_VERSION_HEADER, agent.status().getVersion())
        .setHeader(GALAXY_SLOT_VERSION_HEADER, slotStatus.getVersion())
        .setBodyGenerator(createStaticBodyGenerator("restarting", UTF_8))
        .build();
    SlotStatusRepresentation slotStatusRepresentation = httpClient.execute(request, createJsonResponseHandler(slotStatusCodec, Status.OK.getStatusCode()));
    updateStatus(slotStatusRepresentation.toSlotStatus(slotStatus.getInstanceId()));
    return slotStatus;
  }
  catch (Exception e) {
    log.error(e);
    return setErrorStatus(e.getMessage());
  }
}

代码示例来源:origin: com.proofpoint.galaxy/galaxy-coordinator

@Override
public SlotStatus assign(Installation installation)
{
  try {
    Request request = RequestBuilder.preparePut()
        .setUri(uriBuilderFrom(slotStatus.getSelf()).appendPath("assignment").build())
        .setHeader(CONTENT_TYPE, APPLICATION_JSON)
        .setHeader(GALAXY_AGENT_VERSION_HEADER, agent.status().getVersion())
        .setHeader(GALAXY_SLOT_VERSION_HEADER, slotStatus.getVersion())
        .setBodyGenerator(jsonBodyGenerator(installationCodec, InstallationRepresentation.from(installation)))
        .build();
    SlotStatusRepresentation slotStatusRepresentation = httpClient.execute(request, createJsonResponseHandler(slotStatusCodec, Status.OK.getStatusCode()));
    updateStatus(slotStatusRepresentation.toSlotStatus(slotStatus.getInstanceId()));
    return slotStatus;
  }
  catch (Exception e) {
    log.error(e);
    return setErrorStatus(e.getMessage());
  }
}

代码示例来源:origin: com.proofpoint.galaxy/galaxy-agent

public static void main(String[] args)
      throws Exception
  {
    try {
      Bootstrap app = new Bootstrap(
          new DiscoveryModule(),
          new NodeModule(),
          new HttpServerModule(),
          new HttpEventModule(),
          new JsonModule(),
          new JaxrsModule(),
          new MBeanModule(),
          new JmxModule(),
          new AgentMainModule());

      app.strictConfig().initialize();
    }
    catch (Exception e) {
      log.error(e, "Startup failed");
      System.exit(1);
    }
  }
}

代码示例来源:origin: com.proofpoint.galaxy/galaxy-coordinator

public static void main(String[] args)
      throws Exception
  {
    try {
      Bootstrap app = new Bootstrap(
          new NodeModule(),
          new HttpServerModule(),
          new HttpClientModule(Global.class),
          new HttpEventModule(),
          new DiscoveryModule(),
          new JsonModule(),
          new JaxrsModule(),
          new MBeanModule(),
          new JmxModule(),
          new CoordinatorMainModule(),
          installIfPropertyEquals(new LocalProvisionerModule(), "coordinator.provisioner", "local"),
          installIfPropertyEquals(new AwsProvisionerModule(), "coordinator.provisioner", "aws"));

      app.strictConfig().initialize();
    }
    catch (Throwable e) {
      log.error(e, "Startup failed");
      System.exit(1);
    }
  }
}

相关文章

微信公众号

最新文章

更多