Java 类ch.qos.logback.core.util.ExecutorServiceUtil 实例源码
项目:bartleby
文件:ContextBase.java
public ExecutorService getExecutorService() {
if (executorService == null) {
synchronized (this) {
if (executorService == null) {
executorService = ExecutorServiceUtil.newExecutorService();
}
}
}
return executorService;
}
项目:bartleby
文件:Basic.java
@Ignore
@Test
public void withOneSlowTask() throws InterruptedException {
executor.execute(new InterruptIgnoring(1000));
Thread.sleep(100);
ExecutorServiceUtil.shutdown(executor);
}
项目:bartleby
文件:LogbackValve.java
@Override
protected void stopInternal() throws LifecycleException {
started = false;
setState(LifecycleState.STOPPING);
lifeCycleManager.reset();
if (executorService != null) {
ExecutorServiceUtil.shutdown(executorService);
executorService = null;
}
}
项目:splunk-logback
文件:UdpSocketOutputStreamTest.java
@Test
public void testSuccesfullyMessage() throws JoranException, InterruptedException, ExecutionException, UnsupportedEncodingException {
Future<String> future = ExecutorServiceUtil.newExecutorService().submit(this.task);
LoggerContext context = new LoggerContext();
new ContextInitializer(context).configureByResource(getClass().getResource("/SplunkUdpSocketAppenderTest-logback.xml"));
String logLineMultiplied = createLogLineMultiplied("geub", UdpSocketOutputStream.UDP_MAX_LENGTH_IN_BYTES / 4);
context.getLogger(getClass()).info(logLineMultiplied);
Assert.assertEquals("Wrong value", logLineMultiplied, future.get());
Assert.assertEquals(UdpSocketOutputStream.UDP_MAX_LENGTH_IN_BYTES, getBytesLength(logLineMultiplied));
}
项目:splunk-logback
文件:UdpSocketOutputStreamTest.java
@Test
public void testSuccesfullyTruncateMessage() throws JoranException, InterruptedException, ExecutionException, UnsupportedEncodingException {
Future<String> future = ExecutorServiceUtil.newExecutorService().submit(this.task);
LoggerContext context = new LoggerContext();
new ContextInitializer(context).configureByResource(getClass().getResource("/SplunkUdpSocketAppenderTest-logback.xml"));
String logLineMultiplied = createLogLineMultiplied("geub", UdpSocketOutputStream.UDP_MAX_LENGTH_IN_BYTES);
context.getLogger(getClass()).info(logLineMultiplied);
Assert.assertEquals("Wrong value", createLogLineMultiplied("geub", UdpSocketOutputStream.UDP_MAX_LENGTH_IN_BYTES / 4), future.get());
Assert.assertEquals(UdpSocketOutputStream.UDP_MAX_LENGTH_IN_BYTES, getBytesLength(future.get()));
}
项目:splunk-logback
文件:SplunkTcpSocketAppenderTest.java
@Test
public void testSuccesfullySendMessage() throws JoranException, InterruptedException, ExecutionException {
Future<String> future = ExecutorServiceUtil.newExecutorService().submit(this.task);
LoggerContext context = new LoggerContext();
new ContextInitializer(context).configureByResource(getClass().getResource("/SplunkTcpSocketAppenderTest-logback.xml"));
String uuid = UUID.randomUUID().toString();
context.getLogger(getClass()).info(uuid);
context.stop();
Assert.assertEquals("Valor do log incorreto", uuid, future.get());
}
项目:splunk-logback
文件:SplunkUdpSocketAppenderTest.java
@Test
public void testSuccesfullySendMessage() throws JoranException, InterruptedException, ExecutionException {
Future<String> future = ExecutorServiceUtil.newExecutorService().submit(this.task);
LoggerContext context = new LoggerContext();
new ContextInitializer(context).configureByResource(getClass().getResource("/SplunkUdpSocketAppenderTest-logback.xml"));
String uuid = UUID.randomUUID().toString();
context.getLogger(getClass()).info(uuid);
Assert.assertEquals("Wrong value", uuid, future.get());
}
项目:bartleby
文件:ContextBase.java
private synchronized void stopExecutorService() {
if (executorService != null) {
ExecutorServiceUtil.shutdown(executorService);
executorService = null;
}
}
项目:bartleby
文件:LogbackValve.java
@Override
public void startInternal() throws LifecycleException {
executorService = ExecutorServiceUtil.newExecutorService();
if (filename == null) {
String tomcatBaseProperty = OptionHelper
.getSystemProperty("catalina.base");
filename = tomcatBaseProperty + File.separatorChar + DEFAULT_CONFIG_FILE;
File baseConfigFile = new File(filename);
if (!baseConfigFile.exists()) {
String tomcatHomeProperty = OptionHelper
.getSystemProperty("catalina.home");
filename = tomcatHomeProperty + File.separatorChar
+ DEFAULT_CONFIG_FILE;
}
getStatusManager().add(
new InfoStatus("filename property not set. Assuming [" + filename
+ "]", this));
}
File configFile = new File(filename);
if (configFile.exists()) {
try {
JoranConfigurator jc = new JoranConfigurator();
jc.setContext(this);
jc.doConfigure(filename);
} catch (JoranException e) {
// TODO can we do better than printing a stack trace on syserr?
e.printStackTrace();
}
} else {
getStatusManager().add(
new WarnStatus("[" + filename + "] does not exist", this));
}
if (!quiet) {
StatusPrinter.print(getStatusManager());
}
started = true;
setState(LifecycleState.STARTING);
}