当前位置: 首页>>代码示例>>Java>>正文


Java SyslogIF.shutdown方法代码示例

本文整理汇总了Java中org.productivity.java.syslog4j.SyslogIF.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Java SyslogIF.shutdown方法的具体用法?Java SyslogIF.shutdown怎么用?Java SyslogIF.shutdown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.productivity.java.syslog4j.SyslogIF的用法示例。


在下文中一共展示了SyslogIF.shutdown方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shutdown

import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void shutdown() throws SyslogRuntimeException {
	for(int i=0; i<this.multipleSyslogConfig.getProtocols().size(); i++) {
		String protocol = (String) this.multipleSyslogConfig.getProtocols().get(i);
		
		SyslogIF syslog = Syslog.getInstance(protocol);
		
		syslog.shutdown();
	}
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:10,代码来源:MultipleSyslog.java

示例2: _testMaxActiveSockets

import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的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;
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:38,代码来源:MaxActiveSocketsTest.java

示例3: testUnixSyslog

import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void testUnixSyslog() {
	if (Boolean.getBoolean(SyslogConstants.DISABLE_UNIX_PROPERTY)) {
		assertTrue(true);
		return;
	}

	SyslogIF syslog = Syslog.getInstance(SyslogConstants.UNIX_SYSLOG);
	
	syslog.getConfig().setFacility(SyslogIF.FACILITY_KERN);
	
	syslog.error(this.getClass().getName() + ": unix_syslog " + System.currentTimeMillis());
	
	syslog.flush();
	
	syslog.shutdown();
	
	AbstractSyslog abstractSyslog = (AbstractSyslog) syslog;
	
	assertNull(abstractSyslog.getWriter());
	abstractSyslog.returnWriter(null);
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:22,代码来源:UnixSyslogTest.java

示例4: execute

import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public Result execute(Result previousResult, int nr)
{		
	Result result = previousResult;
	result.setNrErrors(1);
	result.setResult( false );
	
	String servername=environmentSubstitute(getServerName());
	
	if(Const.isEmpty(servername)) {
		logError(BaseMessages.getString(PKG, "JobEntrySyslog.MissingServerName"));
	}
	
	String messageString=environmentSubstitute(getMessage());
	
	if(Const.isEmpty(messageString)) {
		logError(BaseMessages.getString(PKG, "JobEntrySyslog.MissingMessage"));
	}
	
	int nrPort=Const.toInt(environmentSubstitute(getPort()), SyslogDefs.DEFAULT_PORT);

	SyslogIF syslog=null;
	try {
		String pattern=null;
		
		if(isAddTimestamp()) {
			// add timestamp to message
			pattern= environmentSubstitute(getDatePattern());
			if(Const.isEmpty(pattern)) {
				logError(BaseMessages.getString(PKG, "JobEntrySyslog.DatePatternEmpty"));
				throw new KettleException(BaseMessages.getString(PKG, "JobEntrySyslog.DatePatternEmpty"));
			}
		
		}
		
		// Open syslog connection
		// Set a Specific Host, then Log to It
		syslog = Syslog.getInstance("udp");
		syslog.getConfig().setHost(servername);
		syslog.getConfig().setPort(nrPort);
		syslog.getConfig().setFacility(getFacility());
		syslog.getConfig().setSendLocalName(false);
		syslog.getConfig().setSendLocalTimestamp(false);
		SyslogDefs.sendMessage(syslog, SyslogDefs.getPriority(getPriority()), 
				messageString, isAddTimestamp(), pattern, isAddHostName());
		
		// message was sent
		result.setNrErrors(0);
		result.setResult(true);
	} catch(Exception e){
		logError(BaseMessages.getString(PKG, "JobEntrySyslog.ErrorSendingMessage", e.toString())); //$NON-NLS-1$
	} finally{
       	if(syslog!=null) syslog.shutdown();
       }

	return result;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:57,代码来源:JobEntrySyslog.java

示例5: execute

import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public Result execute( Result previousResult, int nr ) {
  Result result = previousResult;
  result.setNrErrors( 1 );
  result.setResult( false );

  String servername = environmentSubstitute( getServerName() );

  if ( Utils.isEmpty( servername ) ) {
    logError( BaseMessages.getString( PKG, "JobEntrySyslog.MissingServerName" ) );
  }

  String messageString = environmentSubstitute( getMessage() );

  if ( Utils.isEmpty( messageString ) ) {
    logError( BaseMessages.getString( PKG, "JobEntrySyslog.MissingMessage" ) );
  }

  int nrPort = Const.toInt( environmentSubstitute( getPort() ), SyslogDefs.DEFAULT_PORT );

  SyslogIF syslog = null;
  try {
    String pattern = null;

    if ( isAddTimestamp() ) {
      // add timestamp to message
      pattern = environmentSubstitute( getDatePattern() );
      if ( Utils.isEmpty( pattern ) ) {
        logError( BaseMessages.getString( PKG, "JobEntrySyslog.DatePatternEmpty" ) );
        throw new KettleException( BaseMessages.getString( PKG, "JobEntrySyslog.DatePatternEmpty" ) );
      }

    }

    // Open syslog connection
    // Set a Specific Host, then Log to It
    syslog = Syslog.getInstance( "udp" );
    syslog.getConfig().setHost( servername );
    syslog.getConfig().setPort( nrPort );
    syslog.getConfig().setFacility( getFacility() );
    syslog.getConfig().setSendLocalName( false );
    syslog.getConfig().setSendLocalTimestamp( false );
    SyslogDefs.sendMessage(
      syslog, SyslogDefs.getPriority( getPriority() ), messageString, isAddTimestamp(), pattern,
      isAddHostName() );

    // message was sent
    result.setNrErrors( 0 );
    result.setResult( true );
  } catch ( Exception e ) {
    logError( BaseMessages.getString( PKG, "JobEntrySyslog.ErrorSendingMessage", e.toString() ) );
  } finally {
    if ( syslog != null ) {
      syslog.shutdown();
    }
  }

  return result;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:59,代码来源:JobEntrySyslog.java

示例6: testUDPSession

import org.productivity.java.syslog4j.SyslogIF; //导入方法依赖的package包/类
public void testUDPSession() {
	SyslogServerConfigIF serverConfig = new UDPNetSyslogServerConfig(9999);
	
	UDPSessionHandler handler1 = new UDPSessionHandler("a");
	serverConfig.addEventHandler(handler1);
	
	UDPSessionHandler handler2 = new UDPSessionHandler("b");
	serverConfig.addEventHandler(handler2);
	
	SyslogServer.createThreadedInstance("udp_session",serverConfig);
	
	SyslogUtility.sleep(100);
	
	assertTrue(handler1.initialized);
	assertTrue(handler2.initialized);

	SyslogConfigIF config = new UDPNetSyslogConfig();
	config.setPort(9999);
	
	SyslogIF syslog1 = Syslog.createInstance("udp_session_1",config);
	
	syslog1.info("1");
	syslog1.info("2");

	SyslogIF syslog2 = Syslog.createInstance("udp_session_2",config);
	
	syslog2.info("3");
	syslog2.info("4");

	SyslogUtility.sleep(100);
	
	syslog1.shutdown();
	syslog2.shutdown();
	SyslogServer.destroyInstance("udp_session");
	
	try {
		SyslogServer.getInstance("udp_session");
		fail();
		
	} catch (SyslogRuntimeException sre) {
		//
	}
	
	assertTrue(handler1.okay);
	assertTrue(handler2.okay);
	
	SyslogUtility.sleep(250);
	
	assertTrue(handler1.destroyed);
	assertTrue(handler2.destroyed);
}
 
开发者ID:syslog4j,项目名称:syslog4j,代码行数:52,代码来源:SyslogServerSessionTest.java


注:本文中的org.productivity.java.syslog4j.SyslogIF.shutdown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。