├── .mvn
├── jvm.config
├── maven.config
└── wrapper
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── .gitignore
├── spring-cloud-lattice-connector
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── META-INF
│ │ │ │ └── services
│ │ │ │ ├── org.springframework.cloud.CloudConnector
│ │ │ │ └── org.springframework.cloud.lattice.connector.LatticeServiceInfoCreator
│ │ └── java
│ │ │ └── org
│ │ │ └── springframework
│ │ │ └── cloud
│ │ │ └── lattice
│ │ │ └── connector
│ │ │ ├── RedisServiceInfoCreator.java
│ │ │ ├── Process.java
│ │ │ ├── MysqlServiceInfoCreator.java
│ │ │ ├── LatticeServiceInfoCreator.java
│ │ │ ├── AmqpServiceInfoCreator.java
│ │ │ └── LatticeConnector.java
│ └── test
│ │ ├── java
│ │ └── org
│ │ │ └── springframework
│ │ │ └── cloud
│ │ │ └── lattice
│ │ │ └── connector
│ │ │ ├── RedisServiceInfoCreatorTests.java
│ │ │ ├── AmqpServiceInfoCreatorTests.java
│ │ │ ├── MysqlServiceInfoCreatorTests.java
│ │ │ └── AbstractServiceInfoCreatorTests.java
│ │ └── resources
│ │ └── lattice-test
│ │ ├── alrp.json
│ │ └── dlrp.json
└── pom.xml
├── spring-cloud-lattice-sample
├── src
│ └── main
│ │ ├── resources
│ │ ├── application.yml
│ │ └── bootstrap.yml
│ │ ├── docker
│ │ └── Dockerfile
│ │ └── java
│ │ └── org
│ │ └── springframework
│ │ └── cloud
│ │ └── lattice
│ │ └── sample
│ │ └── SampleLatticeApplication.java
└── pom.xml
├── spring-cloud-lattice-core
├── src
│ └── main
│ │ ├── resources
│ │ └── META-INF
│ │ │ └── spring.factories
│ │ └── java
│ │ └── org
│ │ └── springframework
│ │ └── cloud
│ │ └── lattice
│ │ ├── LatticeAutoConfiguration.java
│ │ ├── LatticeProperties.java
│ │ └── LatticeCloudApplicationListener.java
└── pom.xml
├── spring-cloud-lattice-discovery
├── src
│ └── main
│ │ ├── resources
│ │ └── META-INF
│ │ │ └── spring.factories
│ │ └── java
│ │ └── org
│ │ └── springframework
│ │ └── cloud
│ │ └── lattice
│ │ └── discovery
│ │ ├── LatticeServer.java
│ │ ├── EnableLatticeDiscoveryClient.java
│ │ ├── RibbonLatticeAutoConfiguration.java
│ │ ├── LatticeEnvironmentPostProcessor.java
│ │ ├── LatticeDiscoveryProperties.java
│ │ ├── LatticeServerList.java
│ │ ├── LatticeDiscoveryClientConfiguration.java
│ │ ├── LatticeDiscoveryClient.java
│ │ ├── LatticeRibbonClientConfiguration.java
│ │ ├── ReceptorService.java
│ │ └── config
│ │ └── DiscoverConfigServerBootstrapConfiguration.java
└── pom.xml
├── .travis.yml
├── .settings.xml
├── README.md
├── spring-cloud-security-dependencies
├── pom.xml
└── .factorypath
├── pom.xml
├── spring-cloud-lattice-dependencies
├── pom.xml
└── .factorypath
├── mvnw.cmd
├── mvnw
└── LICENSE.txt
/.mvn/jvm.config:
--------------------------------------------------------------------------------
1 | -Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom
--------------------------------------------------------------------------------
/.mvn/maven.config:
--------------------------------------------------------------------------------
1 | -DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/libs-snapshot-local -P spring
2 |
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spring-attic/spring-cloud-lattice/HEAD/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.3/apache-maven-3.3.3-bin.zip
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *~
2 | #*
3 | *#
4 | .#*
5 | .classpath
6 | .project
7 | .settings/
8 | .springBeans
9 | target/
10 | _site/
11 | .idea
12 | *.iml
13 | *.swp
14 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-connector/src/main/resources/META-INF/services/org.springframework.cloud.CloudConnector:
--------------------------------------------------------------------------------
1 | org.springframework.cloud.lattice.connector.LatticeConnector
--------------------------------------------------------------------------------
/spring-cloud-lattice-sample/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 |
2 | ribbon:
3 | ServerListRefreshInterval: 1000
4 |
5 | endpoints:
6 | health:
7 | sensitive: false
8 | restart:
9 | enabled: true
10 | shutdown:
11 | enabled: true
--------------------------------------------------------------------------------
/spring-cloud-lattice-sample/src/main/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM java:8
2 | VOLUME /tmp
3 | ADD spring-cloud-lattice-sample-1.0.1.BUILD-SNAPSHOT.jar spring-cloud-lattice-sample.jar
4 | RUN bash -c 'touch spring-cloud-lattice-sample.jar'
5 | ENTRYPOINT ["java","-jar","/spring-cloud-lattice-sample.jar"]
--------------------------------------------------------------------------------
/spring-cloud-lattice-sample/src/main/resources/bootstrap.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8080
3 |
4 | #TODO remove when ltc supports PROCESS_GUID env var
5 | spring:
6 | application:
7 | name: ${PROCESS_GUID:spring-cloud-lattice-sample}
8 | cloud:
9 | config:
10 | discovery:
11 | service-id: configserver
--------------------------------------------------------------------------------
/spring-cloud-lattice-connector/src/main/resources/META-INF/services/org.springframework.cloud.lattice.connector.LatticeServiceInfoCreator:
--------------------------------------------------------------------------------
1 | org.springframework.cloud.lattice.connector.AmqpServiceInfoCreator
2 | org.springframework.cloud.lattice.connector.MysqlServiceInfoCreator
3 | org.springframework.cloud.lattice.connector.RedisServiceInfoCreator
4 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-core/src/main/resources/META-INF/spring.factories:
--------------------------------------------------------------------------------
1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
2 | org.springframework.cloud.lattice.LatticeAutoConfiguration
3 |
4 | # Application Listeners
5 | org.springframework.context.ApplicationListener=\
6 | org.springframework.cloud.lattice.LatticeCloudApplicationListener
7 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-discovery/src/main/resources/META-INF/spring.factories:
--------------------------------------------------------------------------------
1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
2 | org.springframework.cloud.lattice.discovery.RibbonLatticeAutoConfiguration
3 |
4 | # Discovery Client Configuration
5 | org.springframework.cloud.client.discovery.EnableDiscoveryClient=\
6 | org.springframework.cloud.lattice.discovery.LatticeDiscoveryClientConfiguration
7 |
8 | # Environment Post Processors
9 | org.springframework.boot.env.EnvironmentPostProcessor=\
10 | org.springframework.cloud.lattice.discovery.LatticeEnvironmentPostProcessor
11 |
12 | org.springframework.cloud.bootstrap.BootstrapConfiguration=\
13 | org.springframework.cloud.lattice.discovery.config.DiscoverConfigServerBootstrapConfiguration
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | before_install:
3 | - git config user.name "$GIT_NAME"
4 | - git config user.email "$GIT_EMAIL"
5 | - git config credential.helper "store --file=.git/credentials"
6 | - echo "https://$GH_TOKEN:@github.com" > .git/credentials
7 | - gem install asciidoctor
8 | - git clone https://github.com/markfisher/receptor-client
9 | - cd receptor-client && ./gradlew clean build install -x test && cd ..
10 | install:
11 | - ./mvnw install -P docs -q -U -DskipTests=true -Dmaven.test.redirectTestOutputToFile=true
12 | #- ./docs/src/main/asciidoc/ghpages.sh
13 | script:
14 | - '[ "${TRAVIS_PULL_REQUEST}" != "false" ] || ./mvnw -s .settings.xml deploy -nsu -Dmaven.test.redirectTestOutputToFile=true'
15 | - '[ "${TRAVIS_PULL_REQUEST}" = "false" ] || ./mvnw install -nsu -Dmaven.test.redirectTestOutputToFile=true'
16 | env:
17 | global:
18 | - GIT_NAME="Spencer Gibb"
19 | - GIT_EMAIL=sgibb@pivotal.io
20 | - CI_DEPLOY_USERNAME=sgibb
21 | - secure: KOapzy/aGVSP418AQeUR+84L2nN/Bb32Tt5hmy4WgO2vibPrJXF9b8Hypy5iRUmdc9vkdxp9nxmM4WU/DrbuNoiqFLt2da7e439q32hdKD1El3uNdbne4hOxQptrRRBDOrwsfQyfAZLS0IYnp7XSTCmWcBD7FKBybTeEJGw7nnE=
22 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-core/src/main/java/org/springframework/cloud/lattice/LatticeAutoConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice;
18 |
19 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
20 | import org.springframework.context.annotation.Bean;
21 | import org.springframework.context.annotation.Configuration;
22 |
23 | /**
24 | * @author Spencer Gibb
25 | */
26 | @Configuration
27 | @EnableConfigurationProperties
28 | public class LatticeAutoConfiguration {
29 |
30 | @Bean
31 | public LatticeProperties latticeProperties() {
32 | return new LatticeProperties();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-core/src/main/java/org/springframework/cloud/lattice/LatticeProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice;
18 |
19 | import lombok.Data;
20 |
21 | import org.springframework.boot.context.properties.ConfigurationProperties;
22 |
23 | /**
24 | * @author Spencer Gibb
25 | */
26 | @ConfigurationProperties("spring.cloud.lattice")
27 | @Data
28 | public class LatticeProperties {
29 | private Receptor receptor = new Receptor();
30 |
31 | @Data
32 | public static class Receptor {
33 | private String host = "receptor.192.168.11.11.xip.io";
34 | private String username;
35 | private String password;
36 | private boolean useRouterAddress;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-core/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | spring-cloud-lattice-core
8 | jar
9 | Spring Cloud Lattice Core
10 | Spring Cloud Lattice Core
11 |
12 |
13 | org.springframework.cloud
14 | spring-cloud-lattice
15 | 1.0.0.BUILD-SNAPSHOT
16 | ..
17 |
18 |
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-autoconfigure
23 |
24 |
25 | org.cloudfoundry.receptor
26 | receptor-client
27 |
28 |
29 | org.projectlombok
30 | lombok
31 |
32 | true
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-starter-test
37 | test
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-core/src/main/java/org/springframework/cloud/lattice/LatticeCloudApplicationListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice;
18 |
19 | import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
20 | import org.springframework.context.ApplicationListener;
21 |
22 | /**
23 | * @author Dave Syer
24 | *
25 | */
26 | public class LatticeCloudApplicationListener implements
27 | ApplicationListener {
28 |
29 | @Override
30 | public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
31 | if (!event.getEnvironment().resolvePlaceholders("${PROCESS_GUID:}").equals("")) {
32 | event.getEnvironment().addActiveProfile("cloud");
33 | event.getEnvironment().addActiveProfile("lattice");
34 | }
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-connector/src/test/java/org/springframework/cloud/lattice/connector/RedisServiceInfoCreatorTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.connector;
18 |
19 | import static org.hamcrest.Matchers.equalTo;
20 | import static org.junit.Assert.assertThat;
21 |
22 | import org.junit.Test;
23 | import org.springframework.cloud.service.common.RedisServiceInfo;
24 |
25 | /**
26 | * @author Spencer Gibb
27 | */
28 | public class RedisServiceInfoCreatorTests extends AbstractServiceInfoCreatorTests {
29 |
30 | @Test
31 | public void mysqlLatticeWorks() {
32 | LatticeConnector connector = createConnector();
33 |
34 | RedisServiceInfo serviceInfo = findServiceInfo(connector, RedisServiceInfo.class, "redis-1");
35 | assertThat(serviceInfo.getUri(), equalTo("redis://192.168.11.11:61001"));
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-connector/src/test/java/org/springframework/cloud/lattice/connector/AmqpServiceInfoCreatorTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.connector;
18 |
19 | import static org.hamcrest.Matchers.equalTo;
20 | import static org.junit.Assert.assertThat;
21 |
22 | import org.junit.Test;
23 | import org.springframework.cloud.service.common.AmqpServiceInfo;
24 |
25 | /**
26 | * @author Spencer Gibb
27 | */
28 | public class AmqpServiceInfoCreatorTests extends AbstractServiceInfoCreatorTests {
29 |
30 | @Test
31 | public void amqpLatticeWorks() {
32 | LatticeConnector connector = createConnector();
33 |
34 | AmqpServiceInfo serviceInfo = findServiceInfo(connector, AmqpServiceInfo.class, "rabbit-1");
35 | assertThat(serviceInfo.getUri(), equalTo("amqp://guest:guest@192.168.11.11:61002"));
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-connector/src/test/java/org/springframework/cloud/lattice/connector/MysqlServiceInfoCreatorTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.connector;
18 |
19 | import static org.hamcrest.Matchers.equalTo;
20 | import static org.junit.Assert.assertThat;
21 |
22 | import org.junit.Test;
23 | import org.springframework.cloud.service.common.MysqlServiceInfo;
24 |
25 | /**
26 | * @author Spencer Gibb
27 | */
28 | public class MysqlServiceInfoCreatorTests extends AbstractServiceInfoCreatorTests {
29 |
30 | @Test
31 | public void mysqlLatticeWorks() {
32 | LatticeConnector connector = createConnector();
33 | MysqlServiceInfo serviceInfo = findServiceInfo(connector, MysqlServiceInfo.class, "mysql-1");
34 | assertThat(serviceInfo.getJdbcUrl(),
35 | equalTo("jdbc:mysql://192.168.11.11:61003/test?user=root&password=password"));
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-connector/src/main/java/org/springframework/cloud/lattice/connector/RedisServiceInfoCreator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.connector;
18 |
19 | import org.springframework.cloud.service.common.RedisServiceInfo;
20 |
21 | import org.cloudfoundry.receptor.commands.ActualLRPResponse;
22 |
23 | /**
24 | * @author Spencer Gibb
25 | */
26 | public class RedisServiceInfoCreator extends LatticeServiceInfoCreator {
27 |
28 | public RedisServiceInfoCreator() {
29 | super("redis");
30 | }
31 |
32 | @Override
33 | public RedisServiceInfo createServiceInfo(Process process) {
34 | ActualLRPResponse actual = process.getFirstActual();
35 | String address = actual.getAddress();
36 | int port = actual.getPorts()[0].getHostPort();
37 | String password = null;
38 | return new RedisServiceInfo(actual.getInstanceGuid(), address, port, password);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-connector/src/main/java/org/springframework/cloud/lattice/connector/Process.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.connector;
18 |
19 | import java.util.ArrayList;
20 | import java.util.List;
21 |
22 | import lombok.Data;
23 |
24 | import org.cloudfoundry.receptor.commands.ActualLRPResponse;
25 | import org.cloudfoundry.receptor.commands.DesiredLRPResponse;
26 |
27 | /**
28 | * @author Spencer Gibb
29 | */
30 | @Data
31 | public class Process {
32 | private final DesiredLRPResponse desired;
33 | private final List actuals = new ArrayList<>();
34 |
35 | public ActualLRPResponse getFirstActual() {
36 | if (actuals.isEmpty()) {
37 | throw new IllegalArgumentException("empty actuals");
38 | }
39 | return actuals.get(0);
40 | }
41 |
42 | public String getProcessGuid() {
43 | return desired.getProcessGuid();
44 | }
45 |
46 | public void add(ActualLRPResponse actual) {
47 | actuals.add(actual);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-discovery/src/main/java/org/springframework/cloud/lattice/discovery/LatticeServer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.discovery;
18 |
19 | import com.netflix.loadbalancer.Server;
20 |
21 | /**
22 | * @author Spencer Gibb
23 | */
24 | public class LatticeServer extends Server {
25 |
26 | private final MetaInfo metaInfo;
27 |
28 | public LatticeServer(final String appName, final String instanceId, String host,
29 | String port) {
30 | super(host, new Integer(port));
31 | metaInfo = new MetaInfo() {
32 | @Override
33 | public String getAppName() {
34 | return appName;
35 | }
36 |
37 | @Override
38 | public String getServerGroup() {
39 | return null;
40 | }
41 |
42 | @Override
43 | public String getServiceIdForDiscovery() {
44 | return null;
45 | }
46 |
47 | @Override
48 | public String getInstanceId() {
49 | return instanceId;
50 | }
51 | };
52 | }
53 |
54 | @Override
55 | public MetaInfo getMetaInfo() {
56 | return metaInfo;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-connector/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | spring-cloud-lattice-connector
8 | jar
9 | Spring Cloud Lattice Connector
10 | Spring Cloud Lattice Connector
11 |
12 |
13 | org.springframework.cloud
14 | spring-cloud-lattice
15 | 1.0.0.BUILD-SNAPSHOT
16 | ..
17 |
18 |
19 |
20 |
21 |
22 | org.springframework.cloud
23 | spring-cloud-core
24 |
25 |
26 | org.cloudfoundry.receptor
27 | receptor-client
28 |
29 |
30 | org.projectlombok
31 | lombok
32 |
33 | true
34 |
35 |
36 | org.springframework.boot
37 | spring-boot-starter-test
38 | test
39 |
40 |
41 | org.springframework.boot
42 | spring-boot-starter-logging
43 | test
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-discovery/src/main/java/org/springframework/cloud/lattice/discovery/EnableLatticeDiscoveryClient.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.discovery;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.ElementType;
21 | import java.lang.annotation.Inherited;
22 | import java.lang.annotation.Retention;
23 | import java.lang.annotation.RetentionPolicy;
24 | import java.lang.annotation.Target;
25 |
26 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
27 |
28 | /**
29 | * Convenience annotation for clients to enable Lattice discovery configuration
30 | * (specifically). Use this (optionally) in case you want discovery and know for sure that
31 | * it is Lattice you want. All it does is turn on discovery and let the autoconfiguration
32 | * find the eureka classes if they are available (i.e. you need receptor on the classpath
33 | * as well).
34 | *
35 | * @author Dave Syer
36 | * @author Spencer Gibb
37 | */
38 | @Target(ElementType.TYPE)
39 | @Retention(RetentionPolicy.RUNTIME)
40 | @Documented
41 | @Inherited
42 | @EnableDiscoveryClient
43 | public @interface EnableLatticeDiscoveryClient {
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-discovery/src/main/java/org/springframework/cloud/lattice/discovery/RibbonLatticeAutoConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2014 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.discovery;
18 |
19 | import org.springframework.boot.autoconfigure.AutoConfigureAfter;
20 | import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
21 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
22 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
23 | import org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration;
24 | import org.springframework.cloud.netflix.ribbon.RibbonClients;
25 | import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
26 | import org.springframework.context.annotation.Configuration;
27 |
28 | /**
29 | * @author Dave Syer
30 | */
31 | @Configuration
32 | @EnableConfigurationProperties
33 | @ConditionalOnBean(SpringClientFactory.class)
34 | @ConditionalOnProperty(value = "ribbon.lattice.enabled", matchIfMissing = true)
35 | @AutoConfigureAfter(RibbonAutoConfiguration.class)
36 | @RibbonClients(defaultConfiguration = LatticeRibbonClientConfiguration.class)
37 | public class RibbonLatticeAutoConfiguration {
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-connector/src/test/resources/lattice-test/alrp.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "process_guid": "redis",
4 | "instance_guid": "redis-1",
5 | "cell_id": "lattice-cell-01",
6 | "domain": "lattice",
7 | "index": 0,
8 | "address": "192.168.11.11",
9 | "ports": [
10 | {
11 | "container_port": 6379,
12 | "host_port": 61001
13 | }
14 | ],
15 | "state": "RUNNING",
16 | "crash_count": 0,
17 | "since": 1429561928335848700,
18 | "evacuating": false,
19 | "modification_tag": {
20 | "epoch": "95a2c14e-7ac1-484a-7ef5-e4cc8bcbf308",
21 | "index": 2
22 | }
23 | },
24 | {
25 | "process_guid": "rabbit",
26 | "instance_guid": "rabbit-1",
27 | "cell_id": "lattice-cell-01",
28 | "domain": "lattice",
29 | "index": 0,
30 | "address": "192.168.11.11",
31 | "ports": [
32 | {
33 | "container_port": 5672,
34 | "host_port": 61002
35 | }
36 | ],
37 | "state": "RUNNING",
38 | "crash_count": 0,
39 | "since": 1429562034084270600,
40 | "evacuating": false,
41 | "modification_tag": {
42 | "epoch": "6885eb4b-9bee-4a94-78a3-cc553caa0dcb",
43 | "index": 2
44 | }
45 | },
46 | {
47 | "process_guid": "mysql",
48 | "instance_guid": "mysql-1",
49 | "cell_id": "lattice-cell-01",
50 | "domain": "lattice",
51 | "index": 0,
52 | "address": "192.168.11.11",
53 | "ports": [
54 | {
55 | "container_port": 3306,
56 | "host_port": 61003
57 | }
58 | ],
59 | "state": "RUNNING",
60 | "crash_count": 0,
61 | "since": 1429562159451845000,
62 | "evacuating": false,
63 | "modification_tag": {
64 | "epoch": "70045c14-8d67-4fb9-67a4-115b4f0ff99f",
65 | "index": 2
66 | }
67 | }
68 | ]
69 |
--------------------------------------------------------------------------------
/.settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | repo.spring.io
6 | ${env.CI_DEPLOY_USERNAME}
7 | ${env.CI_DEPLOY_PASSWORD}
8 |
9 |
10 |
11 |
12 |
18 | spring
19 | true
20 |
21 |
22 | spring-snapshots
23 | Spring Snapshots
24 | http://repo.spring.io/libs-snapshot-local
25 |
26 | true
27 |
28 |
29 |
30 | spring-milestones
31 | Spring Milestones
32 | http://repo.spring.io/libs-milestone-local
33 |
34 | false
35 |
36 |
37 |
38 | spring-releases
39 | Spring Releases
40 | http://repo.spring.io/release
41 |
42 | false
43 |
44 |
45 |
46 |
47 |
48 | spring-snapshots
49 | Spring Snapshots
50 | http://repo.spring.io/libs-snapshot-local
51 |
52 | true
53 |
54 |
55 |
56 | spring-milestones
57 | Spring Milestones
58 | http://repo.spring.io/libs-milestone-local
59 |
60 | false
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-discovery/src/main/java/org/springframework/cloud/lattice/discovery/LatticeEnvironmentPostProcessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.discovery;
18 |
19 | import java.util.Collections;
20 |
21 | import org.springframework.boot.SpringApplication;
22 | import org.springframework.boot.context.config.ConfigFileApplicationListener;
23 | import org.springframework.boot.env.EnvironmentPostProcessor;
24 | import org.springframework.core.Ordered;
25 | import org.springframework.core.env.ConfigurableEnvironment;
26 | import org.springframework.core.env.MapPropertySource;
27 |
28 | /**
29 | * @author Spencer Gibb
30 | */
31 | public class LatticeEnvironmentPostProcessor implements
32 | EnvironmentPostProcessor, Ordered {
33 |
34 | // Before ConfigFileApplicationListener
35 | private int order = ConfigFileApplicationListener.DEFAULT_ORDER - 1;
36 |
37 | @Override
38 | public int getOrder() {
39 | return this.order;
40 | }
41 |
42 | @Override
43 | public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
44 | Object processGuid = System.getenv("PROCESS_GUID");
45 | if (processGuid != null) {
46 | MapPropertySource propertySource = new MapPropertySource(
47 | "latticeBridgeEnvironment", Collections.singletonMap(
48 | "spring.application.name", processGuid));
49 | environment.getPropertySources().addLast(propertySource);
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## This project is obselete and no longer maintained.
2 |
3 | ## Spring Cloud Lattice
4 |
5 | Preview of Spring Cloud Lattice implementation
6 |
7 | ### Setup
8 |
9 | Tested with lattice v0.5.0
10 |
11 | Create redis, rabbit and mysql using the [lattice docs](http://lattice.cf/docs/docker-image-examples/).
12 |
13 | ```
14 | mysql -h"192.168.11.11" -p"somesecret" -u"root"
15 | CREATE DATABASE test;
16 | ```
17 |
18 | ### Running the sample
19 |
20 | 1. [Install lattice](http://lattice.cf/docs/getting-started.html)
21 | 2. Follow the getting started guide, including scaling `lattice-app` to 3
22 | 4. run `mvn --settings .settings.xml install`
23 | 5. run `PROCESS_GUID=spring-cloud-lattice-sample java -jar spring-cloud-lattice-sample/target/spring-cloud-lattice-sample-1.0.0.BUILD-SNAPSHOT.jar`
24 | 6. visit [http://localhost:8080?service=lattice-app](http://localhost:8080?service=lattice-app) verify that the 3 services rotate through as you refresh
25 |
26 | ### Running the sample ON LATTICE
27 |
28 | 1. `./mvnw clean package`
29 | 1. `ltc build-droplet sc-lattice-sample java --path=spring-cloud-lattice-sample/target/spring-cloud-lattice-sample-1.0.0.BUILD-SNAPSHOT.jar`
30 | 1. `ltc launch-droplet sc-lattice-sample sc-lattice-sample`
31 | 1. visit [http://spring-cloud-lattice-sample.192.168.11.11.xip.io?service=sc-lattice-sample](http://spring-cloud-lattice-sample.192.168.11.11.xip.io?service=sc-lattice-sample) verify that the 3 services rotate through as you refresh
32 | 1. visit [http://sc-lattice-sample.192.168.11.11.xip.io/me](http://sc-lattice-sample.192.168.11.11.xip.io/me) verify that the 3 services rotate through as you refresh
33 |
34 | ### IDE Discovery
35 |
36 | if you run SampleLatticeApplication in the IDE on port 8081 you can run it on lattice
37 | with the following command
38 |
39 | `LATTICE_CLI_TIMEOUT=180 ltc create spring-cloud-lattice-sample spencergibb/spring-cloud-lattice-sample -- java -jar /spring-cloud-lattice-sample.jar --spring.cloud.lattice.discovery.routes.myservice.port=8081`
40 |
41 | Then call `http://spring-cloud-lattice-sample.192.168.11.11.xip.io/call` and it will hit
42 | the service running in the ide.
43 |
44 | ### Config Server
45 |
46 | TODO: document using catalyst `ltc create -m 512 catalyst mstine/catalyst`
47 |
48 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-connector/src/main/java/org/springframework/cloud/lattice/connector/MysqlServiceInfoCreator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.connector;
18 |
19 | import org.cloudfoundry.receptor.commands.ActualLRPResponse;
20 | import org.springframework.cloud.service.common.MysqlServiceInfo;
21 | import org.springframework.cloud.util.UriInfo;
22 |
23 | /**
24 | * @author Spencer Gibb
25 | */
26 | public class MysqlServiceInfoCreator extends LatticeServiceInfoCreator {
27 |
28 | public MysqlServiceInfoCreator() {
29 | super("mysql");
30 | }
31 |
32 | @Override
33 | public MysqlServiceInfo createServiceInfo(Process process) {
34 | ActualLRPResponse actual = process.getFirstActual();
35 | String scheme = "jdbc:"+ MysqlServiceInfo.MYSQL_SCHEME;
36 | String address = actual.getAddress();
37 | int port = actual.getPorts()[0].getHostPort();
38 | String username = "root";
39 | String password = findRequiredEnvVar(process, "MYSQL_ROOT_PASSWORD");
40 | String path = findEnvVar(process, "MYSQL_DATABASE_NAME", "test");
41 |
42 | return new MysqlServiceInfo(actual.getInstanceGuid(), constructJdbcUrl(scheme, address, port, username, password, path));
43 | }
44 |
45 | private String constructJdbcUrl(String scheme, String address, int port, String username, String password, String path) {
46 | return new StringBuilder().append(scheme)
47 | .append("://")
48 | .append(address)
49 | .append(":")
50 | .append(port)
51 | .append("/")
52 | .append(path)
53 | .append("?user=")
54 | .append(username)
55 | .append("&password=")
56 | .append(password).toString();
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-discovery/src/main/java/org/springframework/cloud/lattice/discovery/LatticeDiscoveryProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.discovery;
18 |
19 | import java.net.InetAddress;
20 | import java.util.LinkedHashMap;
21 | import java.util.Map;
22 |
23 | import lombok.AccessLevel;
24 | import lombok.Data;
25 | import lombok.Getter;
26 | import lombok.Setter;
27 | import lombok.SneakyThrows;
28 |
29 | import org.springframework.boot.context.properties.ConfigurationProperties;
30 |
31 | /**
32 | * @author Spencer Gibb
33 | */
34 | @ConfigurationProperties("spring.cloud.lattice.discovery")
35 | @Data
36 | public class LatticeDiscoveryProperties {
37 | private boolean enabled = true;
38 |
39 | @Getter(AccessLevel.PRIVATE)
40 | @Setter(AccessLevel.PRIVATE)
41 | private HostInfo hostInfo = initHostInfo();
42 |
43 | private String ipAddress = this.hostInfo.getIpAddress();
44 |
45 | private String hostname = this.hostInfo.getHostname();
46 |
47 | private boolean preferIpAddress = false;
48 |
49 | private Map routes = new LinkedHashMap<>();
50 |
51 | public String getHostname() {
52 | return this.preferIpAddress ? this.ipAddress : this.hostname;
53 | }
54 |
55 | @SneakyThrows
56 | private HostInfo initHostInfo() {
57 | return new HostInfo(InetAddress.getLocalHost().getHostAddress(), InetAddress
58 | .getLocalHost().getHostName());
59 | }
60 |
61 | @Data
62 | private class HostInfo {
63 | private final String ipAddress;
64 | private final String hostname;
65 | }
66 |
67 | @Data
68 | protected static class Route {
69 | private String address = "192.168.11.1";
70 | private int port;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-connector/src/main/java/org/springframework/cloud/lattice/connector/LatticeServiceInfoCreator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.connector;
18 |
19 | import org.cloudfoundry.receptor.support.EnvironmentVariable;
20 | import org.springframework.cloud.ServiceInfoCreator;
21 | import org.springframework.cloud.service.ServiceInfo;
22 |
23 | /**
24 | * @author Spencer Gibb
25 | */
26 | public abstract class LatticeServiceInfoCreator implements ServiceInfoCreator {
27 |
28 | private final String prefix;
29 |
30 | protected LatticeServiceInfoCreator(String prefix) {
31 | this.prefix = prefix;
32 | }
33 |
34 | @Override
35 | public boolean accept(Process process) {
36 | return process.getProcessGuid().toLowerCase().startsWith(getPrefix());
37 | }
38 |
39 | protected String getPrefix() {
40 | return this.prefix;
41 | }
42 |
43 | protected String findRequiredEnvVar(Process process, String varName) {
44 | String value = findEnvVar(process, varName);
45 | if (value == null) {
46 | throw new IllegalStateException(varName + " env var is missing");
47 | }
48 | return value;
49 | }
50 |
51 | protected String findEnvVar(Process process, String varName, String defaultValue) {
52 | String value = findEnvVar(process, varName);
53 | if (value == null) {
54 | return defaultValue;
55 | }
56 | return value;
57 | }
58 |
59 | protected String findEnvVar(Process process, String varName) {
60 | String value = null;
61 | for (EnvironmentVariable env : process.getDesired().getEnv()) {
62 | if (env.getName().equals(varName)) {
63 | value = env.getValue();
64 | }
65 | }
66 | return value;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-discovery/src/main/java/org/springframework/cloud/lattice/discovery/LatticeServerList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.discovery;
18 |
19 | import java.util.List;
20 |
21 | import lombok.SneakyThrows;
22 |
23 | import org.springframework.core.convert.converter.Converter;
24 |
25 | import com.netflix.client.config.IClientConfig;
26 | import com.netflix.loadbalancer.AbstractServerList;
27 |
28 | import org.cloudfoundry.receptor.commands.ActualLRPResponse;
29 |
30 | /**
31 | * @author Spencer Gibb
32 | */
33 | public class LatticeServerList extends AbstractServerList {
34 |
35 | private LatticeDiscoveryProperties props;
36 | private ReceptorService receptorService;
37 | private String serviceId;
38 |
39 | public LatticeServerList(LatticeDiscoveryProperties props,
40 | ReceptorService receptorService, String serviceId) {
41 | this.props = props;
42 | this.receptorService = receptorService;
43 | this.serviceId = serviceId;
44 | }
45 |
46 | @Override
47 | public void initWithNiwsConfig(IClientConfig clientConfig) {
48 | this.serviceId = clientConfig.getClientName();
49 | }
50 |
51 | @Override
52 | public List getInitialListOfServers() {
53 | return getServers();
54 | }
55 |
56 | @Override
57 | public List getUpdatedListOfServers() {
58 | return getServers();
59 | }
60 |
61 | @SneakyThrows
62 | private List getServers() {
63 | List servers = receptorService.getActualLRPsByProcessGuid(
64 | serviceId, new Converter() {
65 | @Override
66 | public LatticeServer convert(ActualLRPResponse response) {
67 | return new LatticeServer(response.getProcessGuid(), response
68 | .getInstanceGuid(), response.getAddress(), String
69 | .valueOf(response.getPorts()[0].getHostPort()));
70 | }
71 | });
72 |
73 | return servers;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-discovery/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | spring-cloud-lattice-discovery
8 | jar
9 | Spring Cloud Lattice Discovery
10 | Spring Cloud Lattice Discovery
11 |
12 |
13 | org.springframework.cloud
14 | spring-cloud-lattice
15 | 1.0.0.BUILD-SNAPSHOT
16 | ..
17 |
18 |
19 |
20 |
21 | commons-logging
22 | commons-logging
23 | 1.2
24 | true
25 |
26 |
27 | org.springframework.cloud
28 | spring-cloud-lattice-core
29 |
30 |
31 | org.springframework.cloud
32 | spring-cloud-commons
33 |
34 |
35 | org.springframework.cloud
36 | spring-cloud-config-client
37 | true
38 |
39 |
40 | org.springframework.cloud
41 | spring-cloud-netflix-core
42 |
43 |
44 | com.netflix.ribbon
45 | ribbon
46 |
47 |
48 | com.netflix.ribbon
49 | ribbon-core
50 |
51 |
52 | com.netflix.ribbon
53 | ribbon-loadbalancer
54 |
55 |
56 | com.netflix.ribbon
57 | ribbon-httpclient
58 |
59 |
60 | com.netflix.archaius
61 | archaius-core
62 |
63 |
64 | org.cloudfoundry.receptor
65 | receptor-client
66 |
67 |
68 | org.projectlombok
69 | lombok
70 |
71 | true
72 |
73 |
74 | org.springframework.boot
75 | spring-boot-starter-test
76 | test
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-discovery/src/main/java/org/springframework/cloud/lattice/discovery/LatticeDiscoveryClientConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.discovery;
18 |
19 | import org.cloudfoundry.receptor.client.ReceptorClient;
20 |
21 | import org.springframework.beans.factory.annotation.Autowired;
22 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
23 | import org.springframework.boot.test.TestRestTemplate;
24 | import org.springframework.cloud.lattice.LatticeProperties;
25 | import org.springframework.context.annotation.Bean;
26 | import org.springframework.context.annotation.Configuration;
27 | import org.springframework.http.client.ClientHttpRequestFactory;
28 | import org.springframework.util.StringUtils;
29 |
30 | /**
31 | * @author Spencer Gibb
32 | */
33 | @Configuration
34 | @EnableConfigurationProperties
35 | public class LatticeDiscoveryClientConfiguration {
36 |
37 | @Autowired
38 | private LatticeProperties latticeProperties;
39 |
40 | @Bean
41 | public ReceptorService receptorService() {
42 | return new ReceptorService(receptorClient(), latticeProperties, latticeDiscoveryProperties());
43 | }
44 |
45 | @Bean
46 | public ReceptorClient receptorClient() {
47 | if (!StringUtils
48 | .hasText(latticeProperties.getReceptor().getUsername())) {
49 | return new ReceptorClient(latticeProperties.getReceptor()
50 | .getHost());
51 | }
52 | return new ReceptorClient(latticeProperties.getReceptor().getHost(),
53 | getClientRequestFactory());
54 | }
55 |
56 | private ClientHttpRequestFactory getClientRequestFactory() {
57 | String username = latticeProperties.getReceptor().getUsername();
58 | String password = latticeProperties.getReceptor().getPassword();
59 | return new TestRestTemplate(username, password).getRequestFactory();
60 | }
61 |
62 | @Bean
63 | public LatticeDiscoveryClient latticeDiscoveryClient() {
64 | return new LatticeDiscoveryClient(receptorService(), receptorClient());
65 | }
66 |
67 | @Bean
68 | public LatticeDiscoveryProperties latticeDiscoveryProperties() {
69 | return new LatticeDiscoveryProperties();
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-connector/src/main/java/org/springframework/cloud/lattice/connector/AmqpServiceInfoCreator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.connector;
18 |
19 | import org.springframework.cloud.service.common.AmqpServiceInfo;
20 |
21 | import org.cloudfoundry.receptor.commands.ActualLRPResponse;
22 | import org.springframework.cloud.util.UriInfo;
23 |
24 | /**
25 | * @author Spencer Gibb
26 | */
27 | public class AmqpServiceInfoCreator extends LatticeServiceInfoCreator {
28 |
29 | public AmqpServiceInfoCreator() {
30 | super("rabbit");
31 | }
32 |
33 | @Override
34 | public AmqpServiceInfo createServiceInfo(Process process) {
35 | ActualLRPResponse actual = process.getFirstActual();
36 | String address = actual.getAddress();
37 | int port = actual.getPorts()[0].getHostPort();
38 | String username = "guest";
39 | String password = "guest";
40 | String virtualHost = null;
41 | return new LatticeAmqpServiceInfo(actual.getInstanceGuid(), address, port, username, password, virtualHost);
42 | }
43 |
44 |
45 | private static class LatticeAmqpServiceInfo extends AmqpServiceInfo {
46 | public LatticeAmqpServiceInfo(String id, String host, int port, String username, String password, String virtualHost) {
47 | super(id, host, port, username, password, virtualHost);
48 | }
49 |
50 | @Override
51 | protected UriInfo validateAndCleanUriInfo(UriInfo uriInfo) {
52 | if (uriInfo.getScheme() == null) {
53 | throw new IllegalArgumentException("Missing scheme in amqp URI: " + uriInfo);
54 | }
55 |
56 | if (uriInfo.getHost() == null) {
57 | throw new IllegalArgumentException("Missing authority in amqp URI: " + uriInfo);
58 | }
59 |
60 | if (uriInfo.getUserName() == null || uriInfo.getPassword() == null) {
61 | throw new IllegalArgumentException("Missing userinfo in amqp URI: " + uriInfo);
62 | }
63 |
64 | String path = uriInfo.getPath();
65 | if (path == null) {
66 | //NO-OP, this is the default vhost
67 | } else {
68 | // Check that the path only has a single segment. As we have an authority component
69 | // in the URI, paths always begin with a slash.
70 | if (path.indexOf('/') != -1) {
71 | throw new IllegalArgumentException("Multiple segments in path of amqp URI: " + uriInfo);
72 | }
73 | }
74 | return uriInfo;
75 | }
76 | }
77 |
78 | }
--------------------------------------------------------------------------------
/spring-cloud-security-dependencies/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | spring-cloud-dependencies-parent
7 | org.springframework.cloud
8 | 1.1.0.BUILD-SNAPSHOT
9 |
10 |
11 | spring-cloud-commons-dependencies
12 | 1.1.0.BUILD-SNAPSHOT
13 | pom
14 | spring-cloud-commons-dependencies
15 | Spring Cloud Commons Dependencies
16 |
17 | 1.1.0.BUILD-SNAPSHOT
18 |
19 |
20 |
21 |
22 | org.springframework.cloud
23 | spring-cloud-commons
24 | 1.1.0.BUILD-SNAPSHOT
25 |
26 |
27 | org.springframework.cloud
28 | spring-cloud-context
29 | 1.1.0.BUILD-SNAPSHOT
30 |
31 |
32 | org.springframework.cloud
33 | spring-cloud-starter
34 | 1.1.0.BUILD-SNAPSHOT
35 |
36 |
37 |
38 |
39 |
40 | spring
41 |
42 |
43 | spring-snapshots
44 | Spring Snapshots
45 | https://repo.spring.io/libs-snapshot-local
46 |
47 | true
48 |
49 |
50 |
51 | spring-milestones
52 | Spring Milestones
53 | https://repo.spring.io/libs-milestone-local
54 |
55 | false
56 |
57 |
58 |
59 | spring-releases
60 | Spring Releases
61 | https://repo.spring.io/release
62 |
63 | false
64 |
65 |
66 |
67 |
68 |
69 | spring-snapshots
70 | Spring Snapshots
71 | https://repo.spring.io/libs-snapshot-local
72 |
73 | true
74 |
75 |
76 |
77 | spring-milestones
78 | Spring Milestones
79 | https://repo.spring.io/libs-milestone-local
80 |
81 | false
82 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-discovery/src/main/java/org/springframework/cloud/lattice/discovery/LatticeDiscoveryClient.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.discovery;
18 |
19 | import java.util.ArrayList;
20 | import java.util.LinkedHashSet;
21 | import java.util.List;
22 |
23 | import org.cloudfoundry.receptor.client.ReceptorClient;
24 | import org.springframework.beans.factory.annotation.Value;
25 | import org.springframework.cloud.client.DefaultServiceInstance;
26 | import org.springframework.cloud.client.ServiceInstance;
27 | import org.springframework.cloud.client.discovery.DiscoveryClient;
28 | import org.springframework.core.convert.converter.Converter;
29 |
30 | import org.cloudfoundry.receptor.commands.ActualLRPResponse;
31 |
32 | /**
33 | * @author Spencer Gibb
34 | */
35 | public class LatticeDiscoveryClient implements DiscoveryClient {
36 |
37 | private final ReceptorService receptorService;
38 | private final ReceptorClient receptorClient;
39 |
40 | @Value("${spring.application.name}")
41 | private String serviceId;
42 |
43 | @Value("${cf.instance.ip:127.0.0.1}")
44 | private String host;
45 |
46 | @Value("${cf.instance.port:${server.port}}")
47 | private int port;
48 |
49 | public LatticeDiscoveryClient(ReceptorService receptorService, ReceptorClient receptorClient) {
50 | this.receptorService = receptorService;
51 | this.receptorClient = receptorClient;
52 | }
53 |
54 | @Override
55 | public String description() {
56 | return "Spring Cloud Lattice Discovery Client";
57 | }
58 |
59 | @Override
60 | public ServiceInstance getLocalServiceInstance() {
61 | return new DefaultServiceInstance(serviceId, host, port, false);
62 | }
63 |
64 | @Override
65 | public List getInstances(final String serviceId) {
66 | List instances = receptorService.getActualLRPsByProcessGuid(
67 | serviceId, new Converter() {
68 | @Override
69 | public ServiceInstance convert(ActualLRPResponse response) {
70 | return new DefaultServiceInstance(serviceId, response
71 | .getAddress(), response.getPorts()[0].getHostPort(),
72 | false);
73 | }
74 | });
75 |
76 | return instances;
77 | }
78 |
79 | @Override
80 | public List getServices() {
81 | LinkedHashSet services = new LinkedHashSet<>();
82 | List responses = receptorClient.getActualLRPs();
83 |
84 | for (ActualLRPResponse response : responses) {
85 | services.add(response.getProcessGuid());
86 | }
87 | return new ArrayList<>(services);
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | org.springframework.cloud
8 | spring-cloud-lattice
9 | 1.0.0.BUILD-SNAPSHOT
10 | pom
11 | Spring Cloud Lattice
12 | Spring Cloud Lattice
13 |
14 |
15 | org.springframework.cloud
16 | spring-cloud-build
17 | 1.1.0.BUILD-SNAPSHOT
18 |
19 |
20 |
21 |
22 |
23 | https://github.com/spring-cloud/spring-cloud-lattice
24 |
25 | scm:git:git://github.com/spring-cloud/spring-cloud-lattice.git
26 |
27 |
28 | scm:git:ssh://git@github.com/spring-cloud/spring-cloud-lattice.git
29 |
30 | HEAD
31 |
32 |
33 |
34 | spring-cloud-lattice-dependencies
35 | spring-cloud-lattice-core
36 | spring-cloud-lattice-discovery
37 | spring-cloud-lattice-connector
38 | spring-cloud-lattice-sample
39 |
40 |
41 |
42 |
43 |
44 | org.springframework.cloud
45 | spring-cloud-lattice-dependencies
46 | ${project.version}
47 | pom
48 | import
49 |
50 |
51 |
52 |
53 |
54 | 1.0.0.M1
55 |
56 |
57 |
58 |
59 | spring
60 |
61 |
62 | spring-snapshots
63 | Spring Snapshots
64 | https://repo.spring.io/libs-snapshot-local
65 |
66 | true
67 |
68 |
69 |
70 | spring-milestones
71 | Spring Milestones
72 | https://repo.spring.io/libs-milestone-local
73 |
74 | false
75 |
76 |
77 |
78 | spring-releases
79 | Spring Releases
80 | https://repo.spring.io/release
81 |
82 | false
83 |
84 |
85 |
86 |
87 |
88 | spring-snapshots
89 | Spring Snapshots
90 | https://repo.spring.io/libs-snapshot-local
91 |
92 | true
93 |
94 |
95 |
96 | spring-milestones
97 | Spring Milestones
98 | https://repo.spring.io/libs-milestone-local
99 |
100 | false
101 |
102 |
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-dependencies/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | spring-cloud-dependencies-parent
7 | org.springframework.cloud
8 | 1.1.0.BUILD-SNAPSHOT
9 |
10 |
11 | spring-cloud-lattice-dependencies
12 | 1.0.0.BUILD-SNAPSHOT
13 | pom
14 | spring-cloud-lattice-dependencies
15 | Spring Cloud Lattice Dependencies
16 |
17 | 1.0.0.M1
18 |
19 |
20 |
21 |
22 | org.springframework.cloud
23 | spring-cloud-netflix-dependencies
24 | 1.1.0.BUILD-SNAPSHOT
25 | pom
26 | import
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-lattice-core
31 | ${project.version}
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-lattice-connector
36 | ${project.version}
37 |
38 |
39 | org.springframework.cloud
40 | spring-cloud-lattice-discovery
41 | ${project.version}
42 |
43 |
44 | org.cloudfoundry.receptor
45 | receptor-client
46 | ${receptor.version}
47 |
48 |
49 |
50 |
51 |
52 | spring
53 |
54 |
55 | spring-snapshots
56 | Spring Snapshots
57 | https://repo.spring.io/libs-snapshot-local
58 |
59 | true
60 |
61 |
62 |
63 | spring-milestones
64 | Spring Milestones
65 | https://repo.spring.io/libs-milestone-local
66 |
67 | false
68 |
69 |
70 |
71 | spring-releases
72 | Spring Releases
73 | https://repo.spring.io/release
74 |
75 | false
76 |
77 |
78 |
79 |
80 |
81 | spring-snapshots
82 | Spring Snapshots
83 | https://repo.spring.io/libs-snapshot-local
84 |
85 | true
86 |
87 |
88 |
89 | spring-milestones
90 | Spring Milestones
91 | https://repo.spring.io/libs-milestone-local
92 |
93 | false
94 |
95 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-discovery/src/main/java/org/springframework/cloud/lattice/discovery/LatticeRibbonClientConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.discovery;
18 |
19 | import static com.netflix.client.config.CommonClientConfigKey.DeploymentContextBasedVipAddresses;
20 | import static com.netflix.client.config.CommonClientConfigKey.EnableZoneAffinity;
21 |
22 | import javax.annotation.PostConstruct;
23 |
24 | import org.springframework.beans.factory.annotation.Autowired;
25 | import org.springframework.beans.factory.annotation.Value;
26 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
27 | import org.springframework.context.annotation.Bean;
28 | import org.springframework.context.annotation.Configuration;
29 |
30 | import com.netflix.client.config.IClientConfig;
31 | import com.netflix.config.ConfigurationManager;
32 | import com.netflix.config.DynamicPropertyFactory;
33 | import com.netflix.config.DynamicStringProperty;
34 | import com.netflix.loadbalancer.ServerList;
35 |
36 | /**
37 | * @author Spencer Gibb
38 | */
39 | @Configuration
40 | public class LatticeRibbonClientConfiguration {
41 |
42 | @Autowired
43 | private LatticeDiscoveryProperties props;
44 |
45 | @Autowired
46 | private ReceptorService receptorService;
47 |
48 | @Value("${ribbon.client.name}")
49 | private String serviceId = "client";
50 |
51 | protected static final String VALUE_NOT_SET = "__not__set__";
52 |
53 | protected static final String DEFAULT_NAMESPACE = "ribbon";
54 |
55 | public LatticeRibbonClientConfiguration() {
56 | }
57 |
58 | public LatticeRibbonClientConfiguration(String serviceId) {
59 | this.serviceId = serviceId;
60 | }
61 |
62 | @Bean
63 | @ConditionalOnMissingBean
64 | public ServerList> ribbonServerList(IClientConfig config) {
65 | // TODO: this is a common thing between impl, maybe ServerListFactory?
66 | LatticeServerList serverList = new LatticeServerList(props, receptorService,
67 | serviceId);
68 | return serverList;
69 | }
70 |
71 | // TODO: preprocess, setProp, getProperty, getKey are common accross impls, move to
72 | // RibbonClientConfiguration
73 | @PostConstruct
74 | public void preprocess() {
75 | // FIXME: what should this be?
76 | setProp(this.serviceId, DeploymentContextBasedVipAddresses.key(), this.serviceId);
77 | setProp(this.serviceId, EnableZoneAffinity.key(), "true");
78 | }
79 |
80 | protected void setProp(String serviceId, String suffix, String value) {
81 | // how to set the namespace properly?
82 | String key = getKey(serviceId, suffix);
83 | DynamicStringProperty property = getProperty(key);
84 | if (property.get().equals(VALUE_NOT_SET)) {
85 | ConfigurationManager.getConfigInstance().setProperty(key, value);
86 | }
87 | }
88 |
89 | protected DynamicStringProperty getProperty(String key) {
90 | return DynamicPropertyFactory.getInstance().getStringProperty(key, VALUE_NOT_SET);
91 | }
92 |
93 | protected String getKey(String serviceId, String suffix) {
94 | return serviceId + "." + DEFAULT_NAMESPACE + "." + suffix;
95 | }
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-sample/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | spring-cloud-lattice-sample
7 | jar
8 | Spring Cloud Lattice Sample
9 | Spring Cloud Lattice Sample
10 |
11 |
12 | org.springframework.cloud
13 | spring-cloud-lattice
14 | 1.0.0.BUILD-SNAPSHOT
15 | ..
16 |
17 |
18 |
19 | springcloud
20 |
21 |
22 |
23 |
24 |
25 | org.springframework.boot
26 | spring-boot-maven-plugin
27 |
28 |
29 |
30 | repackage
31 |
32 |
33 |
34 |
35 |
36 |
37 | maven-deploy-plugin
38 |
39 | true
40 |
41 |
42 |
43 |
44 | com.spotify
45 | docker-maven-plugin
46 | 0.2.3
47 |
48 | ${docker.image.prefix}/${project.artifactId}
49 | src/main/docker
50 |
51 |
52 | /
53 | ${project.build.directory}
54 | ${project.build.finalName}.jar
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | org.springframework.boot
65 | spring-boot-starter-web
66 |
67 |
68 | org.springframework.boot
69 | spring-boot-starter-actuator
70 |
71 |
72 | org.springframework.cloud
73 | spring-cloud-config-client
74 |
75 |
76 | org.springframework.cloud
77 | spring-cloud-lattice-connector
78 |
79 |
80 | org.springframework.cloud
81 | spring-cloud-spring-service-connector
82 |
83 |
84 | org.springframework.cloud
85 | spring-cloud-lattice-discovery
86 |
87 |
88 | org.springframework.cloud
89 | spring-cloud-starter-hystrix
90 |
91 |
92 | org.projectlombok
93 | lombok
94 | true
95 |
96 |
97 | org.springframework.boot
98 | spring-boot-starter-jdbc
99 |
100 |
101 | mysql
102 | mysql-connector-java
103 |
104 |
105 | org.springframework.data
106 | spring-data-mongodb
107 |
108 |
109 | org.springframework.boot
110 | spring-boot-starter-amqp
111 |
112 |
113 | org.springframework.boot
114 | spring-boot-starter-redis
115 |
116 |
117 | org.springframework.data
118 | spring-data-commons
119 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-connector/src/main/java/org/springframework/cloud/lattice/connector/LatticeConnector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.connector;
18 |
19 | import org.cloudfoundry.receptor.client.ReceptorClient;
20 | import org.cloudfoundry.receptor.client.ReceptorOperations;
21 | import org.cloudfoundry.receptor.commands.ActualLRPResponse;
22 | import org.cloudfoundry.receptor.commands.DesiredLRPResponse;
23 | import org.springframework.cloud.AbstractCloudConnector;
24 | import org.springframework.cloud.FallbackServiceInfoCreator;
25 | import org.springframework.cloud.app.ApplicationInstanceInfo;
26 | import org.springframework.cloud.app.BasicApplicationInstanceInfo;
27 | import org.springframework.cloud.service.BaseServiceInfo;
28 | import org.springframework.cloud.util.EnvironmentAccessor;
29 |
30 | import java.lang.Class;
31 | import java.lang.Object;
32 | import java.lang.Override;
33 | import java.lang.String;
34 | import java.lang.SuppressWarnings;
35 | import java.util.ArrayList;
36 | import java.util.HashMap;
37 | import java.util.List;
38 | import java.util.Map;
39 |
40 | /**
41 | * @author Spencer Gibb
42 | */
43 | public class LatticeConnector extends AbstractCloudConnector {
44 |
45 | private EnvironmentAccessor environment = new EnvironmentAccessor();
46 | private ReceptorOperations receptorClient;
47 |
48 | @SuppressWarnings({ "unchecked", "rawtypes" })
49 | public LatticeConnector() {
50 | super((Class) LatticeServiceInfoCreator.class);
51 | String receptorHost = environment.getEnvValue("SPRING_CLOUD_LATTICE_RECEPTOR_HOST");
52 | if (receptorHost == null) {
53 | receptorHost = "receptor.192.168.11.11.xip.io";
54 | }
55 | //TODO: support username/password
56 | this.receptorClient = new ReceptorClient(receptorHost);
57 | }
58 |
59 | public void setEnvironmentAccessor(EnvironmentAccessor environment) {
60 | this.environment = environment;
61 | }
62 |
63 | public void setReceptorOperations(ReceptorOperations receptorClient) {
64 | this.receptorClient = receptorClient;
65 | }
66 |
67 | @Override
68 | public boolean isInMatchingCloud() {
69 | return environment.getEnvValue("PROCESS_GUID") != null;
70 | }
71 |
72 | @Override
73 | public ApplicationInstanceInfo getApplicationInstanceInfo() {
74 | String instanceGuid = environment.getEnvValue("INSTANCE_GUID");
75 | String processGuid = environment.getEnvValue("PROCESS_GUID");
76 | //TODO: read receptor?
77 | HashMap map = new HashMap<>();
78 | return new BasicApplicationInstanceInfo(instanceGuid, processGuid, map);
79 | }
80 |
81 | @Override
82 | protected List getServicesData() {
83 | Map processes = new HashMap<>();
84 | List desiredLRPs = receptorClient.getDesiredLRPs();
85 |
86 | for (DesiredLRPResponse desired : desiredLRPs) {
87 | processes.put(desired.getProcessGuid(), new Process(desired));
88 | }
89 |
90 | List actualLRPs = receptorClient.getActualLRPs();
91 | for (ActualLRPResponse actual : actualLRPs) {
92 | Process process = processes.get(actual.getProcessGuid());
93 | if (process != null) {
94 | process.add(actual);
95 | }
96 | }
97 |
98 | return new ArrayList<>(processes.values());
99 | }
100 |
101 | @Override
102 | protected FallbackServiceInfoCreator getFallbackServiceInfoCreator() {
103 | return new FallbackServiceInfoCreator() {
104 | @Override
105 | public BaseServiceInfo createServiceInfo(Process process) {
106 | return new BaseServiceInfo(process.getProcessGuid());
107 | }
108 | };
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-connector/src/test/java/org/springframework/cloud/lattice/connector/AbstractServiceInfoCreatorTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.connector;
18 |
19 | import static org.hamcrest.Matchers.instanceOf;
20 | import static org.hamcrest.Matchers.is;
21 | import static org.junit.Assert.assertNotNull;
22 | import static org.junit.Assert.assertThat;
23 | import static org.mockito.Mockito.when;
24 | import static org.mockito.MockitoAnnotations.initMocks;
25 |
26 | import com.fasterxml.jackson.databind.DeserializationFeature;
27 | import com.fasterxml.jackson.databind.ObjectMapper;
28 | import com.fasterxml.jackson.databind.type.CollectionType;
29 | import com.fasterxml.jackson.databind.type.TypeFactory;
30 | import org.cloudfoundry.receptor.client.ReceptorOperations;
31 | import org.cloudfoundry.receptor.commands.ActualLRPResponse;
32 | import org.cloudfoundry.receptor.commands.DesiredLRPResponse;
33 | import lombok.SneakyThrows;
34 | import org.junit.Before;
35 | import org.mockito.Mock;
36 | import org.springframework.cloud.service.ServiceInfo;
37 | import org.springframework.cloud.util.EnvironmentAccessor;
38 |
39 | import java.io.InputStreamReader;
40 | import java.io.Reader;
41 | import java.util.List;
42 | import java.util.Scanner;
43 |
44 | /**
45 | * @author Spencer Gibb
46 | */
47 | public class AbstractServiceInfoCreatorTests {
48 |
49 | @Mock
50 | protected EnvironmentAccessor env;
51 |
52 | @Mock
53 | protected ReceptorOperations receptor;
54 |
55 | protected ObjectMapper mapper = new ObjectMapper();
56 |
57 | @Before
58 | public void setup() {
59 | initMocks(this);
60 | mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
61 | }
62 |
63 | protected LatticeConnector createConnector() {
64 | LatticeConnector connector = new LatticeConnector();
65 | connector.setEnvironmentAccessor(env);
66 | connector.setReceptorOperations(receptor);
67 |
68 | String alrpJson = readTestDataFile("/lattice-test/alrp.json");
69 | String dlrpJson = readTestDataFile("/lattice-test/dlrp.json");
70 |
71 | List dlrpResponses = read(DesiredLRPResponse.class, dlrpJson);
72 | List alrpResponses = read(ActualLRPResponse.class, alrpJson);
73 |
74 | when(receptor.getActualLRPs()).thenReturn(alrpResponses);
75 | when(receptor.getDesiredLRPs()).thenReturn(dlrpResponses);
76 | return connector;
77 | }
78 |
79 | protected String readTestDataFile(String fileName) {
80 | Scanner scanner = null;
81 | try {
82 | Reader fileReader = new InputStreamReader(getClass().getResourceAsStream(
83 | fileName));
84 | scanner = new Scanner(fileReader);
85 | return scanner.useDelimiter("\\Z").next();
86 | }
87 | finally {
88 | if (scanner != null) {
89 | scanner.close();
90 | }
91 | }
92 | }
93 |
94 | @SneakyThrows
95 | protected List read(Class aClass, String s) {
96 | CollectionType type = TypeFactory.defaultInstance().constructCollectionType(List.class, aClass);
97 | return mapper.readValue(s, type);
98 | }
99 |
100 |
101 | @SuppressWarnings("unchecked")
102 | protected T findServiceInfo(LatticeConnector connector, Class type, String serviceInfoId) {
103 | List serviceInfos = connector.getServiceInfos();
104 | assertNotNull("serviceInfos was null", serviceInfos);
105 |
106 | ServiceInfo serviceInfo = null;
107 | for (ServiceInfo si : serviceInfos) {
108 | if (si.getId().equals(serviceInfoId)) {
109 | serviceInfo = si;
110 | }
111 | }
112 | assertNotNull("serviceInfo is null", serviceInfo);
113 | assertThat(serviceInfo, is(instanceOf(type)));
114 | return (T) serviceInfo;
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-discovery/src/main/java/org/springframework/cloud/lattice/discovery/ReceptorService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.discovery;
18 |
19 | import org.cloudfoundry.receptor.client.ReceptorClient;
20 | import org.cloudfoundry.receptor.commands.ActualLRPResponse;
21 | import org.cloudfoundry.receptor.commands.DesiredLRPResponse;
22 | import org.cloudfoundry.receptor.support.HttpRoute;
23 | import org.cloudfoundry.receptor.support.Port;
24 |
25 | import java.util.ArrayList;
26 | import java.util.List;
27 | import java.util.Map;
28 |
29 | import org.springframework.cloud.lattice.LatticeProperties;
30 | import org.springframework.cloud.lattice.discovery.LatticeDiscoveryProperties.Route;
31 | import org.springframework.core.convert.converter.Converter;
32 |
33 | /**
34 | * @author Spencer Gibb
35 | * @author Dave Syer
36 | */
37 | public class ReceptorService {
38 |
39 | public static final String UNKNOWN = "";
40 | private ReceptorClient receptor;
41 | private LatticeProperties latticeProperties;
42 | private LatticeDiscoveryProperties discoveryProperties;
43 |
44 | public ReceptorService(ReceptorClient receptor, LatticeProperties latticeProperties, LatticeDiscoveryProperties discoveryProperties) {
45 | this.receptor = receptor;
46 | this.latticeProperties = latticeProperties;
47 | this.discoveryProperties = discoveryProperties;
48 | }
49 |
50 | public List getActualLRPsByProcessGuid(String processGuid,
51 | Converter converter) {
52 | List responses = getResponses(processGuid);
53 | List lrps = new ArrayList<>();
54 | for (ActualLRPResponse response : responses) {
55 | T converted = converter.convert(response);
56 | lrps.add(converted);
57 | }
58 | return lrps;
59 | }
60 |
61 | private List getResponses(String processGuid) {
62 | List responses = new ArrayList<>();
63 | if (!latticeProperties.getReceptor().isUseRouterAddress()) {
64 | responses.addAll(receptor.getActualLRPsByProcessGuid(processGuid));
65 | }
66 | else {
67 | DesiredLRPResponse desired = receptor.getDesiredLRP(processGuid);
68 | if (desired != null) {
69 | ActualLRPResponse response = new ActualLRPResponse();
70 | String address = getAddress(desired);
71 | response.setAddress(address);
72 | response.setIndex(0);
73 | response.setInstanceGuid(processGuid + ":" + address);
74 | Port port = new Port();
75 | port.setHostPort(80);
76 | response.setPorts(new Port[] { port });
77 | response.setProcessGuid(processGuid);
78 | responses.add(response);
79 | }
80 | }
81 | if (responses.isEmpty() && discoveryProperties.getRoutes().containsKey(processGuid)) {
82 | Route route = discoveryProperties.getRoutes().get(processGuid);
83 | ActualLRPResponse response = new ActualLRPResponse();
84 | response.setAddress(route.getAddress());
85 | response.setIndex(0);
86 | response.setInstanceGuid(processGuid + ":" + route.getAddress() + ":"
87 | + route.getPort());
88 | Port port = new Port();
89 | port.setHostPort(route.getPort());
90 | response.setPorts(new Port[] { port });
91 | response.setProcessGuid(processGuid);
92 | }
93 |
94 | return responses;
95 | }
96 |
97 | private String getAddress(DesiredLRPResponse desired) {
98 | Map routes = desired.getRoutes();
99 | if (routes.isEmpty()) {
100 | return UNKNOWN;
101 | }
102 | org.cloudfoundry.receptor.support.Route[] cfRoutes = routes.get("cf-router");
103 | if (cfRoutes.length == 0 || !(cfRoutes[0] instanceof HttpRoute)) {
104 | return UNKNOWN;
105 | }
106 | String[] hostnames = ((HttpRoute) cfRoutes[0]).getHostnames();
107 | if (hostnames.length == 0) {
108 | return UNKNOWN;
109 | }
110 | return hostnames[0];
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-discovery/src/main/java/org/springframework/cloud/lattice/discovery/config/DiscoverConfigServerBootstrapConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.discovery.config;
18 |
19 | import lombok.extern.apachecommons.CommonsLog;
20 |
21 | import org.springframework.beans.factory.annotation.Autowired;
22 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
23 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
24 | import org.springframework.cloud.client.ServiceInstance;
25 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
26 | import org.springframework.cloud.client.discovery.event.HeartbeatEvent;
27 | import org.springframework.cloud.client.discovery.event.HeartbeatMonitor;
28 | import org.springframework.cloud.config.client.ConfigClientProperties;
29 | import org.springframework.cloud.config.client.ConfigServicePropertySourceLocator;
30 | import org.springframework.cloud.lattice.LatticeAutoConfiguration;
31 | import org.springframework.cloud.lattice.discovery.LatticeDiscoveryClient;
32 | import org.springframework.cloud.lattice.discovery.LatticeDiscoveryClientConfiguration;
33 | import org.springframework.context.ApplicationEvent;
34 | import org.springframework.context.annotation.Configuration;
35 | import org.springframework.context.annotation.Import;
36 | import org.springframework.context.event.ContextRefreshedEvent;
37 | import org.springframework.context.event.SmartApplicationListener;
38 |
39 | import java.util.List;
40 |
41 | /**
42 | * Bootstrap configuration for a config client that wants to lookup the config server via
43 | * discovery.
44 | *
45 | * @author Dave Syer
46 | */
47 | @ConditionalOnClass({ LatticeDiscoveryClient.class, ConfigServicePropertySourceLocator.class })
48 | @ConditionalOnProperty(value = "spring.cloud.config.discovery.enabled", matchIfMissing = true)
49 | @Configuration
50 | @EnableDiscoveryClient
51 | @Import({LatticeAutoConfiguration.class, LatticeDiscoveryClientConfiguration.class})
52 | @CommonsLog
53 | public class DiscoverConfigServerBootstrapConfiguration implements
54 | SmartApplicationListener {
55 |
56 | private HeartbeatMonitor monitor = new HeartbeatMonitor();
57 |
58 | @Autowired
59 | private ConfigClientProperties config;
60 |
61 | @Autowired
62 | private LatticeDiscoveryClient discovery;
63 |
64 | @Override
65 | public void onApplicationEvent(ApplicationEvent event) {
66 | if (event instanceof ContextRefreshedEvent) {
67 | refresh();
68 | }
69 | else if (event instanceof HeartbeatEvent) {
70 | if (this.monitor.update(((HeartbeatEvent) event).getValue())) {
71 | refresh();
72 | }
73 | }
74 | }
75 |
76 | @Override
77 | public int getOrder() {
78 | return 0;
79 | }
80 |
81 | @Override
82 | public boolean supportsEventType(Class extends ApplicationEvent> eventType) {
83 | return ContextRefreshedEvent.class.isAssignableFrom(eventType)
84 | || HeartbeatEvent.class.isAssignableFrom(eventType);
85 | }
86 |
87 | @Override
88 | public boolean supportsSourceType(Class> sourceType) {
89 | return true;
90 | }
91 |
92 | private void refresh() {
93 | try {
94 | log.info("Locating configserver via discovery");
95 | List instances = discovery.getInstances(this.config.getDiscovery().getServiceId());
96 | if (instances == null || instances.isEmpty()) {
97 | log.warn("Unable to locate an instance of " + this.config.getDiscovery().getServiceId());
98 | return;
99 | }
100 | ServiceInstance instance = instances.iterator().next();
101 | String url = instance.getUri().toString();
102 | /* FIXME: howto support username, password and configPath without metadata?
103 | if (server.getMetadata().containsKey("password")) {
104 | String user = server.getMetadata().get("user");
105 | user = user == null ? "user" : user;
106 | this.config.setUsername(user);
107 | String password = server.getMetadata().get("password");
108 | this.config.setPassword(password);
109 | }
110 | if (server.getMetadata().containsKey("configPath")) {
111 | String path = server.getMetadata().get("configPath");
112 | if (url.endsWith("/") && path.startsWith("/")) {
113 | url = url.substring(0, url.length() - 1);
114 | }
115 | url = url + path;
116 | }
117 | */
118 | this.config.setUri(url);
119 | log.debug("Found configserver url: "+url);
120 | }
121 | catch (Exception ex) {
122 | log.warn("Could not locate configserver via discovery", ex);
123 | }
124 | }
125 |
126 | }
127 |
--------------------------------------------------------------------------------
/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM https://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
40 |
41 | @REM set %HOME% to equivalent of $HOME
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43 |
44 | @REM Execute a user defined script before this one
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49 | :skipRcPre
50 |
51 | @setlocal
52 |
53 | set ERROR_CODE=0
54 |
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal
56 | @setlocal
57 |
58 | @REM ==== START VALIDATION ====
59 | if not "%JAVA_HOME%" == "" goto OkJHome
60 |
61 | echo.
62 | echo Error: JAVA_HOME not found in your environment. >&2
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2
64 | echo location of your Java installation. >&2
65 | echo.
66 | goto error
67 |
68 | :OkJHome
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init
70 |
71 | echo.
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2
75 | echo location of your Java installation. >&2
76 | echo.
77 | goto error
78 |
79 | @REM ==== END VALIDATION ====
80 |
81 | :init
82 |
83 | set MAVEN_CMD_LINE_ARGS=%*
84 |
85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86 | @REM Fallback to current working directory if not found.
87 |
88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90 |
91 | set EXEC_DIR=%CD%
92 | set WDIR=%EXEC_DIR%
93 | :findBaseDir
94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
95 | cd ..
96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
97 | set WDIR=%CD%
98 | goto findBaseDir
99 |
100 | :baseDirFound
101 | set MAVEN_PROJECTBASEDIR=%WDIR%
102 | cd "%EXEC_DIR%"
103 | goto endDetectBaseDir
104 |
105 | :baseDirNotFound
106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107 | cd "%EXEC_DIR%"
108 |
109 | :endDetectBaseDir
110 |
111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112 |
113 | @setlocal EnableExtensions EnableDelayedExpansion
114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116 |
117 | :endReadAdditionalConfig
118 |
119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120 |
121 | set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar""
122 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
123 |
124 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
125 | if ERRORLEVEL 1 goto error
126 | goto end
127 |
128 | :error
129 | set ERROR_CODE=1
130 |
131 | :end
132 | @endlocal & set ERROR_CODE=%ERROR_CODE%
133 |
134 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
135 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
136 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
137 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
138 | :skipRcPost
139 |
140 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
141 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
142 |
143 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
144 |
145 | exit /B %ERROR_CODE%
146 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-sample/src/main/java/org/springframework/cloud/lattice/sample/SampleLatticeApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2015 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.lattice.sample;
18 |
19 | import java.util.ArrayList;
20 | import java.util.List;
21 |
22 | import lombok.extern.apachecommons.CommonsLog;
23 |
24 | import org.springframework.amqp.core.Binding;
25 | import org.springframework.amqp.core.BindingBuilder;
26 | import org.springframework.amqp.core.Queue;
27 | import org.springframework.amqp.core.TopicExchange;
28 | import org.springframework.amqp.rabbit.connection.ConnectionFactory;
29 | import org.springframework.amqp.rabbit.core.RabbitTemplate;
30 | import org.springframework.beans.factory.annotation.Autowired;
31 | import org.springframework.boot.SpringApplication;
32 | import org.springframework.boot.bind.RelaxedPropertyResolver;
33 | import org.springframework.cloud.client.ServiceInstance;
34 | import org.springframework.cloud.client.SpringCloudApplication;
35 | import org.springframework.cloud.client.discovery.DiscoveryClient;
36 | import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
37 | import org.springframework.cloud.config.java.AbstractCloudConfig;
38 | import org.springframework.context.annotation.Bean;
39 | import org.springframework.context.annotation.Configuration;
40 | import org.springframework.core.env.Environment;
41 | import org.springframework.data.redis.connection.RedisConnectionFactory;
42 | import org.springframework.data.redis.core.StringRedisTemplate;
43 | import org.springframework.jdbc.core.JdbcTemplate;
44 | import org.springframework.web.bind.annotation.RequestMapping;
45 | import org.springframework.web.bind.annotation.RequestParam;
46 | import org.springframework.web.bind.annotation.RestController;
47 | import org.springframework.web.client.RestTemplate;
48 |
49 | import javax.sql.DataSource;
50 |
51 | /**
52 | * @author Spencer Gibb
53 | */
54 | @SpringCloudApplication
55 | @RestController
56 | @CommonsLog
57 | public class SampleLatticeApplication {
58 |
59 | final static String queueName = "spring-boot";
60 |
61 | public static final String CLIENT_NAME = "myservice";
62 | // public static final String CLIENT_NAME = "lattice-app";
63 |
64 | @Autowired
65 | LoadBalancerClient loadBalancer;
66 |
67 | @Autowired
68 | DiscoveryClient discoveryClient;
69 |
70 | @Autowired
71 | RestTemplate restTemplate;
72 |
73 | @Autowired
74 | Environment env;
75 |
76 | @Autowired(required = false)
77 | RelaxedPropertyResolver resolver;
78 |
79 | @Autowired
80 | DataSource dataSource;
81 |
82 | @Autowired
83 | RedisConnectionFactory redisConnectionFactory;
84 |
85 | @Autowired
86 | StringRedisTemplate redis;
87 |
88 | @Autowired
89 | RabbitTemplate rabbit;
90 |
91 | @Configuration
92 | protected static class LatticeConfig extends AbstractCloudConfig {
93 | @Bean
94 | DataSource dataSource() {
95 | return connectionFactory().dataSource();
96 | }
97 |
98 | @Bean
99 | RedisConnectionFactory redisConnectionFactory() {
100 | return connectionFactory().redisConnectionFactory();
101 | }
102 |
103 | @Bean
104 | StringRedisTemplate template(RedisConnectionFactory connectionFactory) {
105 | return new StringRedisTemplate(connectionFactory);
106 | }
107 |
108 | @Bean
109 | Queue queue() {
110 | return new Queue(queueName, false);
111 | }
112 |
113 | @Bean
114 | TopicExchange exchange() {
115 | return new TopicExchange("spring-boot-exchange");
116 | }
117 |
118 | @Bean
119 | Binding binding(Queue queue, TopicExchange exchange) {
120 | return BindingBuilder.bind(queue).to(exchange).with(queueName);
121 | }
122 |
123 | @Bean
124 | ConnectionFactory rabbitConnectionFactory() {
125 | return connectionFactory().rabbitConnectionFactory();
126 | }
127 | }
128 |
129 | @RequestMapping("/me")
130 | public ServiceInstance me() {
131 | return discoveryClient.getLocalServiceInstance();
132 | }
133 |
134 | @RequestMapping("/services")
135 | public List services() {
136 | List list = new ArrayList();
137 | for (String id : discoveryClient.getServices()) {
138 | list.addAll(discoveryClient.getInstances(id));
139 | }
140 | return list ;
141 | }
142 |
143 | @RequestMapping("/")
144 | public ServiceInstance lb(
145 | @RequestParam(value = "service", defaultValue = CLIENT_NAME) String serviceId) {
146 | return loadBalancer.choose(serviceId);
147 | }
148 |
149 | @RequestMapping("/ds")
150 | public String ds() {
151 | return dataSource.toString();
152 | }
153 |
154 | @RequestMapping("/ds/select")
155 | public Integer selectOne() {
156 | JdbcTemplate jdbc = new JdbcTemplate(dataSource);
157 | return jdbc.queryForObject("SELECT 1 FROM DUAL", Integer.class);
158 | }
159 |
160 | @RequestMapping("/redis")
161 | public String redis() {
162 | return redisConnectionFactory.toString();
163 | }
164 |
165 | @RequestMapping("/redis/test")
166 | public String redisTemplate() {
167 | redis.opsForValue().set("redisTest", "redisTestValue");
168 | return redis.opsForValue().get("redisTest");
169 | }
170 |
171 | @RequestMapping("/rabbit")
172 | public String rabbit() {
173 | String message = "Sending hi";
174 | rabbit.convertAndSend(queueName, message);
175 | return "Sent: "+message;
176 | }
177 |
178 | @RequestMapping("/hi")
179 | public String hi() {
180 | ServiceInstance instance = discoveryClient.getLocalServiceInstance();
181 | String msg = instance.getServiceId() + ":" + instance.getHost() + ":"
182 | + instance.getPort();
183 | log.info("/hi called: " + msg);
184 | return msg;
185 | }
186 |
187 | @RequestMapping("/call")
188 | public String call() {
189 | return "myservice says: "
190 | + restTemplate.getForObject("http://myservice/hi", String.class);
191 | }
192 |
193 | @RequestMapping("/myenv")
194 | public String env(@RequestParam("prop") String prop) {
195 | String property = new RelaxedPropertyResolver(env).getProperty(prop, "Not Found");
196 | return property;
197 | }
198 |
199 | public static void main(String[] args) {
200 | SpringApplication.run(SampleLatticeApplication.class, args);
201 | }
202 | }
203 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-connector/src/test/resources/lattice-test/dlrp.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "setup": {
4 | "download": {
5 | "from": "http://file_server.service.dc1.consul:8080/v1/static/healthcheck.tgz",
6 | "to": "/tmp",
7 | "cache_key": ""
8 | }
9 | },
10 | "action": {
11 | "run": {
12 | "path": "/entrypoint.sh",
13 | "args": [
14 | "redis-server"
15 | ],
16 | "dir": "/data",
17 | "env": null,
18 | "resource_limits": {},
19 | "privileged": true
20 | }
21 | },
22 | "monitor": {
23 | "run": {
24 | "path": "/tmp/healthcheck",
25 | "args": [
26 | "-port",
27 | "6379"
28 | ],
29 | "env": null,
30 | "resource_limits": {},
31 | "log_source": "HEALTH"
32 | }
33 | },
34 | "process_guid": "redis",
35 | "domain": "lattice",
36 | "rootfs": "docker:///library/redis#latest",
37 | "instances": 1,
38 | "env": [
39 | {
40 | "name": "PROCESS_GUID",
41 | "value": "redis"
42 | },
43 | {
44 | "name": "PORT",
45 | "value": "6379"
46 | }
47 | ],
48 | "start_timeout": 0,
49 | "disk_mb": 1024,
50 | "memory_mb": 128,
51 | "cpu_weight": 100,
52 | "privileged": true,
53 | "ports": [
54 | 6379
55 | ],
56 | "routes": {
57 | "cf-router": [
58 | {
59 | "hostnames": [
60 | "redis.192.168.11.11.xip.io",
61 | "redis-6379.192.168.11.11.xip.io"
62 | ],
63 | "port": 6379
64 | }
65 | ]
66 | },
67 | "log_guid": "redis",
68 | "log_source": "APP",
69 | "metrics_guid": "",
70 | "modification_tag": {
71 | "epoch": "93f52bf6-bff9-41a4-4e8b-364797ccb8d8",
72 | "index": 0
73 | }
74 | },
75 | {
76 | "setup": {
77 | "download": {
78 | "from": "http://file_server.service.dc1.consul:8080/v1/static/healthcheck.tgz",
79 | "to": "/tmp",
80 | "cache_key": ""
81 | }
82 | },
83 | "action": {
84 | "run": {
85 | "path": "/docker-entrypoint.sh",
86 | "args": [
87 | "rabbitmq-server"
88 | ],
89 | "dir": "/",
90 | "env": null,
91 | "resource_limits": {},
92 | "privileged": true
93 | }
94 | },
95 | "monitor": {
96 | "run": {
97 | "path": "/tmp/healthcheck",
98 | "args": [
99 | "-port",
100 | "5672"
101 | ],
102 | "env": null,
103 | "resource_limits": {},
104 | "log_source": "HEALTH"
105 | }
106 | },
107 | "process_guid": "rabbit",
108 | "domain": "lattice",
109 | "rootfs": "docker:///library/rabbitmq#latest",
110 | "instances": 1,
111 | "env": [
112 | {
113 | "name": "PROCESS_GUID",
114 | "value": "rabbit"
115 | },
116 | {
117 | "name": "PORT",
118 | "value": "5672"
119 | }
120 | ],
121 | "start_timeout": 0,
122 | "disk_mb": 1024,
123 | "memory_mb": 128,
124 | "cpu_weight": 100,
125 | "privileged": true,
126 | "ports": [
127 | 5672
128 | ],
129 | "routes": {
130 | "cf-router": [
131 | {
132 | "hostnames": [
133 | "rabbit.192.168.11.11.xip.io",
134 | "rabbit-5672.192.168.11.11.xip.io"
135 | ],
136 | "port": 5672
137 | }
138 | ]
139 | },
140 | "log_guid": "rabbit",
141 | "log_source": "APP",
142 | "metrics_guid": "",
143 | "modification_tag": {
144 | "epoch": "0fe8b9f0-24af-49dd-5640-8931bc2041e3",
145 | "index": 0
146 | }
147 | },
148 | {
149 | "setup": {
150 | "download": {
151 | "from": "http://file_server.service.dc1.consul:8080/v1/static/healthcheck.tgz",
152 | "to": "/tmp",
153 | "cache_key": ""
154 | }
155 | },
156 | "action": {
157 | "run": {
158 | "path": "/entrypoint.sh",
159 | "args": [
160 | "mysqld"
161 | ],
162 | "dir": "/",
163 | "env": null,
164 | "resource_limits": {},
165 | "privileged": true
166 | }
167 | },
168 | "monitor": {
169 | "run": {
170 | "path": "/tmp/healthcheck",
171 | "args": [
172 | "-port",
173 | "3306"
174 | ],
175 | "env": null,
176 | "resource_limits": {},
177 | "log_source": "HEALTH"
178 | }
179 | },
180 | "process_guid": "mysql",
181 | "domain": "lattice",
182 | "rootfs": "docker:///library/mysql#latest",
183 | "instances": 1,
184 | "env": [
185 | {
186 | "name": "PROCESS_GUID",
187 | "value": "mysql"
188 | },
189 | {
190 | "name": "MYSQL_ROOT_PASSWORD",
191 | "value": "password"
192 | },
193 | {
194 | "name": "PORT",
195 | "value": "3306"
196 | }
197 | ],
198 | "start_timeout": 0,
199 | "disk_mb": 1024,
200 | "memory_mb": 128,
201 | "cpu_weight": 100,
202 | "privileged": true,
203 | "ports": [
204 | 3306
205 | ],
206 | "routes": {
207 | "cf-router": [
208 | {
209 | "hostnames": [
210 | "mysql.192.168.11.11.xip.io",
211 | "mysql-3306.192.168.11.11.xip.io"
212 | ],
213 | "port": 3306
214 | }
215 | ]
216 | },
217 | "log_guid": "mysql",
218 | "log_source": "APP",
219 | "metrics_guid": "",
220 | "modification_tag": {
221 | "epoch": "3d4df6bc-aecf-4bc4-7820-64b6c97f04ac",
222 | "index": 0
223 | }
224 | }
225 | ]
226 |
--------------------------------------------------------------------------------
/mvnw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ----------------------------------------------------------------------------
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # https://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | # ----------------------------------------------------------------------------
20 |
21 | # ----------------------------------------------------------------------------
22 | # Maven2 Start Up Batch script
23 | #
24 | # Required ENV vars:
25 | # ------------------
26 | # JAVA_HOME - location of a JDK home dir
27 | #
28 | # Optional ENV vars
29 | # -----------------
30 | # M2_HOME - location of maven2's installed home dir
31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven
32 | # e.g. to debug Maven itself, use
33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35 | # ----------------------------------------------------------------------------
36 |
37 | if [ -z "$MAVEN_SKIP_RC" ] ; then
38 |
39 | if [ -f /etc/mavenrc ] ; then
40 | . /etc/mavenrc
41 | fi
42 |
43 | if [ -f "$HOME/.mavenrc" ] ; then
44 | . "$HOME/.mavenrc"
45 | fi
46 |
47 | fi
48 |
49 | # OS specific support. $var _must_ be set to either true or false.
50 | cygwin=false;
51 | darwin=false;
52 | mingw=false
53 | case "`uname`" in
54 | CYGWIN*) cygwin=true ;;
55 | MINGW*) mingw=true;;
56 | Darwin*) darwin=true
57 | #
58 | # Look for the Apple JDKs first to preserve the existing behaviour, and then look
59 | # for the new JDKs provided by Oracle.
60 | #
61 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
62 | #
63 | # Apple JDKs
64 | #
65 | export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
66 | fi
67 |
68 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
69 | #
70 | # Apple JDKs
71 | #
72 | export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
73 | fi
74 |
75 | if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
76 | #
77 | # Oracle JDKs
78 | #
79 | export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
80 | fi
81 |
82 | if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
83 | #
84 | # Apple JDKs
85 | #
86 | export JAVA_HOME=`/usr/libexec/java_home`
87 | fi
88 | ;;
89 | esac
90 |
91 | if [ -z "$JAVA_HOME" ] ; then
92 | if [ -r /etc/gentoo-release ] ; then
93 | JAVA_HOME=`java-config --jre-home`
94 | fi
95 | fi
96 |
97 | if [ -z "$M2_HOME" ] ; then
98 | ## resolve links - $0 may be a link to maven's home
99 | PRG="$0"
100 |
101 | # need this for relative symlinks
102 | while [ -h "$PRG" ] ; do
103 | ls=`ls -ld "$PRG"`
104 | link=`expr "$ls" : '.*-> \(.*\)$'`
105 | if expr "$link" : '/.*' > /dev/null; then
106 | PRG="$link"
107 | else
108 | PRG="`dirname "$PRG"`/$link"
109 | fi
110 | done
111 |
112 | saveddir=`pwd`
113 |
114 | M2_HOME=`dirname "$PRG"`/..
115 |
116 | # make it fully qualified
117 | M2_HOME=`cd "$M2_HOME" && pwd`
118 |
119 | cd "$saveddir"
120 | # echo Using m2 at $M2_HOME
121 | fi
122 |
123 | # For Cygwin, ensure paths are in UNIX format before anything is touched
124 | if $cygwin ; then
125 | [ -n "$M2_HOME" ] &&
126 | M2_HOME=`cygpath --unix "$M2_HOME"`
127 | [ -n "$JAVA_HOME" ] &&
128 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
129 | [ -n "$CLASSPATH" ] &&
130 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
131 | fi
132 |
133 | # For Migwn, ensure paths are in UNIX format before anything is touched
134 | if $mingw ; then
135 | [ -n "$M2_HOME" ] &&
136 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
137 | [ -n "$JAVA_HOME" ] &&
138 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
139 | # TODO classpath?
140 | fi
141 |
142 | if [ -z "$JAVA_HOME" ]; then
143 | javaExecutable="`which javac`"
144 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
145 | # readlink(1) is not available as standard on Solaris 10.
146 | readLink=`which readlink`
147 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
148 | if $darwin ; then
149 | javaHome="`dirname \"$javaExecutable\"`"
150 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
151 | else
152 | javaExecutable="`readlink -f \"$javaExecutable\"`"
153 | fi
154 | javaHome="`dirname \"$javaExecutable\"`"
155 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
156 | JAVA_HOME="$javaHome"
157 | export JAVA_HOME
158 | fi
159 | fi
160 | fi
161 |
162 | if [ -z "$JAVACMD" ] ; then
163 | if [ -n "$JAVA_HOME" ] ; then
164 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
165 | # IBM's JDK on AIX uses strange locations for the executables
166 | JAVACMD="$JAVA_HOME/jre/sh/java"
167 | else
168 | JAVACMD="$JAVA_HOME/bin/java"
169 | fi
170 | else
171 | JAVACMD="`which java`"
172 | fi
173 | fi
174 |
175 | if [ ! -x "$JAVACMD" ] ; then
176 | echo "Error: JAVA_HOME is not defined correctly." >&2
177 | echo " We cannot execute $JAVACMD" >&2
178 | exit 1
179 | fi
180 |
181 | if [ -z "$JAVA_HOME" ] ; then
182 | echo "Warning: JAVA_HOME environment variable is not set."
183 | fi
184 |
185 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
186 |
187 | # For Cygwin, switch paths to Windows format before running java
188 | if $cygwin; then
189 | [ -n "$M2_HOME" ] &&
190 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
191 | [ -n "$JAVA_HOME" ] &&
192 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
193 | [ -n "$CLASSPATH" ] &&
194 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
195 | fi
196 |
197 | # traverses directory structure from process work directory to filesystem root
198 | # first directory with .mvn subdirectory is considered project base directory
199 | find_maven_basedir() {
200 | local basedir=$(pwd)
201 | local wdir=$(pwd)
202 | while [ "$wdir" != '/' ] ; do
203 | if [ -d "$wdir"/.mvn ] ; then
204 | basedir=$wdir
205 | break
206 | fi
207 | wdir=$(cd "$wdir/.."; pwd)
208 | done
209 | echo "${basedir}"
210 | }
211 |
212 | # concatenates all lines of a file
213 | concat_lines() {
214 | if [ -f "$1" ]; then
215 | echo "$(tr -s '\n' ' ' < "$1")"
216 | fi
217 | }
218 |
219 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
220 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
221 |
222 | # Provide a "standardized" way to retrieve the CLI args that will
223 | # work with both Windows and non-Windows executions.
224 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
225 | export MAVEN_CMD_LINE_ARGS
226 |
227 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
228 |
229 | exec "$JAVACMD" \
230 | $MAVEN_OPTS \
231 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
232 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
233 | ${WRAPPER_LAUNCHER} "$@"
234 |
235 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/spring-cloud-lattice-dependencies/.factorypath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
--------------------------------------------------------------------------------
/spring-cloud-security-dependencies/.factorypath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
--------------------------------------------------------------------------------