티스토리 뷰

대용량 분산캐시 서버 Infinispan 설치 방법에 대해서 알아보도록 하겠습니다.

설치에 앞서 infinispan에 대해 알아보면  대용량 HashMap 서버라고 보시면 됩니다.

clustering 및 replication, distribution 등을 지원하여 memcached 를 대체하는 솔루션이 되었습니다.

현재는 어느정도 성숙버전까지 올라와 있기 때문에 (5.1 version) 불안해 할 필요가 없을꺼라 생각됩니다.


maven을 이용한 설치

참고 URL : https://docs.jboss.org/author/display/ISPN/Infinispan+Maven+Archetypes

   http://cafe.naver.com/jbossug/2302

step 1. mvn repository download

$ mvn archetype:generate \
    -DarchetypeGroupId=org.infinispan.archetypes \
    -DarchetypeArtifactId=newproject-archetype \
    -DarchetypeVersion=1.0.10 \
    -DarchetypeRepository=http://repository.jboss.org/nexus/content/groups/public

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.rocksea.infinispan</groupId>
   <artifactId>app</artifactId>
   <packaging>jar</packaging>
   <version>1.0-SNAPSHOT</version>
   <name>A sample project using Infinispan</name>
   <url>http://www.myorganization.org</url>

   <properties>
      <!--
         Which Infinispan version do you want to use?  Released versions are always more reliable than snapshots!
      -->
      <version.infinispan>4.2.0.FINAL</version.infinispan>
   </properties>

   <dependencies>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-core</artifactId>
         <version>${version.infinispan}</version>
      </dependency>
   </dependencies>

   <build>
      <plugins>
         <!-- enforce java 1.6 and maven 2.1.0 -->
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <version>1.0-beta-1</version>
            <executions>
               <execution>
                  <id>enforce-java</id>
                  <goals>
                     <goal>enforce</goal>
                  </goals>
                  <configuration>
                     <rules>
                        <requireJavaVersion>
                           <version>[1.6,)</version>
                        </requireJavaVersion>
                        <requireMavenVersion>
                           <version>[2.1.0,)</version>
                        </requireMavenVersion>
                     </rules>
                  </configuration>
               </execution>
            </executions>
         </plugin>

         <!-- by default, compile to JDK 1.6 compatibility -->
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.1</version>
            <configuration>
               <source>1.6</source>
               <target>1.6</target>
               <encoding>UTF-8</encoding>
            </configuration>
         </plugin>
      </plugins>
   </build>

   <repositories>
      <repository>
         <id>JBoss.org Public Repository</id>
         <releases>
            <enabled>true</enabled>
         </releases>
         <snapshots>
            <enabled>true</enabled>
         </snapshots>
         <url>http://repository.jboss.org/nexus/content/groups/public/</url>
      </repository>
   </repositories>

   <profiles>
      <profile>
         <!-- This profile is used to run the sample Application.java file.  Remove this in any production usage.  -->
         <id>run</id>
         <activation>
            <activeByDefault>false</activeByDefault>
         </activation>
         <build>
            <plugins>
               <plugin>
                  <groupId>org.codehaus.mojo</groupId>
                  <artifactId>exec-maven-plugin</artifactId>
                  <version>1.1</version>
                  <executions>
                     <execution>
                        <phase>process-classes</phase>
                        <goals>
                           <goal>java</goal>
                        </goals>
                     </execution>
                  </executions>
                  <configuration>
                     <mainClass>com.rocksea.infinispan.Application</mainClass>
                  </configuration>
               </plugin>
            </plugins>
         </build>
      </profile>
   </profiles>
</project>

 

step2. eclipse project로 변경 ( eclipse에서 사용할 경우 )

$ mvn eclipse:eclipse

 

step3. test run

$ mvn install -Prun

 

실행결과

rocksea@rocksea ~/cache $ mvn install -Prun
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building A sample project using Infinispan
[INFO]    task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [enforcer:enforce {execution: enforce-java}]
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 4 resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] Preparing exec:java
[WARNING] Removing: java from forked lifecycle, to prevent recursive invocation.
[INFO] [enforcer:enforce {execution: enforce-java}]
[INFO] [exec:java {execution: default}]



   ******************************** 



Hello.  This is a sample application making use of Infinispan.


1.  Demonstrating basic usage of Infinispan.  This cache stores arbitrary Strings.
2012. 6. 18 오후 2:44:03 org.infinispan.configuration.parsing.Parser parseEviction
WARN: ISPN000176: The 'wakeUpInterval' attribute of the 'eviction' configuration XML element is deprecated. Setting the 'wakeUpInterval' attribute of the 'expiration' configuration XML element to 100 instead
2012. 6. 18 오후 2:44:03 org.infinispan.factories.GlobalComponentRegistry start
INFO: ISPN000128: Infinispan version: Infinispan 'Brahma' 5.1.3.FINAL
  Storing value 'World' under key 'Hello'
  Done.  Saw old value as 'null'
  Replacing 'World' with 'Mars'.
  Successful? true


2.  Demonstrating usage of Infinispan with expirable entries.
  Storing key 'RHT' for 10 seconds.
  Checking for existence of key.  Is it there? true
  Sleeping for 10 seconds...
  Checking for existence of key.  Is it there? false


3.  Demonstrating asynchronous operations - where writes can be done in a non-blocking fashion.
  Put #1
  Put #1
  Put #1
  Checking future...
  Checking future...
  Checking future...
  Everything stored!


4.  Demonstrating use of listeners.
  Attaching listener
  Put #1
Thread rocksea.Application.main() has modified an entry in the cache named another under key 1!
Thread rocksea.Application.main() has modified an entry in the cache named another under key 1!
Thread rocksea.Application.main() has modified an entry in the cache named another under key 1!
Thread rocksea.Application.main() has modified an entry in the cache named another under key 1!
  Put #2
Thread rocksea.Application.main() has modified an entry in the cache named another under key 2!
Thread rocksea.Application.main() has modified an entry in the cache named another under key 2!
Thread rocksea.Application.main() has modified an entry in the cache named another under key 2!
Thread rocksea.Application.main() has modified an entry in the cache named another under key 2!
  Put #3
Thread rocksea.Application.main() has modified an entry in the cache named another under key 3!
Thread rocksea.Application.main() has modified an entry in the cache named another under key 3!
Thread rocksea.Application.main() has modified an entry in the cache named another under key 3!
Thread rocksea.Application.main() has modified an entry in the cache named another under key 3!
Sample complete.



   ******************************** 



[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/rocksea/cache/src/test/resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] No sources to compile
[INFO] [surefire:test {execution: default-test}]
[INFO] No tests to run.
[INFO] [jar:jar {execution: default-jar}]
[INFO] [install:install {execution: default-install}]
[INFO] Installing /home/rocksea/cache/target/cache-1.0-SNAPSHOT.jar to /home/rocksea/.m2/repository/rocksea/cache/1.0-SNAPSHOT/cache-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12 seconds
[INFO] Finished at: Mon Jun 18 14:44:13 KST 2012
[INFO] Final Memory: 33M/219M
[INFO] ------------------------------------------------------------------------

 

댓글