Where is the Mashup API endpoint?
For the default application: http://<HOSTNAME>:<BASEPORT+10>/access
For every other applications: http://<HOSTNAME>:<BASEPORT+10>/access.<applicationId>
You interact with the Mashup API using the
AccessClient example ServerInfos serverInfos = new ServerInfos("http://host:10010/access"); AccessClient client = AccessClientFactory.createAccessClient(new ServerInfos[] { serverInfos }); AccessRequest request = new AccessRequest(); request.setPage("search"); request.addParameter("q", "disney"); ResultFeed result = client.getResultFeed(request); Note:
SERVICE_URI is the Mashup API endpoint where the
AccessClient should make the requests.
Where is the Mashup API endpoint?For the default application: For every other applications: How to configure a proxyServerInfos serverInfos = new ServerInfos("http://HOST:PORT/access"); serverInfos.setProxyHost("host"); serverInfos.setProxyPort(8080); serverInfos.setProxyLogin("login"); serverInfos.setProxyPassword("password"); AccessClient accessClient = AccessClientFactory.createAccessClient(new ServerInfos[] { serverInfos }); AccessRequest request = new AccessRequest(); request.setPage("search"); request.addParameter("q", "disney"); ResultFeed result = client.getResultFeed(request); How to send security tokens to a secured Search APIRequirement: To send security tokens, you must first enable security on your Mashup UI pages. For more information, see Adding Security to Your Application in the Exalead CloudView Mashup Builder User's Guide. You can then list security tokens as follows: ServerInfos serverInfos = new ServerInfos("http://HOST:PORT/access"); AccessClient client = AccessClientFactory.createAccessClient(new ServerInfos[] {serverInfos }); List<String> tokens = new ArrayList<String>(); tokens.add("Everybody"); AccessRequest request = new AccessRequest(); request.addParameters(AccessParameter.SECURITY, tokens); request.setPage("search"); request.addParameter("q", "disney"); ResultFeed result = client.getResultFeed(request); How to configure failoverTo enable failover, you must specify the
ServerInfos host1 = new ServerInfos("http://HOST1:PORT/access"); host1.setIsAlivePath("/admin/isAlive"); host1.setPower(1); ServerInfos host2 = new ServerInfos("http://HOST2:PORT/access"); host2.setIsAlivePath("/admin/isAlive"); host2.setPower(10); AccessClient accessClient = AccessClientFactory.createAccessClient(new ServerInfos[] { host1, host2 }); AccessRequest request = new AccessRequest(); request.setPage("search"); request.addParameter("q", "disney"); ResultFeed result = client.getResultFeed(request); How to configure the max number of concurrent connections to the distant hostServerInfos serverInfos = new ServerInfos("http://HOST:PORT/access"); Properties options = new Properties(); options.put("http.max_number_of_connections_per_server", 10); AccessClient accessClient = AccessClientFactory.createAccessClient(new ServerInfos[] { serverInfos }, options); AccessRequest request = new AccessRequest(); request.setPage("search"); request.addParameter("q", "disney"); ResultFeed result = client.getResultFeed(request); How to configure the stale connection checkSee Apache documentation:
ServerInfos serverInfos = new ServerInfos("http://HOST:PORT/access"); Properties options = new Properties(); options.put("http.commons-httpclient.stale_checking_enabled", "true"); AccessClient accessClient = AccessClientFactory.createAccessClient(new ServerInfos[] { serverInfos }, options); AccessRequest request = new AccessRequest(); request.setPage("search"); request.addParameter("q", "disney"); ResultFeed result = client.getResultFeed(request); How to configure a socket read timeoutThe following code snippet shows how to configure a socket read timeout
to ServerInfos serverInfos = new ServerInfos("http://HOST:PORT/access"); Properties options = new Properties(); options.put("http.socket.timeout", 5000); // 5 seconds timeout AccessClient accessClient = AccessClientFactory.createAccessClient(new ServerInfos[] { serverInfos }, options); AccessRequest request = new AccessRequest(); request.setPage("search"); request.addParameter("q", "disney"); ResultFeed result = client.getResultFeed(request); |