Search in sources :

Example 1 with EmptyStateHolder

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();
    }
}
Also used : EmptyStateHolder(io.siddhi.core.util.snapshot.state.EmptyStateHolder) SingleSyncStateHolder(io.siddhi.core.util.snapshot.state.SingleSyncStateHolder) SingleSyncStateHolder(io.siddhi.core.util.snapshot.state.SingleSyncStateHolder) StateHolder(io.siddhi.core.util.snapshot.state.StateHolder) SingleStateHolder(io.siddhi.core.util.snapshot.state.SingleStateHolder) EmptyStateHolder(io.siddhi.core.util.snapshot.state.EmptyStateHolder) SingleStateHolder(io.siddhi.core.util.snapshot.state.SingleStateHolder)

Example 2 with 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();
    }
}
Also used : EmptyStateHolder(io.siddhi.core.util.snapshot.state.EmptyStateHolder) PartitionStateHolder(io.siddhi.core.util.snapshot.state.PartitionStateHolder) PartitionSyncStateHolder(io.siddhi.core.util.snapshot.state.PartitionSyncStateHolder) SingleSyncStateHolder(io.siddhi.core.util.snapshot.state.SingleSyncStateHolder) PartitionStateHolder(io.siddhi.core.util.snapshot.state.PartitionStateHolder) SingleSyncStateHolder(io.siddhi.core.util.snapshot.state.SingleSyncStateHolder) SingleStateHolder(io.siddhi.core.util.snapshot.state.SingleStateHolder) PartitionSyncStateHolder(io.siddhi.core.util.snapshot.state.PartitionSyncStateHolder) EmptyStateHolder(io.siddhi.core.util.snapshot.state.EmptyStateHolder) StateHolder(io.siddhi.core.util.snapshot.state.StateHolder) SingleStateHolder(io.siddhi.core.util.snapshot.state.SingleStateHolder)

Aggregations

EmptyStateHolder (io.siddhi.core.util.snapshot.state.EmptyStateHolder)2 SingleStateHolder (io.siddhi.core.util.snapshot.state.SingleStateHolder)2 SingleSyncStateHolder (io.siddhi.core.util.snapshot.state.SingleSyncStateHolder)2 StateHolder (io.siddhi.core.util.snapshot.state.StateHolder)2 PartitionStateHolder (io.siddhi.core.util.snapshot.state.PartitionStateHolder)1 PartitionSyncStateHolder (io.siddhi.core.util.snapshot.state.PartitionSyncStateHolder)1