This repository has been archived by the owner on Jun 7, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ribbon-webapp and hack out the beginning of an example UI
- Loading branch information
Showing
12 changed files
with
230 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
~ | ||
~ Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
--> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.wildfly.swarm.examples</groupId> | ||
<artifactId>wildfly-swarm-examples-ribbon-parent</artifactId> | ||
<version>1.0.0.Alpha6-SNAPSHOT</version> | ||
<relativePath>../</relativePath> | ||
</parent> | ||
|
||
<artifactId>wildfly-swarm-example-ribbon-frontend</artifactId> | ||
|
||
<name>WildFly Swarm Examples: Netflix Ribbon - Front End</name> | ||
<description>WildFly Swarm Examples: Netflix Ribbon - Front End</description> | ||
|
||
<packaging>jar</packaging> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.wildfly.swarm</groupId> | ||
<artifactId>wildfly-swarm-plugin</artifactId> | ||
<configuration> | ||
<mainClass>org.wildfly.swarm.examples.netflix.ribbon.frontend.Main</mainClass> | ||
<properties> | ||
<jboss.bind.address>127.0.0.1</jboss.bind.address> | ||
<java.net.preferIPv4Stack>true</java.net.preferIPv4Stack> | ||
</properties> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>package</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.wildfly.swarm</groupId> | ||
<artifactId>wildfly-swarm-undertow</artifactId> | ||
<version>${version.wildfly-swarm}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.wildfly.swarm</groupId> | ||
<artifactId>wildfly-swarm-ribbon-webapp</artifactId> | ||
<version>${version.wildfly-swarm}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
53 changes: 53 additions & 0 deletions
53
ribbon/frontend/src/main/java/org/wildfly/swarm/examples/netflix/ribbon/frontend/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.wildfly.swarm.examples.netflix.ribbon.frontend; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.wildfly.swarm.container.Container; | ||
import org.wildfly.swarm.jgroups.JGroupsFraction; | ||
import org.wildfly.swarm.undertow.WARArchive; | ||
|
||
/** | ||
* @author Lance Ball | ||
*/ | ||
public class Main { | ||
public static void main(String... args) throws Exception { | ||
Container container = new Container(); | ||
JGroupsFraction fraction = new JGroupsFraction() | ||
.defaultChannel( "swarm-jgroups") | ||
.stack( "udp", (s)->{ | ||
s.transport( "UDP", (t)->{ | ||
t.socketBinding("jgroups-udp"); | ||
}); | ||
s.protocol("TCP", (p -> { | ||
p.property("bind_port", "9090"); | ||
})); | ||
s.protocol("TCPPING", (p)-> { | ||
p.property("initial_hosts", "localhost[9090],localhost[9091],localhost[9092],localhost[9093]") | ||
.property("port_range", "4") | ||
.property("timeout", "3000") | ||
.property("num_initial_members", "4"); | ||
}); | ||
s.protocol( "FD_SOCK", (p)->{ | ||
p.socketBinding( "jgroups-udp-fd" ); | ||
}); | ||
s.protocol( "FD_ALL" ); | ||
s.protocol( "VERIFY_SUSPECT" ); | ||
s.protocol( "pbcast.NAKACK2" ); | ||
s.protocol( "UNICAST3" ); | ||
s.protocol( "pbcast.STABLE" ); | ||
s.protocol( "pbcast.GMS" ); | ||
s.protocol( "UFC" ); | ||
s.protocol( "MFC" ); | ||
s.protocol( "FRAG2" ); | ||
s.protocol( "RSVP" ); | ||
}) | ||
.channel( "swarm-jgroups", (c)->{ | ||
c.stack( "udp" ); | ||
}); | ||
container.fraction(fraction); | ||
container.start(); | ||
WARArchive war = ShrinkWrap.create(WARArchive.class); | ||
war.staticContent(); | ||
war.addAllDependencies(); | ||
container.deploy(war); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
ribbon/frontend/src/main/resources/WEB-INF/undertow-handlers.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
not path-prefix('/ribbon/') and not path-prefix('/css/') and not path-prefix('/js/') and not path-prefix('/images') and regex('/.*') -> rewrite('/index.html') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
body { | ||
font-family: sans-serif; | ||
margin: 1em; | ||
} | ||
|
||
.service { | ||
} | ||
|
||
.service h2 { | ||
border-bottom: 1px dotted; | ||
margin: 1ex; | ||
} | ||
|
||
.service .service-address { | ||
margin: 1ex 2ex; | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>WildFly Swarm Ribbon Example</title> | ||
<link rel="stylesheet" href="/css/app.css"/> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.3/react.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.3/react-dom.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | ||
<script src="/ribbon/ribbon.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div id="app"></div> | ||
<script type="text/babel" src="/js/app.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
var Ribbon = ribbon(); | ||
|
||
var App = React.createClass({ | ||
render: function() { | ||
return ( | ||
<div> | ||
<h1>WildFly Swarm Ribbon Example</h1> | ||
<Topology /> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
var Topology = React.createClass({ | ||
getInitialState: function() { | ||
return {data: []}; | ||
}, | ||
|
||
componentDidMount: function() { | ||
var component = this; | ||
Ribbon.topologyEvents.addEventListener('topologyChange', function(message) { | ||
component.setState({data: JSON.parse(message.data)}); | ||
}); | ||
}, | ||
|
||
render: function() { | ||
var services = []; | ||
for (var service in this.state.data) { | ||
var addresses = this.state.data[service]; | ||
services.push( | ||
( | ||
<Service service={service} addresses={addresses} key={service} /> | ||
) | ||
); | ||
} | ||
return ( | ||
<div id='topology'> | ||
<h2>Service Topology</h2> | ||
{services} | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
var Service = React.createClass({ | ||
render: function() { | ||
var addresses = this.props.addresses.map(function(address) { | ||
return ( | ||
<Address address={address} key={address}/> | ||
); | ||
}); | ||
return ( | ||
<div className='service'> | ||
<h2>{this.props.service}</h2> | ||
{addresses} | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
var Address = React.createClass({ | ||
render: function() { | ||
return ( | ||
<p className='service-address'>{this.props.address}</p> | ||
); | ||
} | ||
}); | ||
|
||
ReactDOM.render( | ||
<App />, | ||
document.getElementById('app') | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,5 +31,6 @@ | |
<modules> | ||
<module>time</module> | ||
<module>events</module> | ||
<module>frontend</module> | ||
</modules> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters