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


Java SafeIterator类代码示例

本文整理汇总了Java中com.espertech.esper.client.SafeIterator的典型用法代码示例。如果您正苦于以下问题:Java SafeIterator类的具体用法?Java SafeIterator怎么用?Java SafeIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: call

import com.espertech.esper.client.SafeIterator; //导入依赖的package包/类
public Object call() throws Exception {
    try {
        long total = 0;
        for (int loop = 0; loop < numRepeats; loop++) {
            // Insert event into named window
            sendMarketBean(threadKey, loop + 1);
            total += loop + 1;

            // iterate over private statement
            SafeIterator safeIter = statement.safeIterator();
            EventBean[] received = EPAssertionUtil.iteratorToArray(safeIter);
            safeIter.close();

            for (int i = 0; i < received.length; i++) {
                if (received[i].get("theString").equals(threadKey)) {
                    long sum = (Long) received[i].get("sumLong");
                    Assert.assertEquals(total, sum);
                }
            }
        }
    } catch (Exception ex) {
        log.error("Error in thread " + Thread.currentThread().getId(), ex);
        return false;
    }
    return true;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:27,代码来源:StmtNamedWindowIterateCallable.java

示例2: concurrentSafeQuery

import com.espertech.esper.client.SafeIterator; //导入依赖的package包/类
public <T> List<T> concurrentSafeQuery(RowMapper<T> rm) {
	LOG.info("Concurrent safe query being executed");

	if (epStatement.isStopped() || epStatement.isDestroyed()) {
		LOG
				.error("Concurrent safe query was attempted when the statement was stopped or destroyed");
		throw new EsperStatementInvalidStateException(
				"Attempted to execute a concurrent safe query when esper statement resource had state of "
						+ epStatement.getState());
	}

	SafeIterator<EventBean> safeIter = this.epStatement.safeIterator();

	List<T> objectList = new ArrayList<T>();
	try {
		for (; safeIter.hasNext();) {
			EventBean event = safeIter.next();
			objectList.add(rm.mapRow(event));
		}
	} finally {
		safeIter.close();
	}

	LOG.info("Concurrent safe query was completed");
	return objectList;
}
 
开发者ID:sdcuike,项目名称:esper-2015,代码行数:27,代码来源:EsperStatement.java

示例3: handleGetAllEvents

import com.espertech.esper.client.SafeIterator; //导入依赖的package包/类
protected List<Object> handleGetAllEvents(String strategyName, String ruleName) {

		EPStatement statement = getServiceProvider(strategyName).getEPAdministrator().getStatement(ruleName);
		List<Object> list = new ArrayList<Object>();
		if (statement != null && statement.isStarted()) {
			SafeIterator<EventBean> it = statement.safeIterator();
			try {
				while (it.hasNext()) {
					EventBean bean = it.next();
					Object underlaying = bean.getUnderlying();
					list.add(underlaying);
				}
			} finally {
				it.close();
			}
		}
		return list;
	}
 
开发者ID:curtiszimmerman,项目名称:AlgoTrader,代码行数:19,代码来源:RuleServiceImpl.java

示例4: handleGetAllEventsProperty

import com.espertech.esper.client.SafeIterator; //导入依赖的package包/类
protected List<Object> handleGetAllEventsProperty(String strategyName, String ruleName, String property) throws Exception {

		EPStatement statement = getServiceProvider(strategyName).getEPAdministrator().getStatement(ruleName);
		List<Object> list = new ArrayList<Object>();
		if (statement != null && statement.isStarted()) {
			SafeIterator<EventBean> it = statement.safeIterator();
			try {
				while (it.hasNext()) {
					EventBean bean = it.next();
					Object underlaying = bean.get(property);
					list.add(underlaying);
				}
			} finally {
				it.close();
			}
		}
		return list;
	}
 
开发者ID:curtiszimmerman,项目名称:AlgoTrader,代码行数:19,代码来源:RuleServiceImpl.java

示例5: queryStatement

import com.espertech.esper.client.SafeIterator; //导入依赖的package包/类
/**
 * This method is used to query a certain statement from the CEP Engine. The method will return an ArrayList of EventBeans
 * @param StatementName
 * @return ArrayList<EventBean> 
 */
private ArrayList<EventBean> queryStatement(String StatementName) {
	
	long start = System.currentTimeMillis();
	
	// Get the Eventbean iterator
	SafeIterator<EventBean> iterator = getEsperStatement(StatementName).safeIterator();
	ArrayList<EventBean> result = new ArrayList<EventBean>();
	logger.trace("Querying statement: " + StatementName);
	
	
	// Loop over the list and add them to the result list.
	while (iterator.hasNext()) {
		EventBean event = iterator.next();
		result.add(event);
	}

	iterator.close();

	long end = System.currentTimeMillis();
	logger.trace("queryStatement took " + (end - start) + " msecs to process " + StatementName );

	
	// Return result list
	return result;
}
 
开发者ID:sgrotz,项目名称:myopentrader,代码行数:31,代码来源:EsperFactory.java

示例6: call

import com.espertech.esper.client.SafeIterator; //导入依赖的package包/类
public Object call() throws Exception {
    try {
        for (int loop = 0; loop < numRepeats; loop++) {
            log.info(".call Thread " + Thread.currentThread().getId() + " sending event " + loop);
            String id = Long.toString(threadNum * 100000000 + loop);
            SupportBean bean = new SupportBean(id, 0);
            engine.getEPRuntime().sendEvent(bean);

            for (int i = 0; i < stmt.length; i++) {
                log.info(".call Thread " + Thread.currentThread().getId() + " starting iterator " + loop);
                SafeIterator<EventBean> it = stmt[i].safeIterator();
                boolean found = false;
                for (; it.hasNext(); ) {
                    EventBean theEvent = it.next();
                    if (theEvent.get("theString").equals(id)) {
                        found = true;
                    }
                }
                it.close();
                Assert.assertTrue(found);
                log.info(".call Thread " + Thread.currentThread().getId() + " end iterator " + loop);
            }
        }
    } catch (AssertionFailedError ex) {
        log.error("Assertion error in thread " + Thread.currentThread().getId(), ex);
        return false;
    } catch (Throwable t) {
        log.error("Error in thread " + Thread.currentThread().getId(), t);
        return false;
    }
    return true;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:33,代码来源:StmtIterateCallable.java

示例7: concurrentSafeQueryForObject

import com.espertech.esper.client.SafeIterator; //导入依赖的package包/类
public <T> T concurrentSafeQueryForObject(RowMapper<T> rm) {
	LOG.info("Concurrent safe query for object being executed");

	if (epStatement.isStopped() || epStatement.isDestroyed()) {
		LOG
				.error("Concurrent safe query for object was attempted when the statement was stopped or destroyed");
		throw new EsperStatementInvalidStateException(
				"Attempted to execute a concurrent safe query for object when esper statement resource had state of "
						+ epStatement.getState());
	}

	SafeIterator<EventBean> safeIter = this.epStatement.safeIterator();

	T result = null;
	try {
		// Only retrieve the last result
		while (safeIter.hasNext()) {
			EventBean event = safeIter.next();
			if (!safeIter.hasNext()) {
				result = rm.mapRow(event);
			}

		}
	} finally {
		safeIter.close();
	}

	LOG.info("Concurrent safe query for object was completed");
	return result;
}
 
开发者ID:sdcuike,项目名称:esper-2015,代码行数:31,代码来源:EsperStatement.java

示例8: handleGetLastEvent

import com.espertech.esper.client.SafeIterator; //导入依赖的package包/类
protected Object handleGetLastEvent(String strategyName, String ruleName) {

		EPStatement statement = getServiceProvider(strategyName).getEPAdministrator().getStatement(ruleName);
		if (statement != null && statement.isStarted()) {
			SafeIterator<EventBean> it = statement.safeIterator();
			try {
				if (it.hasNext()) {
					return it.next().getUnderlying();
				}
			} finally {
				it.close();
			}
		}
		return null;
	}
 
开发者ID:curtiszimmerman,项目名称:AlgoTrader,代码行数:16,代码来源:RuleServiceImpl.java

示例9: handleGetLastEventProperty

import com.espertech.esper.client.SafeIterator; //导入依赖的package包/类
protected Object handleGetLastEventProperty(String strategyName, String ruleName, String property) throws Exception {

		EPStatement statement = getServiceProvider(strategyName).getEPAdministrator().getStatement(ruleName);
		if (statement != null && statement.isStarted()) {
			SafeIterator<EventBean> it = statement.safeIterator();
			try {
				return it.next().get(property);
			} finally {
				it.close();
			}
		}
		return null;
	}
 
开发者ID:curtiszimmerman,项目名称:AlgoTrader,代码行数:14,代码来源:RuleServiceImpl.java

示例10: call

import com.espertech.esper.client.SafeIterator; //导入依赖的package包/类
public Object call() throws Exception
{
    try
    {
        long total = 0;
        for (int loop = 0; loop < numRepeats; loop++)
        {
            // Insert event into named window
            sendMarketBean(threadKey, loop + 1);
            total += loop + 1;

            // iterate over private statement
            SafeIterator safeIter = statement.safeIterator();
            EventBean[] received = EPAssertionUtil.iteratorToArray(safeIter);
            safeIter.close();

            for (int i = 0; i < received.length; i++)
            {
                if (received[i].get("theString").equals(threadKey))
                {
                    long sum = (Long) received[i].get("sumLong");
                    Assert.assertEquals(total, sum);
                }
            }
        }
    }
    catch (Exception ex)
    {
        log.fatal("Error in thread " + Thread.currentThread().getId(), ex);
        return false;
    }
    return true;
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:34,代码来源:StmtNamedWindowIterateCallable.java

示例11: runAssertionStartStop

import com.espertech.esper.client.SafeIterator; //导入依赖的package包/类
private void runAssertionStartStop(EPServiceProvider epService) {
    String epl = "@IterableUnbound every tag=" + SupportBean.class.getName();
    EPStatement patternStmt = epService.getEPAdministrator().createPattern(epl, "MyPattern");
    assertEquals(StatementType.PATTERN, ((EPStatementSPI) patternStmt).getStatementMetadata().getStatementType());

    // Pattern started when created
    assertFalse(patternStmt.iterator().hasNext());
    SafeIterator<EventBean> safe = patternStmt.safeIterator();
    assertFalse(safe.hasNext());
    safe.close();

    // Stop pattern
    patternStmt.stop();
    sendEvent(epService);
    assertNull(patternStmt.iterator());

    // Start pattern
    patternStmt.start();
    assertFalse(patternStmt.iterator().hasNext());

    // Send event
    SupportBean theEvent = sendEvent(epService);
    assertSame(theEvent, patternStmt.iterator().next().get("tag"));
    safe = patternStmt.safeIterator();
    assertSame(theEvent, safe.next().get("tag"));
    safe.close();

    // Stop pattern
    patternStmt.stop();
    assertNull(patternStmt.iterator());

    // Start again, iterator is zero
    patternStmt.start();
    assertFalse(patternStmt.iterator().hasNext());

    // assert statement-eventtype reference info
    EPServiceProviderSPI spi = (EPServiceProviderSPI) epService;
    assertTrue(spi.getStatementEventTypeRef().isInUse(SupportBean.class.getName()));
    Set<String> stmtNames = spi.getStatementEventTypeRef().getStatementNamesForType(SupportBean.class.getName());
    assertTrue(stmtNames.contains("MyPattern"));

    patternStmt.destroy();

    assertFalse(spi.getStatementEventTypeRef().isInUse(SupportBean.class.getName()));
    stmtNames = spi.getStatementEventTypeRef().getStatementNamesForType(SupportBean.class.getName());
    assertFalse(stmtNames.contains("MyPattern"));
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:48,代码来源:ExecPatternStartStop.java

示例12: safeIterator

import com.espertech.esper.client.SafeIterator; //导入依赖的package包/类
public synchronized SafeIterator<EventBean> safeIterator(int statementId, ContextPartitionSelector selector) {
    AgentInstance[] instances = getAgentInstancesForStmt(statementId, selector);
    return new AgentInstanceArraySafeIterator(instances);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:5,代码来源:ContextManagerNested.java

示例13: safeIterator

import com.espertech.esper.client.SafeIterator; //导入依赖的package包/类
public synchronized SafeIterator<EventBean> safeIterator(int statementId) {
    AgentInstance[] instances = getAgentInstancesForStmt(statementId);
    return new AgentInstanceArraySafeIterator(instances);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:5,代码来源:ContextManagerImpl.java

示例14: safeIterator

import com.espertech.esper.client.SafeIterator; //导入依赖的package包/类
public SafeIterator<EventBean> safeIterator(int statementId) {
    return iteratorHandler.safeIterator(statementId);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:4,代码来源:ContextDescriptor.java

示例15: safeIterator

import com.espertech.esper.client.SafeIterator; //导入依赖的package包/类
public synchronized SafeIterator<EventBean> safeIterator(String statementId, ContextPartitionSelector selector) {
    AgentInstance[] instances = getAgentInstancesForStmt(statementId, selector);
    return new AgentInstanceArraySafeIterator(instances);
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:5,代码来源:ContextManagerNested.java


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