Skip to content

Commit

Permalink
Merge branch 'gcloud' of https://github.com/otrack/infinispan-aof int…
Browse files Browse the repository at this point in the history
…o gcloud
  • Loading branch information
otrack committed Apr 1, 2019
2 parents b4d2a53 + 1caf9c6 commit fa515c8
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 19 deletions.
3 changes: 1 addition & 2 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
<relativePath>../</relativePath>
</parent>

<groupId>org.infinispan</groupId>
<artifactId>infinispan-creson-client</artifactId>
<name>infinispan-creson-server</name>
<name>infinispan-creson-client</name>
<description>The client side of the CRESON framework.</description>

<dependencies>
Expand Down
12 changes: 12 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@
<skipTests>${skipTests}</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
1 change: 0 additions & 1 deletion server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<relativePath>../</relativePath>
</parent>

<groupId>org.infinispan</groupId>
<artifactId>infinispan-creson-server</artifactId>
<name>infinispan-creson-server</name>
<description>Server side of the CRESON framework.</description>
Expand Down
39 changes: 30 additions & 9 deletions server/src/main/bin/server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,37 @@

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CLASSPATH="${DIR}/*:${DIR}/lib/*"
JVM="-XX:+UseConcMarkSweepGC -Xms64m -Xmx1024m -Djava.net.preferIPv4Stack=true -Djgroups.tcp.address=${IP} -Dlog4j.configurationFile=${DIR}/log4j2.xml"
CONFIG="jgroups-creson-tcp.xml"

if [ "${CLOUD}" == "ec2" ];
if [[ "${CLOUD}" == "" ]];
then
CLOUD="$1"
IP='127.0.0.1'
PORT='11222'
# EXTRA='-rf 2 -userLibs .'
CONFIG='jgroups-creson-udp.xml'
fi

if [[ "$2" != "" ]];
then
PORT=$2
fi

if [[ "${CLOUD}" == "ec2" ]];
then
echo "AWS EC2 mode"
CONFIG=jgroups-creson-ec2.xml
IP=`/sbin/ifconfig eth0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}'`
#IP=`/sbin/ifconfig eth0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}'`
IP=`hostname -I | sed -e 's/[[:space:]]*$//'`
PIP=`curl -s checkip.amazonaws.com`
EXTRA=${EXTRA}"-proxy ${PIP}:11222 -rf 2"
EXTRA="-proxy ${PIP}:11222 -ec2 -rf 1"
elif [[ "${CLOUD}" == "vpc" ]];
then
echo "AWS EC2 VPC mode"
CONFIG=jgroups-creson-ec2.xml
elif [ "${CLOUD}" == "gcp" ];
IP=`hostname -I | sed -e 's/[[:space:]]*$//'`
EXTRA="-ec2 -rf 1"
elif [[ "${CLOUD}" == "gcp" ]];
then
echo "GCP mode"
CONFIG=jgroups-creson-gcp.xml
Expand All @@ -23,15 +42,17 @@ then
| sed s,%BUCKET_SECRET%,${BUCKET_SECRET},g \
| sed s,%IP%,${IP},g > tmp
mv tmp ${CONFIG}
elif [ "${CLOUD}" == "k8s" ];
elif [[ "${CLOUD}" == "k8s" ]];
then
echo "K8S mode"
CONFIG=jgroups-creson-k8s.xml
else
echo "local mode"
fi

mv ${CONFIG} jgroups.xml
cp ${CONFIG} jgroups.xml

echo "java -ea -cp ${CLASSPATH} ${JVM} org.infinispan.creson.Server -server ${IP}:${PORT} ${EXTRA}"
java -ea -cp ${CLASSPATH} ${JVM} org.infinispan.creson.Server -server ${IP}:${PORT} ${EXTRA}
JVM="-XX:+UseConcMarkSweepGC -Xms64m -Xmx1024m -Djava.net.preferIPv4Stack=true -Djgroups.tcp.address=${IP} -Dlog4j.configurationFile=\"${DIR}/log4j2.xml\""
CMD="java -ea -cp \"${CLASSPATH}\" ${JVM} org.infinispan.creson.Server -server ${IP}:${PORT} ${EXTRA}"
echo ${CMD}
bash -c "$CMD"
14 changes: 7 additions & 7 deletions server/src/main/java/org/infinispan/creson/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void doMain(String[] args) {
return;
}

Runnable runnable = (Runnable) () -> {
Runnable runnable = () -> {
File folder = new File(userLib);
File[] listOfFiles = folder.listFiles();
for (File file : listOfFiles) {
Expand All @@ -101,7 +101,7 @@ public void doMain(String[] args) {
}

ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
scheduler.scheduleAtFixedRate(runnable,3, 3, TimeUnit.SECONDS);
scheduler.scheduleAtFixedRate(runnable, 3, 3, TimeUnit.SECONDS);

String host = server.split(":")[0];
int port = Integer.valueOf(
Expand All @@ -124,7 +124,7 @@ public void doMain(String[] args) {
replicationFactor,
maxEntries,
false,
STORAGE_PATH_PREFIX + "/"+ host,
STORAGE_PATH_PREFIX + "/" + host,
true,
false);

Expand Down Expand Up @@ -178,16 +178,16 @@ public static synchronized void loadLibrary(java.io.File jar) {
try {
java.net.URLClassLoader loader = (java.net.URLClassLoader) ClassLoader.getSystemClassLoader();
java.net.URL url = jar.toURI().toURL();
for (java.net.URL it : java.util.Arrays.asList(loader.getURLs())) {
for (java.net.URL it : loader.getURLs()) {
if (it.equals(url)) {
return;
}
}
System.out.println("Loading "+jar.getName());
System.out.println("Loading " + jar.getName());
java.lang.reflect.Method method = java.net.URLClassLoader.class.
getDeclaredMethod("addURL", new Class[]{java.net.URL.class});
getDeclaredMethod("addURL", java.net.URL.class);
method.setAccessible(true); /*promote the method to public access*/
method.invoke(loader, new Object[]{url});
method.invoke(loader, url);
} catch (final java.lang.NoSuchMethodException |
java.lang.IllegalAccessException |
java.net.MalformedURLException |
Expand Down
56 changes: 56 additions & 0 deletions server/src/main/resources/jgroups-creson-udp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<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-4.0.xsd">
<UDP mcast_addr="${jgroups.udp.mcast_addr:228.6.7.8}"
mcast_port="${jgroups.udp.mcast_port:46655}"
ucast_send_buf_size="1m"
mcast_send_buf_size="1m"
ucast_recv_buf_size="20m"
mcast_recv_buf_size="25m"
ip_ttl="${jgroups.ip_ttl:2}"
thread_naming_pattern="pl"
enable_diagnostics="false"
bundler_type="no-bundler"
max_bundle_size="8500"

thread_pool.min_threads="${jgroups.thread_pool.min_threads:0}"
thread_pool.max_threads="${jgroups.thread_pool.max_threads:200}"
thread_pool.keep_alive_time="60000"
/>
<PING />
<MERGE3 min_interval="10000"
max_interval="30000"
/>
<FD_SOCK />
<!-- Suspect node `timeout` to `timeout + timeout_check_interval` millis after the last heartbeat -->
<FD_ALL timeout="10000"
interval="2000"
timeout_check_interval="1000"
/>
<VERIFY_SUSPECT timeout="1000"/>
<pbcast.NAKACK2 xmit_interval="100"
xmit_table_num_rows="50"
xmit_table_msgs_per_row="1024"
xmit_table_max_compaction_time="30000"
resend_last_seqno="true"
/>
<UNICAST3 xmit_interval="100"
xmit_table_num_rows="50"
xmit_table_msgs_per_row="1024"
xmit_table_max_compaction_time="30000"
/>
<pbcast.STABLE stability_delay="500"
desired_avg_gossip="5000"
max_bytes="1M"
/>
<pbcast.GMS print_local_addr="false"
join_timeout="${jgroups.join_timeout:5000}"
/>
<UFC max_credits="2m"
min_threshold="0.40"
/>
<MFC max_credits="2m"
min_threshold="0.40"
/>
<FRAG3 frag_size="8000"/>
</config>

0 comments on commit fa515c8

Please sign in to comment.