Issues with binary storage.
mickeyteg Jan 9, 2013 8:44 AMHi - I am new to ModeShape and Java. My intention is to develop a distributed file server application which will server clients over WebDav and through URL. The files will be replicated to other sever in different geographies. In am currently testing the Binary file store example and could not able to create a persistent store.
I see that the Binary store is unable to create a store and using the temp directory of windows. I know if the infinispan-configuration.xml is configured properly, it will end up creating a temp store. I couldn't figure out where I am going wrong. Here are resource files. Also, please help me with the approach I should take for my use case.
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.net.URL; import javax.jcr.Node; import javax.jcr.Repository; import javax.jcr.RepositoryException; import javax.jcr.Session; import org.modeshape.common.collection.Problems; import org.modeshape.jcr.ModeShapeEngine; import org.modeshape.jcr.RepositoryConfiguration; /** * * @author test */ public class ModeShapeTest1 { /** * @param args the command line arguments */ public static void main(String[] args) { // Create and start the engine ... ModeShapeEngine engine = new ModeShapeEngine(); engine.start(); // Load the configuration for a repository via the classloader (can also use path to a file)... Repository repository = null; String repositoryName = null; try { URL url = ModeShapeTest1.class.getClassLoader().getResource("my-repository-config.json"); System.out.println(url); RepositoryConfiguration config = RepositoryConfiguration.read(url); System.out.println("Cache Config : "+ config.getStoreName()); Long lng = config.getBinaryStorage().getMinimumBinarySizeInBytes(); System.out.println(lng); // We could change the name of the repository programmatically ... // config = config.withName("Some Other Repository"); // Verify the configuration for the repository ... Problems problems = config.validate(); if (problems.hasErrors()) { System.err.println("Problems starting the engine."); System.err.println(problems); System.exit(-1); } // Deploy the repository ... repository = engine.deploy(config); repositoryName = config.getName(); System.out.println(repositoryName + " Storage : " + config.getStoreName()); } catch (Throwable e) { e.printStackTrace(); System.exit(-1); return; } Session session = null; try { // Get the repository repository = engine.getRepository(repositoryName); // Create a session ... session = repository.login("default"); // Get the root node ... Node root = session.getRootNode(); assert root != null; session.save(); root.addNode("MyNode1"); System.out.println("Found the root node in the \"" + session.getWorkspace().getName() + "\" workspace"); } catch (RepositoryException e) { e.printStackTrace(); } finally { if (session != null) session.logout(); System.out.println("Shutting down engine ..."); try { engine.shutdown().get(); System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(); } } } }
-------------------------------- my-repository-config.json -------------------------------- { "name" : "Data-Repository", "workspaces" : { "predefined" : ["otherWorkspace"], "default" : "default", "allowCreation" : true }, "security" : { "anonymous" : { "roles" : ["readonly","readwrite","admin"], "useOnFailedLogin" : false } }, "storage" : { "cacheConfiguration" : "Configuration.xml", "cacheName" : "DataRepository", "binaryStorage" : { "type" : "file", "directory" : "store", "minimumBinarySizeInBytes" : 512 } } }
--------------------------------------- infinispan-configuration.xml --------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:infinispan:config:5.1 http://www.infinispan.org/schemas/infinispan-config-5.1.xsd" xmlns="urn:infinispan:config:5.1"> <global/> <namedCache name="DataRepository"> <transaction transactionManagerLookupClass ="org.infinispan.transaction.lookup.DummyTransactionManagerLookup" transactionMode ="TRANSACTIONAL" lockingMode ="OPTIMISTIC"/> <loaders passivation ="false" shared ="false" preload ="false"> <loader class ="org.infinispan.loaders.file.FileCacheStore" fetchPersistentState ="false" purgeOnStartup ="false"> <properties> <property name ="location" value="store"/> </properties> </loader> </loaders> </namedCache> </infinispan>
------------------- Output Logs ------------------ run: file:/C:/Documents%20and%20Settings/test/My%20Documents/NetBeansProjects/ModeShapeTest1/build/classes/my-repository-config.json Cache Config : DataRepository //I see its picking up values from JSON file 512 Data-Repository Storage : DataRepository Jan 9, 2013 5:33:13 PM org.modeshape.jcr.ModeShape <clinit> INFO: Initializing ModeShape version 3.0.1.Final Jan 9, 2013 5:33:13 PM org.modeshape.jcr.value.binary.TransientBinaryStore newTempDirectory INFO: ModeShape is using the following directory for transient storage of binary values: C:\DOCUME~1\test\LOCALS~1\Temp Jan 9, 2013 5:33:14 PM org.infinispan.factories.GlobalComponentRegistry start INFO: ISPN000128: Infinispan version: Infinispan 'Brahma' 5.1.2.FINAL Jan 9, 2013 5:33:17 PM org.hibernate.search.Version <clinit> INFO: HSEARCH000034: Hibernate Search 4.1.1.Final Jan 9, 2013 5:33:17 PM org.hibernate.annotations.common.Version <clinit> INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final} Jan 9, 2013 5:33:18 PM org.hibernate.search.indexes.serialization.avro.impl.AvroSerializationProvider <init> INFO: HSEARCH000079: Serialization protocol version 1.0 Found the root node in the "default" workspace Shutting down engine ... Success! BUILD SUCCESSFUL (total time: 8 seconds)