use of io.siddhi.core.util.snapshot.state.EmptyStateHolder in project siddhi by wso2.
the class SiddhiAppContext method generateStateHolder.
public StateHolder generateStateHolder(String name, StateFactory stateFactory, boolean unSafe) {
if (stateFactory != null) {
StateHolder stateHolder;
if (unSafe) {
stateHolder = new SingleStateHolder(stateFactory);
} else {
stateHolder = new SingleSyncStateHolder(stateFactory);
}
if (SnapshotService.getSkipStateStorageThreadLocal().get() == null || !SnapshotService.getSkipStateStorageThreadLocal().get()) {
Map<String, StateHolder> stateHolderMap = getSnapshotService().getStateHolderMap(SiddhiConstants.PARTITION_ID_DEFAULT, SiddhiConstants.PARTITION_ID_DEFAULT);
stateHolderMap.put(name + "-" + idGenerator.createNewId(), stateHolder);
}
return stateHolder;
} else {
return new EmptyStateHolder();
}
}
use of io.siddhi.core.util.snapshot.state.EmptyStateHolder in project siddhi by wso2.
the class SiddhiQueryContext method generateStateHolder.
public StateHolder generateStateHolder(String name, boolean groupBy, StateFactory stateFactory, boolean unSafe) {
if (stateFactory != null) {
StateHolder stateHolder;
if (unSafe) {
if (partitioned || groupBy) {
stateHolder = new PartitionStateHolder(stateFactory);
} else {
stateHolder = new SingleStateHolder(stateFactory);
}
} else {
if (partitioned || groupBy) {
stateHolder = new PartitionSyncStateHolder(stateFactory);
} else {
stateHolder = new SingleSyncStateHolder(stateFactory);
}
}
if (SnapshotService.getSkipStateStorageThreadLocal().get() == null || !SnapshotService.getSkipStateStorageThreadLocal().get()) {
Map<String, StateHolder> stateHolderMap = siddhiAppContext.getSnapshotService().getStateHolderMap(partitionId, this.getName());
stateHolderMap.put(idGenerator.createNewId() + "-" + name, stateHolder);
}
stateful = true;
return stateHolder;
} else {
return new EmptyStateHolder();
}
}
Aggregations