Skip to content

Commit

Permalink
final
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfrehe committed Oct 22, 2021
1 parent 4df0a34 commit 9ecee6e
Show file tree
Hide file tree
Showing 22 changed files with 200 additions and 73 deletions.
27 changes: 0 additions & 27 deletions azure-pipelines.yml

This file was deleted.

4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.8'
version: '3.3'

services:
postgres:
Expand All @@ -16,7 +16,7 @@ services:
container_name: libadmin_service
build: ./springBootService/
ports:
- "80:80"
- "8080:8080"
links:
- "postgres:postgres"
depends_on:
Expand Down
26 changes: 0 additions & 26 deletions loadtest/LoadtestUtilMKMB.py

This file was deleted.

7 changes: 7 additions & 0 deletions loadtest/libadmin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM python:3
WORKDIR /usr/src/app
COPY . .
RUN pip install --upgrade pip && \
pip install requests
CMD ["LoadtestUtilMKMB.py"]
ENTRYPOINT ["python3"]
39 changes: 39 additions & 0 deletions loadtest/libadmin/LoadtestUtilMKMB.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import requests
import concurrent.futures
import threading
import json
from random import randrange

thread_local = threading.local()

def get_session():
if not hasattr(thread_local, "session"):
thread_local.session = requests.Session()
return thread_local.session

def post_verlag_test():
session = get_session()
headers = {'Content-Type': 'application/json'}
book = {'book': {'title':'Die Bibel','author':'Deine Mudda','publisher':'Christlicher Staat deutscher Nation','isbn':'978-3-16-148410-0'}}
with session.post("http://localhost:8080/addBook", headers=headers, data=book) as response:
print(f"Response_code = {response.status_code}")
print(f"Response test = {response.text}")
print(f"Response time = {response.elapsed.total_seconds()}")

def get_verlag_test():
session = get_session()
headers = {'Content-Type': 'application/json'}
isbn = {'isbn': '978-3-16-148410-0'}
with session.get("http://localhost:8080/findBook", params=isbn) as response:
print(f"Response_code = {response.status_code}")
print(f"Response test = {response.text}")
print(f"Response time = {response.elapsed.total_seconds()}s")

####hier könnt ihr die worker anpassen. mehr worker = mehr threads = mehr speed? ist aber python
with concurrent.futures.ThreadPoolExecutor(max_workers=12) as executor:
print("i am here")

executor.map(post_verlag_test())
####hier muss noch eine for schleife hin(mehr ausführungen der for schleife = mehr worker?)
for x in range(200):
executor.map(get_verlag_test())
38 changes: 24 additions & 14 deletions springBootService/.mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/*
* Copyright 2007-present the original author or authors.
*
Expand All @@ -22,39 +23,43 @@ public class MavenWrapperDownloader {

private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is
* provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
* Path to the maven-wrapper.properties file, which might contain a downloadUrl
* property to use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar";

/**
* Name of the property which should be used to override the default download url for the wrapper.
* Name of the property which should be used to override the default download
* url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";

/**
* @param args[]
*/
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());

// If the maven-wrapper.properties exists, read it and check if it contains a custom
// If the maven-wrapper.properties exists, read it and check if it contains a
// custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Expand All @@ -65,7 +70,7 @@ public static void main(String args[]) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
Expand All @@ -76,8 +81,8 @@ public static void main(String args[]) {
System.out.println("- Downloading from: " + url);

File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
Expand All @@ -94,6 +99,11 @@ public static void main(String args[]) {
}
}

/**
* @param urlString
* @param destination
* @throws Exception
*/
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
Expand Down
2 changes: 1 addition & 1 deletion springBootService/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ FROM openjdk:11-jdk
ARG JAVA_OPTS
COPY --from=MAVEN_BUILD ./build/target/*.jar /app/libadmin.jar
ENV JAVA_OPTS=$JAVA_OPTS
EXPOSE 80
EXPOSE 8080
ENTRYPOINT exec java $JAVA_OPTS -jar /app/libadmin.jar
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


@SpringBootApplication
public class IsbnvalidatorApplication {

/**
* @param args
*/
public static void main(String[] args) {
SpringApplication.run(IsbnvalidatorApplication.class, args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,44 +40,74 @@ public Book() {

}

/**
* @return int
*/
// Getter und Setter zum Initialisiern und Auslesen von den Datenfeldern eines
// Buches.
public int getId() {
return id;
}

/**
* @param id
*/
public void setId(int id) {
this.id = id;
}

/**
* @return String
*/
public String getTitle() {
return title;
}

/**
* @param title
*/
public void setTitle(String title) {
this.title = title;
}

/**
* @return String
*/
public String getAuthor() {
return author;
}

/**
* @param author
*/
public void setAuthor(String author) {
this.author = author;
}

/**
* @return String
*/
public String getPublisher() {
return publisher;
}

/**
* @param publisher
*/
public void setPublisher(String publisher) {
this.publisher = publisher;
}

/**
* @return String
*/
public String getIsbn() {
return isbn;
}

/**
* @param isbn
*/
public void setIsbn(String isbn) {
this.isbn = isbn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,26 @@ public class ISBNValidationResult {
public ISBNValidationResult() {
}


/**
* @param isValid
*/
public void setValid(boolean isValid) {
this.isValid = isValid;
}


/**
* @return boolean
*/
public boolean isValid() {
return this.isValid;
}


/**
* @return String
*/
@Override
public String toString() {
return "ValidationResult{" + "isValid='" + isValid + '}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public BookController(BookService service) {
*
* @param request
*/
@PostMapping(path = "/addbook")
@PostMapping(path = "/addBook")
public void createBook(@RequestBody AddRequest request) {
service.createBook(request.getBook());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@
public class AddRequest {
private Book book;

/**
* @return Book
*/
public Book getBook() {
return book;
}

/**
* @param book
*/
public void setBook(Book book) {
this.book = book;
}
Expand Down
Loading

0 comments on commit 9ecee6e

Please sign in to comment.