Java Code Examples for io.siddhi.core.config.SiddhiAppContext#getPartitionFlowId()
The following examples show how to use
io.siddhi.core.config.SiddhiAppContext#getPartitionFlowId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InsertIntoStreamEndPartitionCallback.java From siddhi with Apache License 2.0 | 6 votes |
@Override public void send(ComplexEventChunk complexEventChunk, int noOfEvents) { if (getSiddhiDebugger() != null) { getSiddhiDebugger() .checkBreakPoint(getQueryName(), SiddhiDebugger.QueryTerminal.OUT, complexEventChunk.getFirst()); } complexEventChunk.reset(); if (complexEventChunk.getFirst() != null) { String flowId = SiddhiAppContext.getPartitionFlowId(); SiddhiAppContext.stopPartitionFlow(); try { while (complexEventChunk.hasNext()) { ComplexEvent complexEvent = complexEventChunk.next(); if (complexEvent.getType() == ComplexEvent.Type.EXPIRED) { complexEvent.setType(ComplexEvent.Type.CURRENT); } } publisher.send(complexEventChunk.getFirst()); } finally { SiddhiAppContext.startPartitionFlow(flowId); } } }
Example 2
Source File: PartitionStateHolder.java From siddhi with Apache License 2.0 | 6 votes |
@Override public void returnState(State state) { String partitionFlowId = SiddhiAppContext.getPartitionFlowId(); String groupByFlowId = SiddhiAppContext.getGroupByFlowId(); if (state.activeUseCount == 0) { try { if (state.canDestroy()) { removeState(partitionFlowId, groupByFlowId); } } catch (Throwable t) { log.error("Dropping partition state for partition key '" + partitionFlowId + "' and the group by key '" + groupByFlowId + "', due to error! " + t.getMessage(), t); removeState(partitionFlowId, groupByFlowId); } } else if (state.activeUseCount < 0) { throw new SiddhiAppRuntimeException("State active count has reached less then zero for partition key '" + partitionFlowId + "' and the group by key '" + groupByFlowId + "', current value is " + state.activeUseCount); } }
Example 3
Source File: PartitionStateHolder.java From siddhi with Apache License 2.0 | 5 votes |
@Override public State getState() { String partitionFlowId = SiddhiAppContext.getPartitionFlowId(); String groupByFlowId = SiddhiAppContext.getGroupByFlowId(); Map<String, State> partitionStates = states.computeIfAbsent(partitionFlowId, k -> new HashMap<>()); return partitionStates.computeIfAbsent(groupByFlowId, s -> stateFactory.createNewState()); }
Example 4
Source File: PartitionStateHolder.java From siddhi with Apache License 2.0 | 5 votes |
@Override public State cleanGroupByStates() { String partitionFlowId = SiddhiAppContext.getPartitionFlowId(); Map<String, State> groupByStates = states.remove(partitionFlowId); if (groupByStates != null) { return groupByStates.values().stream().findFirst().orElse(null); } return null; }
Example 5
Source File: PartitionStateHolder.java From siddhi with Apache License 2.0 | 5 votes |
@Override public void returnGroupByStates(Map states) { String partitionFlowId = SiddhiAppContext.getPartitionFlowId(); for (Iterator<Map.Entry<String, State>> iterator = ((Set<Map.Entry<String, State>>) states.entrySet()).iterator(); iterator.hasNext(); ) { Map.Entry<String, State> stateEntry = iterator.next(); State state = stateEntry.getValue(); if (state.activeUseCount == 0) { try { if (state.canDestroy()) { iterator.remove(); } } catch (Throwable t) { log.error("Dropping partition state for partition key '" + partitionFlowId + "' and the group by key '" + stateEntry.getKey() + "', due to error! " + t.getMessage(), t); iterator.remove(); } } else if (state.activeUseCount < 0) { throw new SiddhiAppRuntimeException("State active count has reached less then zero for partition key '" + partitionFlowId + "' and the group by key '" + stateEntry.getKey() + "', current value is " + state.activeUseCount); } } if (states.isEmpty()) { states.remove(partitionFlowId); } }
Example 6
Source File: PartitionStateHolder.java From siddhi with Apache License 2.0 | 4 votes |
@Override public Map<String, State> getAllGroupByStates() { String partitionFlowId = SiddhiAppContext.getPartitionFlowId(); return states.computeIfAbsent(partitionFlowId, k -> new HashMap<>()); }
Example 7
Source File: Scheduler.java From siddhi with Apache License 2.0 | 4 votes |
public SchedulerState() { this.key = SiddhiAppContext.getPartitionFlowId(); this.eventCaller = new EventCaller(this, key); }