本文整理汇总了Java中org.productivity.java.syslog4j.server.SyslogServer类的典型用法代码示例。如果您正苦于以下问题:Java SyslogServer类的具体用法?Java SyslogServer怎么用?Java SyslogServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SyslogServer类属于org.productivity.java.syslog4j.server包,在下文中一共展示了SyslogServer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
serverStream = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(serverStream);
final TCPNetSyslogServerConfig tcpNetSyslogServerConfig = new TCPNetSyslogServerConfig(45553);
tcpNetSyslogServerConfig.addEventHandler(new PrintStreamSyslogServerEventHandler(ps));
final UDPNetSyslogServerConfig udpNetSyslogServerConfig = new UDPNetSyslogServerConfig(45553);
udpNetSyslogServerConfig.addEventHandler(new PrintStreamSyslogServerEventHandler(ps));
final SSLTCPNetSyslogServerConfig ssltcpNetSyslogServerConfig = new SSLTCPNetSyslogServerConfig();
ssltcpNetSyslogServerConfig.setPort(45554);
ssltcpNetSyslogServerConfig.addEventHandler(new PrintStreamSyslogServerEventHandler(ps));
final String keyStore = this.getClass().getClassLoader().getResource("test-keystore.jks").getFile();
ssltcpNetSyslogServerConfig.setKeyStore(keyStore);
ssltcpNetSyslogServerConfig.setKeyStorePassword("password");
ssltcpNetSyslogServerConfig.setTrustStore(keyStore);
ssltcpNetSyslogServerConfig.setTrustStorePassword("password");
SyslogServer.createThreadedInstance("testTcp", tcpNetSyslogServerConfig);
SyslogServer.createThreadedInstance("testUdp", udpNetSyslogServerConfig);
SyslogServer.createThreadedInstance("testTls", ssltcpNetSyslogServerConfig);
}
示例2: startServerThread
import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
protected void startServerThread(String protocol) {
assertTrue(SyslogServer.exists(protocol));
this.server = SyslogServer.getInstance(protocol);
if (isSyslogServerTcpBacklog() && this.server.getConfig() instanceof TCPNetSyslogServerConfig) {
((TCPNetSyslogServerConfig) this.server.getConfig()).setBacklog(0);
}
AbstractNetSyslogServerConfig config = (AbstractNetSyslogServerConfig) this.server.getConfig();
config.setPort(TEST_PORT);
config.addEventHandler(this.recorderEventHandler);
if (this.server.getThread() == null) {
Thread t = new Thread(this.server);
t.setName("SyslogServer: " + protocol);
t.start();
this.server.setThread(t);
assertEquals(t,this.server.getThread());
}
}
示例3: tearDown
import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
public void tearDown() {
System.out.print("Shutting down Syslog...");
Syslog.shutdown();
System.out.println("done.");
SyslogUtility.sleep(100);
System.out.print("Shutting down SyslogServer...");
SyslogServer.shutdown();
System.out.println("done.");
SyslogUtility.sleep(100);
Syslog.initialize();
SyslogServer.initialize();
}
示例4: setUp
import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
protected void setUp() {
serverStream = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(serverStream);
final TCPNetSyslogServerConfig tcpNetSyslogServerConfig = new TCPNetSyslogServerConfig(45553);
tcpNetSyslogServerConfig.addEventHandler(new PrintStreamSyslogServerEventHandler(ps));
final UDPNetSyslogServerConfig udpNetSyslogServerConfig = new UDPNetSyslogServerConfig(45553);
udpNetSyslogServerConfig.addEventHandler(new PrintStreamSyslogServerEventHandler(ps));
final SSLTCPNetSyslogServerConfig ssltcpNetSyslogServerConfig = new SSLTCPNetSyslogServerConfig();
ssltcpNetSyslogServerConfig.setPort(45554);
ssltcpNetSyslogServerConfig.addEventHandler(new PrintStreamSyslogServerEventHandler(ps));
ssltcpNetSyslogServerConfig.setKeyStore(this.getClass().getClassLoader().getResource("test-keystore.jks").getFile());
ssltcpNetSyslogServerConfig.setKeyStorePassword("password");
ssltcpNetSyslogServerConfig.setTrustStore(this.getClass().getClassLoader().getResource("test-keystore.jks").getFile());
ssltcpNetSyslogServerConfig.setTrustStorePassword("password");
SyslogServer.createThreadedInstance("testTcp", tcpNetSyslogServerConfig);
SyslogServer.createThreadedInstance("testUdp", udpNetSyslogServerConfig);
SyslogServer.createThreadedInstance("testTls", ssltcpNetSyslogServerConfig);
}
示例5: tearDown
import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
/**
* Stops syslog server and removes auditlog configuration.
*
*/
@Override
public void tearDown(ManagementClient managementClient) throws Exception {
// stop syslog server
SyslogServer.shutdown();
server.setThread(null);
server.getConfig().removeAllEventHandlers();
removeResource(managementClient, AUDIT_LOG_LOGGER_SYSLOG_HANDLER_ADDR);
removeResource(managementClient, AUDIT_LOG_LOGGER_SYSLOG_HANDLER_ADDR2);
removeResource(managementClient, AUDIT_SYSLOG_HANDLER_ADDR2);
removeResource(managementClient, AUDIT_SYSLOG_HANDLER_ADDR);
CoreUtils.applyUpdate(Util.getWriteAttributeOperation(AUDIT_LOG_LOGGER_ADDR, LOG_READ_ONLY, false),
managementClient.getControllerClient());
}
示例6: tearDown
import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
@Override
public void tearDown(final ManagementClient managementClient) throws Exception {
// stop syslog server
LOGGER.info("stopping syslog server");
SyslogServer.shutdown();
LOGGER.info("syslog server stopped");
// remove syslog-profile
final ModelNode op = Operations.createRemoveOperation(SYSLOG_PROFILE_ADDR);
op.get(OPERATION_HEADERS, ROLLBACK_ON_RUNTIME_FAILURE).set(false);
op.get(OPERATION_HEADERS, ALLOW_RESOURCE_SERVICE_RESTART).set(true);
executeOperation(op);
LOGGER.info("syslog server logging profile removed");
super.tearDown(managementClient);
}
示例7: startServer
import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
/**
* Getting ready for tests.
* @throws InterruptedException
*/
@Before
public void startServer() throws InterruptedException {
MockLogAppender.setupLogging();
SyslogServerConfigIF serverConfig = new UDPNetSyslogServerConfig(SERVER_HOST, SERVER_PORT);
serverConfig.setShutdownWait(0);
m_logStream = new TestPrintStream(new StringOutputStream());
SyslogServerEventHandlerIF eventHandler = new PrintStreamSyslogServerEventHandler(m_logStream);
serverConfig.addEventHandler(eventHandler);
m_server = SyslogServer.createThreadedInstance("test-udp", serverConfig);
m_server.initialize("udp", serverConfig);
//Need this sleep, found a deadlock in the server.
Thread.sleep(100);
m_server.run();
}
示例8: startServerThread
import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
protected void startServerThread(String protocol) {
this.server = SyslogServer.getInstance(protocol);
AbstractNetSyslogServerConfig config = (AbstractNetSyslogServerConfig) this.server.getConfig();
config.setPort(TEST_PORT);
config.addEventHandler(this.recorderEventHandler);
this.server = SyslogServer.getThreadedInstance(protocol);
}
示例9: testCreateAndDestroyServerByProtocol
import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
public void testCreateAndDestroyServerByProtocol() {
UDPNetSyslogServerConfig config = new UDPNetSyslogServerConfig();
config.setPort(999);
SyslogServerIF server = SyslogServer.createInstance("udpToDestroy",config);
SyslogServerIF matchServer = SyslogServer.getInstance("udpToDestroy");
assertEquals(server,matchServer);
SyslogServer.destroyInstance("");
SyslogServer.destroyInstance("udpToDestroy");
try {
SyslogServer.getInstance("udpToDestroy");
fail("udpToDestroy should not exist");
} catch (SyslogRuntimeException sre) {
//
}
assertFalse(SyslogServer.getSuppressRuntimeExceptions());
SyslogServer.setSuppressRuntimeExceptions(true);
assertTrue(SyslogServer.getSuppressRuntimeExceptions());
assertNull(SyslogServer.getInstance("udpToDestroy"));
SyslogServer.setSuppressRuntimeExceptions(false);
}
示例10: testNonDefinedSyslogServerInstance
import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
public void testNonDefinedSyslogServerInstance() {
try {
SyslogServer.getInstance("not_defined");
fail("not_defined shouldn't exist");
} catch (SyslogRuntimeException sre) {
assertTrue(sre.getMessage().startsWith("SyslogServer instance \"not_defined\" not defined; use \"tcp\" or \"udp\" or call SyslogServer.createInstance(protocol,config) first"));
}
}
示例11: _testMaxActiveSockets
import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
protected int _testMaxActiveSockets(TCPNetSyslogServerConfigIF serverConfig) {
Counter c = new Counter();
serverConfig.setMaxActiveSockets(2);
serverConfig.addEventHandler(c);
SyslogServer.createThreadedInstance("tcp_maxactivesockets",serverConfig);
TCPNetSyslogConfigIF config = new TCPNetSyslogConfig();
config.setPort(8888);
SyslogIF syslog1 = Syslog.createInstance("tcp_maxactivesockets1",config);
syslog1.info("test1");
syslog1.flush();
SyslogUtility.sleep(200);
SyslogIF syslog2 = Syslog.createInstance("tcp_maxactivesockets2",config);
syslog2.info("test2");
syslog2.flush();
SyslogUtility.sleep(200);
SyslogIF syslog3 = Syslog.createInstance("tcp_maxactivesockets3",config);
syslog3.info("test3");
syslog3.flush();
SyslogUtility.sleep(200);
syslog1.shutdown();
SyslogUtility.sleep(200);
Syslog.destroyInstance("tcp_maxactivesockets1");
Syslog.destroyInstance("tcp_maxactivesockets2");
Syslog.destroyInstance("tcp_maxactivesockets3");
SyslogServer.destroyInstance("tcp_maxactivesockets");
return c.counter;
}
示例12: setUp
import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
public void setUp() throws Exception {
if (ONCE) {
ONCE = false;
} else {
SyslogServer.getInstance(getServerProtocol()).getConfig().setHost("127.0.0.1");
}
super.setUp();
}
示例13: testFreshConnectionInterval
import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
public void testFreshConnectionInterval() {
TCPNetSyslogServerConfigIF serverConfig = new TCPNetSyslogServerConfig();
serverConfig.setPort(8888);
SocketCounter counter = new SocketCounter();
serverConfig.addEventHandler(counter);
SyslogServerIF server = SyslogServer.createThreadedInstance("tcp_8888",serverConfig);
SyslogUtility.sleep(100);
TCPNetSyslogConfigIF config = new TCPNetSyslogConfig();
config.setPort(8888);
config.setFreshConnectionInterval(300);
SyslogIF syslog = Syslog.createInstance("tcp_8888",config);
for(int i=0; i<10; i++) {
syslog.info("message " + i);
SyslogUtility.sleep(100);
}
SyslogUtility.sleep(100);
SyslogServer.destroyInstance(server);
Syslog.destroyInstance(syslog);
SyslogUtility.sleep(100);
assertEquals("OpenCounter",3,counter.openCounter);
assertEquals("EventCounter",10,counter.eventCounter);
assertEquals("CloseCounter",3,counter.closeCounter);
}
示例14: getServerProtocol
import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
protected String getServerProtocol() throws Exception {
SSLTCPNetSyslogServerConfigIF config = new SSLTCPNetSyslogServerConfig();
SSLConfigUtil.configure(config);
SyslogServer.createThreadedInstance("pooledSslTcp", config);
return "pooledSslTcp";
}
示例15: setup
import org.productivity.java.syslog4j.server.SyslogServer; //导入依赖的package包/类
/**
* Starts Syslog server and configures syslog handler in the AS.
*
*/
@Override
public void setup(ManagementClient managementClient) throws Exception {
// clear created server instances (TCP/UDP)
SyslogServer.shutdown();
// start and set syslog server
final String host = managementClient.getMgmtAddress();
SyslogServerConfigIF config = getSyslogConfig();
config.setUseStructuredData(true);
config.setHost(host);
config.setPort(SYSLOG_PORT);
config.addEventHandler(new BlockedSyslogServerEventHandler());
final String syslogProtocol = getSyslogProtocol();
server = SyslogServer.createInstance(syslogProtocol, config);
// start syslog server
SyslogServer.getThreadedInstance(syslogProtocol);
// Add the normal syslog handler
addSyslogHandler(managementClient, AUDIT_SYSLOG_HANDLER_ADDR, host, null, null);
// Add the syslog handler we will switch to
addSyslogHandler(managementClient, AUDIT_SYSLOG_HANDLER_ADDR2, host, "TestApp", Facility.LINE_PRINTER);
// Reference the first audit logger for now
ModelNode op = Util.createAddOperation(AUDIT_LOG_LOGGER_SYSLOG_HANDLER_ADDR);
CoreUtils.applyUpdate(op, managementClient.getControllerClient());
op = Util.getWriteAttributeOperation(AUDIT_LOG_LOGGER_ADDR, LOG_READ_ONLY, false);
CoreUtils.applyUpdate(op, managementClient.getControllerClient());
}