Skip to content

Commit

Permalink
First attempt at clustering, still failing
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Apr 19, 2013
1 parent c116597 commit 39fc9a7
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 27 deletions.
37 changes: 34 additions & 3 deletions pom.xml
Expand Up @@ -4,15 +4,42 @@
<groupId>demo</groupId>
<artifactId>node-goes-from-federated-to-ispn</artifactId>
<version>0.0.1-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-jcr</artifactId>
<version>3.2-SNAPSHOT</version>
</dependency>
</dependencies>
<dependency>
<groupId>org.jboss.jbossts</groupId>
<artifactId>jbossjta</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<!-- We could use SL4J with any other binding, but here we'll use Log4J -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.modeshape.bom</groupId>
<artifactId>modeshape-bom-embedded</artifactId>
<version>3.2-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -51,5 +78,9 @@
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>JBoss-Releases</id>
<url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
</repository>
</repositories>
</project>
52 changes: 28 additions & 24 deletions src/main/java/demo/Main.java
Expand Up @@ -2,7 +2,9 @@
package demo;

import static java.lang.System.exit;
import static java.lang.System.in;
import static java.lang.System.out;
import static java.lang.Thread.currentThread;
import static org.modeshape.jcr.RepositoryConfiguration.read;

import java.util.concurrent.ExecutionException;
Expand All @@ -26,65 +28,67 @@ public class Main {

JcrRepository repo;

static Session session;

private final String repoName = "repo";

private final static String repoConfig = "/repository.json";

public static void main(String[] args) {
try {
me.start();
Session session = me.repo.login();
public static void main(String[] args) throws Exception {

me.start();

// only take action if we have been run with a parameter
// otherwise we assume that this is a "cluster listener"
if (args.length > 0) {
try {

setup: {
session.getRootNode().addNode("nonfederated");
new JcrTools(true).uploadFileAndBlock(session, Main.class
.getResource("/thing2"), "/nonfederated");
}

action: {
final Workspace ws = session.getWorkspace();
ws.copy("/p1/thing1", "/nonfederated/thing1");
session.removeItem("/p1/thing1");
ws.copy("/nonfederated/thing2", "/p1/thing2");
session.removeItem("/nonfederated/thing2");
}

session.save();
session.logout();
session = me.repo.login();
session.save();

tests: {
assert !session.nodeExists("/p1/thing1") : "Shouldn't find /p1/thing1!";
assert session.nodeExists("/nonfederated/thing1") : "Should find /nonfederated/thing1!";
assert !session.nodeExists("/nonfederated/thing2") : "Shouldn't find /nonfederated/thing2!";
assert session.nodeExists("/p1/thing2") : "Should find /p1/thing2!";
}

session.save();
session.logout();
me.stop();
session.save();
session.logout();

} catch (Exception e) {
e.printStackTrace();
exit(1);
} catch (Exception e) {
e.printStackTrace();
exit(1);
}
}
in.read();
me.stop();
exit(0);

}

private void start() throws ConfigurationException, ParsingException,
RepositoryException {
engine.start();
out.println("Engine started...");
engine.deploy(read(this.getClass().getResource(repoConfig)));
assert (currentThread().getContextClassLoader()
.getResource("infinispan_configuration.xml")) != null : "Couldn't find ISPN config!";
repo = engine.deploy(read(this.getClass().getResource(repoConfig)));
out.println("Repo deployed...");
engine.startRepository(repoName);
out.println("Repo started...");
repo = engine.getRepository(repoName);
session = me.repo.login();
out.println("Session acquired...");
}

private void stop() throws NoSuchRepositoryException, InterruptedException,
ExecutionException {
session.logout();
out.println("Session released.");
// block waiting for all repos to shutdown
out.println("Engine stopping...");
engine.shutdown().get();
Expand Down
56 changes: 56 additions & 0 deletions src/main/resources/infinispan_configuration.xml
@@ -0,0 +1,56 @@
<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">

<global>
<!-- Defines the global settings shared by all caches -->
<transport clusterName="modeshape-cluster">
<properties>
<property name="configurationFile" value="${fcrepo.ispn.jgroups.configuration:config/jgroups.xml}"/>
</properties>
</transport>
</global>

<default>
</default>

<namedCache name="FedoraRepository">

<clustering mode="distribution">
<sync/>
<l1 enabled="false" lifespan="0" onRehash="false"/>
<stateTransfer chunkSize="100" fetchInMemoryState="true"/>
</clustering>

<locking concurrencyLevel="1000" lockAcquisitionTimeout="15000" useLockStriping="false" />

<deadlockDetection enabled="true" spinDuration="1000"/>


<eviction maxEntries="100" strategy="LRU" threadPolicy="DEFAULT"/>

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

<loaders passivation="false" shared="false" preload="false">

<!--
The 'fetchPersistentState' attribute applies when this cache joins the cluster; the value doesn't
really matter to us in this case. See the documentation for more options.
-->
<loader class="org.infinispan.loaders.file.FileCacheStore" fetchPersistentState="true"
purgeOnStartup="false">
<!-- See the documentation for more configuration examples and flags. -->
<properties>
<!-- We have to set the location where we want to store the data. -->
<property name="location" value="${fcrepo.ispn.CacheDirPath:target/FedoraRepository/storage}"/>

<property name="fsyncMode" value="perWrite"/>
</properties>

</loader>

</loaders>
</namedCache>
</infinispan>
91 changes: 91 additions & 0 deletions src/main/resources/jgroups.xml
@@ -0,0 +1,91 @@
<!--
~ JBoss, Home of Professional Open Source
~ Copyright 2010 Red Hat Inc. and/or its affiliates and other
~ contributors as indicated by the @author tags. All rights reserved.
~ See the copyright.txt in the distribution for a full listing of
~ individual contributors.
~
~ This is free software; you can redistribute it and/or modify it
~ under the terms of the GNU Lesser General Public License as
~ published by the Free Software Foundation; either version 2.1 of
~ the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public
~ License along with this software; if not, write to the Free
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<config xmlns="urn:org:jgroups"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/JGroups-3.2.xsd">
<TCP
bind_addr="${jgroups.tcp.address:0.0.0.0}"
bind_port="${jgroups.tcp.port:7800}"
loopback="false"
port_range="30"
recv_buf_size="20m"
send_buf_size="640k"
max_bundle_size="64000"
max_bundle_timeout="30"
enable_bundling="true"
use_send_queues="true"
enable_diagnostics="false"
bundler_type="old"

thread_naming_pattern="pl"

thread_pool.enabled="true"
thread_pool.min_threads="2"
thread_pool.max_threads="30"
thread_pool.keep_alive_time="60000"
thread_pool.queue_enabled="true"
thread_pool.queue_max_size="100"
thread_pool.rejection_policy="Discard"

oob_thread_pool.enabled="true"
oob_thread_pool.min_threads="2"
oob_thread_pool.max_threads="30"
oob_thread_pool.keep_alive_time="60000"
oob_thread_pool.queue_enabled="false"
oob_thread_pool.queue_max_size="100"
oob_thread_pool.rejection_policy="Discard"
/>

<!-- Ergonomics, new in JGroups 2.11, are disabled by default in TCPPING until JGRP-1253 is resolved -->
<TCPPING timeout="3000"
initial_hosts="${jgroups.tcpping.initial_hosts:localhost[7800]}"
port_range="5"
num_initial_members="1"
ergonomics="false"
/>

<MERGE2 max_interval="30000" min_interval="10000"/>
<FD_SOCK/>
<FD timeout="3000" max_tries="3"/>
<VERIFY_SUSPECT timeout="1500"/>
<pbcast.NAKACK2 use_mcast_xmit="false"
xmit_interval="1000"
xmit_table_num_rows="100"
xmit_table_msgs_per_row="10000"
xmit_table_max_compaction_time="10000"
max_msg_batch_size="100"/>

<UNICAST2 stable_interval="5000"
xmit_interval="500"
max_bytes="1m"
xmit_table_num_rows="20"
xmit_table_msgs_per_row="10000"
xmit_table_max_compaction_time="10000"
max_msg_batch_size="100"/>
<pbcast.STABLE stability_delay="500" desired_avg_gossip="5000" max_bytes="1m"/>
<pbcast.GMS print_local_addr="false" join_timeout="3000" view_bundling="true"/>
<UFC max_credits="200k" min_threshold="0.20"/>
<MFC max_credits="200k" min_threshold="0.20"/>
<FRAG2 frag_size="60000"/>
<RSVP timeout="60000" resend_interval="500" ack_on_delivery="false" />
</config>
24 changes: 24 additions & 0 deletions src/main/resources/log4j.properties
@@ -0,0 +1,24 @@
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %t %5p %m%n

# Root logger option
log4j.rootLogger=INFO, stdout

# Set up the default logging to be INFO level, then override specific units
log4j.logger.org.modeshape=DEBUG
log4j.logger.org.infinispan=INFO
log4j.org.jboss.logging=INFO

#log4j.logger.org.modeshape.jcr.query=TRACE
# This line turns off INFO messages in the org.infinispan.factories.GlobalComponentRegistries
# class. As of Infinispan 5.1.0.BETA4, Infinispan logs its version information every time
# a new cache manager (?) is instantiated, and this next line turns it off. This may
# affect a few other log messages, so this should be removed as soon as Infinispan
# logs the message only once; see https://issues.jboss.org/browse/ISPN-1518
log4j.logger.org.infinispan.factories.GlobalComponentRegistry=OFF

# This line turns on detailed log messages
#log4j.logger.org.modeshape=DEBUG
10 changes: 10 additions & 0 deletions src/main/resources/repository.json
@@ -1,10 +1,20 @@
{
"name": "repo",
"jndiName" : "",
"workspaces": {
"predefined": [],
"default": "default",
"allowCreation": false
},
"storage" : {
"cacheName" : "FedoraRepository",
"cacheConfiguration" : "infinispan_configuration.xml}",
"binaryStorage" : {
"type" : "cache",
"dataCacheName" : "FedoraRepository",
"metadataCacheName" : "FedoraRepository"
}
},
"externalSources": {"targetDirectory": {
"classname": "org.modeshape.connector.filesystem.FileSystemConnector",
"directoryPath": "target/classes/test-objects",
Expand Down

0 comments on commit 39fc9a7

Please sign in to comment.