Search in sources :

Example 1 with ProxyProperties

use of uk.gov.gchq.gaffer.proxystore.ProxyProperties in project Gaffer by gchq.

the class GetProxyPropertiesHandler method doOperation.

/**
 * This implementation could work with with any store and properties but gets ONLY the Proxy Properties value from the Proxy store.
 *
 * @param operation the {@link GetProxyProperties} to be executed
 * @param context   the operation chain context, containing the user who executed the operation
 * @param store     the {@link Store} the operation should be run on
 * @return          the proxy specific properties only.
 * @throws OperationException Error making return string map
 */
@Override
public Map<String, Object> doOperation(final GetProxyProperties operation, final Context context, final Store store) throws OperationException {
    try {
        ProxyProperties properties = new ProxyProperties(store.getProperties().getProperties());
        HashMap<String, Object> rtn = new HashMap<>();
        rtn.put(GAFFER_CONTEXT_ROOT, properties.getGafferContextRoot());
        rtn.put(GAFFER_HOST, properties.getGafferHost());
        rtn.put(GAFFER_PORT, String.valueOf(properties.getGafferPort()));
        rtn.put(CONNECT_TIMEOUT, String.valueOf(properties.getConnectTimeout()));
        rtn.put(READ_TIMEOUT, String.valueOf(properties.getReadTimeout()));
        rtn.put(URL_INFERRED, properties.getGafferUrl().toString());
        return rtn;
    } catch (final Exception e) {
        throw new OperationException("Error making return string map", e);
    }
}
Also used : GetProxyProperties(uk.gov.gchq.gaffer.proxystore.operation.GetProxyProperties) ProxyProperties(uk.gov.gchq.gaffer.proxystore.ProxyProperties) HashMap(java.util.HashMap) OperationException(uk.gov.gchq.gaffer.operation.OperationException) OperationException(uk.gov.gchq.gaffer.operation.OperationException)

Example 2 with ProxyProperties

use of uk.gov.gchq.gaffer.proxystore.ProxyProperties in project Gaffer by gchq.

the class DoubleProxyTest method setUpStores.

@BeforeEach
public void setUpStores() throws OperationException {
    SingleUseProxyMapStore.cleanUp();
    ProxyProperties proxyProperties = new ProxyProperties();
    proxyProperties.setStoreClass(SingleUseProxyMapStore.class);
    // this direct Proxy to the RestMapStore can be ignored, unless adding elements is desired.
    Graph ignore = new Graph.Builder().storeProperties(proxyProperties).config(new GraphConfig("RestApiGraph")).addSchema(Schema.fromJson(getClass().getResourceAsStream("/schema/basicEntitySchema.json"))).build();
    federatedStoreGraph = new Graph.Builder().config(new GraphConfig("federatedStoreGraph")).storeProperties(new FederatedStoreProperties()).build();
    connectGraphs("RestProxy1");
    connectGraphs("RestProxy2");
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) ProxyProperties(uk.gov.gchq.gaffer.proxystore.ProxyProperties) AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) Graph(uk.gov.gchq.gaffer.graph.Graph) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with ProxyProperties

use of uk.gov.gchq.gaffer.proxystore.ProxyProperties in project Gaffer by gchq.

the class FederatedStoreToFederatedStoreTest method setUpStores.

@BeforeEach
public void setUpStores() throws OperationException {
    SingleUseFederatedStore.cleanUp();
    ProxyProperties proxyProperties = new ProxyProperties();
    proxyProperties.setStoreClass(SingleUseFederatedStore.class);
    restApiFederatedGraph = new Graph.Builder().storeProperties(proxyProperties).config(new GraphConfig("RestApiGraph")).addSchema(new Schema()).build();
    federatedStoreGraph = new Graph.Builder().config(new GraphConfig("federatedStoreGraph")).storeProperties(new FederatedStoreProperties()).build();
    connectGraphs();
    addMapStore();
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) ProxyProperties(uk.gov.gchq.gaffer.proxystore.ProxyProperties) AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) Graph(uk.gov.gchq.gaffer.graph.Graph) Schema(uk.gov.gchq.gaffer.store.schema.Schema) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with ProxyProperties

use of uk.gov.gchq.gaffer.proxystore.ProxyProperties in project Gaffer by gchq.

the class FederatedStoreRecursionIT method createInnerProxyToOuterFederatedStore.

protected void createInnerProxyToOuterFederatedStore() throws OperationException {
    ProxyProperties storeProperties = new ProxyProperties();
    storeProperties.setReadTimeout(120000);
    storeProperties.setConnectTimeout(120000);
    proxyToRestServiceFederatedGraph.execute(new FederatedOperationChain.Builder<>().operationChain(OperationChain.wrap(new AddGraph.Builder().graphId(INNER_PROXY).schema(new Schema()).storeProperties(storeProperties).build())).build(), user);
}
Also used : ProxyProperties(uk.gov.gchq.gaffer.proxystore.ProxyProperties) FederatedOperationChain(uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperationChain) Schema(uk.gov.gchq.gaffer.store.schema.Schema)

Example 5 with ProxyProperties

use of uk.gov.gchq.gaffer.proxystore.ProxyProperties in project gaffer-doc by gchq.

the class ExportToOtherGraphExample method simpleToOtherGafferRestApi.

public void simpleToOtherGafferRestApi() {
    // ---------------------------------------------------------
    final ProxyProperties proxyProperties = new ProxyProperties();
    proxyProperties.setStoreClass(ProxyStore.class);
    proxyProperties.setStorePropertiesClass(ProxyProperties.class);
    proxyProperties.setGafferHost("localhost");
    proxyProperties.setGafferPort(8081);
    proxyProperties.setGafferContextRoot("/rest/v1");
    final OperationChain<Iterable<? extends Element>> opChain = new OperationChain.Builder().first(new GetAllElements.Builder().view(new View.Builder().edge("edge").build()).build()).then(new ExportToOtherGraph.Builder().graphId("otherGafferRestApiGraphId").storeProperties(proxyProperties).build()).build();
    // ---------------------------------------------------------
    showExample(opChain, "This example will export all Edges with group 'edge' to another Gaffer REST API." + "To export to another Gaffer REST API, we go via a Gaffer Proxy Store. We just need to tell the proxy store the host, port and context root of the REST API." + "Note that you will need to include the proxy-store module as a maven dependency to do this.");
}
Also used : ProxyProperties(uk.gov.gchq.gaffer.proxystore.ProxyProperties) ExportToOtherGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph) Element(uk.gov.gchq.gaffer.data.element.Element) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View)

Aggregations

ProxyProperties (uk.gov.gchq.gaffer.proxystore.ProxyProperties)10 BeforeEach (org.junit.jupiter.api.BeforeEach)4 GraphConfig (uk.gov.gchq.gaffer.graph.GraphConfig)4 Schema (uk.gov.gchq.gaffer.store.schema.Schema)4 AddGraph (uk.gov.gchq.gaffer.federatedstore.operation.AddGraph)3 Graph (uk.gov.gchq.gaffer.graph.Graph)3 HashMap (java.util.HashMap)2 GetProxyProperties (uk.gov.gchq.gaffer.proxystore.operation.GetProxyProperties)2 User (uk.gov.gchq.gaffer.user.User)2 URL (java.net.URL)1 Test (org.junit.jupiter.api.Test)1 Element (uk.gov.gchq.gaffer.data.element.Element)1 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)1 FederatedOperationChain (uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperationChain)1 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)1 OperationException (uk.gov.gchq.gaffer.operation.OperationException)1 ExportToOtherGraph (uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph)1 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)1 Context (uk.gov.gchq.gaffer.store.Context)1 Store (uk.gov.gchq.gaffer.store.Store)1