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


Java EPStatement.removeAllListeners方法代码示例

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


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

示例1: removeEventType

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
/**
 * deletes Eventype from Esper
 *
 * @param eventType
 * @throws Exception
 */
public void removeEventType(final EapEventType eventType) {
	// System.out.println(esperConfiguration.getEventTypeNameUsedBy(eventType.getTypeName()));
	final Set<String> names = new HashSet<String>(this.esperConfiguration.getEventTypeNameUsedBy(eventType.getTypeName()));
	for (final String statementName : names) {
		final EPStatement statement = this.getStatement(statementName);
		if (statement != null) {
			statement.removeAllListeners();
			statement.destroy();
		}
		final Object ruleOrQuery = this.statementNames.get(statementName);
		if (ruleOrQuery != null) {
			if (ruleOrQuery instanceof QueryWrapper) {
				final QueryWrapper liveQuery = (QueryWrapper) ruleOrQuery;
				liveQuery.remove();
			} else if (ruleOrQuery instanceof TransformationRule) {
				final TransformationRule rule = (TransformationRule) ruleOrQuery;
				Broker.getInstance().remove(rule);
			} else {
				System.err.println("WARNING - Parent of statement '" + statementName + "' is neither transformation rule nor live query.");
			}
			this.statementNames.remove(statementName);
		}
	}
	this.esperConfiguration.removeEventType(eventType.getTypeName(), true);
}
 
开发者ID:bptlab,项目名称:Unicorn,代码行数:32,代码来源:StreamProcessingAdapter.java

示例2: tryPatternWithExpr

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void tryPatternWithExpr(EPServiceProvider epService, String text) {
    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    sendBeanLong(epService, 10L);
    epService.getEPRuntime().sendEvent(new SupportMarketDataBean("IBM", 0, 0L, ""));
    assertFalse(listener.getAndClearIsInvoked());

    epService.getEPRuntime().sendEvent(new SupportMarketDataBean("IBM", 0, 5L, ""));
    assertTrue(listener.getAndClearIsInvoked());

    sendBeanLong(epService, 0L);
    epService.getEPRuntime().sendEvent(new SupportMarketDataBean("IBM", 0, 0L, ""));
    assertTrue(listener.getAndClearIsInvoked());
    epService.getEPRuntime().sendEvent(new SupportMarketDataBean("IBM", 0, 1L, ""));
    assertFalse(listener.getAndClearIsInvoked());

    sendBeanLong(epService, 20L);
    epService.getEPRuntime().sendEvent(new SupportMarketDataBean("IBM", 0, 10L, ""));
    assertTrue(listener.getAndClearIsInvoked());

    stmt.removeAllListeners();
    stmt.destroy();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:26,代码来源:ExecFilterExpressions.java

示例3: removeStmtFromEngine

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void removeStmtFromEngine(long manifestId, String source, String eplName) {
    EPStatement oldStmt = epService.getEPAdministrator().getStatement(eplName);
    if (oldStmt != null) {
        oldStmt.stop();
        oldStmt.removeAllListeners();
        oldStmt.destroy();
    }
}
 
开发者ID:oneops,项目名称:oneops,代码行数:9,代码来源:Sensor.java

示例4: remove

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
/**
 * removes query from Esper
 *
 * @param query
 * @return
 */
public void remove(final QueryWrapper query) {
	final EPStatement statement = this.getStatement(query.getStatementName());
	if (statement != null) {
		statement.removeAllListeners();
		statement.destroy();
	}

	this.statementNames.remove(query.getStatementName());
}
 
开发者ID:bptlab,项目名称:Unicorn,代码行数:16,代码来源:StreamProcessingAdapter.java

示例5: removeTransformationRule

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
/**
 * Finds {@link EPStatement} for {@link TransformationRule}, removes the
 * listener and destroys the statement. The statement is also removed from
 * the map of statments.
 *
 * @param transformationRule
 */
public void removeTransformationRule(final TransformationRule transformationRule) {
	final EPStatement statement = this.getStatement(TransformationRuleLogic.generateStatementName(transformationRule));
	if (statement != null) {
		statement.removeAllListeners();
		statement.destroy();
	}
	this.statementNames.remove(statement);
}
 
开发者ID:bptlab,项目名称:Unicorn,代码行数:16,代码来源:StreamProcessingAdapter.java

示例6: call

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
public Object call() throws Exception {
    SupportMTUpdateListener listenerIsolated = new SupportMTUpdateListener();
    SupportMTUpdateListener listenerUnisolated = new SupportMTUpdateListener();
    EPStatement stmt = engine.getEPAdministrator().createEPL("select * from SupportBean");

    try {
        for (int i = 0; i < loopCount; i++) {
            EPServiceProviderIsolated isolated = engine.getEPServiceIsolated("i1");
            isolated.getEPAdministrator().addStatement(stmt);

            listenerIsolated.reset();
            stmt.addListener(listenerIsolated);
            Object theEvent = new SupportBean();
            //System.out.println("Sensing event : " + event + " by thread " + Thread.currentThread().getId());
            isolated.getEPRuntime().sendEvent(theEvent);
            findEvent(listenerIsolated, i, theEvent);
            stmt.removeAllListeners();

            isolated.getEPAdministrator().removeStatement(stmt);

            stmt.addListener(listenerUnisolated);
            theEvent = new SupportBean();
            engine.getEPRuntime().sendEvent(theEvent);
            findEvent(listenerUnisolated, i, theEvent);
            stmt.removeAllListeners();
        }
    } catch (Exception ex) {
        log.error("Error in thread " + threadNum, ex);
        return false;
    }
    return true;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:33,代码来源:IsolateUnisolateCallable.java

示例7: runAssertionSimpleSelectUpdateOnly

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionSimpleSelectUpdateOnly(EPServiceProvider epService) {
    SupportSubscriberRowByRowSpecificNStmt subscriber = new SupportSubscriberRowByRowSpecificNStmt();
    EPStatement stmt = epService.getEPAdministrator().createEPL("select theString, intPrimitive from " + SupportBean.class.getName() + "#lastevent");
    stmt.setSubscriber(subscriber);

    // get statement, attach listener
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    // send event
    epService.getEPRuntime().sendEvent(new SupportBean("E1", 100));
    subscriber.assertOneReceivedAndReset(stmt, new Object[]{"E1", 100});
    EPAssertionUtil.assertPropsPerRow(stmt.iterator(), FIELDS, new Object[][]{{"E1", 100}});
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), FIELDS, new Object[]{"E1", 100});

    // remove listener
    stmt.removeAllListeners();

    // send event
    epService.getEPRuntime().sendEvent(new SupportBean("E2", 200));
    subscriber.assertOneReceivedAndReset(stmt, new Object[]{"E2", 200});
    EPAssertionUtil.assertPropsPerRow(stmt.iterator(), FIELDS, new Object[][]{{"E2", 200}});
    assertFalse(listener.isInvoked());

    // add listener
    SupportStmtAwareUpdateListener stmtAwareListener = new SupportStmtAwareUpdateListener();
    stmt.addListener(stmtAwareListener);

    // send event
    epService.getEPRuntime().sendEvent(new SupportBean("E3", 300));
    subscriber.assertOneReceivedAndReset(stmt, new Object[]{"E3", 300});
    EPAssertionUtil.assertPropsPerRow(stmt.iterator(), FIELDS, new Object[][]{{"E3", 300}});
    EPAssertionUtil.assertProps(stmtAwareListener.assertOneGetNewAndReset(), FIELDS, new Object[]{"E3", 300});

    // subscriber with EPStatement in the footprint
    stmt.removeAllListeners();
    SupportSubscriberRowByRowSpecificWStmt subsWithStatement = new SupportSubscriberRowByRowSpecificWStmt();
    stmt.setSubscriber(subsWithStatement);
    epService.getEPRuntime().sendEvent(new SupportBean("E10", 999));
    subsWithStatement.assertOneReceivedAndReset(stmt, new Object[]{"E10", 999});

    stmt.destroy();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:44,代码来源:ExecClientSubscriberMgmt.java

示例8: main

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
	EPServiceProvider epServiceProvider = EsperUtil.esperConfig(config);

	log.info("{info:'3.5.1. Time Window'}");
	StringBuilder stringBuilder = new StringBuilder();
	stringBuilder.append("select * ")
			.append("from Withdrawal.win:time(4 sec)");

	String epl = stringBuilder.toString();
	EPStatement epStatement = epServiceProvider.getEPAdministrator().createEPL(epl);
	epStatement.addListener(MyUpdateListener::update);

	Withdrawal withdrawal = new Withdrawal("doctor", BigDecimal.valueOf(123.50D));
	epServiceProvider.getEPRuntime().sendEvent(withdrawal);
	TimeUnit.SECONDS.sleep(4);

	withdrawal = new Withdrawal("doctor who ", BigDecimal.valueOf(23.50D));
	epServiceProvider.getEPRuntime().sendEvent(withdrawal);
	TimeUnit.SECONDS.sleep(3);

	// 输出结果:时间窗口数据结构(只保留最近时间段数据)和长度窗口数据结构类似,度量标准不同而已。从官方图示可知,时间窗口持续移动者。
	// {newEvents:BeanEventBean eventType=BeanEventType name=Withdrawal clazz=com.doctor.esper.event.Withdrawal bean={"account":"doctor","amount":123.5}}
	// {oldEvents:BeanEventBean eventType=BeanEventType name=Withdrawal clazz=com.doctor.esper.event.Withdrawal bean={"account":"doctor","amount":123.5}}
	// {newEvents:BeanEventBean eventType=BeanEventType name=Withdrawal clazz=com.doctor.esper.event.Withdrawal bean={"account":"doctor who ","amount":23.5}}
	log.info("{info:'3.5.1.  Time Batch'}");
	stringBuilder = new StringBuilder();
	stringBuilder.append("select * ")
			.append("from Withdrawal.win:time_batch(4 sec)");

	epl = stringBuilder.toString();
	epStatement.removeAllListeners();
	epStatement.addListener(MyUpdateListener::update);
	TimeUnit.SECONDS.sleep(1);
	withdrawal = new Withdrawal("doctor", BigDecimal.valueOf(123.50D));
	epServiceProvider.getEPRuntime().sendEvent(withdrawal);

	TimeUnit.SECONDS.sleep(3);
	withdrawal = new Withdrawal("doctor who ", BigDecimal.valueOf(23.50D));
	epServiceProvider.getEPRuntime().sendEvent(withdrawal);

	TimeUnit.SECONDS.sleep(7);
	withdrawal = new Withdrawal("doctor who ", BigDecimal.valueOf(23.50D));
	epServiceProvider.getEPRuntime().sendEvent(withdrawal);
	// 从输出结果来看:时间批处理窗口函数会每隔一个时间窗口期,批量处理事件流的进入或淘汰(触发监听器)。从官方文档图示所示,窗口是每隔一段时间移动一个时间窗口。
	// {oldEvents:BeanEventBean eventType=BeanEventType name=Withdrawal clazz=com.doctor.esper.event.Withdrawal bean={"account":"doctor who ","amount":23.5}}
	// {newEvents:BeanEventBean eventType=BeanEventType name=Withdrawal clazz=com.doctor.esper.event.Withdrawal bean={"account":"doctor","amount":123.5}}
	// {newEvents:BeanEventBean eventType=BeanEventType name=Withdrawal clazz=com.doctor.esper.event.Withdrawal bean={"account":"doctor who ","amount":23.5}}
	// {oldEvents:BeanEventBean eventType=BeanEventType name=Withdrawal clazz=com.doctor.esper.event.Withdrawal bean={"account":"doctor","amount":123.5}}
	// {oldEvents:BeanEventBean eventType=BeanEventType name=Withdrawal clazz=com.doctor.esper.event.Withdrawal bean={"account":"doctor who ","amount":23.5}}
	// {newEvents:BeanEventBean eventType=BeanEventType name=Withdrawal clazz=com.doctor.esper.event.Withdrawal bean={"account":"doctor who ","amount":23.5}}

}
 
开发者ID:sdcuike,项目名称:esper-2015,代码行数:53,代码来源:Chapter3ProcessingTimeWindows.java


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