Skip to content

Commit

Permalink
Merge pull request #145 from Orange-OpenSource/fix/binding-generic
Browse files Browse the repository at this point in the history
Rename ApplicationBinding to Binding
  • Loading branch information
arnaudruffin committed Feb 25, 2016
2 parents 27c9f11 + 533cbf0 commit d3fe6db
Show file tree
Hide file tree
Showing 23 changed files with 248 additions and 85 deletions.
39 changes: 19 additions & 20 deletions .idea/codeStyleSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ buildscript {
}
}
repositories {
maven {
url new File(rootProject.projectDir, "libs-reactor").toURI().toURL().toString()
}
mavenLocal()
jcenter()
//URL repo to get the desired compiled version
maven { url "https://jitpack.io" }
maven { url 'http://repo.spring.io/libs-snapshot' }
}

}
println(new File(rootProject.projectDir, "libs-reactor").toURI().toURL().toString())
apply plugin: 'java'
apply plugin: 'spring-boot'
apply plugin: 'war'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 0.2.1
version = 0.2.2
domainName = org.cloudfoundry
projectName = autosleep
group = org.cloudfoundry.autosleep
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
72a192f6f081c6b64cb226e9aaaa5e3884ccb266
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>2.5.0.BUILD-SNAPSHOT</version>
<name>Non-Blocking Reactive Foundation for the JVM</name>
<description>Non-Blocking Reactive Foundation for the JVM</description>
<url>https://github.com/reactor/reactor</url>
<organization>
<name>reactor</name>
<url>http://github.com/reactor</url>
</organization>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>smaldini</id>
<name>Stephane Maldini</name>
<email>[email protected]</email>
</developer>
</developers>
<scm>
<connection>scm:git:git://github.com/reactor/reactor-core</connection>
<developerConnection>scm:git:git://github.com/reactor/reactor-core</developerConnection>
<url>https://github.com/reactor/reactor-core</url>
</scm>
<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/reactor/reactor/issues</url>
</issueManagement>
<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.0</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.reactivex</groupId>
<artifactId>rxjava</artifactId>
<version>1.0.14</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.reactivestreams</groupId>
<artifactId>reactive-streams</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
67e1de98da0f1b110cb297c31e647e03d41d78c9
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ce0bce42258cad0758ae32842c353c20a806279c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-stream</artifactId>
<version>2.5.0.BUILD-SNAPSHOT</version>
<name>Reactive Streams implementation for Reactive Extensions and more</name>
<description>Reactive Streams implementation for Reactive Extensions and more</description>
<url>https://github.com/reactor/reactor</url>
<organization>
<name>reactor</name>
<url>http://github.com/reactor</url>
</organization>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>smaldini</id>
<name>Stephane Maldini</name>
<email>[email protected]</email>
</developer>
</developers>
<scm>
<connection>scm:git:git://github.com/reactor/reactor-core</connection>
<developerConnection>scm:git:git://github.com/reactor/reactor-core</developerConnection>
<url>https://github.com/reactor/reactor-core</url>
</scm>
<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/reactor/reactor/issues</url>
</issueManagement>
<dependencies>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>2.5.0.BUILD-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
93d4a73b796929c95a9647eeb12dea62ed930139
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package org.cloudfoundry.autosleep.dao.model;

import lombok.*;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import javax.persistence.Entity;
Expand All @@ -14,30 +19,29 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor
@Entity
public class ApplicationBinding {
public class Binding {

@Id
private String serviceBindingId;
public enum ResourceType {
Application, Route
}

private String serviceInstanceId;
private String resourceId;

private String applicationId;
private ResourceType resourceType;

@Id
private String serviceBindingId;

@Override
public String toString() {
return this.getClass().getSimpleName() + " : [id:" + serviceBindingId + " serviceId:+" + serviceInstanceId
+ " app:" + applicationId + "]";
}
private String serviceInstanceId;

@Override
public boolean equals(Object object) {
if (object == this) {
return true;
} else if (!(object instanceof ApplicationBinding)) {
} else if (!(object instanceof Binding)) {
return false;
} else {
ApplicationBinding other = (ApplicationBinding) object;
Binding other = (Binding) object;
return Objects.equals(serviceBindingId, other.serviceBindingId)
&& Objects.equals(serviceInstanceId, other.serviceInstanceId);
}
Expand All @@ -47,4 +51,10 @@ public boolean equals(Object object) {
public int hashCode() {
return serviceBindingId.hashCode();
}

@Override
public String toString() {
return this.getClass().getSimpleName() + " : [id:" + serviceBindingId + " serviceId:+" + serviceInstanceId
+ " app:" + resourceId + "]";
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.cloudfoundry.autosleep.dao.repositories;

import org.cloudfoundry.autosleep.dao.model.ApplicationBinding;
import org.cloudfoundry.autosleep.dao.model.Binding;
import org.springframework.data.repository.CrudRepository;


public interface BindingRepository extends CrudRepository<ApplicationBinding, String> {
public interface BindingRepository extends CrudRepository<Binding, String> {
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.cloudfoundry.autosleep.dao.repositories.jpa;

import org.cloudfoundry.autosleep.dao.model.ApplicationBinding;
import org.cloudfoundry.autosleep.dao.model.Binding;
import org.cloudfoundry.autosleep.dao.repositories.BindingRepository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface JpaBindingRepository extends JpaRepository<ApplicationBinding, String>, BindingRepository {
public interface JpaBindingRepository extends JpaRepository<Binding, String>, BindingRepository {
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import lombok.extern.slf4j.Slf4j;
import org.cloudfoundry.autosleep.config.Config;
import org.cloudfoundry.autosleep.dao.model.ApplicationBinding;
import org.cloudfoundry.autosleep.dao.model.Binding;
import org.cloudfoundry.autosleep.dao.model.ApplicationInfo;
import org.cloudfoundry.autosleep.dao.model.Binding.ResourceType;
import org.cloudfoundry.autosleep.dao.model.SpaceEnrollerConfig;
import org.cloudfoundry.autosleep.dao.repositories.ApplicationRepository;
import org.cloudfoundry.autosleep.dao.repositories.BindingRepository;
Expand Down Expand Up @@ -51,9 +52,12 @@ public ServiceInstanceBinding createServiceInstanceBinding(CreateServiceInstance
log.debug("createServiceInstanceBinding - {}", bindingId);
SpaceEnrollerConfig spaceEnrollerConfig = spaceEnrollerConfigRepository.findOne(configId);

ApplicationBinding binding = ApplicationBinding.builder().serviceInstanceId(configId)
Binding binding = Binding.builder()
.serviceInstanceId(configId)
.serviceBindingId(bindingId)
.applicationId(appId).build();
.resourceId(appId)
.resourceType(ResourceType.Application)
.build();
applicationLocker.executeThreadSafe(appId, () -> {
ApplicationInfo appInfo = appRepository.findOne(appId);
if (appInfo == null) {
Expand All @@ -80,8 +84,8 @@ public ServiceInstanceBinding deleteServiceInstanceBinding(DeleteServiceInstance
final String bindingId = request.getBindingId();
log.debug("deleteServiceInstanceBinding - {}", bindingId);

final ApplicationBinding binding = bindingRepository.findOne(bindingId);
final String appId = binding.getApplicationId();
final Binding binding = bindingRepository.findOne(bindingId);
final String appId = binding.getResourceId();

SpaceEnrollerConfig serviceInstance = spaceEnrollerConfigRepository
.findOne(request.getInstance().getServiceInstanceId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import lombok.extern.slf4j.Slf4j;
import org.cloudfoundry.autosleep.config.Config;
import org.cloudfoundry.autosleep.dao.model.ApplicationBinding;
import org.cloudfoundry.autosleep.dao.model.Binding;
import org.cloudfoundry.autosleep.dao.model.ApplicationInfo;
import org.cloudfoundry.autosleep.dao.model.SpaceEnrollerConfig;
import org.cloudfoundry.autosleep.dao.repositories.ApplicationRepository;
Expand Down Expand Up @@ -67,10 +67,10 @@ public ServerResponse<List<SpaceEnrollerConfig>> listInstances() {

@RequestMapping(Config.Path.SERVICES_SUB_PATH + "{instanceId}/bindings/")
@ResponseBody
public ServerResponse<List<ApplicationBinding>> listBindings(@PathVariable("instanceId") String serviceInstanceId)
public ServerResponse<List<Binding>> listBindings(@PathVariable("instanceId") String serviceInstanceId)
throws ServiceInstanceDoesNotExistException {
log.debug("listServiceBindings - {}", serviceInstanceId);
List<ApplicationBinding> result = new ArrayList<>();
List<Binding> result = new ArrayList<>();
bindingRepository.findAll().forEach(serviceBinding -> {
if (serviceInstanceId.equals(serviceBinding.getServiceInstanceId())) {
result.add(serviceBinding);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void init() {
SpaceEnrollerConfig spaceEnrollerConfig =
spaceEnrollerConfigRepository.findOne(applicationBinding.getServiceInstanceId());
if (spaceEnrollerConfig != null) {
registerApplicationStopper(spaceEnrollerConfig, applicationBinding.getApplicationId());
registerApplicationStopper(spaceEnrollerConfig, applicationBinding.getResourceId());
}
});
spaceEnrollerConfigRepository.findAll().forEach(this::registerSpaceEnroller);
Expand Down
7 changes: 5 additions & 2 deletions src/main/resources/db/changelog/db.changelog-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ databaseChangeLog:
author: Arnaud Ruffin
changes:
- createTable:
tableName: ApplicationBinding
tableName: Binding
columns:
- column:
name: serviceBindingId
Expand All @@ -13,7 +13,10 @@ databaseChangeLog:
primaryKey: true
nullable: false
- column:
name: applicationId
name: resourceId
type: VARCHAR(255)
- column:
name: resourceType
type: VARCHAR(255)
- column:
name: serviceInstanceId
Expand Down
Loading

0 comments on commit d3fe6db

Please sign in to comment.