Using the Proxy in a Non-Secure kvstore
Starting up the Proxy
Use the following command to start up the proxy for a non-secure kvstore.
java -jar lib/httpproxy.jar \
-storeName <kvstore_name> \
-helperHosts <kvstore_helper_host> \
[-hostname <proxy_host>] \
[-httpPort <proxy_http_port>]
where,kvstore_name
is the kvstore's store name obtained from the kvstore deployment. See ping.kvstore_helper_host
is the kvstore's helper host:port list obtained from the kvstore deployment. See Obtaining a KVStore Handle in the Java Direct Driver Developer's Guide.proxy_host
is the hostname of the machine to host the proxy service. If the proxy is to be accessed from machines other than the one on which it is started this should be the hostname of the machine running the proxy. This parameter is optional and defaults tolocalhost
.proxy_http_port
is the port on which the proxy is watching for requests on its host machine. This is an optional parameter and defaults to 80.Note:
Use of port 80 may require additional privileges, depending on your machine.
Connect to the Proxy using Java
The Oracle NoSQL Database Java Driver contains the jar files that enable a Java application to communicate with the proxy.
Install the Java driver in the application's classpath and use the following code to connect to the proxy.
String endpoint = "http://<proxy_host>:<proxy_http_port>";
StoreAccessTokenProvider atProvider = new StoreAccessTokenProvider();
NoSQLHandleConfig config = new NoSQLHandleConfig(endpoint);
config.setAuthorizationProvider(atProvider);
NoSQLHandle handle = NoSQLHandleFactory.createNoSQLHandle(config);
where,
proxy_host
is the hostname of the machine to host the proxy service. This should match the host you configured earlier.proxy_http_port
is the port on which the proxy is watching for requests on its host machine. This should match the http port you configured earlier.
Connect to the Proxy using Python
The Oracle NoSQL Database Python Driver contains the files that enable a Python application to communicate with the proxy.
See Connect to the Proxy Using Python for more information.
Connect to the Proxy using Go
The Oracle NoSQL Database Go SDK contains the files that enable a Go application to communicate with the proxy.
See Connect to the Proxy using Go for more information.
Connect to the Proxy using Node.js
The Oracle NoSQL Database Node.js SDK contains the files that enable a Node.js application to communicate with the proxy.
See Connect to the Proxy using Node.js for more information.
Connect to the Proxy using .NET
The Oracle NoSQL Database .NET SDK contains the files that enable a .NET application to communicate with the proxy.
See Connect to the Proxy using .NET for more information.
Connect to the Proxy using Spring Data
The Oracle NoSQL Database Spring Data SDK contains the files that enable a Spring Data application to communicate with the proxy.
Install the Java driver in the application's classpath. Use the following code to connect to the proxy.
configuration
Spring bean provides a NosqlDbConfig
object. You can use the StoreAccessTokenProvider
class to configure the Spring Data Framework to connect to an Oracle NoSQL Database store.
import com.oracle.nosql.spring.data.config.AbstractNosqlConfiguration;
import com.oracle.nosql.spring.data.config.NosqlDbConfig;
import com.oracle.nosql.spring.data.repository.config.EnableNosqlRepositories;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import oracle.nosql.driver.kv.StoreAccessTokenProvider;
@Configuration
@EnableNosqlRepositories
public class AppConfig extends AbstractNosqlConfiguration {
@Bean
public NosqlDbConfig nosqlDbConfig() {
AuthorizationProvider authorizationProvider;
authorizationProvider = new StoreAccessTokenProvider();
return new NosqlDbConfig("http://<proxy_host:proxy_http_port>", authorizationProvider);
}
}
proxy_host
is the hostname of the machine to host the proxy service.proxy_http_port
is the port on which the proxy is watching for requests on its host machine.
Example
In the following example you start a proxy instance on the local machine called myhost
using HTTP port 8080. It will connect to an Oracle NoSQL Database instance name kvstore
that is running on 2 hosts, kvhost1
and kvhost2
, both on port 5000.
Start up a non-secure kvstore
- Start the proxy in the
localhost
using 8080 as thehttpPort
.java -jar lib/httpproxy.jar \ -storeName kvstore \ -helperHosts kvhost1:5000,kvhost2:5000 \ -httpPort 8080 \ -verbose true
- In the application, run the following code to connect to the proxy.
String endpoint = "http://localhost:8080"; StoreAccessTokenProvider atProvider = new StoreAccessTokenProvider(); NoSQLHandleConfig config = new NoSQLHandleConfig(endpoint); config.setAuthorizationProvider(atProvider); NoSQLHandle handle = NoSQLHandleFactory.createNoSQLHandle(config);
- See Oracle NoSQL Database Drivers to add CRUD operations for the example as needed.