JDeveloper can be used to run cache server ( DefaultCacheServer) and cache ( CacheFactory) instances. WEB-INF/classes/tangosol-coherence-override.xml The archive should contain the following files For example, issue the following command from a command prompt at the root of the Web application directory: The cache factory instance starts and becomes a member of the cluster and returns a command prompt for the command-line tool.Īt the command-line tool command prompt, get the hello-example cache using the cache command:Īt the command-line tool command prompt, retrieve the contents of the cache using the list command.Ĭopy the following empty Web application deployment descriptor to a text file and save the file as web.xml in the /WEB-INF directory.Ĭopy the coherence.jar file to the WEB-INF/lib directory.Ĭopy the example-config.xml file and the tangosol-coherence-override.xml file to the WEB-INF/classes directory.Ĭreate a Web ARchive file (WAR) using the jar utility and save the file as hello.war. Java -cp COHERENCE_HOME\lib\coherence.jar COHERENCE_HOME\config It demonstrates both the persistent and distributed nature of Coherence caches.įrom a command prompt, start a standalone connection factory instance using the CacheFactory class and include the location of the coherence.jar library and the configuration files as a Java -cp option. This step uses the connection factory command-line tool to connect to the hello-example cache and list all items in the cache. However, the cache and key are still available for all cluster members. For example, the Hello World application exits after it loads and displays a key in the cache. The data is available to all members of the cluster and persists even after members leave the cluster. The cache server in this example is configured, by default, to store the cache's data. Save the file to the same directory where the example-config.xml file was saved.įrom a command prompt, start a cache server instance using the DefaultCacheServer class and include the location of the coherence.jar library and the configuration files as a Java -cp option. For example, use your name for the cluster name and the last four digits of your phone number for the port. To configure and start the example cluster:Ĭreate a file named tangosol-coherence-override.xml.Īdd the following override configuration and replace cluster_name and port with values that are unique for this cluster. The default configuration is also modified to load the example-config.xml cache configuration file instead of the default cache configuration file. In particular, the default configuration is modified to create a private cluster which ensures that the two processes do not attempt to join an existing Coherence cluster that may be running on the network. The example cluster uses an operational override file to modify the out-of-box default cluster configuration. The cache server, by default, is configured to store cache data. For simplicity, the two processes are collocated on a single machine. For the sample applications in this chapter, two separate Java processes form the cluster: a cache server process and the Hello World application process. When a JVM joins the cluster, it is called a cluster node, or alternatively, a cluster member. At run time, any JVM process that is running Coherence automatically joins the cluster and can access the caches and other services provided by the cluster. Step 2: Configure and Start the Example ClusterĬaches are hosted on a Coherence cluster. The following cache configuration defines a basic distributed cache which is mapped to the cache name hello-example.Ĭreate an XML file named example-config.xml.Ĭopy the following distributed cache definition to the file: This allows configuration changes to be made to a cache without having to change an application's code. Caches are defined in a cache configuration deployment descriptor and are referred to by name within an application.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |