Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: graphform/transit
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.0.1
Choose a base ref
...
head repository: graphform/transit
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 15 commits
  • 24 files changed
  • 3 contributors

Commits on Nov 18, 2022

  1. Bump typescript version to 4.x

    Use gradle clean command in the run script to delete old artificats while re-running
    Remove agencies that are not supported by the API
    Use the zoomed out view as the default view
    ajay-gov committed Nov 18, 2022
    Copy the full SHA
    dc3f512 View commit details

Commits on Nov 22, 2022

  1. Copy the full SHA
    e77c537 View commit details

Commits on Feb 27, 2023

  1. Copy the full SHA
    939f94e View commit details

Commits on May 11, 2023

  1. Copy the full SHA
    a06e3fb View commit details
  2. Copy the full SHA
    e321daa View commit details
  3. Copy the full SHA
    8ffc8c1 View commit details
  4. Added k8s config.

    jcustenborder committed May 11, 2023
    Copy the full SHA
    5e2eb31 View commit details
  5. Copy the full SHA
    d6dfafb View commit details
  6. Copy the full SHA
    bb22ae7 View commit details
  7. Merge pull request #3 from jcustenborder/master

    Nstream demo support
    jcustenborder authored May 11, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    eba8d73 View commit details
  8. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e9ee859 View commit details

Commits on Aug 30, 2023

  1. Replace AgentRoute annotations with node paths in the server.recon file

    Replace deprecated APIs in gradle file
    ajay-gov committed Aug 30, 2023
    Copy the full SHA
    798cddd View commit details

Commits on Oct 3, 2023

  1. Copy the full SHA
    7fcb3bb View commit details

Commits on Mar 5, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    57f1750 View commit details

Commits on May 29, 2024

  1. Update mapbox API token and use standard stylesheet

    ajay-gov committed May 29, 2024
    Copy the full SHA
    c3e8bca View commit details
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -7,3 +7,4 @@ build
out
server/ui
dist/
server/src/main/resources/ui
3 changes: 3 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library('jenkins-pipeline')

demoServerUiPipeline("transit")
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

## Prerequisites

* [Install JDK 9+](https://www.oracle.com/technetwork/java/javase/downloads/index.html).
* [Install JDK 11+](https://www.oracle.com/technetwork/java/javase/downloads/index.html).
* Ensure that your `JAVA_HOME` environment variable is pointed to your Java installation location.
* Ensure that your `PATH` includes `$JAVA_HOME`.

@@ -28,7 +28,7 @@ Execute the command `./run.sh` from a console pointed to the application's home
```

## View the UI
Open the following URL on your browser: http://localhost:9002.
Open the following URL on your browser: http://localhost:9001.

## Run as a Fabric

31 changes: 31 additions & 0 deletions k8s.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: demo-transit
namespace: demo-transit
spec:
replicas: 1
selector:
matchLabels:
demo: transit
serviceName: demo
template:
metadata:
labels:
demo: transit
spec:
containers:
- image: DOCKER_IMAGE
imagePullPolicy: Always
name: demo
ports:
- containerPort: 9001
protocol: TCP
resources:
limits:
cpu: "1"
memory: 1Gi
requests:
cpu: "1"
memory: 1Gi
6 changes: 3 additions & 3 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cd ui
npm install
npm run compile && npm run bundle
mkdir -p ../server/ui
cp -rf index.html dist ../server/ui/
mkdir -p ../server/src/main/resources/ui/
cp -rf dist/* ../server/src/main/resources/ui/
cd ../server
./gradlew run
./gradlew clean run

2 changes: 1 addition & 1 deletion server/README.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

Four different high-level concepts are fundamental to this application: vehicles, agencies, states, and countries.

These concepts share a strictly hierarchical relationship. Each vehicle falls under exactly one (of 67 possible) agencies. Each agency likewise falls under exactly one state, and each state falls under exactly one country.
These concepts share a strictly hierarchical relationship. Each vehicle falls under exactly one agency. Each agency likewise falls under exactly one state, and each state falls under exactly one country.



48 changes: 41 additions & 7 deletions server/build.gradle
Original file line number Diff line number Diff line change
@@ -9,6 +9,11 @@ buildscript {
}
}

plugins {
id 'com.google.cloud.tools.jib' version '3.3.1'
}


apply plugin: 'java-library'
apply plugin: 'application'
apply plugin: 'nebula.ospackage-application'
@@ -25,16 +30,17 @@ def javaVersion = System.getProperty('java.version').split('\\.')
ext.jvmVersion = 11
ext.useModules = !hasProperty('no-modules')
ext.moduleArgs = []
ext.swimVersion=project.property('swim.version')

repositories {
mavenCentral()
}

dependencies {
implementation group: 'org.swimos', name: 'swim-xml', version: version
api group: 'org.swimos', name: 'swim-api', version: version
implementation group: 'org.swimos', name: 'swim-server', version: version
runtimeOnly group: 'org.swimos', name: 'swim-meta', version: version
implementation group: 'org.swimos', name: 'swim-xml', version: swimVersion
api group: 'org.swimos', name: 'swim-api', version: swimVersion
implementation group: 'org.swimos', name: 'swim-server', version: swimVersion
runtimeOnly group: 'org.swimos', name: 'swim-meta', version: swimVersion
}

afterEvaluate {
@@ -73,7 +79,7 @@ afterEvaluate {
}

sourceSets {
main.output.resourcesDir = main.java.outputDir
main.output.resourcesDir = main.java.classesDirectory
}

compileJava {
@@ -84,6 +90,34 @@ afterEvaluate {
exclude '*module-info*'
}

jib {
from {
image = "openjdk:11"
}
to {
image = "nstream/demo-transit:${version}"
auth {
username = "$System.env.REGISTRY_USERNAME"
password = "$System.env.REGISTRY_PASSWORD"
}
}
container {
mainClass = mainClassName
ports = ['9001/tcp']
jvmFlags = ['-Dswim.config=/config/server.recon']
}
extraDirectories {
paths {
path {
// copies a single-file.xml
from = 'src/main/resources'
into = '/config'
includes = ['*.recon']
}
}
}
}

jar {
inputs.property('moduleName', moduleName)
manifest {
@@ -130,7 +164,7 @@ afterEvaluate {
defaultJvmOpts += [
'--module-path', 'APP_HOME_LIBS',
] + moduleArgs + [
'--module', "${moduleName}/${mainClassName}",
'--module', "${moduleName}/${mainClass}",
]
classpath = files()
}
@@ -152,7 +186,7 @@ afterEvaluate {
}

task packageDeb(type: Deb) {
maintainer = 'developer@swim.ai'
maintainer = 'developers@swimos.org'

configurationFile("/etc/sysconfig/${project.name}")
preInstall "addgroup --quiet --system ${project.name}"
3 changes: 2 additions & 1 deletion server/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
application.version=4.0.1
application.version=1.0.0
swim.version=4.1.0.12
2 changes: 1 addition & 1 deletion server/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 1 addition & 0 deletions server/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
requires swim.xml;
requires transitive swim.api;
requires swim.server;
requires java.logging;

exports swim.transit;
exports swim.transit.model;
7 changes: 5 additions & 2 deletions server/src/main/java/swim/transit/NextBusHttpAPI.java
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
import java.net.URL;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Logger;
import java.util.zip.GZIPInputStream;
import swim.api.ref.WarpRef;
import swim.codec.Utf8;
@@ -34,7 +35,7 @@
import swim.xml.Xml;

public class NextBusHttpAPI {

private static final Logger log = Logger.getLogger(NextBusHttpAPI.class.getName());
private NextBusHttpAPI() { }

public static void sendRoutes(List<Agency> agencies, WarpRef warp) {
@@ -79,6 +80,7 @@ private static Routes getRoutes(Agency ag) {
}
return routes;
} catch (Exception e) {
log.severe(() -> String.format("Exception thrown:\n%s", e));
}
return null;
}
@@ -139,6 +141,7 @@ public static Vehicles getVehicleLocations(String pollUrl, Agency ag) {
}
return vehicles;
} catch (Exception e) {
log.severe(() -> String.format("Exception thrown:\n%s", e));
}
return null;
}
@@ -160,7 +163,7 @@ private static Value parse(URL url) {
final Value configValue = Utf8.read(stream, Xml.structureParser().documentParser());
return configValue;
} catch (Throwable e) {
e.printStackTrace();
log.severe(() -> String.format("Exception thrown:\n%s", e));
}
return Value.absent();
}
29 changes: 6 additions & 23 deletions server/src/main/java/swim/transit/TransitPlane.java
Original file line number Diff line number Diff line change
@@ -19,43 +19,25 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import swim.api.SwimAgent;
import swim.api.SwimRoute;
import swim.api.agent.AgentRoute;
import java.util.logging.Logger;

import swim.api.plane.AbstractPlane;
import swim.api.ref.WarpRef;
import swim.api.space.Space;
import swim.kernel.Kernel;
import swim.server.ServerLoader;
import swim.transit.agent.AgencyAgent;
import swim.transit.agent.CountryAgent;
import swim.transit.agent.StateAgent;
import swim.transit.agent.VehicleAgent;
import swim.transit.model.Agency;

public class TransitPlane extends AbstractPlane {
@SwimAgent("country")
@SwimRoute("/country/:id")
AgentRoute<CountryAgent> transitAgent;

@SwimAgent("state")
@SwimRoute("/state/:country/:state")
AgentRoute<StateAgent> stateAgent;

@SwimAgent("agency")
@SwimRoute("/agency/:country/:state/:id")
AgentRoute<AgencyAgent> agencyAgent;

@SwimAgent("vehicle")
@SwimRoute("/vehicle/:country/:state/:agency/:id")
AgentRoute<VehicleAgent> vehicleAgent;
private static final Logger log = Logger.getLogger(TransitPlane.class.getName());

public static void main(String[] args) {
final Kernel kernel = ServerLoader.loadServer();
final Space space = kernel.getSpace("transit");

kernel.start();
System.out.println("Running TransitPlane...");
log.info("Running TransitPlane...");


startAgencies(space);

@@ -90,6 +72,7 @@ private static List<Agency> loadAgencies() {
}
}
} catch (Throwable t) {
log.severe(()->String.format("Exception thrown\n%s", t));
} finally {
try {
if (is != null) {
101 changes: 101 additions & 0 deletions server/src/main/java/swim/transit/TransitUiRouter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// Copyright 2015-2022 Swim.inc
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package swim.transit;

import swim.kernel.KernelProxy;
import swim.structure.Value;
import swim.uri.UriPath;
import swim.web.WebRequest;
import swim.web.WebResponse;
import swim.web.WebRoute;
import swim.web.route.ResourceDirectoryRoute;

/**
* SwimOS kernel module for routing HTTP requests for the bundled UI.
*/
public class TransitUiRouter extends KernelProxy {
final double kernelPriority;
final WebRoute uiRoute;

public TransitUiRouter(double kernelPriority) {
this.kernelPriority = kernelPriority;
this.uiRoute = new ResourceDirectoryRoute(getClass().getClassLoader(), UriPath.parse("ui/"), "index.html");
}

public TransitUiRouter() {
this(KERNEL_PRIORITY);
}

@Override
public final double kernelPriority() {
return this.kernelPriority;
}

@Override
public WebResponse routeRequest(WebRequest request) {
final WebResponse response = this.uiRoute.routeRequest(request);
if (response.isAccepted()) {
return response;
} else {
return super.routeRequest(request);
}
}

@Override
public void trace(Object message) {
// Use this hook to intercept and forward trace log messages
}

@Override
public void debug(Object message) {
// Use this hook to intercept and forward debug log messages
}

@Override
public void info(Object message) {
super.info(message);
// Use this hook to intercept and forward info log messages
}

@Override
public void warn(Object message) {
super.warn(message);
// Use this hook to intercept and forward warning log messages
}

@Override
public void error(Object message) {
super.error(message);
// Use this hook to intercept and forward error log messages
}

@Override
public void fail(Object message) {
super.fail(message);
// Use this hook to intercept and forward failure log messages
}

private static final double KERNEL_PRIORITY = 100.0;

public static TransitUiRouter fromValue(Value moduleConfig) {
final Value header = moduleConfig.getAttr("kernel");
final String kernelClassName = header.get("class").stringValue(null);
if (kernelClassName == null || TransitUiRouter.class.getName().equals(kernelClassName)) {
final double kernelPriority = header.get("priority").doubleValue(KERNEL_PRIORITY);
return new TransitUiRouter(kernelPriority);
}
return null;
}
}
Loading