Skip to content

Commit

Permalink
add features for run.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
liwang0513 committed Jun 25, 2015
1 parent 56c18dc commit 5eb4a51
Show file tree
Hide file tree
Showing 25 changed files with 220 additions and 34 deletions.
4 changes: 2 additions & 2 deletions DeleteRecords/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry including="**/*.java" 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">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
Expand Down
1 change: 1 addition & 0 deletions DeleteRecords/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
22 changes: 22 additions & 0 deletions DeleteRecords/config/server-cache.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<!DOCTYPE cache PUBLIC
"-//GemStone Systems, Inc.//GemFire Declarative Caching 8.0//EN"
"http://www.gemstone.com/dtd/cache8_0.dtd">

<cache>

<pdx read-serialized="true">
<pdx-serializer>
<class-name>com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer</class-name>
<parameter name="classes">
<string>io.pivotal.domain.*</string>
</parameter>
</pdx-serializer>
</pdx>

<region name="Customer">
<region-attributes refid="REPLICATE" />
</region>

</cache>

Binary file added DeleteRecords/lib/DeleteRecords.jar
Binary file not shown.
31 changes: 31 additions & 0 deletions DeleteRecords/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#! /bin/bash

gfsh << !
start server --name=server1 --cache-xml-file=config/cache.xml
exit
!

echo $'\nLoading data...'; sleep 1;

java -cp $GEMFIRE/lib/server-dependencies.jar:lib/DeleteRecords.jar io.pivotal.app.PreLoader

echo $'\nVerifying data...'; sleep 1;

java -cp $GEMFIRE/lib/server-dependencies.jar:lib/DeleteRecords.jar io.pivotal.app.QueryData

echo $'\nDeleting Customer 1001...'; sleep 1;

java -cp $GEMFIRE/lib/server-dependencies.jar:lib/DeleteRecords.jar io.pivotal.app.DeleteOne

echo $'\nVerifying data...'; sleep 1;

java -cp $GEMFIRE/lib/server-dependencies.jar:lib/DeleteRecords.jar io.pivotal.app.QueryData

read -p $'\nPress any key to stop servers...'

gfsh << !
stop server --dir=server1
exit
!

rm -rf server1
25 changes: 25 additions & 0 deletions DeleteRecords/src/main/java/io/pivotal/app/DeleteOne.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.pivotal.app;

import io.pivotal.domain.Customer;

import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.Region;

public class DeleteOne {
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");

// Delete some records
customers.remove(1001);
System.out.println("Customer 1001 was deleted");

// Close cache
cache.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.Region;

public class DeleteRecords {
public static void main(String[] args) {
public class PreLoader {
public static void main(String[] args) throws InterruptedException {
// Create cache
Cache cache = new CacheFactory()
.set("log-level", "error")
Cache cache = new CacheFactory().set("log-level", "error")
.set("cache-xml-file", "config/cache.xml").create();

// Get the customer region
Expand All @@ -20,19 +19,11 @@ public static void main(String[] args) {
// Load the customers into region
Customer cust1 = new Customer(new Integer(1001), "Jaden", "Booth");
customers.put(new Integer(1001), cust1);
System.out.println("Inserted a customer: " + cust1);

Customer cust2 = new Customer(new Integer(1002), "Lydia", "Owen");
customers.put(new Integer(1002), cust2);
System.out.println("Inserted a customer: " + cust2);

Customer cust3 = new Customer(new Integer(1003), "Beverly", "Neal");
customers.put(new Integer(1003), cust3);
System.out.println("Inserted a customer: " + cust3);

// Delete some records
customers.remove(1001);
System.out.println("Customer 1001 was deleted");
System.out.println("Inserted 3 records");

// Close cache
cache.close();
Expand Down
34 changes: 34 additions & 0 deletions DeleteRecords/src/main/java/io/pivotal/app/QueryData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.pivotal.app;

import java.util.Collection;
import java.util.Iterator;

import io.pivotal.domain.Customer;

import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.query.Query;
import com.gemstone.gemfire.cache.query.QueryService;
import com.gemstone.gemfire.cache.query.SelectResults;

public class QueryData {
public static void main(String[] args) throws Exception {
// Create cache
Cache cache = new CacheFactory().set("log-level", "error")
.set("cache-xml-file", "config/cache.xml").create();

// Query the Data
QueryService queryService = cache.getQueryService();
Query query = queryService.newQuery("SELECT * FROM /Customer");
Object result = query.execute();
Collection<?> collection = ((SelectResults<?>) result).asList();
Iterator<?> iter = collection.iterator();
while (iter.hasNext()) {
Customer cus = (Customer) iter.next();
System.out.println(cus);
}

// Close cache
cache.close();
}
}
2 changes: 1 addition & 1 deletion DeleteRecords/src/main/resources/config/cache.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<cache>

<pdx read-serialized="true">
<pdx read-serialized="false">
<pdx-serializer>
<class-name>com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer</class-name>
<parameter name="classes">
Expand Down
2 changes: 1 addition & 1 deletion FunctionService/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry including="**/*.java" kind="src" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
Expand Down
4 changes: 2 additions & 2 deletions FunctionService/.project
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>org.springframework.ide.eclipse.core.springbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.springframework.ide.eclipse.core.springbuilder</name>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
Expand Down
1 change: 1 addition & 0 deletions FunctionService/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package io.pivotal.app;


public class SizeFunctionExecution
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
public class SizeFunctionExecution {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
File renamed without changes.
3 changes: 0 additions & 3 deletions PreLoader/preloader.sh

This file was deleted.

19 changes: 19 additions & 0 deletions PreLoader/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /bin/bash

gfsh << !
start server --name=server1 --cache-xml-file=config/cache.xml
exit
!

echo $'\nLoading data...'; sleep 1;

java -cp $GEMFIRE/lib/server-dependencies.jar:lib/Preloader.jar io.pivotal.app.PreLoader

read -p $'\nPress any key to stop servers...'

gfsh << !
stop server --dir=server1
exit
!

rm -rf server1
2 changes: 1 addition & 1 deletion QueryRegion/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry including="**/*.java" kind="src" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
Expand Down
4 changes: 2 additions & 2 deletions QueryRegion/.project
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>org.springframework.ide.eclipse.core.springbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.springframework.ide.eclipse.core.springbuilder</name>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
Expand Down
1 change: 1 addition & 0 deletions QueryRegion/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
24 changes: 24 additions & 0 deletions QueryRegion/config/server-cache.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!DOCTYPE cache PUBLIC
"-//GemStone Systems, Inc.//GemFire Declarative Caching 8.0//EN"
"http://www.gemstone.com/dtd/cache8_0.dtd">

<cache>

<pdx read-serialized="true">
<pdx-serializer>
<class-name>com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer</class-name>
<parameter name="classes">
<string>io.pivotal.domain.*</string>
</parameter>
</pdx-serializer>
</pdx>

<region name="Customer" >
<region-attributes data-policy="partition" >
<partition-attributes redundant-copies="1" total-num-buckets="11"/>
</region-attributes>
</region>

</cache>

Binary file added QueryRegion/lib/QueryRegion.jar
Binary file not shown.
19 changes: 19 additions & 0 deletions QueryRegion/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /bin/bash

gfsh << !
start server --name=server1 --cache-xml-file=config/cache.xml
exit
!

echo $'\nLoading data...'; sleep 1;

java -cp $GEMFIRE/lib/server-dependencies.jar:lib/QueryRegion.jar io.pivotal.app.QueryRegion

read -p $'\nPress any key to stop servers...'

gfsh << !
stop server --dir=server1
exit
!

rm -rf server1
4 changes: 2 additions & 2 deletions Rebalance/.project
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>org.springframework.ide.eclipse.core.springbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.springframework.ide.eclipse.core.springbuilder</name>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
Expand Down
24 changes: 24 additions & 0 deletions Rebalance/config/server-cache.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!DOCTYPE cache PUBLIC
"-//GemStone Systems, Inc.//GemFire Declarative Caching 8.0//EN"
"http://www.gemstone.com/dtd/cache8_0.dtd">

<cache>

<pdx read-serialized="true">
<pdx-serializer>
<class-name>com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer</class-name>
<parameter name="classes">
<string>io.pivotal.domain.*</string>
</parameter>
</pdx-serializer>
</pdx>

<region name="Customer" >
<region-attributes data-policy="partition" >
<partition-attributes redundant-copies="1" total-num-buckets="11"/>
</region-attributes>
</region>

</cache>

File renamed without changes.

0 comments on commit 5eb4a51

Please sign in to comment.