-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Li Wang
committed
Jun 16, 2015
1 parent
a66f440
commit 610b564
Showing
15 changed files
with
556 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" path="src/main/resources"/> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>FunctionService</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.springframework.ide.eclipse.core.springbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.springframework.ide.eclipse.core.springnature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
eclipse.preferences.version=1 | ||
encoding//src/main/java=UTF-8 | ||
encoding//src/test/java=UTF-8 | ||
encoding/<project>=UTF-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 | ||
org.eclipse.jdt.core.compiler.compliance=1.7 | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.source=1.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
resolveWorkspaceProjects=true | ||
version=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>io.pivotal</groupId> | ||
<artifactId>FunctionService</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>FunctionService</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.gemstone.gemfire</groupId> | ||
<artifactId>gemfire</artifactId> | ||
<version>8.1.0</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>3.8.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<repositories> | ||
<repository> | ||
<id>gemstone-repository</id> | ||
<name>GemFire Repository</name> | ||
<url>http://dist.gemstone.com/maven/release/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
29 changes: 29 additions & 0 deletions
29
FunctionService/src/main/java/io/pivotal/app/PreLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.pivotal.app; | ||
|
||
import io.pivotal.domain.Customer; | ||
import io.pivotal.service.CustomerLoader; | ||
|
||
import com.gemstone.gemfire.cache.Cache; | ||
import com.gemstone.gemfire.cache.CacheFactory; | ||
import com.gemstone.gemfire.cache.Region; | ||
|
||
public class PreLoader { | ||
public static void main(String[] args) { | ||
// Create cache | ||
Cache cache = new CacheFactory() | ||
.set("log-level", "error") | ||
.set("cache-xml-file", "config/cache.xml").create(); | ||
|
||
// Get the customer region | ||
Region<Integer, Customer> customers = cache.getRegion("Customer"); | ||
System.out.println("Got the Customer Region: " + customers); | ||
|
||
// Load 20 customers into region | ||
CustomerLoader customerLoader = new CustomerLoader(customers); | ||
customerLoader.bulkInsertion(20); | ||
|
||
// Close cache | ||
cache.close(); | ||
|
||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
FunctionService/src/main/java/io/pivotal/app/SizeFunctionExecution.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.pivotal.app; | ||
|
||
|
||
public class SizeFunctionExecution | ||
{ | ||
public static void main( String[] args ) | ||
{ | ||
System.out.println( "Hello World!" ); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
FunctionService/src/main/java/io/pivotal/app/StartPeer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.pivotal.app; | ||
|
||
import java.io.IOException; | ||
|
||
import com.gemstone.gemfire.cache.Cache; | ||
import com.gemstone.gemfire.cache.CacheFactory; | ||
|
||
public class StartPeer { | ||
|
||
public static void main(String[] args) throws InterruptedException, IOException { | ||
// Create cache | ||
Cache cache = new CacheFactory() | ||
.set("log-level", "error") | ||
.set("name", args[0]) | ||
.set("cache-xml-file", "config/cache.xml").create(); | ||
|
||
System.out.println(args[0] + " started."); | ||
|
||
// Waiting for other process | ||
Thread.sleep(10000); | ||
|
||
// Close cache | ||
cache.close(); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
FunctionService/src/main/java/io/pivotal/domain/Customer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package io.pivotal.domain; | ||
|
||
public class Customer { | ||
|
||
private Integer customerNumber; | ||
private String firstName; | ||
private String lastName; | ||
|
||
public Customer() { | ||
} | ||
|
||
public Customer(int customerNumber, String firstName, String lastName) { | ||
super(); | ||
this.customerNumber = new Integer(customerNumber); | ||
this.firstName = firstName; | ||
this.lastName = lastName; | ||
} | ||
|
||
public Integer getCustomerNumber() { | ||
return customerNumber; | ||
} | ||
|
||
public void setCustomerNumber(Integer customerNumber) { | ||
this.customerNumber = customerNumber; | ||
} | ||
|
||
public String getFirstName() { | ||
return firstName; | ||
} | ||
|
||
public void setFirstName(String firstName) { | ||
this.firstName = firstName; | ||
} | ||
|
||
public String getLastName() { | ||
return lastName; | ||
} | ||
|
||
public void setLastName(String lastName) { | ||
this.lastName = lastName; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Customer [customerNumber=" + customerNumber + ", firstName=" | ||
+ firstName + ", lastName=" + lastName + "]"; | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
FunctionService/src/main/java/io/pivotal/service/CustomerLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.pivotal.service; | ||
|
||
import io.pivotal.domain.Customer; | ||
import io.pivotal.util.CustomerFactory; | ||
|
||
import com.gemstone.gemfire.cache.Region; | ||
|
||
public class CustomerLoader { | ||
|
||
Region<Integer, Customer> customerRegion = null; | ||
CustomerFactory customerFactory = null; | ||
|
||
public CustomerLoader(Region<Integer, Customer> customerRegion) { | ||
this.customerRegion = customerRegion; | ||
this.customerFactory = new CustomerFactory(); | ||
} | ||
|
||
public void bulkInsertion(int n) { | ||
|
||
for (int i = 0; i < n; i++) { | ||
Customer customer = customerFactory.generateCustomer(i+1); | ||
customerRegion.put(i + 1, customer); | ||
} | ||
|
||
System.out.println("Inserted " + n + " records."); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.