Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update to Modeshape 4.0 and Infinispan 6.x
  • Loading branch information
cbeer committed May 5, 2014
1 parent fc0c981 commit c0aefee
Show file tree
Hide file tree
Showing 28 changed files with 509 additions and 1,129 deletions.
2 changes: 1 addition & 1 deletion fcrepo-auth-roles-basic/src/test/resources/repository.json
Expand Up @@ -8,7 +8,7 @@
},
"storage" : {
"cacheName" : "FedoraRepository",
"cacheConfiguration" : "${fcrepo.infinispan.cache_configuration:config/infinispan/leveldb/infinispan.xml}",
"cacheConfiguration" : "${fcrepo.infinispan.cache_configuration:config/infinispan/leveldb-default/infinispan.xml}",
"binaryStorage" : {
"type" : "cache",
"dataCacheName" : "FedoraRepositoryBinaryData",
Expand Down
@@ -1,38 +1,28 @@
<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:5.2 http://www.infinispan.org/schemas/infinispan-config-5.2.xsd"
xmlns="urn:infinispan:config:5.2">
xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd
urn:infinispan:config:store:leveldb:6.0 http://infinispan.org/schemas/infinispan-cachestore-leveldb-config-6.0.xsd
"
xmlns="urn:infinispan:config:6.0" xmlns:store="urn:infinispan:config:store:leveldb:6.0">

<global>
<globalJmxStatistics enabled="false" allowDuplicateDomains="true"/>
</global>

<default>
<expiration wakeUpInterval="-1" />
<unsafe unreliableReturnValues="true" />
<unsafe unreliableReturnValues="true" />
</default>

<namedCache name="FedoraRepository">

<eviction maxEntries="500" strategy="LIRS" threadPolicy="PIGGYBACK"/>

<transaction
transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup"
transactionMode="TRANSACTIONAL" lockingMode="PESSIMISTIC"/>

<!-- Define the cache loaders (i.e., cache stores). Passivation is false
because we want *all* data to be persisted, not just what doesn't fit
into memory. Shared is false because there are no other caches sharing
this file store. We set preload to false for lazy loading; may be
improved by preloading and configuring eviction. We can have multiple
cache loaders, which get chained. But we'll define just one. -->

<loaders passivation="false" shared="false" preload="false">
<leveldbStore xmlns="urn:infinispan:config:leveldb:5.2"
fetchPersistentState="true"
location="${fcrepo.ispn.repo.CacheDirPath:target}/data"
expiredLocation="${fcrepo.ispn.repo.CacheDirPath:target}/expired">
</leveldbStore>
</loaders>
transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup"
transactionMode="TRANSACTIONAL"
lockingMode="PESSIMISTIC"/>

<persistence passivation="false">
<store:leveldbStore location="${fcrepo.ispn.repo.CacheDirPath:target}/data" expiredLocation="${fcrepo.ispn.repo.CacheDirPath:target}/expired"/>
</persistence>
</namedCache>

</infinispan>
Expand Up @@ -6,20 +6,6 @@
"default" : "default",
"allowCreation" : true
},
"query" : {
"enabled" : "${fcrepo.modeshape.query.enabled:true}",
"indexStorage" : {
"type" : "filesystem",
"location" : "${fcrepo.modeshape.index.location:target/indexes}",
"lockingStrategy" : "native",
"fileSystemAccessType" : "auto"
},
"rebuildUponStartup" : "if_missing",

"indexing" : {
"mode" : "${fcrepo.modeshape.query.mode:sync}"
}
},
"storage" : {
"cacheName" : "FedoraRepository",
"cacheConfiguration" : "${fcrepo.infinispan.cache_configuration:config/infinispan/leveldb-default/infinispan.xml}",
Expand Down
Expand Up @@ -33,8 +33,8 @@

import org.infinispan.schematic.document.Document;
import org.modeshape.connector.filesystem.FileSystemConnector;
import org.modeshape.jcr.federation.spi.DocumentReader;
import org.modeshape.jcr.federation.spi.DocumentWriter;
import org.modeshape.jcr.spi.federation.DocumentReader;
import org.modeshape.jcr.spi.federation.DocumentWriter;
import org.modeshape.jcr.value.BinaryValue;
import org.modeshape.jcr.value.Name;
import org.modeshape.jcr.value.Property;
Expand Down
Expand Up @@ -25,7 +25,7 @@
import org.modeshape.jcr.ExecutionContext;
import org.modeshape.jcr.api.nodetype.NodeTypeManager;
import org.modeshape.jcr.cache.document.DocumentTranslator;
import org.modeshape.jcr.federation.spi.ExtraPropertiesStore;
import org.modeshape.jcr.spi.federation.ExtraPropertiesStore;
import org.modeshape.jcr.value.BinaryValue;
import org.modeshape.jcr.value.NameFactory;
import org.modeshape.jcr.value.Property;
Expand Down
Expand Up @@ -27,6 +27,7 @@
import static org.junit.Assert.assertTrue;

import org.apache.http.client.methods.HttpGet;
import org.junit.Ignore;
import org.junit.Test;

import com.hp.hpl.jena.update.GraphStore;
Expand Down
16 changes: 8 additions & 8 deletions fcrepo-http-api/src/test/resources/test_repository.json
Expand Up @@ -16,14 +16,14 @@
}
},
"externalSources" : {
"fileSystem" : {
"classname" : "org.fcrepo.connector.file.FedoraFileSystemConnector",
"directoryPath" : "target/test-classes/test-objects",
"readonly" : false,
"extraPropertiesStorage": "json",
"cacheTtlSeconds" : 5,
"projections" : [ "default:/files => /" ]
}
"fileSystem" : {
"classname" : "org.fcrepo.connector.file.FedoraFileSystemConnector",
"directoryPath" : "target/test-classes/test-objects",
"readonly" : false,
"extraPropertiesStorage": "json",
"cacheTtlSeconds" : 5,
"projections" : [ "default:/files => /" ]
}
},
"security" : {
"anonymous" : {
Expand Down
Expand Up @@ -40,6 +40,7 @@
import org.infinispan.distexec.DefaultExecutorService;
import org.infinispan.distexec.DistributedExecutorService;
import org.modeshape.jcr.value.binary.infinispan.InfinispanBinaryStore;
import org.modeshape.jcr.value.binary.infinispan.InfinispanUtils;
import org.springframework.stereotype.Component;

/**
Expand Down Expand Up @@ -138,15 +139,15 @@ public static Long getContentSize(final Node ds) throws RepositoryException {
* A static factory function to insulate services from the details of
* building a DistributedExecutorService
*
* @param cache
* @param cacheStore
* @return
*/
public static DistributedExecutorService getClusterExecutor(
final InfinispanBinaryStore cacheStore) {
// Watch out! This is trying to pluck out the blob cache store. This
// works as long as
// modeshape continues to be ordered..
return new DefaultExecutorService(cacheStore.getCaches().get(1));
return new DefaultExecutorService(InfinispanUtils.getBlobCache(cacheStore));
}

/**
Expand Down

This file was deleted.

Expand Up @@ -21,13 +21,12 @@
import org.fcrepo.kernel.utils.FixityInputStream;
import org.fcrepo.kernel.utils.FixityResult;
import org.fcrepo.kernel.utils.FixityResultImpl;
import org.fcrepo.kernel.utils.infinispan.StoreChunkInputStream;
import org.fcrepo.kernel.utils.infinispan.CacheLoaderChunkInputStream;
import org.infinispan.Cache;
import org.infinispan.CacheImpl;
import org.infinispan.distexec.DistributedCallable;
import org.infinispan.loaders.CacheLoaderManager;
import org.infinispan.loaders.CacheStore;
import org.infinispan.loaders.decorators.ChainingCacheStore;
import org.infinispan.persistence.manager.PersistenceManager;
import org.infinispan.persistence.spi.CacheLoader;

import java.io.InputStream;
import java.io.Serializable;
Expand All @@ -46,40 +45,49 @@
public class DistributedFixityCheck implements DistributedCallable<String, byte[], Collection<FixityResult>>,
Serializable {
private final String dataKey;
private final int chunkSize;
private final long length;
private Cache<String, byte[]> cache;

/**
*
* @param dataKey
*/
public DistributedFixityCheck(final String dataKey) {
public DistributedFixityCheck(final String dataKey, final int chunkSize, final long length) {
this.dataKey = dataKey;
this.chunkSize = chunkSize;
this.length = length;
}

@Override
public Collection<FixityResult> call() throws Exception {
final ImmutableSet.Builder<FixityResult> fixityResults = new ImmutableSet.Builder<>();

for (final CacheStore store : stores()) {
for (final CacheLoader store : stores()) {

final String digest = ContentDigest.getAlgorithm(new URI("urn:sha1"));

FixityInputStream fixityInputStream;
final InputStream cacheLoaderChunkInputStream = new StoreChunkInputStream(store, dataKey);
final InputStream cacheLoaderChunkInputStream = new CacheLoaderChunkInputStream(store,
dataKey,
chunkSize,
length);

fixityInputStream = new FixityInputStream(cacheLoaderChunkInputStream, MessageDigest.getInstance(digest));
IOUtils.copy(fixityInputStream, NULL_OUTPUT_STREAM);

final URI calculatedChecksum = ContentDigest.asURI(digest, fixityInputStream.getMessageDigest().digest());
fixityResults.add(
new FixityResultImpl(getExternalIdentifier(store), fixityInputStream.getByteCount(), calculatedChecksum)
new FixityResultImpl(getExternalIdentifier(store),
fixityInputStream.getByteCount(),
calculatedChecksum)
);
}

return fixityResults.build();
}

private String getExternalIdentifier(final CacheStore store) {
private String getExternalIdentifier(final CacheLoader store) {
final String address;

if (cache.getCacheManager().getAddress() != null) {
Expand All @@ -96,13 +104,9 @@ public void setEnvironment(final Cache<String, byte[]> cache, final Set<String>
this.cache = cache;
}

private Set<CacheStore> stores() {
final CacheLoaderManager cacheLoaderManager
= ((CacheImpl) cache).getComponentRegistry().getLocalComponent(CacheLoaderManager.class);
if (cacheLoaderManager.getCacheLoader() instanceof ChainingCacheStore) {
return ((ChainingCacheStore)cacheLoaderManager.getCacheLoader()).getStores().keySet();
} else {
return ImmutableSet.of(cacheLoaderManager.getCacheStore());
}
private Set<CacheLoader> stores() {
return ((CacheImpl)cache).getComponentRegistry()
.getLocalComponent(PersistenceManager.class)
.getStores(CacheLoader.class);
}
}
Expand Up @@ -28,7 +28,9 @@
import org.fcrepo.kernel.utils.FixityResult;
import org.infinispan.distexec.DistributedExecutorService;
import org.modeshape.jcr.value.BinaryKey;
import org.modeshape.jcr.value.binary.infinispan.ChunkBinaryMetadata;
import org.modeshape.jcr.value.binary.infinispan.InfinispanBinaryStore;
import org.modeshape.jcr.value.binary.infinispan.InfinispanUtils;
import org.slf4j.Logger;

import javax.jcr.Property;
Expand All @@ -48,7 +50,6 @@
*/
public class InfinispanCacheStoreEntry extends LocalBinaryStoreEntry {
private static final Logger LOGGER = getLogger(InfinispanCacheStoreEntry.class);
private static final String DATA_SUFFIX = "-data";

/**
*
Expand All @@ -65,9 +66,12 @@ public Collection<FixityResult> checkFixity(final URI checksum, final long size)
final ImmutableSet.Builder<FixityResult> fixityResults = new ImmutableSet.Builder<>();

if (store().hasBinary(key)) {
final String dataKey = dataKeyFor(key);
final String dataKey = InfinispanUtils.dataKeyFrom((InfinispanBinaryStore)store(), key);
final ChunkBinaryMetadata metadata = InfinispanUtils.getMetadata((InfinispanBinaryStore)store(), key);

final DistributedFixityCheck task = new DistributedFixityCheck(dataKey);
final DistributedFixityCheck task = new DistributedFixityCheck(dataKey,
metadata.getChunkSize(),
metadata.getLength());
final List<Future<Collection<FixityResult>>> futures
= clusterExecutor().submitEverywhere(task, dataKey + "-0");

Expand All @@ -94,10 +98,6 @@ public Collection<FixityResult> checkFixity(final URI checksum, final long size)
return fixityResults.build();
}

private String dataKeyFor(final BinaryKey key) {
return key + DATA_SUFFIX;
}

private DistributedExecutorService clusterExecutor() {
return ServiceHelpers.getClusterExecutor((InfinispanBinaryStore)store());
}
Expand Down

0 comments on commit c0aefee

Please sign in to comment.