Skip to content

Commit

Permalink
sample java app
Browse files Browse the repository at this point in the history
  • Loading branch information
suhuruli committed Sep 26, 2017
0 parents commit 87b1b36
Show file tree
Hide file tree
Showing 110 changed files with 1,708 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions .gradle/2.10/taskArtifacts/cache.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#Mon Sep 18 03:41:59 PDT 2017
Binary file added .gradle/2.10/taskArtifacts/cache.properties.lock
Binary file not shown.
Binary file added .gradle/2.10/taskArtifacts/fileHashes.bin
Binary file not shown.
Binary file added .gradle/2.10/taskArtifacts/fileSnapshots.bin
Binary file not shown.
Binary file added .gradle/2.10/taskArtifacts/outputFileStates.bin
Binary file not shown.
Binary file added .gradle/2.10/taskArtifacts/taskArtifacts.bin
Binary file not shown.
1 change: 1 addition & 0 deletions .gradle/2.11/taskArtifacts/cache.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#Fri Sep 22 11:37:13 PDT 2017
Binary file added .gradle/2.11/taskArtifacts/cache.properties.lock
Binary file not shown.
Binary file added .gradle/2.11/taskArtifacts/fileHashes.bin
Binary file not shown.
Binary file added .gradle/2.11/taskArtifacts/fileSnapshots.bin
Binary file not shown.
Binary file added .gradle/2.11/taskArtifacts/outputFileStates.bin
Binary file not shown.
Binary file added .gradle/2.11/taskArtifacts/taskArtifacts.bin
Binary file not shown.
25 changes: 25 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ReliableCollectionsSample</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>servicefabricactor.projectNature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

55 changes: 55 additions & 0 deletions RCMainService/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
apply plugin: 'java'
apply plugin: 'eclipse'

allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-g"
}
}
}

sourceSets {
main {
java.srcDirs = ['src']
output.classesDir = 'out/classes'
resources {
srcDirs = ['src']
}
}
}

dependencies {
compile fileTree(dir: './../../../lib', include: ['*.jar'])
}

clean.doFirst {
delete "out"
delete "../ReliableCollectionsSample/RCMainService/Code/rcmainservice.jar"
delete "../ReliableCollectionsSample/RCMainService/Code/lib"
}

jar {
manifest {
attributes(
'Main-Class': 'reliablecollections.sample.service.ReliableCollectionsSampleServiceHost',
"Class-Path": configurations.compile.collect { 'lib/' + it.getName() }.join(' '))
baseName "rcmainservice"
destinationDir = file('../ReliableCollectionsSample/RCMainService/Code')
}
}

task copyDeps<< {
copy {
from("../../../lib")
into("../ReliableCollectionsSample/RCMainService/Code/lib")
include('*.jar')
}
copy {
from("../../../lib")
into("../ReliableCollectionsSample/RCMainService/Code/lib")
include('*.so')
}
}

defaultTasks 'clean', 'jar', 'copyDeps'
10 changes: 10 additions & 0 deletions RCMainService/build/tmp/jar/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Manifest-Version: 1.0
Main-Class: reliablecollections.sample.service.ReliableCollectionsSamp
leServiceHost
Class-Path: lib/asm-commons-5.0.4.jar lib/asm-analysis-5.0.4.jar lib/a
sm-xml-5.0.4.jar lib/microsoft.servicefabric.fabrictransport-preview.
jar lib/gson-2.7.jar lib/asm-tree-5.0.4.jar lib/system.fabric-preview
.jar lib/microsoft.servicefabric.actors-preview.jar lib/asm-5.0.4.jar
lib/asm-util-5.0.4.jar lib/microsoft.servicefabric.services-preview.
jar

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package reliablecollections.sample.service;

import java.util.Random;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;

import microsoft.servicefabric.data.ReliableStateManager;
import microsoft.servicefabric.services.communication.runtime.CommunicationListener;
import system.fabric.CancellationToken;
import system.fabric.FabricRuntime;
import system.fabric.ServiceContext;
import system.fabric.StatefulServiceContext;
import system.fabric.description.EndpointResourceDescription;

public class HttpCommunicationListener implements CommunicationListener {

private ServiceContext serviceContext;
private String listeningAddress;
private HttpServer httpServer;
private ReliableStateManager stateManager;
public HttpCommunicationListener(ServiceContext serviceContext, ReliableStateManager stateManager) {
this.serviceContext = serviceContext;
this.stateManager = stateManager;
}
@Override
public CompletableFuture<String> openAsync(CancellationToken cancellationToken) {
EndpointResourceDescription serviceEndpoint = this.serviceContext.getCodePackageActivationContext().getEndpoint("ServiceEndpoint");
int port = serviceEndpoint.getPort();
if (serviceContext instanceof StatefulServiceContext){
StatefulServiceContext statefulInitParams = (StatefulServiceContext) this.serviceContext;
String baseAddress = "/";

this.httpServer = new HttpServer(baseAddress, port, stateManager);
this.httpServer.start();

} else {
// TODO
}
return CompletableFuture.completedFuture(this.listeningAddress);
}

@Override
public CompletableFuture<?> closeAsync(CancellationToken cancellationToken) {
this.httpServer.stop();
return CompletableFuture.completedFuture(null);
}

@Override
public void abort() {
this.httpServer.stop();
}

}
Loading

0 comments on commit 87b1b36

Please sign in to comment.