Skip to content

Commit 6b37b96

Browse files
authored
Merge pull request #1 from swimos/version-upgrade
Updates to 3.11.0-SNAPSHOT and updates Gradle to 6.0.1
2 parents d84b5c3 + c9faa1e commit 6b37b96

7 files changed

Lines changed: 55 additions & 57 deletions

File tree

server/build.gradle

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,32 @@ buildscript {
44
repositories {
55
maven { url 'https://plugins.gradle.org/m2/' }
66
}
7-
dependencies {
8-
classpath 'com.netflix.nebula:gradle-ospackage-plugin:6.1.1'
9-
}
107
}
118

12-
apply plugin: 'java'
13-
apply plugin: 'java-library'
14-
apply plugin: 'application'
15-
apply plugin: 'nebula.ospackage-application'
16-
apply plugin: 'idea'
9+
plugins {
10+
id "java"
11+
id "java-library"
12+
id "application"
13+
id "nebula.ospackage-application" version "8.0.3"
14+
id "idea"
15+
}
16+
1717
idea.module.outputDir file("out/production/classes")
1818

1919
group = 'ai.swim'
2020
description = 'Tutorial- Web Agents'
2121
ext.moduleName = 'swim.tutorial'
2222
sourceCompatibility = 1.9
23-
version = project.property('application.version')
23+
version = project.property('swim.version')
2424
mainClassName = 'swim.tutorial.TutorialPlane'
2525

2626
//def moduleName = 'swim.tutorial'
2727
def jvmVersion = System.getProperty('java.version').split('\\.')[0] as Integer
2828
def useModules = jvmVersion >= 9 && !project.hasProperty('no-modules')
2929

3030
repositories {
31-
jcenter()
32-
maven {
33-
url "https://oss.sonatype.org/content/repositories/snapshots/"
34-
}
35-
31+
mavenCentral()
32+
maven { url 'https://swimos.bintray.com/maven/' }
3633
}
3734

3835
dependencies {
@@ -45,7 +42,7 @@ afterEvaluate {
4542
if (useModules) {
4643
doFirst {
4744
options.compilerArgs += [
48-
'--module-path', classpath.asPath,
45+
'--module-path', classpath.asPath,
4946
]
5047
classpath = files()
5148
}
@@ -58,9 +55,9 @@ afterEvaluate {
5855
inputs.property('moduleName', moduleName)
5956
manifest {
6057
attributes(
61-
'Implementation-Title': moduleName,
62-
'Implementation-Version': version,
63-
'Main-Class': mainClassName)
58+
'Implementation-Title': moduleName,
59+
'Implementation-Version': version,
60+
'Main-Class': mainClassName)
6461
}
6562
}
6663

@@ -75,8 +72,8 @@ afterEvaluate {
7572
dependsOn jar
7673
doFirst {
7774
jvmArgs += [
78-
'--module-path', files(configurations.runtimeClasspath, jar.archiveFile).asPath,
79-
'--module', "${moduleName}/${mainClassName}"
75+
'--module-path', files(configurations.runtimeClasspath, jar.archiveFile).asPath,
76+
'--module', "${moduleName}/${mainClassName}"
8077
]
8178
classpath = files()
8279
}
@@ -87,11 +84,11 @@ afterEvaluate {
8784
doFirst {
8885
classpath = files()
8986
defaultJvmOpts = [
90-
'-Dswim.config=/server.recon',
91-
'-Xms3g',
92-
'-Xmx3g',
93-
'--module-path', 'APP_HOME_LIBS',
94-
'--module', "${moduleName}/${mainClassName}"
87+
'-Dswim.config=/server.recon',
88+
'-Xms3g',
89+
'-Xmx3g',
90+
'--module-path', 'APP_HOME_LIBS',
91+
'--module', "${moduleName}/${mainClassName}"
9592
]
9693
}
9794
doLast {
@@ -118,8 +115,8 @@ afterEvaluate {
118115
preInstall "adduser --quiet --system --ingroup ${project.name} --no-create-home --disabled-password ${project.name}"
119116
postInstall "systemctl preset ${project.name} > /dev/null 2>&1"
120117
postInstall "systemctl start ${project.name} > /dev/null 2>&1"
121-
preUninstall "systemctl disable ${project.name} > /dev/null 2>&1"
122-
preUninstall "systemctl stop ${project.name} > /dev/null 2>&1"
118+
preUninstall "systemctl disable ${project.name} > /dev/null 2>&1"
119+
preUninstall "systemctl stop ${project.name} > /dev/null 2>&1"
123120
postUninstall "systemctl daemon-reload > /dev/null 2>&1"
124121

125122
from('pkg') {

server/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
application.version=3.10.1-SNAPSHOT
1+
swim.version=3.11.0-SNAPSHOT
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
#Thu Dec 05 14:19:49 GMT 2019
2+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
13
distributionBase=GRADLE_USER_HOME
24
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
4-
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6+
zipStoreBase=GRADLE_USER_HOME

server/src/main/java/swim/tutorial/DataSource.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ void sendCommands() throws InterruptedException {
4646
Thread.sleep(750);
4747
}
4848
}
49+
4950
}

server/src/main/java/swim/tutorial/TutorialPlane.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@
44
import swim.api.agent.AgentRoute;
55
import swim.api.plane.AbstractPlane;
66
import swim.client.ClientRuntime;
7-
import swim.fabric.Fabric;
87
import swim.kernel.Kernel;
98
import swim.server.ServerLoader;
109

1110
public class TutorialPlane extends AbstractPlane {
1211

1312
@SwimRoute("/unit/:id")
14-
AgentRoute<UnitAgent> unitAgent;
13+
private AgentRoute<UnitAgent> unitAgent;
1514

1615
public static void main(String[] args) throws InterruptedException {
1716
final Kernel kernel = ServerLoader.loadServer();
18-
final Fabric fabric = (Fabric) kernel.getSpace("basic");
1917

2018
kernel.start();
2119
System.out.println("Running Tutorial plane...");
@@ -28,4 +26,5 @@ public static void main(String[] args) throws InterruptedException {
2826
final DataSource ds = new DataSource(client, "warp://localhost:9001");
2927
ds.sendCommands();
3028
}
29+
3130
}
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package swim.tutorial;
22

3-
import java.util.Iterator;
43
import swim.api.SwimLane;
54
import swim.api.agent.AbstractAgent;
65
import swim.api.lane.CommandLane;
@@ -10,35 +9,19 @@
109
import swim.recon.Recon;
1110
import swim.structure.Record;
1211
import swim.structure.Value;
12+
import java.util.Iterator;
1313

1414
public class UnitAgent extends AbstractAgent {
1515

1616
@SwimLane("histogram")
17-
protected final MapLane<Long, Value> histogram = this.<Long, Value>mapLane()
18-
.didUpdate((k,n,o) -> {
17+
private final MapLane<Long, Value> histogram = this.<Long, Value>mapLane()
18+
.didUpdate((k, n, o) -> {
1919
logMessage("histogram: replaced " + k + "'s value to " + Recon.toString(n) + " from " + Recon.toString(o));
2020
dropOldData();
2121
});
2222

23-
24-
private void dropOldData() {
25-
final long now = System.currentTimeMillis();
26-
final Iterator<Long> iterator = histogram.keyIterator();
27-
while(iterator.hasNext()) {
28-
long key = iterator.next();
29-
if ((now - key) > 2*60*1000L) {
30-
// remove items that are older than 2 minutes
31-
histogram.remove(key);
32-
} else {
33-
// map is sorted by the sort order of the keys, so break out of the loop on the first
34-
// key that is newer than 2 minutes
35-
break;
36-
}
37-
}
38-
}
39-
4023
@SwimLane("history")
41-
protected final ListLane<Value> history = this.<Value>listLane()
24+
private final ListLane<Value> history = this.<Value>listLane()
4225
.didUpdate((idx, newValue, oldValue) -> {
4326
logMessage("history: appended {" + idx + ", " + Recon.toString(newValue) + "}");
4427
final long bucket = newValue.getItem(0).longValue() / 5000 * 5000;
@@ -49,14 +32,14 @@ private void dropOldData() {
4932
});
5033

5134
@SwimLane("latest")
52-
protected final ValueLane<Value> latest = this.<Value>valueLane()
35+
private final ValueLane<Value> latest = this.<Value>valueLane()
5336
.didSet((newValue, oldValue) -> {
5437
logMessage("latest: set to " + Recon.toString(newValue) + " from " + Recon.toString(oldValue));
5538
this.history.add(
5639
Record.create(2)
5740
.item(System.currentTimeMillis())
5841
.item(newValue)
59-
);
42+
);
6043
});
6144

6245
@SwimLane("publish")
@@ -66,6 +49,22 @@ private void dropOldData() {
6649
latest.set(v);
6750
});
6851

52+
private void dropOldData() {
53+
final long now = System.currentTimeMillis();
54+
final Iterator<Long> iterator = histogram.keyIterator();
55+
while (iterator.hasNext()) {
56+
long key = iterator.next();
57+
if ((now - key) > 2 * 60 * 1000L) {
58+
// remove items that are older than 2 minutes
59+
histogram.remove(key);
60+
} else {
61+
// map is sorted by the sort order of the keys, so break out of the loop on the first
62+
// key that is newer than 2 minutes
63+
break;
64+
}
65+
}
66+
}
67+
6968
private void logMessage(Object o) {
7069
System.out.println("[" + nodeUri() + "] " + o);
7170
}
@@ -74,4 +73,5 @@ private void logMessage(Object o) {
7473
public void didStart() {
7574
logMessage("Hello, world!");
7675
}
76+
7777
}

server/src/main/resources/server.recon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ tutorial: @fabric {
99
serverCompressionLevel: 0# -1 = default; 0 = off; 1-9 = deflate level
1010
clientCompressionLevel: 0# -1 = default; 0 = off; 1-9 = deflate level
1111
}
12-
}
12+
}

0 commit comments

Comments
 (0)