can we use solr as persistent store for apache ignite? - solr

I have been working to integrate solr and apache ignite.....while I am trying to run the program write
class org.apache.ignite.IgniteCheckedException: Cannot enable write-behind (writer or store is not provided) for cache
this error is shown
CacheConfiguration textMetaConfig = new CacheConfiguration<>("textMetaCache");
textMetaConfig.setWriteThrough(true);
textMetaConfig.setReadThrough(true);
textMetaConfig.setAtomicityMode(CacheAtomicityMode.ATOMIC);
textMetaConfig.setWriteBehindEnabled(true);
textMetaConfig.setWriteBehindFlushSize(40960);
textMetaConfig.setWriteBehindFlushFrequency(1);
textMetaConfig.setWriteBehindFlushThreadCount(5);
textMetaConfig.setCacheMode(CacheMode.PARTITIONED);
textMetaConfig.setIndexedTypes(String.class, TextMeta.class);
this is how i have configured cache

You can implement the CacheStore interface to integrate with any kind of persistence storage. Out of the box Ignite provides Cassandra store implementation and JDBC store implementation which covers most of the regular relational databases. For anything else you will have to create your own implementation. And in any case, the store must be configured via CacheConfiguration.setCacheStoreFactory(..) configuration property. Please refer to this page for details: https://apacheignite.readme.io/docs/persistent-store

Related

How to test Spring database down?

I have this SpringBoot server app using PostgreSQL database if it's up and sending error response if it's down. So my app is running regardless the database connection.
I would very much like to test it (jUnit / mockmvc).
My question is very simple, yet I did not find the answer online:
how does one simulate a database connection loss in SpringBoot?
If anyone wants, I can supply code (project is up at https://github.com/k-wasilewski/workshop/)
Have you thought of Testcontainers? You can spin up your docker image through a Junit test and make your spring boot use that as your database.
Since you use junit, you can start/stop this container at will.
This will generate a test which creates the condition you are looking for and write code as to what to expect when the database is down.
Here are some links to get started,
Testcontainers and Junit4 with Testcontainers quickstart - https://www.testcontainers.org/quickstart/junit_4_quickstart/
Spring boot documentation - Use Testcontainers for integration testing
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-testcontainers
Testcontainer github link example for springboot app
https://github.com/testcontainers/testcontainers-java/tree/master/examples/spring-boot
Testcontainer - Generic container javadoc. You can find methods for start/stop
container here. call from your Junit.
https://javadoc.io/static/org.testcontainers/testcontainers/1.12.4/org/testcontainers/containers/GenericContainer.html
You can implement your own Datasource based on DelegatingDataSource and then let it throw exceptions instead of delegating when ever you want to.
I've done this before by creating a Spring Boot test configuration class that created the DataSource and wrapped it in a Java proxy. The proxy simply passed method calls down to the underlying DataSource, until a certain flag was set. Once the flag was set, then any method called on the proxy would throw an exception without calling the underlying DataSource. Essentially, this allowed me to "bring the database down" or "up" simply by flipping the flag.

Where to find the OSB Business service configuration details in the underlying database?

In OSB Layer when the endpoint uri is changed, I need to alert the core group that the endpoint has changed and to review it. I tried SLA Alert rules but it does not have options for it. My question is, the endpoint uri should be saved somewhere in the underlying database. If so what is the schema and the table name to query it.
URI or in fact any other part of OSB artifact is not stored in relational database but rather kept in memory in it's original XML structure. It can be only accessed thru dedicated session management API. Interfaces you will need to use are part o com.bea.wli.sb.management.configuration and com.bea.wli.sb.management.query packages. Unfortunately it is not as straightforward as it sounds, in short, to extract URI information you will need to:
Create session instance(SessionManagementMBean)
Obtain ALSBConfigurationMBean instance that operates on SessionManagementMBean
Create Query object instance(BusinessServiceQuery) an run it on ALSBConfigurationMBean to get ref object to osb artifact of your interest
Invoke getServiceDefinition on your ref object to get XML service
definition
Extract URI from XML service definition with XPath
Downside of this approach is that you are basically pooling configuration each time you want to check if anything has changed.
More information including JAVA/WLST examples can be found in Oracle Fusion Middleware Java API Reference for Oracle Service Bus
There is also a good blog post describing OSB customization with WLST ALSB/OSB customization using WLST
The information about services and all its properties can be obtained via Java API. The API documentation contains sample code, so you can get it up and running quite quickly, see the Querying resources paragraph when following the given link.
We use the API to read the service (both proxy and business) configuration and for simple management.
As long as you only read the properties you do not need to handle management sessions. Once you change the values, you need to start a session and activate it once you are done -- a very similar approach to Service bus console.

Distribute Solr Using Replication without Using SolrCloud

I want to use Solr replication without using SolrCloud.
I have three Solr servers, one is master and others are slave.
How to dispatch the search query on the Solr server which isn't busy?
What tools do and how to lead?
You can use any load balancer - Solr talks HTTP, which makes any existing load balancing technology available. HAProxy, varnish, nginx, etc. will all work as you expect, and you'll be able to use all the advanced features that the different packages offer. It'll also be independent of the client, meaning that you're not limited to the LBHttpSolrServer class from SolrJ or what your particular client offers. Certain LB solutions also offer high throughput caching (varnish) or dynamic real time fallover between live nodes.
Another option we've also used successfully is to replicate the core to each web node, allowing us to always query localhost for searching.
You have configured solr in master-slave mode. I think you can use LBHttpSolrServer from solrj api for querying the solr. You need to send the update requests to master node explicitly. The LBHttpSolrServer will provide you the load balancing among all the specified nodes. In the master-slave mode, slave are responsible for keeping themselves updated with the master.
Do NOT use this class for indexing in master/slave scenarios since documents must be sent to the correct master; no inter-node routing is done. In SolrCloud (leader/replica) scenarios, this class may be used for updates since updates will be forwarded to the appropriate leader.
I hope this will help.
apache camel can be used for general load balancer. like this:
public class LoadBalancer {
public static void main(String args[]) throws Exception {
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
public void configure() {
from("jetty://http://localhost:8080")
.loadBalance().roundRobin().to("http://172.28.39.138:8080","http://172.168.20.118:8080");
}
});
context.start();
Thread.sleep(100000);
context.stop();
}
}
There is some other materials maybe useful:
Basic Apache Camel LoadBalancer Failover Example
http://camel.apache.org/load-balancer.html
But is seems there are not straight way to solr-camel integration, because camel can be used to balance the requests upon he java "Beans" components
http://camel.apache.org/loadbalancing-mina-example.html
There is another useful example:
https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/CustomLoadBalanceTest.java
And you can use camel as a proxy between client and server
http://camel.apache.org/how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html
There are some presentation to beginning with apache camel,its approach and architecture:
http://www.slideshare.net/ieugen222/eip-cu-apache-camel

What are the differences between mobiledata and cloudant services?

hello I am analyzing these two services to use In my app, and I could not find some doc about the difference between these two services. I know that mobiledata extends the cloudant, but what are the pro and cons? In my case I need to have more control above the data, for example create views (I could not create In mobiledata service) etc
So, do you know what the main divergences between these two services? When to use mobile data or cloudant?
Thanks
There are three ways to use Cloudant on Bluemix from an iOS application:
Use Cloudant directly by adding it as a service to your application.
Use MobileFirst for iOS, the Data part specifically (currently beta).
Use the Mobile Data cross-platform SDK.
(1) and (2) allow you to use views within Cloudant by adding them
via either the Cloudant dashboard or by using the Cloudant HTTP API.
(3) is a service which uses Cloudant in the background, but provides
no direct access to your data using the Cloudant HTTP API; you're
limited to the services exposed by the SDK. Therefore you can't use
many Cloudant features like views or Cloudant Query. Think of
Cloudant more as an implementation detail here, rather than an
exposed component as it is for (1) and (2).
Therefore, (1) or (2) is probably more suitable for your needs as
you mention wanting to use views.
Backend of mobile data service of bluemix is cloudant.For details please refer below link on getting started:
https://www.ibm.com/developerworks/cloud/library/cl-rapiddev-app/
http://www.techrepublic.com/blog/the-enterprise-cloud/managing-your-databases-in-the-cloud-how-cloudant-does-it/
https://www.ibm.com/developerworks/cloud/library/cl-rapiddev-app/
P.S- Cloudant is no-sql(create view wont be supported) DBAAS
For details on no-sql,please follow below link:
http://www.zdnet.com/article/what-is-nosql-and-why-do-you-need-it/
Cloudant is the IBM bluemix mobile data backend. And yes you can build sorted secondary key:value indexes, called "views" using JavaScript MapReduce functions.
Here is an example :
map: function(doc){
if (doc.rep){ emit({"rep": doc.rep}, doc.amount); }
}
reduce: _sum
For more details you can refer these links :
http://examples.cloudant.com/sales/_design/sales/index.html
http://examples.cloudant.com/sales/_design/sales/index.html#basic
http://examples.cloudant.com/whatwouldbiebersay/_design/whatwouldbiebersay/index.html
For mobiledata cloudant is acting behind the scenes. Cloudant is an open source
non-relational, distributed database service of the same name that requires zero-configuration.
Cloudant is based on the Apache-backed CouchDB project and the open source BigCouch
project.
Please follow below link for more details:
https://cloudant.com/cloudant-ibm-bluemix-tutorials-and-demos/

Grails: updating hibernate after externally loading data

I have a grails application. I'd like to load data into the underlying database with something external to grails, perl, specifically. I know I have to update the hibernate sequence after external data loading, otherwise on the next create object in grails, hibernate throws an exception; but is there anything else I need to update? Do I have to clear the hibernate cache, for instance? This would seem to be a very common issue, but there's no discussion of it in the grails docs. Thanks.
Found this
http://grails.1312388.n4.nabble.com/Accessing-the-2nd-level-cache-to-allow-it-to-be-cleared-via-a-controller-or-service-td1390985.html
Hibernate has APIs for this. You can get the query cache via sessionFactory.getQueryCache() and clear it using
sessionFactory.queryCache.clear()
You can access a cache for a domain classes using its full class name, e.g.
def cache = sessionFactory.getSecondLevelCacheRegion('com.foo.bar.Book')
and clear it via
sessionFactory.getSecondLevelCacheRegion('com.foo.bar.Book').clear()
You can also call evict() on the sessionFactory for an entire class
sessionFactory.evict(com.foo.bar.Book)
or for an individual instance
sessionFactory.evict(com.foo.bar.Book, 42)

Resources