io.vertx.core.logging.Logger.warn()方法的使用及代码示例

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

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

Logger.warn介绍

暂无

代码示例

代码示例来源:origin: eclipse-vertx/vert.x

@Override
 public void run() {
  logger.warn("hello");
 }
});

代码示例来源:origin: eclipse-vertx/vert.x

private void reportBytesWritten(Object msg) {
 if (metrics != null) {
  long bytes = getBytes(msg);
  if (bytes == -1) {
   log.warn("Metrics could not be updated to include bytes written because of unknown object " + msg.getClass() + " being written.");
  } else {
   bytesWritten += bytes;
  }
 }
}

代码示例来源:origin: eclipse-vertx/vert.x

private void setClusterViewChangedHandler(HAManager haManager) {
 haManager.setClusterViewChangedHandler(members -> {
  ownSubs.forEach(address -> {
   subs.add(address, nodeInfo, addResult -> {
    if (addResult.failed()) {
     log.warn("Failed to update subs map with self", addResult.cause());
    }
   });
  });
  subs.removeAllMatching((Serializable & Predicate<ClusterNodeInfo>) ci -> !members.contains(ci.nodeId), removeResult -> {
   if (removeResult.failed()) {
    log.warn("Error removing subs", removeResult.cause());
   }
  });
 });
}

代码示例来源:origin: eclipse-vertx/vert.x

synchronized void connect() {
 if (connected) {
  throw new IllegalStateException("Already connected");
 }
 client.connect(serverID.port, serverID.host, res -> {
  if (res.succeeded()) {
   connected(res.result());
  } else {
   log.warn("Connecting to server " + serverID + " failed", res.cause());
   close();
  }
 });
}

代码示例来源:origin: eclipse-vertx/vert.x

@Override
public void handle(Message<T> message) {
 Handler<Message<T>> theHandler;
 ContextInternal ctx;
 synchronized (this) {
  if (demand == 0L) {
   if (pending.size() < maxBufferedMessages) {
    pending.add(message);
   } else {
    if (discardHandler != null) {
     discardHandler.handle(message);
    } else {
     log.warn("Discarding message as more than " + maxBufferedMessages + " buffered in paused consumer. address: " + address);
    }
   }
   return;
  } else {
   if (pending.size() > 0) {
    pending.add(message);
    message = pending.poll();
   }
   if (demand != Long.MAX_VALUE) {
    demand--;
   }
   theHandler = handler;
  }
  ctx = handlerContext;
 }
 deliver(theHandler, message, ctx);
}

代码示例来源:origin: eclipse-vertx/vert.x

Method setter = getSetter(fieldName, options.getClass());
if (setter == null) {
 log.warn("No such property to configure on options: " + options.getClass().getName() + "." + fieldName);
 continue;
  arg = Enum.valueOf((Class<? extends Enum>)argType, propVal);
 } else {
  log.warn("Invalid type for setter: " + argType);
  continue;
 log.warn("Invalid argtype:" + argType + " on options: " + options.getClass().getName() + "." + fieldName);
 continue;

代码示例来源:origin: eclipse-vertx/vert.x

LOGGER.warn("A change in " + file.getAbsolutePath() + " has been detected, but the file does not belong to a " +
  "watched roots: " + roots);
return false;

代码示例来源:origin: eclipse-vertx/vert.x

protected ContextImpl(VertxInternal vertx, EventLoop eventLoop, WorkerPool internalBlockingPool, WorkerPool workerPool, String deploymentID, JsonObject config,
           ClassLoader tccl) {
 if (DISABLE_TCCL && tccl != ClassLoader.getSystemClassLoader()) {
  log.warn("You have disabled TCCL checks but you have a custom TCCL to set.");
 }
 this.deploymentID = deploymentID;
 this.config = config;
 this.eventLoop = eventLoop;
 this.tccl = tccl;
 this.owner = vertx;
 this.workerPool = workerPool;
 this.internalBlockingPool = internalBlockingPool;
 this.orderedTasks = new TaskQueue();
 this.internalOrderedTasks = new TaskQueue();
 this.closeHooks = new CloseHooks(log);
}

代码示例来源:origin: eclipse-vertx/vert.x

protocols.retainAll(Arrays.asList(engine.getSupportedProtocols()));
if (protocols.isEmpty()) {
 log.warn("no SSL/TLS protocols are enabled due to configuration restrictions");

代码示例来源:origin: eclipse-vertx/vert.x

private synchronized void checkQuorumWhenAdded(final String nodeID, final long start) {
 if (clusterMap.containsKey(nodeID)) {
  checkQuorum();
  if (attainedQuorum) {
   checkSubs(nodeID);
  }
 } else {
  vertx.setTimer(200, tid -> {
   // This can block on a monitor so it needs to run as a worker
   vertx.executeBlockingInternal(fut -> {
    if (System.currentTimeMillis() - start > 10000) {
     log.warn("Timed out waiting for group information to appear");
    } else if (!stopped) {
     ContextInternal context = vertx.getContext();
     try {
      // Remove any context we have here (from the timer) otherwise will screw things up when verticles are deployed
      ContextImpl.setContext(null);
      checkQuorumWhenAdded(nodeID, start);
     } finally {
      ContextImpl.setContext((ContextImpl) context);
     }
    }
    fut.complete();
   }, null);
  });
 }
}

代码示例来源:origin: eclipse-vertx/vert.x

private VertxMetrics initialiseMetrics(VertxOptions options) {
 if (options.getMetricsOptions() != null && options.getMetricsOptions().isEnabled()) {
  VertxMetricsFactory factory = options.getMetricsOptions().getFactory();
  if (factory == null) {
   factory = ServiceHelper.loadFactoryOrNull(VertxMetricsFactory.class);
   if (factory == null) {
    log.warn("Metrics has been set to enabled but no VertxMetricsFactory found on classpath");
   }
  }
  if (factory != null) {
   VertxMetrics metrics = factory.metrics(options);
   Objects.requireNonNull(metrics, "The metric instance created from " + factory + " cannot be null");
   return metrics;
  }
 }
 return null;
}

代码示例来源:origin: eclipse-vertx/vert.x

private void testWarning(Logger logger) {
 String result = record(() -> logger.warn("hello"));
 assertContains("[main] WARN my-slf4j-logger - hello", result);
 result = record(() -> logger.warn("exception", new NullPointerException()));
 assertTrue(result.contains("[main] WARN my-slf4j-logger - exception"));
 assertTrue(result.contains("java.lang.NullPointerException"));
 result = record(() -> logger.warn("hello {} and {}", "Paulo", "Julien"));
 assertContains("[main] WARN my-slf4j-logger - hello Paulo and Julien", result);
 result = record(() -> logger.warn("hello {}", "vert.x"));
 assertContains("[main] WARN my-slf4j-logger - hello vert.x", result);
 result = record(() -> logger.warn("hello {} - {}", "vert.x"));
 assertContains("[main] WARN my-slf4j-logger - hello vert.x - {}", result);
 result = record(() -> logger.warn("hello {}", "vert.x", "foo"));
 assertContains("[main] WARN my-slf4j-logger - hello vert.x", result);
 result = record(() -> logger.warn("{}, an exception has been thrown", new IllegalStateException(), "Luke"));
 assertTrue(result.contains("[main] WARN my-slf4j-logger - Luke, an exception has been thrown"));
 assertTrue(result.contains("java.lang.IllegalStateException"));
 result = record(() -> logger.warn("{}, an exception has been thrown", "Luke", new IllegalStateException()));
 assertTrue(result.contains("[main] WARN my-slf4j-logger - Luke, an exception has been thrown"));
 assertTrue(result.contains("java.lang.IllegalStateException"));
}

代码示例来源:origin: eclipse-vertx/vert.x

Logger logger = LoggerFactory.getLogger("my-log4j2-logger");
String result = recording.execute(() -> {
 logger.warn("hello");
});
assertTrue(result.contains("hello"));
result = recording.execute(() -> {
 logger.warn("exception", new NullPointerException());
});
assertTrue(result.contains("exception"));
 logger.warn("hello {} and {}", "Paulo", "Julien");
});
assertTrue(result.contains("hello Paulo and Julien"));
 logger.warn("hello {}", "vert.x");
});
assertTrue(result.contains("hello vert.x"));
 logger.warn("hello {} - {}", "vert.x");
});
assertTrue(result.contains("hello vert.x - {}"));
 logger.warn("hello {} {}", "vert.x", "foo");
});
String expected = "hello vert.x foo";
 logger.warn("{}, an exception has been thrown", new IllegalStateException(), "Luke");
});
assertTrue(result.contains("Luke, an exception has been thrown"));

代码示例来源:origin: eclipse-vertx/vert.x

private void schedulePing() {
 EventBusOptions options = eventBus.options();
 pingTimeoutID = vertx.setTimer(options.getClusterPingInterval(), id1 -> {
  // If we don't get a pong back in time we close the connection
  timeoutID = vertx.setTimer(options.getClusterPingReplyInterval(), id2 -> {
   // Didn't get pong in time - consider connection dead
   log.warn("No pong from server " + serverID + " - will consider it dead");
   close();
  });
  ClusteredMessage pingMessage =
   new ClusteredMessage<>(serverID, PING_ADDRESS, null, null, null, new PingMessageCodec(), true, eventBus);
  Buffer data = pingMessage.encodeToWire();
  socket.write(data);
 });
}

代码示例来源:origin: eclipse-vertx/vert.x

/**
 * test socks4a proxy for accessing arbitrary server port using an already resolved address.
 */
@Test
public void testWithSocks4LocalResolver() throws Exception {
 NetClientOptions clientOptions = new NetClientOptions()
   .setProxyOptions(new ProxyOptions().setType(ProxyType.SOCKS4).setPort(11080));
 NetClient client = vertx.createNetClient(clientOptions);
 server.connectHandler(sock -> {
 });
 proxy = new Socks4Proxy(null).start(vertx);
 server.listen(1234, "localhost", ar -> {
  assertTrue(ar.succeeded());
  client.connect(1234, "127.0.0.1", ar2 -> {
   if (ar2.failed()) {
    log.warn("failed", ar2.cause());
   }
   assertTrue(ar2.succeeded());
   // make sure we have gone through the proxy
   assertEquals("127.0.0.1:1234", proxy.getLastUri());
   testComplete();
  });
 });
 await();
}

代码示例来源:origin: eclipse-vertx/vert.x

/**
 * test socks5 proxy for accessing arbitrary server port.
 */
@Test
public void testWithSocks5Proxy() throws Exception {
 NetClientOptions clientOptions = new NetClientOptions()
   .setProxyOptions(new ProxyOptions().setType(ProxyType.SOCKS5).setPort(11080));
 NetClient client = vertx.createNetClient(clientOptions);
 server.connectHandler(sock -> {
 });
 proxy = new SocksProxy(null);
 proxy.start(vertx);
 server.listen(1234, "localhost", ar -> {
  assertTrue(ar.succeeded());
  client.connect(1234, "localhost", ar2 -> {
   if (ar2.failed()) {
    log.warn("failed", ar2.cause());
   }
   assertTrue(ar2.succeeded());
   // make sure we have gone through the proxy
   assertEquals("localhost:1234", proxy.getLastUri());
   testComplete();
  });
 });
 await();
}

代码示例来源:origin: eclipse-vertx/vert.x

/**
 * test socks4a proxy for accessing arbitrary server port.
 */
@Test
public void testWithSocks4aProxy() throws Exception {
 NetClientOptions clientOptions = new NetClientOptions()
   .setProxyOptions(new ProxyOptions().setType(ProxyType.SOCKS4).setPort(11080));
 NetClient client = vertx.createNetClient(clientOptions);
 server.connectHandler(sock -> {
 });
 proxy = new Socks4Proxy(null);
 proxy.start(vertx);
 server.listen(1234, "localhost", ar -> {
  assertTrue(ar.succeeded());
  client.connect(1234, "localhost", ar2 -> {
   if (ar2.failed()) {
    log.warn("failed", ar2.cause());
   }
   assertTrue(ar2.succeeded());
   // make sure we have gone through the proxy
   assertEquals("localhost:1234", proxy.getLastUri());
   testComplete();
  });
 });
 await();
}

代码示例来源:origin: eclipse-vertx/vert.x

/**
 * test http connect proxy for accessing a arbitrary server port
 * note that this may not work with a "real" proxy since there are usually access rules defined
 * that limit the target host and ports (e.g. connecting to localhost or to port 25 may not be allowed)
 */
@Test
public void testWithHttpConnectProxy() throws Exception {
 NetClientOptions clientOptions = new NetClientOptions()
   .setProxyOptions(new ProxyOptions().setType(ProxyType.HTTP).setPort(13128));
 NetClient client = vertx.createNetClient(clientOptions);
 server.connectHandler(sock -> {
 });
 proxy = new HttpProxy(null);
 proxy.start(vertx);
 server.listen(1234, "localhost", ar -> {
  assertTrue(ar.succeeded());
  client.connect(1234, "localhost", ar2 -> {
   if (ar2.failed()) {
    log.warn("failed", ar2.cause());
   }
   assertTrue(ar2.succeeded());
   // make sure we have gone through the proxy
   assertEquals("localhost:1234", proxy.getLastUri());
   testComplete();
  });
 });
 await();
}

代码示例来源:origin: eclipse-vertx/vert.x

/**
 * test socks4a proxy for accessing arbitrary server port using username auth.
 */
@Test
public void testWithSocks4aProxyAuth() throws Exception {
 NetClientOptions clientOptions = new NetClientOptions()
   .setProxyOptions(new ProxyOptions().setType(ProxyType.SOCKS4).setPort(11080)
     .setUsername("username"));
 NetClient client = vertx.createNetClient(clientOptions);
 server.connectHandler(sock -> {
 });
 proxy = new Socks4Proxy("username");
 proxy.start(vertx);
 server.listen(1234, "localhost", ar -> {
  assertTrue(ar.succeeded());
  client.connect(1234, "localhost", ar2 -> {
   if (ar2.failed()) {
    log.warn("failed", ar2.cause());
   }
   assertTrue(ar2.succeeded());
   // make sure we have gone through the proxy
   assertEquals("localhost:1234", proxy.getLastUri());
   testComplete();
  });
 });
 await();
}

代码示例来源:origin: eclipse-vertx/vert.x

private VertxImpl(VertxOptions options, Transport transport) {
  log.warn("You're already on a Vert.x context, are you sure you want to create a new Vertx instance?");

相关文章