All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.ftrossbach.kiqr.client.service.rest.SpecificBlockingRestKiqrClientImpl Maven / Gradle / Ivy

package com.github.ftrossbach.kiqr.client.service.rest;

import com.github.ftrossbach.kiqr.client.service.GenericBlockingKiqrClient;
import com.github.ftrossbach.kiqr.client.service.SpecificBlockingKiqrClient;
import com.github.ftrossbach.kiqr.commons.config.querymodel.requests.Window;
import org.apache.kafka.common.serialization.Serde;
import java.util.Map;
import java.util.Optional;

/**
 * Created by ftr on 10/03/2017.
 */
public class SpecificBlockingRestKiqrClientImpl implements SpecificBlockingKiqrClient{


    private final String store;
    private final Class keyClass;
    private final Class valueClass;
    private final Serde keySerde;
    private final Serde valueSerde;
    private final GenericBlockingKiqrClient genericClient;
    

    public SpecificBlockingRestKiqrClientImpl(String host, int port, String store, Class keyClass, Class valueClass, Serde keySerde, Serde valueSerde) {
        this.keyClass = keyClass;
        this.valueClass = valueClass;
        this.keySerde = keySerde;
        this.valueSerde = valueSerde;
        this.genericClient = initGenericService(host, port);
        this.store = store;
    }

    public SpecificBlockingRestKiqrClientImpl(GenericBlockingKiqrClient genericClient, String store, Class keyClass, Class valueClass, Serde keySerde, Serde valueSerde) {
        this.keyClass = keyClass;
        this.valueClass = valueClass;
        this.keySerde = keySerde;
        this.valueSerde = valueSerde;
        this.genericClient = genericClient;
        this.store = store;
    }

    protected GenericBlockingKiqrClient initGenericService(String host, int port){
       return new GenericBlockingRestKiqrClientImpl(host, port);
    }


    @Override
    public Optional getScalarKeyValue( K key) {
        return genericClient.getScalarKeyValue(store, keyClass, key, valueClass, keySerde, valueSerde);
    }

    @Override
    public Map getAllKeyValues() {
        return genericClient.getAllKeyValues(store, keyClass, valueClass, keySerde, valueSerde);
    }

    @Override
    public Map getRangeKeyValues( K from, K to) {
        return genericClient.getRangeKeyValues(store, keyClass, valueClass, keySerde, valueSerde, from, to);
    }

    @Override
    public  Map getWindow( K key, long from, long to) {
        return genericClient.getWindow(store, keyClass, key, valueClass, keySerde, valueSerde, from, to);
    }

    @Override
    public Optional count(String store) {
        return genericClient.count(store);
    }

    @Override
    public Map getSession(K key) {
        return genericClient.getSession(store, keyClass, key, valueClass, keySerde, valueSerde);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy