Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
boglesby committed Jan 4, 2020
0 parents commit 5252f0c
Show file tree
Hide file tree
Showing 40 changed files with 3,925 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
build/
.idea/
.gradle/
.classpath
.project
.settings/
.idea/
.java-version
build-eclipse/
/tags
out/
setenv.sh

.DS_store
*.iml
*.ipr
*.iws
*.swp
*.log
*.patch
*.diff
*.dat
*.rej
*.orig
1,409 changes: 1,409 additions & 0 deletions README.md

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
buildscript {
ext {
springBootVersion = '2.2.2.RELEASE'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}

plugins {
id 'io.franzbecker.gradle-lombok' version '1.11'
}

allprojects {
repositories {
mavenCentral()
jcenter()
maven { url 'https://repo.spring.io/libs-release' }
maven { url 'https://repo.spring.io/libs-milestone' }
maven { url 'https://repo.spring.io/libs-snapshot' }
}
}

subprojects {
apply plugin: 'java'
sourceCompatibility = 1.8

group = 'example.cloudcache'
version = '0.0.1-SNAPSHOT'

configurations {
provided
compile.extendsFrom provided
}


task copyDependancies(type: Copy) {
into "$buildDir/dependancies"
from(configurations.compile - configurations.provided)
}

jar {
dependsOn copyDependancies
}
}

project(':client') {
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
dependencies {
compile 'org.projectlombok:lombok:1.18.8'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
compile 'org.springframework.geode:spring-geode-starter:1.2.2.RELEASE'
compile 'org.springframework.geode:spring-geode-starter-actuator:1.2.2.RELEASE'
compile "org.springframework.boot:spring-boot-starter-web:2.2.2.RELEASE"
}
}

project(':client-cq') {
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
dependencies {
compile 'org.projectlombok:lombok:1.18.8'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
compile 'org.springframework.geode:spring-geode-starter:1.2.2.RELEASE'
compile 'org.springframework.geode:spring-geode-starter-actuator:1.2.2.RELEASE'
compile "org.springframework.boot:spring-boot-starter-web:2.2.2.RELEASE"
}
}

project(':server') {
dependencies {
provided 'io.pivotal.gemfire:geode-core:9.8.3'
}
}
10 changes: 10 additions & 0 deletions client-cq/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
applications:
- name: clientCqApp
memory: 768M
instances: 1
path: build/libs/client_cq-0.0.1-SNAPSHOT.jar
services:
- pccService
buildpacks:
- https://github.com/cloudfoundry/java-buildpack.git
19 changes: 19 additions & 0 deletions client-cq/src/main/java/io/pivotal/test/client/Client.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.pivotal.test.client;

import io.pivotal.test.client.domain.Trade;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions;
import org.springframework.data.gemfire.config.annotation.EnableStatistics;

@SpringBootApplication
@EnableEntityDefinedRegions(basePackageClasses = Trade.class)
@EnableStatistics
public class Client {

public static void main(String[] args) {
new SpringApplicationBuilder(Client.class)
.build()
.run(args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.pivotal.test.client.cq;

import org.apache.geode.cache.query.CqEvent;
import org.apache.geode.internal.logging.LogService;
import org.apache.logging.log4j.Logger;
import org.springframework.data.gemfire.listener.annotation.ContinuousQuery;
import org.springframework.stereotype.Component;

@Component
public class TradeProcessor {

private static final Logger logger = LogService.getLogger();

@ContinuousQuery(name = "TradeProcessor", query = "SELECT * FROM /Trades WHERE cusip = 'AAPL'")
public void processTrade(CqEvent event) {
logger.info("TradeProcessor.processTrade processing event=" + event);
}
}
35 changes: 35 additions & 0 deletions client-cq/src/main/java/io/pivotal/test/client/domain/Trade.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.pivotal.test.client.domain;

import lombok.Data;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.gemfire.mapping.annotation.Region;

import java.io.Serializable;
import java.math.BigDecimal;

@Data
@Getter
@ToString(exclude = "payload")
@Region("Trades")
@RequiredArgsConstructor
public class Trade {

@Id
@NonNull
private final String id;

@NonNull
private final String cusip;

private final int shares;

@NonNull
private final BigDecimal price;

@NonNull
private final byte[] payload;
}
10 changes: 10 additions & 0 deletions client-cq/src/main/resources/application-local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# GemFire properties
spring.data.gemfire.name=client
spring.data.gemfire.pool.locators=localhost[10334]
spring.data.gemfire.pool.statistic-interval=1000
spring.data.gemfire.stats.archive-file=client_cq.gfs
spring.data.gemfire.logging.log-file=client_cq.log

# Spring Actuator Properties
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
12 changes: 12 additions & 0 deletions client-cq/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# GemFire properties
# This property was causing this exception in pcfone:
# org.apache.geode.security.GemFireSecurityException: Instance could not be obtained from org.springframework.data.gemfire.config.annotation.support.AutoConfiguredAuthenticationInitializer.newAuthenticationInitializer
#spring.data.gemfire.pool.statistic-interval=1000

# Spring Actuator Properties
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*

# GemFire properties
spring.data.gemfire.stats.archive-file=client_cq.gfs
spring.data.gemfire.logging.log-file=client_cq.log
10 changes: 10 additions & 0 deletions client/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
applications:
- name: sdgApp
memory: 768M
instances: 1
path: build/libs/client-0.0.1-SNAPSHOT.jar
services:
- pccService
buildpacks:
- https://github.com/cloudfoundry/java-buildpack.git
123 changes: 123 additions & 0 deletions client/src/main/java/io/pivotal/test/client/Client.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package io.pivotal.test.client;

import io.pivotal.test.client.domain.Trade;
import io.pivotal.test.client.service.TradeService;
import org.apache.geode.internal.logging.LogService;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions;
import org.springframework.data.gemfire.config.annotation.EnableStatistics;
import org.springframework.geode.boot.autoconfigure.ContinuousQueryAutoConfiguration;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;

import static io.pivotal.test.client.Constants.*;

@SpringBootApplication(exclude = ContinuousQueryAutoConfiguration.class) // disable subscriptions
@EnableEntityDefinedRegions(basePackageClasses = Trade.class)
@EnableStatistics
public class Client {

private static final Logger logger = LogService.getLogger();

@Autowired
private TradeService service;

public static void main(String[] args) {
new SpringApplicationBuilder(Client.class)
.web(WebApplicationType.SERVLET)
.build()
.run(args);
}

@Bean
ApplicationRunner runner() {
return args -> {
dumpArguments(args);
List<String> operations = args.getOptionValues(OPERATION);
if (operations == null || operations.get(0).equals("wait")) {
waitForever();
} else {
String operation = operations.get(0);
String parameter1 = (args.containsOption(PARAMETER_1)) ? args.getOptionValues(PARAMETER_1).get(0) : null;
String parameter2 = (args.containsOption(PARAMETER_2)) ? args.getOptionValues(PARAMETER_2).get(0) : null;
String parameter3 = (args.containsOption(PARAMETER_3)) ? args.getOptionValues(PARAMETER_3).get(0) : null;
switch (operation) {
case PUT:
this.service.put(Integer.parseInt(parameter1), Integer.parseInt(parameter2));
break;
case GET:
this.service.get(Integer.parseInt(parameter1));
break;
case DESTROY:
this.service.destroy(Integer.parseInt(parameter1));
break;
case QUERY_BY_CUSIP:
this.service.queryByCusip(Integer.parseInt(parameter1));
break;
case FUNCTION_UPDATE:
this.service.functionUpdate(Integer.parseInt(parameter1));
break;
case PUT_FOREVER:
Optional putThreads = parameter3 == null ? Optional.empty() : Optional.of(Integer.parseInt(parameter3));
this.service.putForever(Integer.parseInt(parameter1), Integer.parseInt(parameter2), putThreads);
break;
case GET_FOREVER:
Optional getThreads = parameter2 == null ? Optional.empty() : Optional.of(Integer.parseInt(parameter2));
this.service.getForever(Integer.parseInt(parameter1), getThreads);
break;
case DESTROY_FOREVER:
Optional destroyThreads = parameter2 == null ? Optional.empty() : Optional.of(Integer.parseInt(parameter2));
this.service.destroyForever(Integer.parseInt(parameter1), destroyThreads);
break;
case QUERY_BY_CUSIP_FOREVER:
Optional queryThreads = parameter1 == null ? Optional.empty() : Optional.of(Integer.parseInt(parameter1));
this.service.queryByCusipForever(queryThreads);
break;
case FUNCTION_UPDATE_FOREVER:
Optional functionThreads = parameter2 == null ? Optional.empty() : Optional.of(Integer.parseInt(parameter2));
this.service.functionUpdateForever(Integer.parseInt(parameter1), functionThreads);
break;
case GET_ONE:
this.service.getOne(Integer.parseInt(parameter1));
break;
case QUERY_ONE_BY_CUSIP:
this.service.queryOneByCusip(parameter1);
break;
case START_TEST:
Optional testThreads = parameter3 == null ? Optional.empty() : Optional.of(Integer.parseInt(parameter3));
this.service.startTest(Integer.parseInt(parameter1), Integer.parseInt(parameter2), testThreads);
break;
}
}
};
}

// @Bean
// MappingPdxSerializer myCustomMappingPdxSerializer() {
// logger.warn("XXX Client.myCustomMappingPdxSerializer ", new Exception());
// return MappingPdxSerializer.newMappingPdxSerializer();
// }

private void dumpArguments(ApplicationArguments args) {
logger.info("Client Command Line Arguments: " + Arrays.toString(args.getSourceArgs()));
for (String name : args.getOptionNames()){
logger.info("Client Option Argument: " + name + "=" + args.getOptionValues(name));
}
}

private void waitForever() throws InterruptedException {
Object obj = new Object();
synchronized (obj) {
obj.wait();
}
}
}
Loading

0 comments on commit 5252f0c

Please sign in to comment.