Search in sources :

Example 1 with StateStoreContext

use of org.apache.pulsar.functions.api.StateStoreContext in project pulsar by yahoo.

the class JavaInstanceRunnable method setupStateStore.

private void setupStateStore() throws Exception {
    this.stateManager = new InstanceStateManager();
    if (null == stateStorageServiceUrl) {
        stateStoreProvider = StateStoreProvider.NULL;
    } else {
        stateStoreProvider = getStateStoreProvider();
        Map<String, Object> stateStoreProviderConfig = new HashMap<>();
        stateStoreProviderConfig.put(BKStateStoreProviderImpl.STATE_STORAGE_SERVICE_URL, stateStorageServiceUrl);
        stateStoreProvider.init(stateStoreProviderConfig, instanceConfig.getFunctionDetails());
        StateStore store = stateStoreProvider.getStateStore(instanceConfig.getFunctionDetails().getTenant(), instanceConfig.getFunctionDetails().getNamespace(), instanceConfig.getFunctionDetails().getName());
        StateStoreContext context = new StateStoreContextImpl();
        store.init(context);
        stateManager.registerStore(store);
    }
}
Also used : StateStoreContextImpl(org.apache.pulsar.functions.instance.state.StateStoreContextImpl) HashMap(java.util.HashMap) StateStore(org.apache.pulsar.functions.api.StateStore) InstanceStateManager(org.apache.pulsar.functions.instance.state.InstanceStateManager) StateStoreContext(org.apache.pulsar.functions.api.StateStoreContext)

Example 2 with StateStoreContext

use of org.apache.pulsar.functions.api.StateStoreContext in project incubator-pulsar by apache.

the class JavaInstanceRunnable method setupStateStore.

private void setupStateStore() throws Exception {
    this.stateManager = new InstanceStateManager();
    if (null == stateStorageServiceUrl) {
        stateStoreProvider = StateStoreProvider.NULL;
    } else {
        stateStoreProvider = getStateStoreProvider();
        Map<String, Object> stateStoreProviderConfig = new HashMap<>();
        stateStoreProviderConfig.put(BKStateStoreProviderImpl.STATE_STORAGE_SERVICE_URL, stateStorageServiceUrl);
        stateStoreProvider.init(stateStoreProviderConfig, instanceConfig.getFunctionDetails());
        StateStore store = stateStoreProvider.getStateStore(instanceConfig.getFunctionDetails().getTenant(), instanceConfig.getFunctionDetails().getNamespace(), instanceConfig.getFunctionDetails().getName());
        StateStoreContext context = new StateStoreContextImpl();
        store.init(context);
        stateManager.registerStore(store);
    }
}
Also used : StateStoreContextImpl(org.apache.pulsar.functions.instance.state.StateStoreContextImpl) HashMap(java.util.HashMap) StateStore(org.apache.pulsar.functions.api.StateStore) InstanceStateManager(org.apache.pulsar.functions.instance.state.InstanceStateManager) StateStoreContext(org.apache.pulsar.functions.api.StateStoreContext)

Example 3 with StateStoreContext

use of org.apache.pulsar.functions.api.StateStoreContext in project pulsar by apache.

the class JavaInstanceRunnable method setupStateStore.

private void setupStateStore() throws Exception {
    this.stateManager = new InstanceStateManager();
    if (null == stateStorageServiceUrl) {
        stateStoreProvider = StateStoreProvider.NULL;
    } else {
        stateStoreProvider = getStateStoreProvider();
        Map<String, Object> stateStoreProviderConfig = new HashMap<>();
        stateStoreProviderConfig.put(BKStateStoreProviderImpl.STATE_STORAGE_SERVICE_URL, stateStorageServiceUrl);
        stateStoreProvider.init(stateStoreProviderConfig, instanceConfig.getFunctionDetails());
        StateStore store = stateStoreProvider.getStateStore(instanceConfig.getFunctionDetails().getTenant(), instanceConfig.getFunctionDetails().getNamespace(), instanceConfig.getFunctionDetails().getName());
        StateStoreContext context = new StateStoreContextImpl();
        store.init(context);
        stateManager.registerStore(store);
    }
}
Also used : StateStoreContextImpl(org.apache.pulsar.functions.instance.state.StateStoreContextImpl) HashMap(java.util.HashMap) StateStore(org.apache.pulsar.functions.api.StateStore) InstanceStateManager(org.apache.pulsar.functions.instance.state.InstanceStateManager) StateStoreContext(org.apache.pulsar.functions.api.StateStoreContext)

Aggregations

HashMap (java.util.HashMap)3 StateStore (org.apache.pulsar.functions.api.StateStore)3 StateStoreContext (org.apache.pulsar.functions.api.StateStoreContext)3 InstanceStateManager (org.apache.pulsar.functions.instance.state.InstanceStateManager)3 StateStoreContextImpl (org.apache.pulsar.functions.instance.state.StateStoreContextImpl)3